DirectedAltruistic.java

  1. package org.opentrafficsim.road.gtu.lane.tactical.directedlanechange;

  2. import org.djunits.unit.AccelerationUnit;
  3. import org.djunits.value.vdouble.scalar.Acceleration;
  4. import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
  5. import org.opentrafficsim.road.gtu.lane.tactical.following.DualAccelerationStep;

  6. /**
  7.  * The altruistic driver changes lane when that is beneficial for all drivers.
  8.  * <p>
  9.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  10.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  11.  * </p>
  12.  * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
  13.  */
  14. public class DirectedAltruistic extends AbstractDirectedLaneChangeModel
  15. {
  16.     /**
  17.      * @param perception LanePerception; the perception to use
  18.      */
  19.     public DirectedAltruistic(final LanePerception perception)
  20.     {
  21.         super(perception);
  22.     }

  23.     /** {@inheritDoc} */
  24.     @Override
  25.     public final Acceleration applyDriverPersonality(final DualAccelerationStep accelerationSteps)
  26.     {
  27.         // The unit of the result is the acceleration unit of the leader acceleration.
  28.         // Discussion. The altruistic driver personality in Treiber adds two accelerations together. This reduces the
  29.         // "sensitivity" for keep lane, keep right and follow route incentives.
  30.         // This implementation returns the average of the two in order to avoid this sensitivity problem.
  31.         AccelerationUnit unit = accelerationSteps.getLeaderAcceleration().getDisplayUnit();
  32.         return new Acceleration((accelerationSteps.getLeaderAcceleration().getInUnit()
  33.                 + accelerationSteps.getFollowerAcceleration().getInUnit(unit)) / 2, unit);
  34.     }

  35.     /** {@inheritDoc} */
  36.     @Override
  37.     public final String getName()
  38.     {
  39.         return "Altruistic";
  40.     }

  41.     /** {@inheritDoc} */
  42.     @Override
  43.     public final String getLongName()
  44.     {
  45.         return "Altruistic lane change model (as described by Treiber).";
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public final String toString()
  50.     {
  51.         return "DirectedAltruistic [name=" + getName() + "]";
  52.     }

  53. }