View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2   
3   import java.util.LinkedHashSet;
4   
5   import org.djutils.immutablecollections.Immutable;
6   import org.djutils.immutablecollections.ImmutableLinkedHashSet;
7   import org.djutils.immutablecollections.ImmutableSet;
8   import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
9   import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
10  import org.opentrafficsim.road.gtu.lane.tactical.AbstractLaneBasedTacticalPlanner;
11  import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
12  import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.MandatoryIncentive;
13  import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.VoluntaryIncentive;
14  
15  /**
16   * <p>
17   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
18   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
19   * </p>
20   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
22   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
23   */
24  public abstract class AbstractIncentivesTacticalPlanner extends AbstractLaneBasedTacticalPlanner
25  {
26  
27      /** Set of mandatory lane change incentives. */
28      private final LinkedHashSet<MandatoryIncentive> mandatoryIncentives = new LinkedHashSet<>();
29  
30      /** Set of voluntary lane change incentives. */
31      private final LinkedHashSet<VoluntaryIncentive> voluntaryIncentives = new LinkedHashSet<>();
32  
33      /** Set of acceleration incentives. */
34      private final LinkedHashSet<AccelerationIncentive> accelerationIncentives = new LinkedHashSet<>();
35  
36      /** Immutable set of mandatory lane change incentives. */
37      private final ImmutableSet<MandatoryIncentive> immutableMandatoryIncentives =
38              new ImmutableLinkedHashSet<>(this.mandatoryIncentives, Immutable.WRAP);
39  
40      /** Immutable set of voluntary lane change incentives. */
41      private final ImmutableSet<VoluntaryIncentive> immutableVoluntaryIncentives =
42              new ImmutableLinkedHashSet<>(this.voluntaryIncentives, Immutable.WRAP);
43  
44      /** Immutable set of acceleration lane change incentives. */
45      private final ImmutableSet<AccelerationIncentive> immutableAccelerationIncentives =
46              new ImmutableLinkedHashSet<>(this.accelerationIncentives, Immutable.WRAP);
47  
48      /**
49       * Constructor.
50       * @param carFollowingModel Car-following model.
51       * @param gtu GTU
52       * @param lanePerception perception
53       */
54      public AbstractIncentivesTacticalPlanner(final CarFollowingModel carFollowingModel, final LaneBasedGtu gtu,
55              final LanePerception lanePerception)
56      {
57          super(carFollowingModel, gtu, lanePerception);
58      }
59  
60      /**
61       * Adds a mandatory incentive. Ignores {@code null}.
62       * @param incentive Incentive to add.
63       */
64      public final void addMandatoryIncentive(final MandatoryIncentive incentive)
65      {
66          if (incentive != null)
67          {
68              this.mandatoryIncentives.add(incentive);
69          }
70      }
71  
72      /**
73       * Adds a voluntary incentive. Ignores {@code null}.
74       * @param incentive Incentive to add.
75       */
76      public final void addVoluntaryIncentive(final VoluntaryIncentive incentive)
77      {
78          if (incentive != null)
79          {
80              this.voluntaryIncentives.add(incentive);
81          }
82      }
83  
84      /**
85       * Adds an acceleration incentive. Ignores {@code null}.
86       * @param incentive Incentive to add.
87       */
88      public final void addAccelerationIncentive(final AccelerationIncentive incentive)
89      {
90          if (incentive != null)
91          {
92              this.accelerationIncentives.add(incentive);
93          }
94      }
95  
96      /**
97       * Returns the mandatory incentives.
98       * @return set of mandatory incentives
99       */
100     public final ImmutableSet<MandatoryIncentive> getMandatoryIncentives()
101     {
102         return this.immutableMandatoryIncentives;
103     }
104 
105     /**
106      * Returns the voluntary incentives.
107      * @return set of voluntary incentives
108      */
109     public final ImmutableSet<VoluntaryIncentive> getVoluntaryIncentives()
110     {
111         return this.immutableVoluntaryIncentives;
112     }
113 
114     /**
115      * Returns the acceleration incentives.
116      * @return set of acceleration incentives
117      */
118     public final ImmutableSet<AccelerationIncentive> getAccelerationIncentives()
119     {
120         return this.immutableAccelerationIncentives;
121     }
122 
123 }