fmincon optimization with nonlinear constraint
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
mohammed hussein
il 20 Set 2020
Commentato: mohammed hussein
il 20 Set 2020
Dear All
I am using the fmincon in matlab to minimize the objective value as
F=-(x(1)^2+x(2)^2+x(3)^2-x(4)^2) .
i have the nonlinear constrain that
x(1)-x(3)=x(2)-x(4)
How can the nonlinear constraint functions to be written as a .m file?
THX very much for your help!
0 Commenti
Risposta accettata
Walter Roberson
il 20 Set 2020
nonlcon = @(x) deal([], x(1)-x(3)-(x(2)-x(4)))
However, you should consider rewriting with one fewer variable.
x(1)-x(3)=x(2)-x(4)
implies x(4) = x(2) + x(3) - x(1) .
Substituting in F=-(x(1)^2+x(2)^2+x(3)^2-x(4)^2) we get
F = -(x(1).^2 + x(2).^2 + x(3).^2 - (x(2) + x(3) - x(1)).^2)
This simplifies to
F = 2*(x2*x3 - x1*x3 - x1*x2)
and since this is an optimization task, the linear scale is not relevant, so you can use
F = x2*x3 - x1*x3 - x1*x2;
No non-linear constraint would be needed.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Problem-Based Optimization Setup 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!