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!