Define a optimization problem

1 visualización (últimos 30 días)
Guilherme Lopes de Campos
Guilherme Lopes de Campos el 1 de Dic. de 2021
Comentada: Guilherme Lopes de Campos el 2 de Dic. de 2021
Hi my dears!
I am try solving a optimization problem with the above equation and constraint :
F.O : 43120*x+23800*y+47750*z
Subject to:
9*x+12*y+9*z <= 690
9.57*x+4.28*y+12.44*z <= 130
x<= 10
y<= 16
z<= 8
I used the follow script:
x = optimvar('x');
y = optimvar('y');
z = optimvar('z');
prob = optimproblem;
prob.Objective = 43120*x+23800*y+47750*z;
prob.Constraints.cons1 = (9/690)*x + (12/690)*y +(9/690)*z <= (690/690);
prob.Constraints.cons2 = 9.57*x + 4.28*y+12.44*z <= 130;
prob.Constraints.cons3 = x <= 10;
prob.Constraints.cons4 = y <= 16;
prob.Constraints.cons5 = z <= 8;
sol = solve(prob,'Solver', 'intlinprog')
When I run, show the message:
Solving problem using intlinprog.
Problem is unbounded.
No integer variables specified. Intlinprog stopped because the linear problem is unbounded.
Can help me, please?
Thank you!

Respuesta aceptada

Alan Weiss
Alan Weiss el 2 de Dic. de 2021
Editada: Alan Weiss el 2 de Dic. de 2021
Perhaps you left out constraints that the x, y, and z variables should be nonnegative. Put those constraints and the upper bound constraints into your optimvar calls:
x = optimvar('x','LowerBound',0,'UpperBound',10);
y = optimvar('y','LowerBound',0,'UpperBound',16);
z = optimvar('z','LowerBound',0,'UpperBound',8);
If you want them to be integer-valued rather than real-valued, set their Type to 'integer'. And don't bother settng the Solver argument of solve, it will choose an appropriate solver.
And if you want to maximize the objective rather than minimize, set the optimproblem ObjectiveSense to 'maximize'.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 comentario
Guilherme Lopes de Campos
Guilherme Lopes de Campos el 2 de Dic. de 2021
Thank you so much Alan Weiss
I am very grateful to you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by