$title TYCO from Winston and Albright, 2nd ed., p. 154 et seq. * It's called FunToys there, as the company name "Tyco" has become * somewhat notorious option limcol = 0; set months / Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec/; * cash inflow (negative value indicates net outflow) parameter cashIn(months) cash inflow in thousands of dollars / Jan -12, Feb -10, Mar -8, Apr -10, May -4, Jun 5, Jul -7, Aug -2, Sep 15, Oct 12, Nov -7, Dec 45/; * minimum cash balance at end of each month ($k) scalar cashBalMin /5/; scalar initialCap /6.5/; set accounts /long-loan, short-loan, cash/; parameter interestRate(accounts) /long-loan 1, short-loan 1.5, cash 0.4/; * convert from percentage to proportion by dividing by 100 interestRate(accounts) = interestRate(accounts) / 100; variable longLoan amount of long-term loan taken in January ($K) shortLoan(months) amount of short-term loans taken out this month ($K) shortPaid(months) amount of short-term loans paid off this month ($K) shortNet(months) net amount of short-term loans owing at end of this month ($K) cashBal(months) cash balance at end of each month ($K) cashInt(months) interest earned on last month's cash balance ($K) longInt interest paid on long-term loan each month ($K) shortInt(months) interest paid on short-term loan each month ($K) cashFinal final cash position ($K); positive variables longLoan, shortLoan, shortPaid, shortNet, cashBal, cashInt, longInt, shortInt; equations EQcashInt(months) define interest earned on cash balance each month EQlongInt define interest paid on long-term loan this month EQshortNet(months) figure net amount of short-term loans owing at end of month EQshortInt(months) define interest paid on short-term loan this month EQcashBal(months) figure cash balance at end of the month EQcashFinal figure final cash position; * note that for months=Jan, cashInt will be zero EQcashInt(months).. cashInt(months) =e= (initialCap$(ord(months) = 1) + cashBal(months-1)) * interestRate('cash'); * set longInt to zero for months=Jan EQlongInt.. longInt =e= longLoan * interestRate('long-loan'); * for months=Jan, shortInt will be zero (no interest paid in first month) * "months-1" goes out of range for this value - check listing file EQshortInt(months).. shortInt(months) =e= shortNet(months-1) * interestRate('short-loan'); * figure balance of short-term loans at the end of this month EQshortNet(months).. shortNet(months) =e= shortNet(months-1) + shortLoan(months) - shortPaid(months); * figure cash balance at end of month EQcashBal(months).. cashBal(months) =e= (initialCap + longLoan)$(ord(months) = 1) + cashBal(months-1) + cashInt(months) + shortLoan(months) - shortPaid(months) + cashIn(months) - longInt$(ord(months) > 1) - shortInt(months); EQcashFinal.. cashFinal =e= cashBal('Dec') + cashBal('Dec') * interestRate('cash') - longInt - longLoan; * pay off all short-term loans by next January shortNet.fx("Dec") = 0; * set minimum cash balance at end of each month cashBal.lo(months) = cashBalMin; model tyco/all/; solve tyco using lp maximizing cashFinal; * convert results to $ from $K longLoan.l = 1000*longLoan.l; shortLoan.l(months) = 1000*shortLoan.l(months); shortPaid.l(months) = 1000*shortPaid.l(months); shortNet.l(months) = 1000*shortNet.l(months); cashBal.l(months) = 1000*cashBal.l(months); cashInt.l(months) = 1000*cashInt.l(months); longInt.l = 1000*longInt.l; shortInt.l(months) = 1000*shortInt.l(months); cashFinal.l = 1000*cashFinal.l; * globally set number of decimals displayed to 2 option decimals=2; display longLoan.l, longInt.l; * for shortLoan, display 2 decimal places; 0:1 indicates maximum 1 label * displayed on each line option shortLoan:2:0:1; display shortLoan.l; option shortPaid:2:0:1; display shortPaid.l; option shortNet:2:0:1; display shortNet.l; option shortInt:2:0:1; display shortInt.l; option cashBal:2:0:1; display cashBal.l; option cashInt:2:0:1; display cashInt.l; display cashFinal.l;