/** * @return <code>true</code> if the vehicle was successfully moved over the node, <code>false * </code> otherwise (e.g. in case where the next link is jammed) */ private boolean moveVehicleOverNode( final QVehicle veh, final QInternalI fromLaneBuffer, final double now) { Id<Link> nextLinkId = veh.getDriver().chooseNextLinkId(); Link currentLink = veh.getCurrentLink(); if ((!fromLaneBuffer.hasGreenForToLink(nextLinkId))) { // there is no longer a stuck check for red links. This means that // in case of an infinite red time the simulation will not stop automatically because // vehicles waiting in front of the red signal will never reach their destination. dg, mar'14 return false; } if (nextLinkId == null) { log.error( "Agent has no or wrong route! agentId=" + veh.getDriver().getId() + " currentLink=" + currentLink.getId().toString() + ". The agent is removed from the simulation."); moveVehicleFromInlinkToAbort(veh, fromLaneBuffer, now); return true; } QLinkInternalI nextQueueLink = network.getNetsimLinks().get(nextLinkId); if (!checkNextLinkSemantics(currentLink, nextLinkId, nextQueueLink, veh)) { moveVehicleFromInlinkToAbort(veh, fromLaneBuffer, now); return true; } if (nextQueueLink.isAcceptingFromUpstream()) { moveVehicleFromInlinkToOutlink(veh, fromLaneBuffer, nextQueueLink); return true; } if (vehicleIsStuck(fromLaneBuffer, now)) { /* We just push the vehicle further after stucktime is over, regardless * of if there is space on the next link or not.. optionally we let them * die here, we have a config setting for that! */ if (network.simEngine.getMobsim().getScenario().getConfig().qsim().isRemoveStuckVehicles()) { moveVehicleFromInlinkToAbort(veh, fromLaneBuffer, now); return false; } else { moveVehicleFromInlinkToOutlink(veh, fromLaneBuffer, nextQueueLink); return true; // (yyyy why is this returning `true'? Since this is a fix to avoid gridlock, this should // proceed in small steps. // kai, feb'12) } } return false; }
/** * Loads the inLinks-array with the corresponding links. Cannot be called in constructor, as the * queueNetwork does not yet know the queueLinks. Should be called by QueueNetwork, after creating * all QueueNodes and QueueLinks. */ /*package*/ void init() { int i = 0; for (Link l : this.node.getInLinks().values()) { this.inLinksArrayCache[i] = network.getNetsimLinks().get(l.getId()); i++; } /* As the order of nodes has an influence on the simulation results, * the nodes are sorted to avoid indeterministic simulations. dg[april08] */ Arrays.sort( this.inLinksArrayCache, new Comparator<NetsimLink>() { @Override public int compare(NetsimLink o1, NetsimLink o2) { return o1.getLink().getId().compareTo(o2.getLink().getId()); } }); }