MATLAB Answers


Issue about "the same lower bound and upper bound" in 'fmincon'

Asked by sxj
on 22 Jul 2019
Latest activity Commented on by sxj
on 22 Jul 2019
Hey, everyone, I have a confusion about the lower bound and upper bound in 'fmincon'. My optimization problem can be described as below:
where and are two endogenous variables, and is the objective function.
I need to do the following two optimizations
1.Both and are endogenous, using 'fmincon' to solve out the optimized and
2.Given , using 'fmincon' to solve out the optimized
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 .
However, the value of optimized under these two methods are different. Which method should I use here?
I check the link 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.


However, the value of optimized under these two methods are different. Which method should I use here?
And how much do the two solutions differ ?
Did you do this for all your constraints, including the linear ones A*x<=b, Aeq*x=beq ?
Thanks for your comments, Torsten and Matt.
The differences are shown as below where I choose the value of objective and endogenous variables in method (1) as reference point. Besides, there are actually four endogenous variables in my problem where I should solve out the optimal ones respectively.
Differences for the value of objective: -0.0023, 2.5349e-04,7.1896e-05,1.5973e-04
Percentage differences for the value of optimized x: -3.82%, 2.81%, -1.16%, 0.62%
Since I need to do sensitive test in which I test how the change of parameters affect the optimized values, it would be import to see which method should be used.
There is no linear constraints but non-linear constraints in my problem. I have already substitute the value of into the constraints when I use method 2.

Sign in to comment.

1 Answer

Answer by Matt J
on 22 Jul 2019
Edited by Matt J
on 22 Jul 2019

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,
f=@(x1) (x1+c).^2;
This way, you avoid doing extra arithmetic with x2 every time fmincon calls your objective.


Hey, Matt, I get your point and would adjust the code as your suggestions.
According to the differences between the two methods which I show above, does it seem to be floating point noise? The optimized value of objective function is almost the same, but the optimized value of endogeneous variables are somewhat different.
If there exists multiple solution, is it the issue of local minimum and global minimum and should I turn to the global search method in MATLAB?
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.
The objective value at the initial point is 9.1347e+03, and the objective value under the two methods are 9.222e+3 and 9.2012e+3 respectively. -0.0023 = (9.2012e+3-9.222e+3)/9.222e+3 measures the difference between the two method in which I choose one of them as the reference point.
The code contains several subfunction, I have to adjust a little for you to run it if it is neccessary.

Sign in to comment.