# transportation.mod
#
# Written by Mike O'Sullivan & Cameron Walker 2004
#
# This file contains the balanced
# transportation model.
#
# Last modified: 2/4/2008
model;
# The supply nodes
set SUPPLY_NODES;
# The demand nodes
set DEMAND_NODES;
# The supply at the supply nodes
param Supply {SUPPLY_NODES} >= 0, integer;
# The demand at the demand nodes
param Demand {DEMAND_NODES} >= 0, integer;
# The cost of sending one unit of flow
param Cost {SUPPLY_NODES, DEMAND_NODES};
# The bounds on the flow of goods
param Lower {SUPPLY_NODES, DEMAND_NODES}
integer default 0;
param Upper {SUPPLY_NODES, DEMAND_NODES}
integer default Infinity;
# The flow of goods from supply nodes to demand nodes
var Flow {i in SUPPLY_NODES, j in DEMAND_NODES}
>= Lower[i, j], <= Upper[i, j], integer;
# The objective is to minimise the transportation cost
minimize TotalCost:
sum {i in SUPPLY_NODES, j in DEMAND_NODES}
Cost[i, j] * Flow[i, j];
# Flow must not exceed supply
subject to UseSupply {i in SUPPLY_NODES}:
sum {j in DEMAND_NODES} Flow[i, j] = Supply[i];
# Flow must meet demand
subject to MeetDemand {j in DEMAND_NODES}:
sum {i in SUPPLY_NODES} Flow[i, j] = Demand[j];