Linear Constraint based on two variables fmincon

조회 수: 1 (최근 30일)
mht6
mht6 2019년 11월 12일
답변: John D'Errico 2019년 11월 12일
Hello,
I am attempting to set a linear constraint on a multivarible optimization of fmincon. I am trying to figure out how to based this constraint on two other parameters.
For example.. I have parameters a,b, and c
I need to say that a < b/2 - c/2
However, I do not mean to say that a is between c/2 and b/2
I mean to say that a is between 0 and (b/2 - c/2 )
Any ideas on how to write this with fmincon linear inequality constraints? I previously and mistakenly had written it like this, and was preventing the a variable from getting lower which is more optimum
A(3,4) = 1;
A(3,2) = -1/2;
A(3,5) = 1/2;
b(3) = 0;
Thanks
  댓글 수: 1
mht6
mht6 2019년 11월 12일
I also should note, a, b, and c in this case are all variables up for optimization

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

답변 (1개)

John D'Errico
John D'Errico 2019년 11월 12일
Why, if you already have other inequality constraints, is this a question? And how you wrote it, using A is inconsistent with you having only 3 variables. So, clearly you have more variables in your real problem, and you even already have more than one linear inequality constraint!
If you had only one constraint, and you had only 3 variables, in the order b, a, and c, you would write:
A = [-1/2, 1, 1/2];
b = 0;
But, assuming this is the THIRD linear inequality constraint, AND that the variables concerned are variables 4, 2, and 5 in the set, you would do this:
A(3,[2 4 5]) = [-1/2, 1, 1/2];
b(3) = 0;
Note that no matter what you do, you cannot enforce a STRICT inequality with < as opposed to <=. Thus you can only set a constraint as:
a - b/2 + c/2 <= 0
and even that is only enforced to within a constraint tolerance.

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by