Calling nonlinear constraints before objective function

1 visualización (últimos 30 días)
Michael Clausen
Michael Clausen el 19 de Mzo. de 2019
Comentada: Torsten el 19 de Mzo. de 2019
Hi, I am new to optimization and I am having a difficult time finding information that can help me with my particular problem:
My objective function take a vector of parameters: [x1 x2 x3 x4 x5]
It then calculate an additional parameter from the given parameters: y1 = (x1*x2*x3)/(x4*x5)
My problem is that my objective function only handles parameters within certain bounds, but when I use lower and upper bounds, these only apply to the parameters [x1 x2 x3 x4 x5] that I put into the objective function, and not to y1.
My approach has been to use a nonlinear constraint function that sets the bounds for possible y1's. But it seem like this is only called after the objective function, meaning that my restrictions to y1 are violated.
Can someone please help me getting my bounds to cover y1 so that the objective function does not use inappropriate y1's.
Thank you very much
-Michael
  1 comentario
Torsten
Torsten el 19 de Mzo. de 2019
If you start with parameters x1,x2,x3,x4 and x5 for which y1 = x1*x2*x3/(x4*x5) is within the bounds you want to impose on it, everything will work out fine.

Iniciar sesión para comentar.

Respuesta aceptada

Rik
Rik el 19 de Mzo. de 2019
You could let your objective function return inf when invalid parameters are provided. Then any minimizer will avoid values resulting in that condition.
function val=MyObjectiveFunction(x1,x2,x3,x4,x5)
y1 = (x1*x2*x3)/(x4*x5);
if y1<0
val=inf;
return
end
val=log(y1);
end

Más respuestas (0)

Categorías

Más información sobre Get Started with Optimization Toolbox 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