Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
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,

Respuestas (1)

Alan Weiss
Alan Weiss el 12 de Ag. de 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

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by