Linear Constraint based on two variables fmincon
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
Risposte (1)
John D'Errico
il 12 Nov 2019
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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!