Define a optimization problem

2 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Alan Weiss
Alan Weiss il 2 Dic 2021
Modificato: Alan Weiss il 2 Dic 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

Più risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by