Define a optimization problem
3 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
採用された回答
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 Center および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!