Nonlinear Optimization problem ( If statement)
4 ビュー (過去 30 日間)
古いコメントを表示
michael francesco pez
2020 年 4 月 24 日
コメント済み: michael francesco pez
2020 年 4 月 28 日
Hello everyone,
I'm tryng to solve a nonlinear optimization problem (constrained) using fmincon with 2232 variables (three vectors x,y,z of 744 elements).
I would like to add an "if condition" to the costraints, something like this:
for i=1:744
if x(i)>=650
y(i)<100
else
y(i)<50
end
end
it gives me the following error message :
"Conversion to logical from optim.problemdef.OptimizationInequality is not possible."
How can I add that kind of constraint?Is it possible with fmincon? If not, what solver would be the best choice?
3 件のコメント
Ameer Hamza
2020 年 4 月 24 日
You mentioned that you get this error
"Conversion to logical from optim.problemdef.OptimizationInequality is not possible."
Can you show the code which cause this error?
採用された回答
Matt J
2020 年 4 月 24 日
編集済み: Matt J
2020 年 4 月 24 日
To do that, each x(i) must have finite upper and lower bounds L(i)<=x(i)<=U(i). You also need to introduce additional unknown binary variables b(i) and express your constraints with the following linear inequalities,
b(i)>=(x(i)-650)/(U(i)-650) + eps %Forces b(i)=1 when x(i)>=650
b(i)<=(x(i)-L(i))/(650-L(i))-eps %Forces b(i)=0 when x(i)<650
y(i)<=50+50*b(i)
Since fmincon does not allow integer variables, you will need to use ga or intlinprog instead.
9 件のコメント
Walter Roberson
2020 年 4 月 28 日
Logically speaking, you cannot know that you have found the minima unless you have tested both sides of each discontinuity. With 774 variables each with a discontinuity, then logically speaking you cannot know that you have found the minima without at least 2^774 function calculations.
This number could potentially be drastically reduced if you could partition the system into linear combinations of subproblems that you can minimize independently.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!