MS&E 212, Spring 2005-06 Handout 3 The AMPL model for the trasnportation model, discussed in the discussion section on 4/7/2006, as well as another example. Brad Null. ------------------------------------------------------------- transp.mod ------------------------------------------------------------- set ORIG; set DEST; param supply {ORIG} >= 0; param demand {DEST} >= 0; param cost {ORIG,DEST} >= 0; var Trans {ORIG,DEST} >= 0; minimize Total_Cost: sum {i in ORIG, j in DEST} cost[i,j] * Trans[i,j]; subject to Supply {i in ORIG}: sum {j in DEST} Trans[i,j] <= supply[i]; subject to Demand {j in DEST}: sum {i in ORIG} Trans[i,j] >= demand[j]; ------------------------------------------------------------- transp.dat ------------------------------------------------------------- param: ORIG: supply := L1 20000 L2 12000 ; param: DEST: demand := W1 4000 W2 6000 W3 2000 W4 10000 W5 8000 ; param cost: W1 W2 W3 W4 W5 := L1 5.31 5.29 5.37 5.34 5.30 L2 5.85 5.79 5.75 5.78 5.78 ; ------------------------------------------------------------- example.mod ------------------------------------------------------------- param T > 0; # No of periods param M > 0; # Large number param fixedcost {2..T+1} >= 0; # Fixed cost of production in period t param prodcost {2..T+1} >= 0; # Production cost of production in period t param storcost {2..T+1} >= 0; # Storage cost of production in period t param demand {2..T+1} >= 0; # Demand in period t var made {2..T+1} >= 0; # Units Produced in period t var stock {1..T+1} >= 0; # Units Stored at end of t var decide {2..T+1} binary; # Decision to produce minimize total_cost: sum {t in 2..T+1} (prodcost[t] * made[t] +fixedcost[t] * decide[t] + storcost[t] * stock[t]); subject to C: stock[1] = 0; subject to A {t in 2..T+1}: stock[t-1] + made[t] = demand[t] + stock[t]; subject to B {t in 2..T+1}: made[t] <= M * decide[t]; ------------------------------------------------------------- example.dat ------------------------------------------------------------- param T:= 6; param demand := 2 6 3 7 4 4 5 6 6 3 7 8; param prodcost := 2 3 3 4 4 3 5 4 6 4 7 5; param storcost := 2 1 3 1 4 1 5 1 6 1 7 1; param fixedcost := 2 12 3 15 4 30 5 23 6 19 7 45; param M := 10;