fmincon optimization with nonlinear constraint

2 Ansichten (letzte 30 Tage)
mohammed hussein
mohammed hussein am 20 Sep. 2020
Kommentiert: mohammed hussein am 20 Sep. 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!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Sep. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Problem-Based Optimization Setup finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by