Expressing non-linear conditions in an NLP optimization problem

2 visualizaciones (últimos 30 días)
Lenilein
Lenilein el 24 de Sept. de 2019
Comentada: Lenilein el 24 de Sept. de 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!

Respuesta aceptada

Matt J
Matt J el 24 de Sept. de 2019
Editada: Matt J el 24 de Sept. de 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 comentarios
Matt J
Matt J el 24 de Sept. de 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.
Lenilein
Lenilein el 24 de Sept. de 2019
Yes, I totally agree! But I'm actually building the model up step by step and at the end I shall have around 10 binary variables. I think that it will then be "worth" the efforts ...

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by