How to added a “if statement” to constraints of matlab linear minimization
1 回表示 (過去 30 日間)
古いコメントを表示
I have a typical linear min problem in matlab. x = linprog(f,A,b,Aeq,beq,lb,ub,x0,options) However, two of the optimization variables x3 and x4 are related this way.
If 0 <x3<20, x4=2*x3; Elseif 20 <x3<40, x4=3*x3; Else x4=4*x3;
How to add the "if condition" in the constraints? or which solver i should use
Thank you,
0 件のコメント
回答 (1 件)
Alan Weiss
2016 年 8 月 12 日
I would solve three problems. For one, put bounds 0 <= x3 <= 20 and set x4 = 2*x3. For another, put bounds 20 <= x3 <= 30 and x4 = 3*x3. For the last, put a bound 40 <= x3 and x4 = 4*x3. Look at the smallest resulting function value, and then you have the solution to your problem.
Alan Weiss
MATLAB mathematical toolbox documentation
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!