+{Page}ReplacementPlan ! 1 Initializations /02/06/2003 11:05:53.820 !---------------------------------------- +{Object.1} ReplacementPlan.[1]Initializations +{Trans} @T.Old = 1; @T.New = 2 strType(@T.Old) = "Old"; strType(@T.New) = "New" !---------------------------------------- !Get data from tables in tables.HTM worksheet CALL OpenTableFile(21,WithPath("tables.HTM")) call GetTable(21,{Table.D}PurchasePrices) call GetTable(21,{Table.D}OandMcosts) call GetTable(21,{Table.D}TradeInValues) close(21) !---------------------------------------- !Write top lines of results file &I.ResultsFile = 21 open(&I.ResultsFile,file=WithPath("ResultsP1.TXT"),action="write") write(&I.ResultsFile,'(A)')"Equipment Replacement Options Analysis" write(&I.ResultsFile,'(A)')"--------------------------------------" write(&I.ResultsFile,*) !---------------------------------------- &R.Alternative = 0 &R.AltsDesired = 10 !Number of top alternatives to be displayed &T.LastYr = 4 !Planning time horizon !---------------------------------------- @T.Year = 0 @D.TradeInValue = 0. -{Trans} -{Object.1} ReplacementPlan.[1]Initializations !---------------------------------------- +{Object.2} ReplacementPlan.[2]StartOfNewYear +{Trans} {nop.P}Trans:{@T.Year = @T.Year + 1}... !---------------------------------------- call ShowTravelNotes(bigSur) !Writes what has been the path so far to trace file !---------------------------------------- if(@T.Year == 1)then !Year 1 decision @T.BuyYear = @T.Year @D.TotalCost = {t.D}PurchasePrices(@T.Type,1) !---------------------------------------- !Write decision action to scratch pad and transfer to Travel Notes write(&255.LinePad,fmt=*)"Year=",@T.Year,". Buy: Type=" & //strType(@T.Type)//". Cost=",@D.TotalCost,". Running tot=",@D.TotalCost call TravelNotes(bigSur,&255.LinePad) !---------------------------------------- elseif(@L.TradeIn)then !Net cost of buying in the new year @T.BuyYear = @T.Year @D.PurchasePrice = {t.D}PurchasePrices(@T.Type,1) @D.TotalCost = @D.TotalCost + @D.PurchasePrice - @D.TradeInValue !---------------------------------------- !Write decision action to scratch pad and transfer to Travel Notes... !Analyst can use any other name for line scratch pad write(&255.LinePad,fmt=*)"Year=",@T.Year,". Buy: Type=" & //strType(@T.Type),". Cost=",@D.PurchasePrice,". Trade-in=", & @D.TradeInValue,". Net cost=",@D.PurchasePrice - @D.TradeInValue call TravelNotes(bigSur,&255.LinePad) !Record decision in chain of notes !---------------------------------------- endif -{Trans} -{Object.2} ReplacementPlan.[2]StartOfNewYear !---------------------------------------- +{Object.4} ReplacementPlan.[4]EndOfYear--->|Total costs +{Branch} {nop.L}Branch={@T.Year == &T.LastYr} -{Branch} +{Trans} {nop.P}Trans:{@D.TradeInValue = {t.D}TradeInValues(@T.Type,@T.Age)}... !---------------------------------------- !Final trade-in @D.TotalCost = @D.TotalCost - @D.TradeInValue !---------------------------------------- write(&255.LinePad,fmt=*)"Final trade-in=",@D.TradeInValue, & ". Running tot=",@D.TotalCost call TravelNotes(bigSur,&255.LinePad) !Record event in chain of notes !---------------------------------------- -{Trans} +{Duration} {nop.D}Duration={@D.TotalCost}... !Setting Duration equal to total costs causes alternatives to ... !line up in best to last order (lowest to highest cost) in Events queue -{Duration} -{Object.4} ReplacementPlan.[4]EndOfYear--->|Total costs !---------------------------------------- +{Object.5} ReplacementPlan.[5]EndOfYear--->|StartOfNewYear +{Branch} {nop.L}Branch={@T.Year < &T.LastYr} -{Branch} +{Trans} {nop.P}Trans:{@D.TradeInValue = 0}... @L.TradeIn = .false. -{Trans} -{Object.5} ReplacementPlan.[5]EndOfYear--->|StartOfNewYear !---------------------------------------- +{Object.6} ReplacementPlan.[6]StartOfNewYear--->|EndOfYear +{Trans} {nop.P}Trans:{@T.Age = @T.Year - @T.BuyYear + 1}... !Get operation and maintenance costs !---------------------------------------- @D.OandMcosts = {t.D}OandMcosts(@T.Type,@T.Age) @D.TotalCost = @D.TotalCost + @D.OandMcosts !---------------------------------------- !Track path/record decision action write(&255.LinePad,fmt=*)"Year=",@T.Year,". O&M=",@D.OandMcosts, & ". Running tot=",@D.TotalCost call TravelNotes(bigSur,&255.LinePad) !---------------------------------------- -{Trans} -{Object.6} ReplacementPlan.[6]StartOfNewYear--->|EndOfYear !---------------------------------------- +{Object.7} ReplacementPlan.[7]Total costs +{Trans} {nop.P}Trans:{&R.Alternative = &R.Alternative +1}... !Alternatives arrive in ascending order of total costs !---------------------------------------- if(&R.Alternative == 1)then write(&I.ResultsFile,fmt=*)"Top",&R.AltsDesired, & "alternatives are shown as requested.", & " Total enumerations were:",EventsRemaining()+1 write(&I.ResultsFile,fmt=*) endif !---------------------------------------- write(9,*)"Alternative:",&R.Alternative," Total cost=",@D.TotalCost write(&I.ResultsFile,*)"Alternative:",&R.Alternative," Total cost=", & @D.TotalCost call ShowTravelNotes(bigSur,&I.ResultsFile) !Writes out begin-to-end path !---------------------------------------- if(&R.Alternative >= &R.AltsDesired)then !---------------------------------------- write(9,fmt=*)"Top",&R.AltsDesired, & "alternatives are shown above as requested.", & " Total enumerations were:",&R.AltsDesired + EventsRemaining() !---------------------------------------- !Since desired number of top alternatives have been written to Results... !file, we are not interested in remaining alternatives $L.YellowFlag = .true. !To stop run endif -{Trans} -{Object.7} ReplacementPlan.[7]Total costs !---------------------------------------- +{Object.9} ReplacementPlan.[9]Initializations--->|StartOfNewYear +{Trans} {nop.P}Trans:{@T.Type = @T.Old}... -{Trans} -{Object.9} ReplacementPlan.[9]Initializations--->|StartOfNewYear !---------------------------------------- +{Object.10} ReplacementPlan.[10]Initializations--->|StartOfNewYear +{Trans} {nop.P}Trans:{@T.Type = @T.New}... -{Trans} -{Object.10} ReplacementPlan.[10]Initializations--->|StartOfNewYear !---------------------------------------- +{Object.11} ReplacementPlan.[11]EndOfYear--->|StartOfNewYear +{Branch} {nop.L}Branch={@T.Year < &T.LastYr} -{Branch} +{Trans} {nop.P}Trans:{@D.TradeInValue = {t.D}TradeInValues(@T.Type,@T.Age)}... @T.Type = @T.Old @L.TradeIn = .true. -{Trans} -{Object.11} ReplacementPlan.[11]EndOfYear--->|StartOfNewYear !---------------------------------------- +{Object.12} ReplacementPlan.[12]EndOfYear--->|StartOfNewYear +{Branch} {nop.L}Branch={@T.Year < &T.LastYr} -{Branch} +{Trans} {nop.P}Trans:{@D.TradeInValue = {t.D}TradeInValues(@T.Type,@T.Age)}... @T.Type = @T.New @L.TradeIn = .true. -{Trans} -{Object.12} ReplacementPlan.[12]EndOfYear--->|StartOfNewYear -{Page}ReplacementPlan //////////////////////////////////////////