How to solve a LPP when the A of linprog does not form a square matrix? I have 5 variables and 2 constraints.

3 views (last 30 days)
Max Z = 0.1*X1 + 0.15*X2 + 0.2*X3 + 0.5*X4 + 1.2*X5
Subject to:
2*X1 + 2*X2 + 2*X3 + 0.6*X4 + 0.3*X5 <= 750
0.04*X2 + 0.08*X3 + 0.09*X4 + 0.135*X5 <= 30.75
All variable >= zero.

Answers (1)

Stephan
Stephan on 17 Sep 2020
Edited: Stephan on 17 Sep 2020
% define all constraints
A = [2, 2, 2, 0.6, 0.3;
0 0.04, 0.08, 0.09, 0.135;
-eye(5)]
b = [750, 30.75, zeros(1,5)]
% define obective function
Z = [0.1, 0.15, 0.2, 0.5, 1.2]
% call linprog with negative Z, due to maximization
sol = linprog(-Z,A,b)
  2 Comments
Stephan
Stephan on 18 Sep 2020
for me it results in - using R2020a:
A =
2.0000 2.0000 2.0000 0.6000 0.3000
0 0.0400 0.0800 0.0900 0.1350
-1.0000 0 0 0 0
0 -1.0000 0 0 0
0 0 -1.0000 0 0
0 0 0 -1.0000 0
0 0 0 0 -1.0000
b =
750.0000 30.7500 0 0 0 0 0
Z =
0.1000 0.1500 0.2000 0.5000 1.2000
Optimal solution found.
sol =
340.8333
0
0
0
227.7778

Sign in to comment.

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!