# define set of Customers set CUSTOMERS := {"1","2","3","4","5","6"}; # define Set of Facilities set FACILITIES := {"A","B","C","D"}; # create set of all (f,c) where f is a facility and c is a customer set FC := FACILITIES * CUSTOMERS; # these are the assignment costs # they correspond to the c_{fc} in our LP model param assignment[FC] := |"1", "2", "3", "4", "5", "6"| |"A"| 12, 23, 163, 34, 15, 67 | |"B"| 27, 183, 54, 53, 169, 11 | |"C"| 139, 38, 56, 56, 131, 22 | |"D"| 48, 15, 61, 11, 32, 133 |; param openingcost[FACILITIES] := <"A"> 86,<"B"> 80,<"C"> 80,<"D"> 80; # the c_f in the LP model param demand[CUSTOMERS] := <"1"> 3,<"2"> 2,<"3"> 2,<"4"> 3,<"5"> 4,<"6"> 1; param CAPACITY := 5; var y[FC] binary; var z[FACILITIES] binary; # define objective function minimize cost: sum in FACILITIES: openingcost[f] * z[f] + sum in FC: assignment[f,c] * y[f,c]; subto assign: forall in CUSTOMERS do sum in FACILITIES: y[f,c] == 1; # to connect a customer to a facility f, facility f has to be opened and opening cost has to paid: subto open: forall in FC do y[f, c] <= z[f]; subto limitedcapacity: forall in FACILITIES do sum in CUSTOMERS: demand[c]*y[f,c] <= CAPACITY;