Is the constraints in fmincon always held during the optimization?
5 views (last 30 days)
Show older comments
I used fmincon to solve a nonlinear constraint optimization problem. In the constraint, I have both linear and nonlinear equality and inequalities. I use "sqp" as the solver for fmincon. Here I want to know, during the optimization process, whether all the equality and inequalities in my constraint are always held? Moreover, when calling fmincon, I also defined low boundary and high boundary for the variables to be optimized. Is there any difference to constrain the variables in low(and high) boundary and in the constraint function (which is used by fmincon)?
Thank you!
0 Comments
Answers (1)
Matt J
on 29 Jan 2016
Edited: Matt J
on 29 Jan 2016
In fmincon, only bounds expressed using lb,ub can be enforced at all iterations and only for certain algorithm selections. sqp is one of them. interior-point will also do this by default, although you can turn it off.
This is one reason why it may be good to use lb,ub when possible, as opposed to nonlcon to express bounds. It allows you to enforce the bounds at all iterations, if that is what you desire. More generally, it allows MATLAB to recognize that those constraints are simpler than the others and give them special, simplified handling. The same goes for A,b,Aeq,beq. It helps when MATLAB knows that constraints are linear and you should use those inputs to tell it so.
4 Comments
Walter Roberson
on 30 Jan 2016
You already asked about using max() and I already answered you; http://uk.mathworks.com/matlabcentral/answers/265614-when-using-fmincon-how-to-avoid-using-max-if-else-end-in-the-constraints#comment_338657. Nonlinear constraints, no matter how expressed, are always a problem for fmincon if they create disjoint regions. If they create "holes" then they might be a problem, depending on the optimization technique being used.
Using max() or min() or if/else in a nonlinear constraint does not necessarily render the objective non-differentiable, but that is a risk. You need to do boundary matching, so that there are no jumps at the interface between conditions. I seem to recall that it works out if you have first order continuity of the objective function for the optimization routines that do not use gradients, second order continuity for those that use gradients but not hessian, and third order continuity for those that need hessians (I am least certain about the requirements for hessians). (If your objective function does not have even first order continuity then you need to use a technique such as ga() or pso())
Matt J
on 30 Jan 2016
Edited: Matt J
on 31 Jan 2016
During the optimization, I want C is always between 0 and 4000, since once C is out of this range, the physical meaning of some equations will lose and become unreal.
One more comment, just to add to the confusion :-)
The regions where your constraint and objective functions take on a real value must form an open set. If these functions are not defined on an open set, then they are non-differentiable, by definition. Or at least, they will be non-differentiable at certain points where fmincon may want to explore. For example,
f(x)=-cos( sqrt(x) )
is not differentiable at x=0, even though it does have a finite right-hand derivative there.
This means that the region you mentioned where "C" becomes non-real must be a closed set.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!