Expressing non-linear conditions in an NLP optimization problem
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lenilein
am 24 Sep. 2019
Kommentiert: Lenilein
am 24 Sep. 2019
Dear Community,
I would like to solve following NLP optimization problem (for example with the fmincon function):
My objective function (to be minimized) is
f=2*x1+3*x2
where x1 and x2 are my two variables.
Furthermore:
y01=5*x1
y02=3*x2
where y01 and y02 are the initial conditions used to solve following ODE system:
dy1dl=(-a0/y2)*log((b0-c0)/(b0-(1-exp(-(a*y1^1.7+y2*y1^1.2)))))
dy2dl=d0*(e0-y2)+(-a0/y2)*log((b0-c0)/(b0-(1-exp(-(a*y1^1.7+y2*y1^1.2)))))/(1+y1)
y1 and y2 for the whole interval L are calculated by iterational solving of the ODE system using ODE45 (since the parameters a0, b0, c0, d0, e0 are different on each small interval)
Now I have the constraint
C=sum(y1)+sum(y2)<100
I am wondering how to integrate the ODE solving routine into the constraint expression and optimization solution line. I first thought having found indications in the chapter about passing extra parameters but finally I don't think it is so helpful in this case since my parameters a0, etc. are not supposed to change from one optimization to other (they just change within the interval L).
Thanks!
0 Kommentare
Akzeptierte Antwort
Matt J
am 24 Sep. 2019
Bearbeitet: Matt J
am 24 Sep. 2019
You would need to use ga() for this, with the nonlinear constraints implemented in the nonlcon input argument
x = ga(fun,nvars,A,b,[],[],lb,ub,@(x)nonlcon(x,a0,b0,d0),1:2)
And yes, you would pass extra parameters to nonlcon in the way that you read. You would pass a vector of a0 values and similarly for the other parameters.
function [c,ceq]=nonlcon(x,a0,b0,d0)
%y1,y2=ode45....
c=C*sum(y1)+D*sum(y2)-100;
ceq=[];
end
5 Kommentare
Matt J
am 24 Sep. 2019
Note though, that if x1 and x2 are binary, like in your previous question, it doesn't really make sense to use an optimization algorithm at all. There are only 4 combinations of values to test.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!