why does fmincon fain to converge when I just change the constraints

2 views (last 30 days)
Hi guys,
I have a question about how does fmincon work with constraints. Basically I have a function f(p1,p2,p3) that I want to minimize. When I add the constraint p1+p2+p3<=1 and p1>0.001 p2>0.001 p3>0.001, there is no problem for fmincon to converge. Notice I put the constraint that p1>0.001 and p2>0.001 and p3>0.001 because they can not equal to 0. Otherwise there will be NaN for the value of f.
Then I change the constraint to p1+p2+p3=1, still with the constraints that p1>0.001 and p2>0.001 and p3>0.001. Then fmincon fails to converge. I know there is possibility that there is a bug in the function f. But I just want to ask, is there any reason that this would happen when f is absolutely right? Do my constraints violate some sort of principle for fmincon to work properly anyway?
Matt J
Matt J on 7 Mar 2014
Note also that with the 'sqp' algorithm, you do not need to supply positivity constraints. If the algorithm strays into a region where the function is non-finite, sqp can recover.

Sign in to comment.

Answers (1)

Matt J
Matt J on 7 Mar 2014
Edited: Matt J on 7 Mar 2014
Different points can be easier to converge to than others. It's possible that the Hessian is singular at the solution under p1+p2+p3=1. One thing you can try is to reformulate the problem in 2D and see if it improves performance:
min g(p1,p2) = f(p1,p2,1-p1-p2)
Matt J
Matt J on 9 Mar 2014
Edited: Matt J on 9 Mar 2014
The function is definitely has a NaN value when p1+p2+p3>1
If that's true, there is something not legal about your function. FMINCON requires the objective function and constraints to be defined and differentiable on an open superset of the feasible region. In fact, for a function to be differentiable at all, it by definition must be defined on some open set. Since p1+p2+p3<=1 is a closed set, your function violates this.

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!