linprog ouputting all zeros as solution in optimization problem
์ด์ ๋๊ธ ํ์
I am trying to solve the following optimization problem (view first lines for the objective function and constraints), and I am getting all zeros as my solution. How can I modify my code to output a non-zero solution? I have tried setting a lower bound, and I left the upper bound empty.
%max๐=3*๐ฅ1+5*x2+6*x3
%s.t. 2๐ฅ1+๐ฅ2+๐ฅ3โค4
% ๐ฅ1+2๐ฅ2+๐ฅ3โค4
% x1+๐ฅ2+2๐ฅ3โค4
% ๐ฅ1+๐ฅ2+๐ฅ3โค3
% x1,๐ฅ2,๐ฅ3โฅ0
A = [2 1 1
1 2 1
1 1 2
1 1 1];
b = [4 4 4 3];
%set Aeq and Beq
Aeq = [];
beq = [];
% objective function
%Z = 3*๐ฅ1+5*x2+6*x3
f = [3 5 6];
%set bounds
%ub = [];
lb = [0,0,0];
[x,fval] = linprog(f,A,b,Aeq,beq,lb)
๋ต๋ณ (1๊ฐ)
Dyuman Joshi
2023๋
11์ 9์ผ
ํธ์ง: Dyuman Joshi
2023๋
11์ 9์ผ
linprog finds the minimum of the problem specified.
To find the maximum, minimize the negative of the objective funciton -
%max๐=3*๐ฅ1+5*x2+6*x3
%s.t. 2๐ฅ1+๐ฅ2+๐ฅ3โค4
% ๐ฅ1+2๐ฅ2+๐ฅ3โค4
% x1+๐ฅ2+2๐ฅ3โค4
% ๐ฅ1+๐ฅ2+๐ฅ3โค3
% x1,๐ฅ2,๐ฅ3โฅ0
A = [2 1 1
1 2 1
1 1 2
1 1 1];
b = [4 4 4 3];
%set Aeq and Beq
Aeq = [];
beq = [];
% objective function
%Z = 3*๐ฅ1+5*x2+6*x3
f = [3 5 6];
%set bounds
ub = [];
lb = [0,0,0];
% vv
[x,fminval] = linprog(-f,A,b,Aeq,beq,lb,ub)
fmaxval = -fminval
์นดํ ๊ณ ๋ฆฌ
๋์๋ง ์ผํฐ ๋ฐ File Exchange์์ Solver Outputs and Iterative Display์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
์ ํ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!