View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical;
2   
3   import org.opentrafficsim.base.parameters.ParameterTypeClass;
4   import org.opentrafficsim.base.parameters.ParameterTypeDuration;
5   import org.opentrafficsim.base.parameters.ParameterTypeLength;
6   import org.opentrafficsim.base.parameters.ParameterTypes;
7   import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
8   import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
9   import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
10  import org.opentrafficsim.road.gtu.lane.tactical.lmrs.Lmrs;
11  
12  /**
13   * A lane-based tactical planner generates an operational plan for the lane-based GTU. It can ask the strategic planner for
14   * assistance on the route to take when the network splits. This abstract class contains a number of helper methods that make it
15   * easy to implement a tactical planner.
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   */
23  public abstract class AbstractLaneBasedTacticalPlanner implements LaneBasedTacticalPlanner
24  {
25  
26      /** Tactical planner parameter. */
27      public static final ParameterTypeClass<LaneBasedTacticalPlanner> LANE_TACTICAL_PLANNER = new ParameterTypeClass<>(
28              "lane tactical planner", "Lane-based tactical planner class.", LaneBasedTacticalPlanner.class, Lmrs.class);
29  
30      /** Look ahead parameter type. */
31      protected static final ParameterTypeLength LOOKAHEAD = ParameterTypes.LOOKAHEAD;
32  
33      /** Time step parameter type. */
34      protected static final ParameterTypeDuration DT = ParameterTypes.DT;
35  
36      /** The car-following model. */
37      private CarFollowingModel carFollowingModel;
38  
39      /** The perception. */
40      private final LanePerception lanePerception;
41  
42      /** GTU. */
43      private final LaneBasedGtu gtu;
44  
45      /**
46       * Instantiates a tactical planner.
47       * @param carFollowingModel car-following model
48       * @param gtu GTU
49       * @param lanePerception perception
50       */
51      public AbstractLaneBasedTacticalPlanner(final CarFollowingModel carFollowingModel, final LaneBasedGtu gtu,
52              final LanePerception lanePerception)
53      {
54          setCarFollowingModel(carFollowingModel);
55          this.gtu = gtu;
56          this.lanePerception = lanePerception;
57      }
58  
59      @Override
60      public final LaneBasedGtu getGtu()
61      {
62          return this.gtu;
63      }
64  
65      @Override
66      public final CarFollowingModel getCarFollowingModel()
67      {
68          return this.carFollowingModel;
69      }
70  
71      /**
72       * Sets the car-following model.
73       * @param carFollowingModel Car-following model to set.
74       */
75      public final void setCarFollowingModel(final CarFollowingModel carFollowingModel)
76      {
77          this.carFollowingModel = carFollowingModel;
78      }
79  
80      @Override
81      public final LanePerception getPerception()
82      {
83          return this.lanePerception;
84      }
85  
86  }