+{Page}Tour ! 1 Start /05/08/2003 18:33:12.294 !---------------------------------------- +{Object.1} Tour.[1]Start INTEGER:: intAlStat +{Trans} CALL OpenTableFile(21,WithPath("Salesman.CFG.HTM")) !WithPath prefixes file name in ... CALL GetTable(21,{Table.30}OperationalData) !quotes with the model's path. CALL GetTable(21,{Table.D}TravelTime,regRowLo=0,regColLo=0) !Row & col indices of tables... CALL GetTable(21,{Table.D}Distance,regRowLo=0,regColLo=0) !start at 0, not default of 1 CLOSE(21) !----- CALL VarLookUp({T.30}OperationalData,"NumberOfItems",1,dblValue=&D.NumberOfItems) CALL VarLookUp({T.30}OperationalData,"MaxTravelBeforeRest",1,dblValue=&D.MaxTravelBeforeRest) CALL VarLookUp({T.30}OperationalData,"MinRestTime",1,dblValue=&D.MinRestTime) CALL VarLookUp({T.30}OperationalData,"DailyFixedCost",1,dblValue=&D.DailyFixedCost) CALL VarLookUp({T.30}OperationalData,"OpCostPerMile",1,dblValue=&D.OpCostPerMile) CALL VarLookUp({T.30}OperationalData,"OpCostPerWorkHour",1,dblValue=&D.OpCostPerWorkHour) CALL VarLookUp({T.30}OperationalData,"TopN",1,dblValue=&D.TopN) !----- OPEN(21,FILE=WithPath("ResultsN.TXT")) !OPEN(22,STATUS='SCRATCH') !----- &B.Items = &D.NumberOfItems WRITE(21,*)&B.Items,"= Parameter for permutations" &B.Sequences = Factorial(&B.Items) WRITE(21,*)"Total possible sequences =",&B.Sequences WRITE(21,*) !----- &B.TopChoices = &D.TopN &B.Sequence = 0 @B.NextItem = 0 @D.TimeSinceRest = 0. @D.TotHours = 0. @D.TotDistance = 0. @D.Time = 0. !Tracks time elapsed during each tour @D.DayMark = 0. !For tracking per diem payments !----- !Allocate starting surrogate's HasBeenAt mem and initialize all Items to logNo by default CALL InitHasBeenAt(bigSur,&B.Items) !----- {?|&B.Sequences} !Echo value of &B.Sequences with ??? and identifying label for easy search -{Trans} -{Object.1} Tour.[1]Start !---------------------------------------- +{Object.3} Tour.[3]SendToWhereNotBeen INTEGER(big):: bigIndx +{SignalTarget} @B.CurrentItem = @B.NextItem @L.VisitedAllTasks = logYes !Presumption to be negated in loop below if not true DO bigIndx = 1, &B.Items !Transmit threads to all Items/tasks not yet visited IF(HasBeenAt(bigSur,bigIndx))CYCLE !Check next Item/task (jump to top of loop) @B.NextItem = bigIndx !Has not been to this task, so... @L.VisitedAllTasks = logNo !Means incoming surrogate will not traverse [6] {Signal.4} !Signal inherits all properties of incoming surrogate; goes to [4] ENDDO -{SignalTarget} -{Object.3} Tour.[3]SendToWhereNotBeen !---------------------------------------- +{Object.4} Tour.[4]SendToWhereNotBeen--->|Segment +{Branch} {nop.L}Branch={logNo} -{Branch} -{Object.4} Tour.[4]SendToWhereNotBeen--->|Segment !---------------------------------------- +{Object.5} Tour.[5]BackAtOrigin +{Trans} &B.Sequence = &B.Sequence + 1 WRITE(strInpLine( 1:20),*)&B.Sequence WRITE(strInpLine(21:40),'(F12.2)')Time() WRITE(strInpLine(41:60),'(F12.1)')@D.TotDistance WRITE(strInpLine(61:80),'(F12.1)')@D.Time WRITE(21,*)REPEAT("-",100) WRITE(21,'(2X,A)')"Tour "//TRIM(ADJUSTL(strInpLine( 1:20))) & //": Total cost = "//TRIM(ADJUSTL(strInpLine(21:40)))//" dollars" & //". Total distance = "//TRIM(ADJUSTL(strInpLine(41:60)))//" miles" & //". Total time = "//TRIM(ADJUSTL(strInpLine(61:80)))//" hours." CALL ShowTravelNotes(bigSur,21) !Write travel/visitation history to 21 &R.Choice = &R.Choice + 1 $L.YellowFlag = &B.Sequence == &B.TopChoices -{Trans} -{Object.5} Tour.[5]BackAtOrigin !---------------------------------------- +{Object.6} Tour.[6]SendToWhereNotBeen--->|Segment +{Branch} {nop.L}Branch={@L.VisitedAllTasks} -{Branch} +{Trans} @B.NextItem = 0 -{Trans} -{Object.6} Tour.[6]SendToWhereNotBeen--->|Segment !---------------------------------------- +{Object.9} Tour.[9]Segment--->|SendToWhereNotBeen +{Duration} {nop.D}Duration={@D.SegmentCosts} -{Duration} -{Object.9} Tour.[9]Segment--->|SendToWhereNotBeen !---------------------------------------- +{Object.11} Tour.[11]Segment--->|BackAtOrigin +{Duration} {nop.D}Duration={@D.SegmentCosts} -{Duration} -{Object.11} Tour.[11]Segment--->|BackAtOrigin -{Page}Tour ////////////////////////////////////////// +{Page}Segment ! 1 PlainTimeDistCosts /05/08/2003 18:33:12.294 !---------------------------------------- +{Object.1} Segment.[1]PlainTimeDistCosts +{Trans} &D.FixedCosts = 0. &D.TimeTillNextNode = {t.D}TravelTime(@B.CurrentItem,@B.NextItem) &D.TimeBasedSegmentOpCost = &D.TimeTillNextNode * &D.OpCostPerWorkHour !----- &D.Distance = {t.D}Distance(@B.CurrentItem,@B.NextItem) &D.MileBasedSegmentOpCost = &D.Distance * &D.OpCostPerMile !----- WRITE(&120.LinePad,*)"-----" CALL TravelNotes(bigSur,&120.LinePad) !----- WRITE(&120.LinePad,*)"Segment from",@B.CurrentItem,"to",@B.NextItem, & " Distance =",&D.Distance," Non-stop travel time =",&D.TimeTillNextNode CALL TravelNotes(bigSur,&120.LinePad) !Record travel (task to which being sent) !----- @D.TimeTillRest = &D.MaxTravelBeforeRest - @D.TimeSinceRest &L.TooLong = &D.TimeTillNextNode > @D.TimeTillRest -{Trans} -{Object.1} Segment.[1]PlainTimeDistCosts !---------------------------------------- +{Object.2} Segment.[2]Rest +{Trans} @D.Time = @D.Time + &D.TimeTillStop @D.TimeSinceRest = @D.TimeSinceRest + &D.TimeTillStop CALL UpdatePerDiemFixedCosts(bigSur) !----- WRITE(&120.LinePad,*)@D.Time," Rest for", & &D.MinRestTime,"hours till",@D.Time + &D.MinRestTime CALL TravelNotes(bigSur,&120.LinePad) !----- @D.Time = @D.Time + &D.MinRestTime &D.TimeTillNextNode = &D.TimeTillNextNode - &D.TimeTillStop @D.TimeSinceRest = 0. !----- WRITE(&120.LinePad,*)@D.Time," Non-stop travel time remaining in this segment =", & &D.TimeTillNextNode,"hours." CALL TravelNotes(bigSur,&120.LinePad) !----- @D.TimeTillRest = &D.MaxTravelBeforeRest &L.TooLong = &D.TimeTillNextNode > @D.TimeTillRest -{Trans} -{Object.2} Segment.[2]Rest !---------------------------------------- +{Object.4} Segment.[4]TotalSegmentCosts +{Trans} @D.Time = @D.Time + &D.TimeTillStop @D.TimeSinceRest = @D.TimeSinceRest + &D.TimeTillStop CALL UpdatePerDiemFixedCosts(bigSur) !----- @D.TotDistance = @D.TotDistance + &D.Distance @D.SegmentCosts = &D.FixedCosts + &D.MileBasedSegmentOpCost + &D.TimeBasedSegmentOpCost !----- !These costs were calculated in Segment.[1] WRITE(&120.LinePad,*)@D.Time," Mile-based cost =",&D.MileBasedSegmentOpCost,& " Time-based cost =",&D.TimeBasedSegmentOpCost CALL TravelNotes(bigSur,&120.LinePad) !----- WRITE(&120.LinePad,*)"Per diem =",&D.FixedCosts," Total segment costs =",@D.SegmentCosts CALL TravelNotes(bigSur,&120.LinePad) !----- WRITE(&120.LinePad,*)"Running totals: Cost =", & Time() + @D.SegmentCosts," Distance =",@D.TotDistance," Time =",@D.Time !Recall that Time() above signifies total cost upto this event, ... !since we are using Event queue to handle costs of surrogate traversals CALL TravelNotes(bigSur,&120.LinePad) !----- CALL SetHasBeenAt(bigSur,logYes,@B.NextItem) !Label target node as being visited -{Trans} -{Object.4} Segment.[4]TotalSegmentCosts !---------------------------------------- +{Object.5} Segment.[5]PlainTimeDistCosts--->|Rest +{Branch} {nop.L}Branch={&L.TooLong} -{Branch} +{Trans} &D.TimeTillStop = @D.TimeTillRest !----- WRITE(&120.LinePad,*)@D.Time," Stop for rest at", & @D.Time + @D.TimeTillRest,"in",&D.TimeTillStop,"hours." CALL TravelNotes(bigSur,&120.LinePad) -{Trans} -{Object.5} Segment.[5]PlainTimeDistCosts--->|Rest !---------------------------------------- +{Object.6} Segment.[6]PlainTimeDistCosts--->|TotalSegmentCosts +{Branch} {nop.L}Branch={.NOT. &L.TooLong} -{Branch} +{Trans} &D.TimeTillStop = &D.TimeTillNextNode !----- !WRITE(&120.LinePad,*)@D.Time," Hours since rest =",@D.TimeSinceRest," Travel", & !&D.TimeTillStop,"hours to next node." !CALL TravelNotes(bigSur,&120.LinePad) -{Trans} -{Object.6} Segment.[6]PlainTimeDistCosts--->|TotalSegmentCosts !---------------------------------------- +{Object.7} Segment.[7]Rest--->|TotalSegmentCosts +{Branch} {nop.L}Branch={.NOT. &L.TooLong} -{Branch} +{Trans} &D.TimeTillStop = &D.TimeTillNextNode !----- !WRITE(&120.LinePad,*)@D.Time," Hours since rest =",@D.TimeSinceRest," Travel", & !&D.TimeTillStop,"hours to next node." !CALL TravelNotes(bigSur,&120.LinePad) -{Trans} -{Object.7} Segment.[7]Rest--->|TotalSegmentCosts !---------------------------------------- +{Object.8} Segment.[8]Rest--->|Rest +{Branch} {nop.L}Branch={&L.TooLong} -{Branch} +{Trans} &D.TimeTillStop = @D.TimeTillRest !----- WRITE(&120.LinePad,*)@D.Time," Stop for rest at", & @D.Time + @D.TimeTillRest,"in",&D.TimeTillStop,"hours." CALL TravelNotes(bigSur,&120.LinePad) -{Trans} -{Object.8} Segment.[8]Rest--->|Rest -{Page}Segment //////////////////////////////////////////