I couldn't find the button in the first post, so I'll repost it here so that I can click solve. I'll work on adding the description on solving for LP Problems.
PROC IML;
names={'87' '89' '91' '93' 'Diesel'};
names2={'Supply' '87' '89' '91' '93' 'Diesel'};
/*number of variables */
n=ncol(A);
/*Maximize, Print Solver Info*/
cntl = {-1,1};
/* Objective Function - Pofit Values of each segments for one oil plant*/
obj = {70 50 30 80 100}; /*Profit = 87[70][X1] + 89[50][X1] + 91[30][X1] + 93[80][X1] + Diesel[100][X1]*/
/* coefficients of the constraint equation*/
A = {
1 1 1 1 1 /*Turn on ALL the segments to later constrain Total Supply*/
,1 0 0 0 0 /*Turn on 87 to later constrain 87 Demand*/
,0 1 0 0 0 /*Turn on 89 to later constrain 89 Demand*/
,0 0 1 0 0 /*Turn on 91 to later constrain 91 Demand*/
,0 0 0 1 0 /*Turn on 93 to later constrain 93 Demand*/
,0 0 0 0 1 /*Turn on Diesel to later constrain Diesel Demand*/
};
/*Constraint Values*/
con = {
1000 /*Total Supply*/
,100 /*87 Demand*/
,200 /*89 Demand*/
,600 /*91 Demand*/
,200 /*93 Demand*/
,100 /*Diesel Demand*/
};
/*Constraint Operators: 'L' for <=, 'G' for >=, 'E' for =*/
ops = {
'L' /*87[1] + 89[1] + 91[1] + 93 [1] + Diesel[1] <= 1000*/
,'L' /*87[1] + 89[0] + 91[0] + 93 [0] + Diesel[0] <= 100*/
,'L' /*87[0] + 89[1] + 91[0] + 93 [0] + Diesel[0] <= 200*/
,'L' /*87[0] + 89[0] + 91[1] + 93 [0] + Diesel[0] <= 600*/
,'L' /*87[0] + 89[0] + 91[0] + 93 [1] + Diesel[0] <= 200*/
,'L' /*87[0] + 89[0] + 91[0] + 93 [0] + Diesel[1] <= 100*/
};
call lpsolve(rc, value, x, dual, redcost,obj, A, con, cntl, ops);
/*Print Solver Information to Results, can do an ODS option to print to a dataset*/
lhs = A*x;
Constraints = con || lhs ;
print Constraints[r=names2
c={"Demand" "Optimal"}
L= "Optimal Mix"];
print obj[L={"Profit Per Segment"} c=names];
print value[L='Maximum Profit'];
QUIT;
... View more