How to added a “if statement” to constraints of matlab linear minimization

4 次查看(过去 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,

回答(1 个)

Alan Weiss
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

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by