Exemplo n.º 1
0
 /**
  * Calculates the acceleration of vehicle me.
  *
  * @param me
  * @param laneSegment
  * @param alphaT
  * @param alphaV0
  * @param alphaA
  * @return the calculated acceleration
  */
 public double calcAcc(
     Vehicle me, LaneSegment laneSegment, double alphaT, double alphaV0, double alphaA) {
   // By default only consider the vehicle in front when calculating acceleration.
   // LDMs that consider more than the front vehicle should override this method.
   final Vehicle frontVehicle = laneSegment.frontVehicle(me);
   return calcAcc(me, frontVehicle, alphaT, alphaV0, alphaA);
 }
Exemplo n.º 2
0
  /**
   * Calculates the acceleration of vehicle me, under European lane changing rules (no
   * "undertaking").
   *
   * @param vCritEur critical speed under which European rules no longer apply
   * @param me
   * @param laneSegment
   * @param leftLaneSegment
   * @param alphaT
   * @param alphaV0
   * @param alphaA
   * @return the acceleration of vehicle me
   */
  public double calcAccEur(
      double vCritEur,
      Vehicle me,
      LaneSegment laneSegment,
      LaneSegment leftLaneSegment,
      double alphaT,
      double alphaV0,
      double alphaA) {

    // calculate normal acceleration in own lane
    final double accInOwnLane = calcAcc(me, laneSegment, alphaT, alphaV0, alphaA);

    // no lane on left-hand side
    if (leftLaneSegment == null) {
      return accInOwnLane;
    }

    // check left-vehicle's speed
    final Vehicle newFrontLeft = leftLaneSegment.frontVehicle(me);
    if (newFrontLeft == null) {
      return accInOwnLane;
    }
    final double speedFront = newFrontLeft.getSpeed();
    if (speedFront <= vCritEur) {
      return accInOwnLane;
    }

    // condition me.getSpeed() > speedFront will be evaluated by softer tanh
    // condition below
    final double accLeft = calcAcc(me, leftLaneSegment, alphaT, alphaV0, alphaA);

    // avoid hard switching by condition vMe>vLeft needed in European
    // acceleration rule
    final double frac = calcSmoothFraction(me.getSpeed(), speedFront);
    final double accResult = frac * Math.min(accInOwnLane, accLeft) + (1 - frac) * accInOwnLane;

    // if (speedFront != -1) {
    // LOG.debug(String
    // .format("pos=%.4f, accLeft: frac=%.4f, acc=%.4f, accLeft=%.4f, accResult=%.4f, meSpeed=%.2f,
    // frontLeftSpeed=%.2f\n",
    // me.getPosition(), frac, accInOwnLane, accLeft, accResult, me.getSpeed(), speedFront));
    // }
    return accResult;
  }