View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2   
3   import org.opentrafficsim.core.gtu.behavioralcharacteristics.BehavioralCharacteristics;
4   import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterException;
5   import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
6   import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
7   import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
8   import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.Desire;
9   import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.LmrsUtil;
10  import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.VoluntaryIncentive;
11  
12  /**
13   * Determines lane change desire in order to adhere to keeping right or left. Such desire only exists if the route and speed
14   * (considered within an anticipation distance) are not affected on the adjacent lane. The level of lane change desire is only
15   * sufficient to overcome the lowest threshold for free lane changes.
16   * <p>
17   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
18   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
19   * <p>
20   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Apr 13, 2016 <br>
21   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
22   */
23  public class IncentiveKeep implements VoluntaryIncentive
24  {
25  
26      /** {@inheritDoc} */
27      @Override
28      public final Desire determineDesire(final BehavioralCharacteristics behavioralCharacteristics,
29          final LanePerception perception, final CarFollowingModel carFollowingModel, final Desire mandatoryDesire,
30          final Desire voluntaryDesire) throws ParameterException, OperationalPlanException
31      {
32          if (mandatoryDesire.getRight() < 0 || voluntaryDesire.getRight() < 0)
33          {
34              // no desire to go right if more dominant incentives provide a negative desire to go right
35              return new Desire(0, 0);
36          }
37          // keep right with dFree
38          return new Desire(0, behavioralCharacteristics.getParameter(LmrsUtil.DFREE));
39      }
40  
41      /** {@inheritDoc} */
42      @Override
43      public final String toString()
44      {
45          return "IncentiveKeep";
46      }
47  
48  }