model ModelName uses "mmxprs"; !gain access to the Xpress-Optimizer solver !declare parameters declarations !sets SUBURBS: set of string REGIONS: set of string !parameters !fixed cost f: array(SUBURBS) of real !demand d: array(REGIONS) of real !capacity c: array(SUBURBS) of real !distance a: array(SUBURBS,REGIONS) of real FeasibleSuburbRegion: dynamic array(SUBURBS,REGIONS) of real end-declarations initializations from "FACLOCdata.txt" f d c a FeasibleSuburbRegion end-initialisations finalize(SUBURBS) finalize(REGIONS) declarations x: array(SUBURBS) of mpvar y: dynamic array(SUBURBS,REGIONS) of mpvar z: mpvar end-declarations forward procedure Print_Solution !CREATE Y-VARIABLES forall(i in SUBURBS, j in REGIONS | FeasibleSuburbRegion(i,j) = 1) do create(y(i,j)) end-do !constraints forall(i in SUBURBS) do sum(j in REGIONS) y(i,j) <= c(i) * x(i) end-do forall(j in REGIONS) do sum(i in SUBURBS) y(i,j) >= d(j) end-do y("SEYMOUR","C") >= 2000*z y("LILYDALE","C") >= 2000*(1-z) forall(i in SUBURBS) do x(i) is_binary end-do Cost:= sum(i in SUBURBS) f(i) * x(i) + sum(i in SUBURBS, j in REGIONS) 20* a(i,j) * y(i,j) minimise(Cost) Print_Solution !************** procedure Print_Solution writeln("total cost: ", getobjval) end-procedure end-model