Documente Academic
Documente Profesional
Documente Cultură
stage1_req stage2_req
demand
profit:=
0.53
0.55
80000
0.72
0.52
0.57
97000
0.79
0.4
0.54
99000
0.75;
To maximize this function using summation notation in SAS, use this code:
proc optmodel;
set Color={'c','m','y'};
set Stage={'s1','s2'};
number ProcessTime{Color,Stage}=
[0.53 0.55
0.52 0.57
0.4 0.54];
number AvailableTime{Stage}=[72000 75600];
number Demand{Color}=[80000 97000 99000];
number Profit{Color}=[0.720 0.790 0.75];
var Amount{Color} >= 0;
maximize TotalProfit = sum{i in Color}Profit[i]*Amount[i];
con TimeConst{j in Stage}: sum{i in
Color}Amount[i]*ProcessTime[i,j]<=AvailableTime[j];
con DemandConst{i in Color}: Amount[i]<=Demand[i];
solve;
print Amount;
quit;
and then hit the run button at the top of the window.
Explanation
The simplest way to solve this in AMPL is to type this code in the console:
var x1 >= 0 ;
var x2 >= 0 ;
var x3 >= 0 ;
maximize Profit: 20*x1+15*x2+17*x3 (0.49*(3.1*x1+10.0*x2+5.6*x3)+0.84*(9.4*x1+8.2*x2+1.1*x3));
subject to time_Cap_M1: (3.1*x1+10.0*x2+5.6*x3)<=480;
subject to time_Cap_M2: (9.4*x1+8.2*x2+1.1*x3)<=540;
solve ;
display x1, x2, x3, Profit;
proc optmodel;
var x1 >= 0 ;
var x2 >= 0 ;
var x3 >= 0 ;
maximize Profit= 20*x1+15*x2+17*x3 (0.49*(3.1*x1+10.0*x2+5.6*x3)+0.84*(9.4*x1+8.2*x2+1.1*x3));
con time_Cap_M1: (3.1*x1+10.0*x2+5.6*x3)<=480;
con time_Cap_M2: (9.4*x1+8.2*x2+1.1*x3)<=540;
solve ;
print x1 x2 x3 Profit;
quit;
and then hit the run button at the top of the window.
cost time_avail:=
0.49
480
0.84
540;
param:
"P1"
"P2"
"P3"
price
20
15
17 ;
:=
To maximize this function using summation notation in SAS, use this code:
proc optmodel;
set PRODUCTS = {'P1','P2','P3'};
A very simple way to solve this problem in AMPL is to use the following code:
reset;
option solver gurobi;
var x1 integer >=0;
var x2 integer >=0;
maximize z: 8*x1+20*x2;
s.t. c1: x1+x2<=11;
s.t. c2: 3*x1+2*x2<=30;
s.t. c3: 1*x1+3*x2<=28;
solve;
display x1, x2, z;
The answers we are looking for are obtained, then, by multiplying x1 and x2 by 10, and
multiplying z by 100.
A very simple way to solve this problem in SAS is to use this code:
proc optmodel;
var x1 integer >=0;
var x2 integer >=0;
maximize z= 8*x1+20*x2;
con c1: x1+x2<=11;
con c2: 3*x1+2*x2<=30;
con c3: 1*x1+3*x2<=28;
solve;
print x1 x2 z;
quit;
The answers we are looking for are obtained, then, by multiplying x1 and x2 by 10, and
multiplying z by 100.
A more sophisticated way to solve this in AMPL, defining lot size as a variable that can be
changed later down the line, would be as follows:
reset;
option solver gurobi;
param lot = 10;
var XHL integer >=0;
var XSL integer >=0;
var XH = XHL * lot;
var XS = XSL * lot;
maximize Z: (80/lot)*XHL+(200/lot)*XSL;
s.t. Plant: XHL+XSL<=(110/lot);
s.t. A: 3*XHL+2*XSL<=(300/lot);
s.t. B: 1*XHL+3*XSL<=(280/lot);
solve;
display XH, XS;
display Z * lot ^ 2;
A more complex way to solve this problem in SAS is to use this code:
proc optmodel;
number lot = 10;
var XHL integer >=0;
To solve this problem in AMPL, we can use the code from the previous question, but using a
value of 5 for the lot size. So, instead of...
param lot = 5;