C ---------------------------------------------------------------------- INTEGER FUNCTION STD_BEGINRT(sim,net,act,veh,i) C ---------------------------------------------------------------------- C - Find the initial route for a given vehicle and copy into vehicle's C - path array C - INCLUDED FILES: #include "dyna.inc" #include "sim.inc" #include "network.inc" #include "activity.inc" #include "vehicle.inc" C - UNMODIFIED ARGUMENTS: RECORD /Sim_Data/ sim ! Simulation parameter data RECORD /Road_Network/ net ! Network Representation RECORD /Activity/ act ! Activity Data INTEGER i ! Index of link vehicle on which ! the vehicle is being generated C - MODIFIED ARGUMENTS: RECORD /Vehicle_Data/ veh ! Vehicle: path data is updated based ! on the driver's initial routing ! decision C - LOCAL VARIABLES: INTEGER ipinittmp ! tmp storage for init path flag INTEGER iftmp,iftmp2! tmp vehicle familiarity storage INTEGER ip ! eq path search index INTEGER ipp ! selected eq path pointer INTEGER ibest ! which (of k paths) the driver selected REAL sum ! sum of "logitized" path times REAL rancall ! storage for random number call REAL cumpri ! sum path priority INTEGER im ! movement index INTEGER ik ! kay path index INTEGER know ! kay path pointer C - FUNCTIONS CALLED INTEGER LINKMOVEINDEX !function C - RETURN VALUE: ! The simulation status C ---------------------------------------------------------------------- veh.jpath(1) = net.link(i).iunod veh.jpath(2) = net.link(i).idnod CR - Get the movement index of the link im = LINKMOVEINDEX(net,i,0) IF (im.LE.0) THEN CALL DYNA_ERROR('Error in Beginrt'//CHAR(0) + ,DYNA_NONFATAL_WARNING + ,DYNA_LOGIC_BUG + ,DYNA_UNKNOWN_ERROR) ENDIF ipinittmp = sim.ipinit ibest = 0 IF (IPINITtmp.EQ.2) THEN C IF THERE ARE NO PATHS SPECIFIED EXTERNALLY FROM THE **** C DOWNSTREAM NODE TO THE REQUIRED DESTINATION, THEN PICK **** C A RANDOM SHORTEST PATH, AS IN IPINIT=0 **** IF (net.link(i).linkdest(veh.jdest).NE.0) THEN C . There is an external equilibrium path available from link i C . to the vehicle's destination C - Determine which of the iftmp paths this driver will select C - (using either an equal or a logit split between paths) ipp = net.link(i).linkdest(veh.jdest) ip = 1 net.eqpath(ipp).tot = net.eqpath(ipp).tot + 1 C - Set the path select flag: negative indicates that PATHUPDATE C - should use ibest'th equilibrium (as opposed to shortest) C - path ibest = -ip-100 ipinittmp = 0 ENDIF ENDIF IF (ibest.EQ.0) THEN C . There is no external equilibrium path available, have the C . driver select the internal "equilibrium" path C - Determine the number of paths the driver can select from C - (based on its familiarity level with the network iftmp2 = veh.ifamiliar IF (iftmp2.EQ.0) THEN iftmp2 = 1 ELSEIF (iftmp2.EQ.1) THEN iftmp2 = act.zone(veh.jdest).ifamz(1) IF (iftmp2.GT.sim.kay) iftmp2 = sim.kay ELSEIF (iftmp2.EQ.2) THEN iftmp2 = act.zone(veh.jdest).ifamz(2) IF (iftmp2.GT.sim.kay) iftmp2 = sim.kay ELSE iftmp2 = act.zone(veh.jdest).ifamz(3) IF (iftmp2.GT.sim.kay) iftmp2 = sim.kay ENDIF Cr - Loop over the first iftmp paths from this vehicle's link to Cr - its destination to determine the logit sum sum = 0.D0 iftmp = 0 DO ik = 1,iftmp2 know = net.leqpd.labelpointerout(veh.jdest,i,ik) IF (know.NE.0) THEN iftmp = iftmp + 1 sum = sum + exp(-1.D0* + net.leqpd.labelout(veh.jdest,i,know)) ENDIF ENDDO rancall = RAN1(sim.iseed) ! Get a random number for this path ! choice ik = 1 know = net.leqpd.labelpointerout(veh.jdest,i,ik) IF (know.NE.0) THEN cumpri = exp(-1.D0* ! Use logit split + net.leqpd.labelout(veh.jdest,i,know)) + /sum cr cumpri = 1.0/iftmp ! Use equal split DO WHILE (ik.LE.iftmp + .AND. + rancall.GT.cumpri) ik = ik + 1 know = net.leqpd.labelpointerout(veh.jdest,i,ik) IF (know.NE.0) THEN cumpri = cumpri + exp(-1.D0* ! Use logit split + net.leqpd.labelout(veh.jdest,i,know))/sum cr cumpri = cumpri + 1.0/iftmp ! Use equal split ENDIF ENDDO ELSE WRITE(ostr,'(A,I5,A,I5,A)') + 'No eqpath on generation link [' + ,net.node(net.link(i).iunod).number + ,'->' + ,net.node(net.link(i).idnod).number + ,']'//CHAR(0) CALL DYNA_ERROR(ostr + ,DYNA_FATAL_ERROR + ,DYNA_LOGIC_BUG + ,DYNA_UNKNOWN_ERROR) ENDIF IF (ik.GT.iftmp) ik = iftmp ibest = -ik ENDIF C - Copy the ibest'th path to the vehicles path array CALL PATHUPDATE(ibest,net,act,i,veh,2) C - Set the vehicles current path index veh.icurrnt = 2 STD_BEGINRT = sim.status RETURN END