View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2   
3   import java.util.SortedSet;
4   
5   import org.djunits.value.vdouble.scalar.Acceleration;
6   import org.djunits.value.vdouble.scalar.Length;
7   import org.djunits.value.vdouble.scalar.Speed;
8   import org.opentrafficsim.core.gtu.GTUException;
9   import org.opentrafficsim.core.gtu.behavioralcharacteristics.BehavioralCharacteristics;
10  import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterException;
11  import org.opentrafficsim.core.gtu.perception.EgoPerception;
12  import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
13  import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
14  import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
15  import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
16  import org.opentrafficsim.road.gtu.lane.perception.categories.IntersectionPerception;
17  import org.opentrafficsim.road.gtu.lane.perception.categories.NeighborsPerception;
18  import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayConflict;
19  import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGTU;
20  import org.opentrafficsim.road.gtu.lane.plan.operational.SimpleOperationalPlan;
21  import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
22  import org.opentrafficsim.road.gtu.lane.tactical.util.ConflictUtil;
23  import org.opentrafficsim.road.gtu.lane.tactical.util.ConflictUtil.ConflictPlans;
24  import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
25  
26  /**
27   * <p>
28   * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
29   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
30   * <p>
31   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 27 jan. 2017 <br>
32   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
33   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
34   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
35   */
36  
37  public class AccelerationConflicts implements AccelerationIncentive
38  {
39  
40      /** Set of yield plans at conflicts with priority. Remembering for static model. */
41      private final ConflictPlans yieldPlans = new ConflictPlans();
42  
43      /** {@inheritDoc} */
44      @Override
45      public void accelerate(final SimpleOperationalPlan simplePlan, final RelativeLane lane, final LaneBasedGTU gtu,
46              final LanePerception perception, final CarFollowingModel carFollowingModel, final Speed speed,
47              final BehavioralCharacteristics bc, final SpeedLimitInfo speedLimitInfo)
48              throws OperationalPlanException, ParameterException, GTUException
49      {
50          Acceleration acceleration = perception.getPerceptionCategory(EgoPerception.class).getAcceleration();
51          Length length = perception.getPerceptionCategory(EgoPerception.class).getLength();
52          SortedSet<HeadwayConflict> conflicts =
53                  perception.getPerceptionCategory(IntersectionPerception.class).getConflicts(lane);
54          SortedSet<HeadwayGTU> leaders = perception.getPerceptionCategory(NeighborsPerception.class).getLeaders(lane);
55          simplePlan.minimizeAcceleration(ConflictUtil.approachConflicts(bc, conflicts, leaders, carFollowingModel, length, speed,
56                  acceleration, speedLimitInfo, this.yieldPlans, gtu));
57          if (this.yieldPlans.getIndicatorIntent().isLeft())
58          {
59              simplePlan.setIndicatorIntentLeft(this.yieldPlans.getIndicatorObjectDistance());
60          }
61          else if (this.yieldPlans.getIndicatorIntent().isRight())
62          {
63              simplePlan.setIndicatorIntentRight(this.yieldPlans.getIndicatorObjectDistance());
64          }
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public String toString()
70      {
71          return "AccelerationConflicts";
72      }
73  
74  }