Calling nonlinear constraints before objective function

조회 수: 1 (최근 30일)
Michael Clausen
Michael Clausen 2019년 3월 19일
댓글: Torsten 2019년 3월 19일
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
Torsten
Torsten 2019년 3월 19일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2019년 3월 19일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by