$ontext Capacitated warehouse location problem This formulation uses data directly Data from: http://people.brunel.ac.uk/~mastjjb/jeb/orlib/capinfo.html $offtext $include capa.inc parameter demand(j) 'demand for each client' cap(i) 'capacity' fcost(i) 'fixed cost' xcost(i,j) 'variable cost' ; display custdata; demand(j) = custdata(j,'demand'); cap(i) = whdata(i,'capacity'); fcost(i) = whdata(i,'fixedcost'); xcost(i,j) = custdata(j,i); display xcost; positive variables x(i,j) 'fraction of orders of this client handled by warehouse'; * note: if x is binary we would restrict a client to be serviced by a single supplier binary variable y(i) 'facility open/close'; variable cost; equations assign(j) 'assignment constraint' capacity(i) 'capacity of supplier' obj 'objective' extra 'this one does not help' ; x.up(i,j)=1; obj.. cost =e= sum(i, fcost(i)*y(i)) + sum((i,j),xcost(i,j)*x(i,j)); assign(j).. sum(i, x(i,j)) =E= 1; capacity(i).. sum(j, demand(j)*x(i,j)) =L= cap(i)*y(i); * this gives tighter formulation but the problem becomes too large to solve quickly extra(i,j).. x(i,j)=L=y(i); option optcr=0; model m1 /obj,assign,capacity/; model m2 /obj,assign,capacity,extra/; solve m1 minimizing cost using mip; parameter ship(i,j) 'recover shipments'; ship(i,j) = x.l(i,j)*demand(j); option y:0,ship:0; display y.l, ship;