/* =========================================================================== AMPL Model of the Eastern Steel Example on Page 105 and following of Moore et al. =========================================================================== */ set MINES; # Mine 1, Mine 2, ... set ELEMENTS; # A, B, ... /* --------------------------------------------------------------------------- Minimum Lbs of each element per ton of alloy --------------------------------------------------------------------------- */ param MinLbs{ELEMENTS}; table MinLbsTable IN "ODBC" "D:\personal\15057\EasternSteelData.mdb" "MinLbs": ELEMENTS <- [Element], MinLbs; read table MinLbsTable; /* --------------------------------------------------------------------------- Cost per ton of ore from each mine --------------------------------------------------------------------------- */ param CostPerTon{MINES}; table CostTable IN "ODBC" "D:\personal\15057\EasternSteelData.mdb" "Cost": MINES <- [Mine], CostPerTon; read table CostTable; /* --------------------------------------------------------------------------- The lbs of each element in each ton of ore from each mine --------------------------------------------------------------------------- */ param LbsPerTon{MINES, ELEMENTS}; table LbsPerTonTable IN "ODBC" "D:\personal\15057\EasternSteelData.mdb" "LbsPerTon": [Mine, Element], LbsPerTon; read table LbsPerTonTable; /* --------------------------------------------------------------------------- Variables are the tons of ore from each Mine per ton of Alloy --------------------------------------------------------------------------- */ var Tons{MINES} >= 0; /* --------------------------------------------------------------------------- Objective: Minimize the cost per ton of the alloy --------------------------------------------------------------------------- */ minimize TotalCost: sum{mine in MINES} CostPerTon[mine]*Tons[mine]; /* --------------------------------------------------------------------------- Constraints: Meet the composition requirements for each basic element --------------------------------------------------------------------------- */ s.t. CompositionConsts {elem in ELEMENTS}: sum{mine in MINES} LbsPerTon[mine, elem]*Tons[mine] >= MinLbs[elem]; /* --------------------------------------------------------------------------- Use one ton of Ore to make one ton of Alloy --------------------------------------------------------------------------- */ s.t. TotalWeight: sum{mine in MINES} Tons[mine] = 1; option solver cplex; solve;