Issue about "the same lower bound and upper bound" in 'fmincon'
3 ビュー (過去 30 日間)
古いコメントを表示
Hey, everyone, I have a confusion about the lower bound and upper bound in 'fmincon'. My optimization problem can be described as below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230770/image.png)
where
and
are two endogenous variables, and
is the objective function.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230772/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230773/image.png)
I need to do the following two optimizations
1.Both
and
are endogenous, using 'fmincon' to solve out the optimized
and ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230772/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230772/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230772/image.png)
2.Given
, using 'fmincon' to solve out the optimized ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230778/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
For the optimization problem 2, I tried the following two methods to do it:
(1) Setting the same lower and upper bound for x2 (which is 1 here), and using 'fmincon' to solve out the optimal x1 and x2;
(2) Substituting
into the objective function and constraint conditions firslty, and use 'fmincon' to solve out the optimized
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230778/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
However, the value of optimized
under these two methods are different. Which method should I use here?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230771/image.png)
I check the link https://www.mathworks.com/help/optim/ug/iterations-can-violate-constraints.html which states that 'If you set a lower bound equal to an upper bound, iterations can violate these constraints.'. Does it mean that the method (1) is wrong?
Your comments are appreciated.
3 件のコメント
Matt J
2019 年 7 月 22 日
Did you do this for all your constraints, including the linear ones A*x<=b, Aeq*x=beq ?
回答 (1 件)
Matt J
2019 年 7 月 22 日
編集済み: Matt J
2019 年 7 月 22 日
No, it is not wrong. It probably means you have multiple solutions or that the differences are merely floating point noise. You should check the objective function value at each solution to be sure.
Neither method 1 and 2 are generally the most efficient, however. The efficient way is to derive a simpler objective function in which x1 is the only input. For example, if your original objective function were,
f=@(x) (x(1)+2*x(2)+3).^2;
the efficient approach when x2=1 would be to simplify this to,
x2=1;
c=2*x2+3;
f=@(x1) (x1+c).^2;
This way, you avoid doing extra arithmetic with x2 every time fmincon calls your objective.
5 件のコメント
Matt J
2019 年 7 月 22 日
I can't really evaluate any of that without seeing the objective and running it myself. What was the objective value at the initial point? If it was 10000 then a difference of 0.0023 doesn't seem significant.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!