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