Define a optimization problem

2 次查看(过去 30 天)
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!

采纳的回答

Alan Weiss
Alan Weiss 2021-12-2
编辑:Alan Weiss 2021-12-2
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

更多回答(0 个)

类别

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

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by