$ondollar title Swedish Steel (LP) Example 4.2 of Rardin (1998) $offsymxref offsymlist offuelxref offuellist option limrow = 0, limcol = 0; option mip=zoom; sets j "ingredients" /1*7/, attrib "attributes of the blend" /carbon, nickel, chrom, molybd/; scalar charge "size of a charge" /1000/; parameter c(j) "unit cost of j" /1 16, 2 10, 3 8, 4 9, 5 48, 6 60, 7 53/; parameter u(j) "upper limits on j" /1 75, 2 250, 3 1000, 4 1000/; table cont(attrib,j) "attrib content of j" 1 2 3 4 5 6 7 carbon .0080 .0070 .0085 .0040 nickel .1800 .0320 1.000 chrom .1200 .0110 1.000 molybd .0010 1.000; parameter minlvl(attrib) "min attrib level in charge" /carbon .0065, nickel .030, chrom .010, molybd .011/; parameter maxlvl(attrib) "max attrib level in charge" /carbon .0075, nickel .035, chrom .012, molybd .013/; free variable cost "total cost"; positive variable x(j) "amount of j used"; equations obj "min total cost", wgt "weight of a charge", minblend(attrib) "minimum blend attrib content", maxblend(attrib) "maximum blend attrib content", avail(j) "availability of ingredient j"; obj.. cost =e= sum(j, c(j)*x(j)); wgt.. sum(j, x(j)) =e= charge; minblend(attrib).. sum(j, cont(attrib,j)*x(j)) =g= minlvl(attrib)*charge; maxblend(attrib).. sum(j, cont(attrib,j)*x(j)) =l= maxlvl(attrib)*charge; avail(j)$(ord(j) le 2).. x(j) =l= u(j); model swesteel /all/; solve swesteel using lp minimizing cost; binary variables y(j) "switching variables for ingredient j"; equation allornoth "all or nothing constraints"; allornoth(j)$(ord(j) le 2).. x(j) =e= u(j)*y(j); model sweallor /obj, wgt, minblend, maxblend, allornoth/; solve sweallor using mip minimizing cost; scalar fixchg /350/; equations fcobj "minimize total cost including fixed charges", switch(j) "fixed charge switching constraint for j"; fcobj.. cost =e= sum(j, c(j)*x(j)) + sum(j$(ord(j) le 4), fixchg*y(j)); switch(j)$(ord(j) le 4).. x(j) =l= u(j)*y(j); model swefix /fcobj, wgt, minblend, maxblend, switch/; solve swefix using mip minimizing cost;