Transpo rtation Models 38 9
a = range(1, M+1)
al = range(M)
b = range(1,N+1)
bl = range(N)
# Index list for decision variables x
xindx = [(a[i],b[j]) for j in bl for i in al]
# Create the model to contain the problem data
model = LpProblem("Unbalanced Transportation Problem 2",LpMinimize)
# Decision variables
x = LpVariable.dicts("X", xindx,0,None)
# The Pulp objective function
model += 20.0 * x[1,1] + 40.0 * x[1,2] + 70.0 * x[1,3] + 50.0*x[1,4] \
+ 100*x[2,1] + 60.0*x[2,2] + 90.0*x[2,3] + 80.0*x[2,4] \
+10.0*x[3,1] + 110.0*x[3,2] + 30.0*x[3,3] + 200*x[3,4] \
+125.0*x[4,1] + 147.0*x[4,2] + 95.0*x[4,3] + 255.0*x[4,4], \
"Transportation cost"
# Supply Constraints
model += x[1,1] + x[1,2] + x[1,3] + x[1,4] <= 300.0,"Supply Pt 1"
model += x[2,1] + x[2,2] + x[2, ...