Ejemplo n.º 1
0
  /**
   * @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;
  }
Ejemplo n.º 2
0
  private void moveVehicleFromInlinkToAbort(
      final QVehicle veh, final QInternalI fromLane, final double now) {
    fromLane.popFirstVehicle();

    // first treat the passengers:
    for (PassengerAgent pp : veh.getPassengers()) {
      if (pp instanceof MobsimAgent) {
        ((MobsimAgent) pp).setStateToAbort(now);
        network.simEngine.internalInterface.arrangeNextAgentState((MobsimAgent) pp);
      } else if (wrnCnt < 1) {
        wrnCnt++;
        log.warn(
            "encountering PassengerAgent that cannot be cast into a MobsimAgent; cannot say if this is a problem");
        log.warn(Gbl.ONLYONCE);
      }
    }

    // now treat the driver:
    veh.getDriver().setStateToAbort(now);
    network.simEngine.internalInterface.arrangeNextAgentState(veh.getDriver());
  }
Ejemplo n.º 3
0
 private boolean vehicleIsStuck(final QInternalI fromLaneBuffer, final double now) {
   return (now - fromLaneBuffer.getLastMovementTimeOfFirstVehicle())
       > network.simEngine.getStuckTime();
 }
Ejemplo n.º 4
0
 private static void moveVehicleFromInlinkToOutlink(
     final QVehicle veh, final QInternalI fromLane, QLinkInternalI nextQueueLink) {
   fromLane.popFirstVehicle();
   veh.getDriver().notifyMoveOverNode(nextQueueLink.getLink().getId());
   nextQueueLink.addFromUpstream(veh);
 }