examples/prod.mod
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/prod.mod	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,331 @@
     1.4 +# PROD, a multiperiod production model
     1.5 +#
     1.6 +# References:
     1.7 +# Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
     1.8 +# for Mathematical Programming." Management Science 36 (1990) 519-554.
     1.9 +
    1.10 +###  PRODUCTION SETS AND PARAMETERS  ###
    1.11 +
    1.12 +set prd 'products';    # Members of the product group
    1.13 +
    1.14 +param pt 'production time' {prd} > 0;
    1.15 +
    1.16 +                        # Crew-hours to produce 1000 units
    1.17 +
    1.18 +param pc 'production cost' {prd} > 0;
    1.19 +
    1.20 +                        # Nominal production cost per 1000, used
    1.21 +                        # to compute inventory and shortage costs
    1.22 +
    1.23 +###  TIME PERIOD SETS AND PARAMETERS  ###
    1.24 +
    1.25 +param first > 0 integer;
    1.26 +                        # Index of first production period to be modeled
    1.27 +
    1.28 +param last > first integer;
    1.29 +
    1.30 +                        # Index of last production period to be modeled
    1.31 +
    1.32 +set time 'planning horizon' := first..last;
    1.33 +
    1.34 +###  EMPLOYMENT PARAMETERS  ###
    1.35 +
    1.36 +param cs 'crew size' > 0 integer;
    1.37 +
    1.38 +                        # Workers per crew
    1.39 +
    1.40 +param sl 'shift length' > 0;
    1.41 +
    1.42 +                        # Regular-time hours per shift
    1.43 +
    1.44 +param rtr 'regular time rate' > 0;
    1.45 +
    1.46 +                        # Wage per hour for regular-time labor
    1.47 +
    1.48 +param otr 'overtime rate' > rtr;
    1.49 +
    1.50 +                        # Wage per hour for overtime labor
    1.51 +
    1.52 +param iw 'initial workforce' >= 0 integer;
    1.53 +
    1.54 +                        # Crews employed at start of first period
    1.55 +
    1.56 +param dpp 'days per period' {time} > 0;
    1.57 +
    1.58 +                        # Regular working days in a production period
    1.59 +
    1.60 +param ol 'overtime limit' {time} >= 0;
    1.61 +
    1.62 +                        # Maximum crew-hours of overtime in a period
    1.63 +
    1.64 +param cmin 'crew minimum' {time} >= 0;
    1.65 +
    1.66 +                        # Lower limit on average employment in a period
    1.67 +
    1.68 +param cmax 'crew maximum' {t in time} >= cmin[t];
    1.69 +
    1.70 +                        # Upper limit on average employment in a period
    1.71 +
    1.72 +param hc 'hiring cost' {time} >= 0;
    1.73 +
    1.74 +                        # Penalty cost of hiring a crew
    1.75 +
    1.76 +param lc 'layoff cost' {time} >= 0;
    1.77 +
    1.78 +                        # Penalty cost of laying off a crew
    1.79 +
    1.80 +###  DEMAND PARAMETERS  ###
    1.81 +
    1.82 +param dem 'demand' {prd,first..last+1} >= 0;
    1.83 +
    1.84 +                        # Requirements (in 1000s)
    1.85 +                        # to be met from current production and inventory
    1.86 +
    1.87 +param pro 'promoted' {prd,first..last+1} logical;
    1.88 +
    1.89 +                        # true if product will be the subject
    1.90 +                        # of a special promotion in the period
    1.91 +
    1.92 +###  INVENTORY AND SHORTAGE PARAMETERS  ###
    1.93 +
    1.94 +param rir 'regular inventory ratio' >= 0;
    1.95 +
    1.96 +                        # Proportion of non-promoted demand
    1.97 +                        # that must be in inventory the previous period
    1.98 +
    1.99 +param pir 'promotional inventory ratio' >= 0;
   1.100 +
   1.101 +                        # Proportion of promoted demand
   1.102 +                        # that must be in inventory the previous period
   1.103 +
   1.104 +param life 'inventory lifetime' > 0 integer;
   1.105 +
   1.106 +                        # Upper limit on number of periods that
   1.107 +                        # any product may sit in inventory
   1.108 +
   1.109 +param cri 'inventory cost ratio' {prd} > 0;
   1.110 +
   1.111 +                        # Inventory cost per 1000 units is
   1.112 +                        # cri times nominal production cost
   1.113 +
   1.114 +param crs 'shortage cost ratio' {prd} > 0;
   1.115 +
   1.116 +                        # Shortage cost per 1000 units is
   1.117 +                        # crs times nominal production cost
   1.118 +
   1.119 +param iinv 'initial inventory' {prd} >= 0;
   1.120 +
   1.121 +                        # Inventory at start of first period; age unknown
   1.122 +
   1.123 +param iil 'initial inventory left' {p in prd, t in time}
   1.124 +              := iinv[p] less sum {v in first..t} dem[p,v];
   1.125 +
   1.126 +                        # Initial inventory still available for allocation
   1.127 +                        # at end of period t
   1.128 +
   1.129 +param minv 'minimum inventory' {p in prd, t in time}
   1.130 +              := dem[p,t+1] * (if pro[p,t+1] then pir else rir);
   1.131 +
   1.132 +                        # Lower limit on inventory at end of period t
   1.133 +
   1.134 +###  VARIABLES  ###
   1.135 +
   1.136 +var Crews{first-1..last} >= 0;
   1.137 +
   1.138 +                        # Average number of crews employed in each period
   1.139 +
   1.140 +var Hire{time} >= 0;    # Crews hired from previous to current period
   1.141 +
   1.142 +var Layoff{time} >= 0;  # Crews laid off from previous to current period
   1.143 +
   1.144 +var Rprd 'regular production' {prd,time} >= 0;
   1.145 +
   1.146 +                        # Production using regular-time labor, in 1000s
   1.147 +
   1.148 +var Oprd 'overtime production' {prd,time} >= 0;
   1.149 +
   1.150 +                        # Production using overtime labor, in 1000s
   1.151 +
   1.152 +var Inv 'inventory' {prd,time,1..life} >= 0;
   1.153 +
   1.154 +                        # Inv[p,t,a] is the amount of product p that is
   1.155 +                        # a periods old -- produced in period (t+1)-a --
   1.156 +                        # and still in storage at the end of period t
   1.157 +
   1.158 +var Short 'shortage' {prd,time} >= 0;
   1.159 +
   1.160 +                        # Accumulated unsatisfied demand at the end of period t
   1.161 +
   1.162 +###  OBJECTIVE  ###
   1.163 +
   1.164 +minimize cost:
   1.165 +
   1.166 +    sum {t in time} rtr * sl * dpp[t] * cs * Crews[t] +
   1.167 +    sum {t in time} hc[t] * Hire[t] +
   1.168 +    sum {t in time} lc[t] * Layoff[t] +
   1.169 +    sum {t in time, p in prd} otr * cs * pt[p] * Oprd[p,t] +
   1.170 +    sum {t in time, p in prd, a in 1..life} cri[p] * pc[p] * Inv[p,t,a] +
   1.171 +    sum {t in time, p in prd} crs[p] * pc[p] * Short[p,t];
   1.172 +
   1.173 +                        # Full regular wages for all crews employed, plus
   1.174 +                        # penalties for hiring and layoffs, plus
   1.175 +                        # wages for any overtime worked, plus
   1.176 +                        # inventory and shortage costs
   1.177 +
   1.178 +                        # (All other production costs are assumed
   1.179 +                        # to depend on initial inventory and on demands,
   1.180 +                        # and so are not included explicitly.)
   1.181 +
   1.182 +###  CONSTRAINTS  ###
   1.183 +
   1.184 +rlim 'regular-time limit' {t in time}:
   1.185 +
   1.186 +    sum {p in prd} pt[p] * Rprd[p,t] <= sl * dpp[t] * Crews[t];
   1.187 +
   1.188 +                        # Hours needed to accomplish all regular-time
   1.189 +                        # production in a period must not exceed
   1.190 +                        # hours available on all shifts
   1.191 +
   1.192 +olim 'overtime limit' {t in time}:
   1.193 +
   1.194 +    sum {p in prd} pt[p] * Oprd[p,t] <= ol[t];
   1.195 +
   1.196 +                        # Hours needed to accomplish all overtime
   1.197 +                        # production in a period must not exceed
   1.198 +                        # the specified overtime limit
   1.199 +
   1.200 +empl0 'initial crew level':  Crews[first-1] = iw;
   1.201 +
   1.202 +                        # Use given initial workforce
   1.203 +
   1.204 +empl 'crew levels' {t in time}:  Crews[t] = Crews[t-1] + Hire[t] - Layoff[t];
   1.205 +
   1.206 +                        # Workforce changes by hiring or layoffs
   1.207 +
   1.208 +emplbnd 'crew limits' {t in time}:  cmin[t] <= Crews[t] <= cmax[t];
   1.209 +
   1.210 +                        # Workforce must remain within specified bounds
   1.211 +
   1.212 +dreq1 'first demand requirement' {p in prd}:
   1.213 +
   1.214 +    Rprd[p,first] + Oprd[p,first] + Short[p,first]
   1.215 +                             - Inv[p,first,1] = dem[p,first] less iinv[p];
   1.216 +
   1.217 +dreq 'demand requirements' {p in prd, t in first+1..last}:
   1.218 +
   1.219 +    Rprd[p,t] + Oprd[p,t] + Short[p,t] - Short[p,t-1]
   1.220 +                          + sum {a in 1..life} (Inv[p,t-1,a] - Inv[p,t,a])
   1.221 +                                                  = dem[p,t] less iil[p,t-1];
   1.222 +
   1.223 +                        # Production plus increase in shortage plus
   1.224 +                        # decrease in inventory must equal demand
   1.225 +
   1.226 +ireq 'inventory requirements' {p in prd, t in time}:
   1.227 +
   1.228 +    sum {a in 1..life} Inv[p,t,a] + iil[p,t] >= minv[p,t];
   1.229 +
   1.230 +                        # Inventory in storage at end of period t
   1.231 +                        # must meet specified minimum
   1.232 +
   1.233 +izero 'impossible inventories' {p in prd, v in 1..life-1, a in v+1..life}:
   1.234 +
   1.235 +    Inv[p,first+v-1,a] = 0;
   1.236 +
   1.237 +                        # In the vth period (starting from first)
   1.238 +                        # no inventory may be more than v periods old
   1.239 +                        # (initial inventories are handled separately)
   1.240 +
   1.241 +ilim1 'new-inventory limits' {p in prd, t in time}:
   1.242 +
   1.243 +    Inv[p,t,1] <= Rprd[p,t] + Oprd[p,t];
   1.244 +
   1.245 +                        # New inventory cannot exceed
   1.246 +                        # production in the most recent period
   1.247 +
   1.248 +ilim 'inventory limits' {p in prd, t in first+1..last, a in 2..life}:
   1.249 +
   1.250 +    Inv[p,t,a] <= Inv[p,t-1,a-1];
   1.251 +
   1.252 +                        # Inventory left from period (t+1)-p
   1.253 +                        # can only decrease as time goes on
   1.254 +
   1.255 +###  DATA  ###
   1.256 +
   1.257 +data;
   1.258 +
   1.259 +set prd := 18REG 24REG 24PRO ;
   1.260 +
   1.261 +param first :=  1 ;
   1.262 +param last  := 13 ;
   1.263 +param life  :=  2 ;
   1.264 +
   1.265 +param cs := 18 ;
   1.266 +param sl :=  8 ;
   1.267 +param iw :=  8 ;
   1.268 +
   1.269 +param rtr := 16.00 ;
   1.270 +param otr := 43.85 ;
   1.271 +param rir :=  0.75 ;
   1.272 +param pir :=  0.80 ;
   1.273 +
   1.274 +param :         pt       pc        cri       crs      iinv   :=
   1.275 +
   1.276 +  18REG      1.194     2304.     0.015     1.100      82.0
   1.277 +  24REG      1.509     2920.     0.015     1.100     792.2
   1.278 +  24PRO      1.509     2910.     0.015     1.100       0.0   ;
   1.279 +
   1.280 +param :     dpp        ol      cmin      cmax        hc        lc   :=
   1.281 +
   1.282 +  1        19.5      96.0       0.0       8.0      7500      7500
   1.283 +  2        19.0      96.0       0.0       8.0      7500      7500
   1.284 +  3        20.0      96.0       0.0       8.0      7500      7500
   1.285 +  4        19.0      96.0       0.0       8.0      7500      7500
   1.286 +  5        19.5      96.0       0.0       8.0     15000     15000
   1.287 +  6        19.0      96.0       0.0       8.0     15000     15000
   1.288 +  7        19.0      96.0       0.0       8.0     15000     15000
   1.289 +  8        20.0      96.0       0.0       8.0     15000     15000
   1.290 +  9        19.0      96.0       0.0       8.0     15000     15000
   1.291 + 10        20.0      96.0       0.0       8.0     15000     15000
   1.292 + 11        20.0      96.0       0.0       8.0      7500      7500
   1.293 + 12        18.0      96.0       0.0       8.0      7500      7500
   1.294 + 13        18.0      96.0       0.0       8.0      7500      7500   ;
   1.295 +
   1.296 +param dem (tr) :
   1.297 +
   1.298 +          18REG     24REG     24PRO   :=
   1.299 +
   1.300 +  1        63.8    1212.0       0.0
   1.301 +  2        76.0     306.2       0.0
   1.302 +  3        88.4     319.0       0.0
   1.303 +  4       913.8     208.4       0.0
   1.304 +  5       115.0     298.0       0.0
   1.305 +  6       133.8     328.2       0.0
   1.306 +  7        79.6     959.6       0.0
   1.307 +  8       111.0     257.6       0.0
   1.308 +  9       121.6     335.6       0.0
   1.309 + 10       470.0     118.0    1102.0
   1.310 + 11        78.4     284.8       0.0
   1.311 + 12        99.4     970.0       0.0
   1.312 + 13       140.4     343.8       0.0
   1.313 + 14        63.8    1212.0       0.0   ;
   1.314 +
   1.315 +param pro (tr) :
   1.316 +
   1.317 +          18REG     24REG     24PRO   :=
   1.318 +
   1.319 +  1           0         1         0
   1.320 +  2           0         0         0
   1.321 +  3           0         0         0
   1.322 +  4           1         0         0
   1.323 +  5           0         0         0
   1.324 +  6           0         0         0
   1.325 +  7           0         1         0
   1.326 +  8           0         0         0
   1.327 +  9           0         0         0
   1.328 + 10           1         0         1
   1.329 + 11           0         0         0
   1.330 + 12           0         0         0
   1.331 + 13           0         1         0
   1.332 + 14           0         1         0   ;
   1.333 +
   1.334 +end;