how to write the nonlinear constraints in fmincon
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Stanley Cheng
il 9 Lug 2014
Risposto: Stanley Cheng
il 9 Lug 2014
Hi everyone,
I am using the fmincon in matlab to minimize the objective value as
F=-(x(1)^2+x(2)^2+x(3)^2) .
So the objective function I write is
function Fexternal=myfun(x)
x1=x(1);
x2=x(2);
x3=x(3);
Fexternal=-(x1^2+x2^2+x3^2).
x is the 3*1 vector design variable in this problem.
However, there are also some other nonlinear constraints for this problem, i.e.
F1<=120;
F2<=100;
F3<=130;
F4<=140;
F5<=150;
F6<=20.
and F1~F6 are all the functions of the three variables x1~x3,i.e.
F1= F1(x(1),x(2),x(3));
F2= F2(x(1),x(2),x(3));
F3= F3(x(1),x(2),x(3));
F4= F4(x(1),x(2),x(3));
F5= F5(x(1),x(2),x(3));
F6= F6(x(1),x(2),x(3));
They are all long expressions and not simple to write all them explicitly.
How can the nonlinear constraint functions to be written as a .m file?
THX very much for your help!
0 Commenti
Risposta accettata
George Papazafeiropoulos
il 9 Lug 2014
Define the constraint function as follows:
function [C,Ceq]=confun(x)
F1=...
F2=...
F3=...
F4=...
F5=...
F6=...
C=[F1-120;F2-100;F3-130;F4-140;F5-150;F6-20];
Ceq=[];
and use the command:
X = fmincon('Fexternal',x0,[],[],[],[],[],[],'confun')
0 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Nonlinear Optimization in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!