fmincon optimization with nonlinear constraint

2 visualizaciones (últimos 30 días)
mohammed hussein
mohammed hussein el 20 de Sept. de 2020
Comentada: mohammed hussein el 20 de Sept. de 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!

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Sept. de 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.

Más respuestas (0)

Categorías

Más información sobre Problem-Based Optimization Setup en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by