-
Notifications
You must be signed in to change notification settings - Fork 0
/
ampl.gms
61 lines (39 loc) · 1.66 KB
/
ampl.gms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$Title AMPL Sample Problem (AMPL,SEQ=74)
$Ontext
A sample problem to demonstrate the power of modeling systems
Fourer, R, Gay, D M, and Kernighan, B W, AMPL: A Mathematical Programming
Language. AT\&T Bell Laboratories, Murray Hill, New Jersey, 1987.
$Offtext
Sets p products / nuts, bolts, washers /
r raw materials / iron, nickel /
tl extended t / 1 * 5 /
t(tl) periods / 1 * 4 /
first(tl) / 1 /
last(tl) / 5 /
Parameters b(r) initial stock / iron 35.8 , nickel 7.32 /
d(r) storage cost / iron .03, nickel .025 /
f(r) residual value / iron .02, nickel -.01 /
Scalar m maximum production / 123 /
Table a(r,p) raw material inputs to produce a unit of product
nuts bolts washers
iron .79 .83 .92
nickel .21 .17 .08
Table c(p,t) profit
1 2 3 4
nuts 1.73 1.8 1.6 2.2
bolts 1.82 1.9 1.7 .95
washers 1.05 1.1 .95 1.33
Variables x(p,tl) production level
s(r,tl) storage at beginning of period
profit income minus cost
Positive Variables x, s
Equations limit(t) capacity constraint
balance(r,tl) raw material balance
obj profit definition;
limit(t).. sum(p, x(p,t)) =l= m ;
balance(r,tl+1).. s(r,tl+1) =e= s(r,tl) - sum(p, a(r,p)*x(p,tl)) ;
obj.. profit =e= sum((p,t), c(p,t)*x(p,t))
+ sum((r,tl), ( -d(r)$t(tl) + f(r)$last(tl) )*s(r,tl));
s.up(r,first) = b(r);
Model ampl maximum revenue production problem / all /
Solve ampl maximizing profit using lp;