Define a optimization problem

조회 수: 2 (최근 30일)
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2021년 12월 1일
댓글: Guilherme Lopes de Campos 2021년 12월 2일
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
  댓글 수: 1
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2021년 12월 2일
Thank you so much Alan Weiss
I am very grateful to you

댓글을 달려면 로그인하십시오.

추가 답변 (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