model "Balanced Transportation" uses "mmxprs"; !gain access to the Xpress-Optimizer solver parameters NUMPLANTS= 3 NUMCITIES= 4 end-parameters !sample declarations section declarations !declare sets PLANTS= 1..NUMPLANTS CITIES=1..NUMCITIES !declare parameters Cost: array(PLANTS,CITIES) of real Supply: array(PLANTS) of real Demand: array(CITIES) of real !declare variables transport: array(PLANTS,CITIES) of mpvar TotalCost: linctr SupplyConstraint: array(PLANTS) of linctr end-declarations !initialisations Cost::[8,6,10,9,9,12,13,7,14,9,16,5] Supply::[35,50,40] Demand::[45,20,30,30] !constraints forall(i in PLANTS) do SupplyConstraint(i):= sum(j in CITIES) transport(i,j) = Supply(i) end-do forall(j in CITIES) do sum(i in PLANTS) transport(i,j) = Demand(j) end-do TotalCost:= sum(i in PLANTS, j in CITIES) Cost(i,j) * transport(i,j) minimise(TotalCost) writeln("Total cost is: $", getobjval) end-model