Optimization using fmincon with respect to 2 variables

조회 수: 9 (최근 30일)
Khalil Messaoudi
Khalil Messaoudi 2021년 12월 21일
댓글: Alan Weiss 2022년 3월 2일
Hello, I'm trying to implement this optimization problem by using fmincon in Matlab . I'm struggling to adapt my constrained conditions in the attached figure to parameters A,b,Aeq,beq, lb,ub,nonIcon in fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon). Like you can also notice,my function depends on 2 variables HatAlpha and HatC. Please note that HatAlpha is a (m+1 x 1)vector and HatC is a (m+1 x m+1) matrix. This is why I'm also wondering if I have to create a new function variable that contains both of them for fmincon. Thank you for any tipp

채택된 답변

Alan Weiss
Alan Weiss 2021년 12월 21일
I think that you would find it much easier to use the problem-based approach rather than fmincon directly. The reason is that with fmincon you have to put all of the control variables into one vector, typically called x. This x would contain both HatAlpha and HatC. With the problem-based approach, you are free to use the variables that are most natural for your problem.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 21
Walter Roberson
Walter Roberson 2022년 3월 2일
What would you want the code to do in the case where the constraints could not be satisfied?
  1. If the lb, ub are inconsisten, or the A, b are inconsistent, or the Aeq, beq are inconsistent ?
  2. If it has used lb, ub, A, b, Aeq, beq to break down the search space into all polytope subspaces, and it has explored the function value at boundaries and in the centroid of each of the subspaces, and finds no evidence that the nonlinear constraints can be satisfied?
Suppose I define a nonlinear constraint function
c = @(x) 1/2-(x(1)==3432523.353208).*(x(2)==90071992547409.92)
That function has a well-defined global minima: it is -1/2 at (3432523.353208, 90071992547409.92) and it is 1/2 everywhere else. Keeping in mind that fmincon() effectively cannot examine the source code to determine those constants, if you were to tell fmincon not to stop until all the constraints were satisfied, how long would you want fmincon to search until it happened to try the exact combination of that pair of floating point values?
Alan Weiss
Alan Weiss 2022년 3월 2일
I stand by my previous comments. It is clear from the exit message that, as far as fmincon is concerned, the constraints are satisfied at the end. If you disagree, it is because you have a different notion of constraint satisfaction.
I told you earlier that your initial constraint function value was extremely large. That has come back to cause you issues now. I suggest again that you rerun the solver from the final point to get your constraint infeasibility to a better value. You culd also scale your constraint infeasibility by, say, taking a nonlinear transformation such as
consval = 1e3*tanh(consval/1e3);
before you return the value.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by