How fmincon really work?
显示 更早的评论
Hello everyone,
So fmicnon in matlab minimize the objective function, technically if we have an objective function that returns a negative values (let's say: objective = cost_negative), then the fmincon will try to minimize it by sending it further to the - infinity right? (for example objective = -1, then fmicnon will try to send it to a number lower than -1 which means -10 or -100 as example)?
if the first statement is correct, then my second question is: let's say we have 2 types of costs (objective = cost_negative + cost_positive), if we give - objective to fmincon this would technically minimize the negative costs to zero and maximize the positive costs?
(I'm using sqp algorithm in order to respect my constraints)
Thank you in advance.
采纳的回答
更多回答(1 个)
Walter Roberson
2024-11-25
fmincon() always tries to minimize the result of the objective function. If the objective function returns negative values, then fmincon() tries to see if it can be driven even more negative.
objective = cost_negative + cost_positive
It will try to minimize the overall value. It doesn't care how the value is composed. It doesn't know (or care) whether an objective of 10 is composed of 1 negative + 9 positive, or 5 negative and 5 positive, or 9 negative and 1 positive. So no it will not maximize the positive costs.
If you want to minimize the negative costs and maximize the positive costs then use an objective of cost_negative - cost_positive -- assuming that cost_negative is "magnitude by which it would be negative"
类别
在 帮助中心 和 File Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!