View Javadoc
1   package org.opentrafficsim.core.gtu.lane.changing;
2   
3   import org.opentrafficsim.core.gtu.following.DualAccelerationStep;
4   import org.opentrafficsim.core.unit.AccelerationUnit;
5   import org.opentrafficsim.core.value.vdouble.scalar.DoubleScalar;
6   
7   /**
8    * The altruistic driver changes lane when that is beneficial for all drivers.
9    * <p>
10   * Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights
11   * reserved. <br>
12   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
13   * <p>
14   * @version 5 nov. 2014 <br>
15   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   */
17  public class Altruistic extends AbstractLaneChangeModel
18  {
19  
20      /** {@inheritDoc} */
21      @Override
22      public final DoubleScalar.Abs<AccelerationUnit> applyDriverPersonality(final DualAccelerationStep accelerationSteps)
23      {
24          // The result gets the unit of the acceleration of element 0 of accelerationSteps.
25          AccelerationUnit unit = accelerationSteps.getLeaderAcceleration().getUnit();
26          return new DoubleScalar.Abs<AccelerationUnit>(accelerationSteps.getLeaderAcceleration().getInUnit()
27                  + accelerationSteps.getFollowerAcceleration().getInUnit(unit), unit);
28      }
29  
30  }