why does fmincon fain to converge when I just change the constraints
1 次查看(过去 30 天)
显示 更早的评论
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?
4 个评论
Matt J
2014-3-7
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.
This will only work if you are using one of FMINCON's algorithms that can enforce bound constraints at all iterations (sqp or interior-point).
Matt J
2014-3-7
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.
回答(1 个)
Matt J
2014-3-7
编辑:Matt J
2014-3-7
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)
p1>=0.001
p2>=0.001
p1+p2<=0.999
4 个评论
Matt J
2014-3-9
编辑:Matt J
2014-3-9
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!