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

1 Ansicht (letzte 30 Tage)
scully2014
scully2014 am 12 Aug. 2016
Beantwortet: Alan Weiss am 12 Aug. 2016
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,

Antworten (1)

Alan Weiss
Alan Weiss am 12 Aug. 2016
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

Community Treasure Hunt

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

Start Hunting!

Translated by