File: facility_location.zpl

package info (click to toggle)
zimpl 2.05.ds2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,644 kB
  • ctags: 2,404
  • sloc: ansic: 16,953; yacc: 814; lex: 304; sh: 182; makefile: 181
file content (57 lines) | stat: -rw-r--r-- 1,730 bytes parent folder | download | duplicates (2)
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
# $Id: facility_location.zpl,v 1.2 2003/10/29 19:44:46 bzfkocht Exp $
#
# Generic formulation for the Capacitated Facility Location Problem
#
# Of course this is also kind of a bin packing problem with packing costs
# and variable sized bins, or a cutting stock problem with cutting costs.
#
set PLANTS := { "A", "B", "C", "D" };
set STORES := { 1 .. 9 };
set PS     := PLANTS * STORES;

# How much does it cost to build a plant and what capacity will 
# it then have?
#
param building[PLANTS] := <"A"> 500, <"B"> 600, <"C"> 700, <"D"> 800;
param capacity[PLANTS] := <"A">  40, <"B">  55, <"C">  73, <"D">  90;

# Here is the demand of each store
#
param demand  [STORES] := <1> 10, <2> 14, <3> 17, <4> 8, <5> 9,
                          <6> 12, <7> 11, <8> 15, <9> 16;

# Transportation cost from each plant to each store
#
param transport[PS] := 
      |  1,  2,  3,  4,  5,  6,  7,  8,  9 |
  |"A"| 55,  4, 17, 33, 47, 98, 19, 10,  6 |
  |"B"| 42, 12,  4, 23, 16, 78, 47,  9, 82 | 
  |"C"| 17, 34, 65, 25,  7, 67, 45, 13, 54 |
  |"D"| 60,  8, 79, 24, 28, 19, 62, 18, 45 |;

var x[PS]     binary;  # Is plant p suppling store s ?
var z[PLANTS] binary;  # Is plant p build ?

# We want it cheap
#
minimize cost: sum <p> in PLANTS : building[p] * z[p]
             + sum <p,s> in PS : transport[p,s] * x[p,s];

# Each store is supplied by exactly one plant
#
subto assign: forall <s> in STORES : sum <p> in PLANTS : x[p,s] == 1;
   
# To be able to supply a store, a plant must be build
#
subto build: forall <p,s> in PS : x[p,s] <= z[p];

# The plant must be able to meet the demands from all stores
# that are connected to it
#
subto limit: forall <p> in PLANTS :
   sum <s> in STORES : demand[s] * x[p,s] <= capacity[p];