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 Center および File ExchangeGet 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