lemon-project-template-glpk

comparison deps/glpk/examples/prod.mod @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:80c24551894c
1 # PROD, a multiperiod production model
2 #
3 # References:
4 # Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
5 # for Mathematical Programming." Management Science 36 (1990) 519-554.
6
7 ### PRODUCTION SETS AND PARAMETERS ###
8
9 set prd 'products'; # Members of the product group
10
11 param pt 'production time' {prd} > 0;
12
13 # Crew-hours to produce 1000 units
14
15 param pc 'production cost' {prd} > 0;
16
17 # Nominal production cost per 1000, used
18 # to compute inventory and shortage costs
19
20 ### TIME PERIOD SETS AND PARAMETERS ###
21
22 param first > 0 integer;
23 # Index of first production period to be modeled
24
25 param last > first integer;
26
27 # Index of last production period to be modeled
28
29 set time 'planning horizon' := first..last;
30
31 ### EMPLOYMENT PARAMETERS ###
32
33 param cs 'crew size' > 0 integer;
34
35 # Workers per crew
36
37 param sl 'shift length' > 0;
38
39 # Regular-time hours per shift
40
41 param rtr 'regular time rate' > 0;
42
43 # Wage per hour for regular-time labor
44
45 param otr 'overtime rate' > rtr;
46
47 # Wage per hour for overtime labor
48
49 param iw 'initial workforce' >= 0 integer;
50
51 # Crews employed at start of first period
52
53 param dpp 'days per period' {time} > 0;
54
55 # Regular working days in a production period
56
57 param ol 'overtime limit' {time} >= 0;
58
59 # Maximum crew-hours of overtime in a period
60
61 param cmin 'crew minimum' {time} >= 0;
62
63 # Lower limit on average employment in a period
64
65 param cmax 'crew maximum' {t in time} >= cmin[t];
66
67 # Upper limit on average employment in a period
68
69 param hc 'hiring cost' {time} >= 0;
70
71 # Penalty cost of hiring a crew
72
73 param lc 'layoff cost' {time} >= 0;
74
75 # Penalty cost of laying off a crew
76
77 ### DEMAND PARAMETERS ###
78
79 param dem 'demand' {prd,first..last+1} >= 0;
80
81 # Requirements (in 1000s)
82 # to be met from current production and inventory
83
84 param pro 'promoted' {prd,first..last+1} logical;
85
86 # true if product will be the subject
87 # of a special promotion in the period
88
89 ### INVENTORY AND SHORTAGE PARAMETERS ###
90
91 param rir 'regular inventory ratio' >= 0;
92
93 # Proportion of non-promoted demand
94 # that must be in inventory the previous period
95
96 param pir 'promotional inventory ratio' >= 0;
97
98 # Proportion of promoted demand
99 # that must be in inventory the previous period
100
101 param life 'inventory lifetime' > 0 integer;
102
103 # Upper limit on number of periods that
104 # any product may sit in inventory
105
106 param cri 'inventory cost ratio' {prd} > 0;
107
108 # Inventory cost per 1000 units is
109 # cri times nominal production cost
110
111 param crs 'shortage cost ratio' {prd} > 0;
112
113 # Shortage cost per 1000 units is
114 # crs times nominal production cost
115
116 param iinv 'initial inventory' {prd} >= 0;
117
118 # Inventory at start of first period; age unknown
119
120 param iil 'initial inventory left' {p in prd, t in time}
121 := iinv[p] less sum {v in first..t} dem[p,v];
122
123 # Initial inventory still available for allocation
124 # at end of period t
125
126 param minv 'minimum inventory' {p in prd, t in time}
127 := dem[p,t+1] * (if pro[p,t+1] then pir else rir);
128
129 # Lower limit on inventory at end of period t
130
131 ### VARIABLES ###
132
133 var Crews{first-1..last} >= 0;
134
135 # Average number of crews employed in each period
136
137 var Hire{time} >= 0; # Crews hired from previous to current period
138
139 var Layoff{time} >= 0; # Crews laid off from previous to current period
140
141 var Rprd 'regular production' {prd,time} >= 0;
142
143 # Production using regular-time labor, in 1000s
144
145 var Oprd 'overtime production' {prd,time} >= 0;
146
147 # Production using overtime labor, in 1000s
148
149 var Inv 'inventory' {prd,time,1..life} >= 0;
150
151 # Inv[p,t,a] is the amount of product p that is
152 # a periods old -- produced in period (t+1)-a --
153 # and still in storage at the end of period t
154
155 var Short 'shortage' {prd,time} >= 0;
156
157 # Accumulated unsatisfied demand at the end of period t
158
159 ### OBJECTIVE ###
160
161 minimize cost:
162
163 sum {t in time} rtr * sl * dpp[t] * cs * Crews[t] +
164 sum {t in time} hc[t] * Hire[t] +
165 sum {t in time} lc[t] * Layoff[t] +
166 sum {t in time, p in prd} otr * cs * pt[p] * Oprd[p,t] +
167 sum {t in time, p in prd, a in 1..life} cri[p] * pc[p] * Inv[p,t,a] +
168 sum {t in time, p in prd} crs[p] * pc[p] * Short[p,t];
169
170 # Full regular wages for all crews employed, plus
171 # penalties for hiring and layoffs, plus
172 # wages for any overtime worked, plus
173 # inventory and shortage costs
174
175 # (All other production costs are assumed
176 # to depend on initial inventory and on demands,
177 # and so are not included explicitly.)
178
179 ### CONSTRAINTS ###
180
181 rlim 'regular-time limit' {t in time}:
182
183 sum {p in prd} pt[p] * Rprd[p,t] <= sl * dpp[t] * Crews[t];
184
185 # Hours needed to accomplish all regular-time
186 # production in a period must not exceed
187 # hours available on all shifts
188
189 olim 'overtime limit' {t in time}:
190
191 sum {p in prd} pt[p] * Oprd[p,t] <= ol[t];
192
193 # Hours needed to accomplish all overtime
194 # production in a period must not exceed
195 # the specified overtime limit
196
197 empl0 'initial crew level': Crews[first-1] = iw;
198
199 # Use given initial workforce
200
201 empl 'crew levels' {t in time}: Crews[t] = Crews[t-1] + Hire[t] - Layoff[t];
202
203 # Workforce changes by hiring or layoffs
204
205 emplbnd 'crew limits' {t in time}: cmin[t] <= Crews[t] <= cmax[t];
206
207 # Workforce must remain within specified bounds
208
209 dreq1 'first demand requirement' {p in prd}:
210
211 Rprd[p,first] + Oprd[p,first] + Short[p,first]
212 - Inv[p,first,1] = dem[p,first] less iinv[p];
213
214 dreq 'demand requirements' {p in prd, t in first+1..last}:
215
216 Rprd[p,t] + Oprd[p,t] + Short[p,t] - Short[p,t-1]
217 + sum {a in 1..life} (Inv[p,t-1,a] - Inv[p,t,a])
218 = dem[p,t] less iil[p,t-1];
219
220 # Production plus increase in shortage plus
221 # decrease in inventory must equal demand
222
223 ireq 'inventory requirements' {p in prd, t in time}:
224
225 sum {a in 1..life} Inv[p,t,a] + iil[p,t] >= minv[p,t];
226
227 # Inventory in storage at end of period t
228 # must meet specified minimum
229
230 izero 'impossible inventories' {p in prd, v in 1..life-1, a in v+1..life}:
231
232 Inv[p,first+v-1,a] = 0;
233
234 # In the vth period (starting from first)
235 # no inventory may be more than v periods old
236 # (initial inventories are handled separately)
237
238 ilim1 'new-inventory limits' {p in prd, t in time}:
239
240 Inv[p,t,1] <= Rprd[p,t] + Oprd[p,t];
241
242 # New inventory cannot exceed
243 # production in the most recent period
244
245 ilim 'inventory limits' {p in prd, t in first+1..last, a in 2..life}:
246
247 Inv[p,t,a] <= Inv[p,t-1,a-1];
248
249 # Inventory left from period (t+1)-p
250 # can only decrease as time goes on
251
252 ### DATA ###
253
254 data;
255
256 set prd := 18REG 24REG 24PRO ;
257
258 param first := 1 ;
259 param last := 13 ;
260 param life := 2 ;
261
262 param cs := 18 ;
263 param sl := 8 ;
264 param iw := 8 ;
265
266 param rtr := 16.00 ;
267 param otr := 43.85 ;
268 param rir := 0.75 ;
269 param pir := 0.80 ;
270
271 param : pt pc cri crs iinv :=
272
273 18REG 1.194 2304. 0.015 1.100 82.0
274 24REG 1.509 2920. 0.015 1.100 792.2
275 24PRO 1.509 2910. 0.015 1.100 0.0 ;
276
277 param : dpp ol cmin cmax hc lc :=
278
279 1 19.5 96.0 0.0 8.0 7500 7500
280 2 19.0 96.0 0.0 8.0 7500 7500
281 3 20.0 96.0 0.0 8.0 7500 7500
282 4 19.0 96.0 0.0 8.0 7500 7500
283 5 19.5 96.0 0.0 8.0 15000 15000
284 6 19.0 96.0 0.0 8.0 15000 15000
285 7 19.0 96.0 0.0 8.0 15000 15000
286 8 20.0 96.0 0.0 8.0 15000 15000
287 9 19.0 96.0 0.0 8.0 15000 15000
288 10 20.0 96.0 0.0 8.0 15000 15000
289 11 20.0 96.0 0.0 8.0 7500 7500
290 12 18.0 96.0 0.0 8.0 7500 7500
291 13 18.0 96.0 0.0 8.0 7500 7500 ;
292
293 param dem (tr) :
294
295 18REG 24REG 24PRO :=
296
297 1 63.8 1212.0 0.0
298 2 76.0 306.2 0.0
299 3 88.4 319.0 0.0
300 4 913.8 208.4 0.0
301 5 115.0 298.0 0.0
302 6 133.8 328.2 0.0
303 7 79.6 959.6 0.0
304 8 111.0 257.6 0.0
305 9 121.6 335.6 0.0
306 10 470.0 118.0 1102.0
307 11 78.4 284.8 0.0
308 12 99.4 970.0 0.0
309 13 140.4 343.8 0.0
310 14 63.8 1212.0 0.0 ;
311
312 param pro (tr) :
313
314 18REG 24REG 24PRO :=
315
316 1 0 1 0
317 2 0 0 0
318 3 0 0 0
319 4 1 0 0
320 5 0 0 0
321 6 0 0 0
322 7 0 1 0
323 8 0 0 0
324 9 0 0 0
325 10 1 0 1
326 11 0 0 0
327 12 0 0 0
328 13 0 1 0
329 14 0 1 0 ;
330
331 end;