View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.unit.LengthUnit;
6   import org.djunits.value.vdouble.scalar.Length;
7   import org.opentrafficsim.base.parameters.ParameterException;
8   import org.opentrafficsim.base.parameters.ParameterSet;
9   import org.opentrafficsim.base.parameters.ParameterTypes;
10  import org.opentrafficsim.base.parameters.Parameters;
11  import org.opentrafficsim.core.gtu.GtuException;
12  import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
13  import org.opentrafficsim.road.gtu.lane.tactical.following.GtuFollowingModelOld;
14  import org.opentrafficsim.road.gtu.lane.tactical.lanechangemobil.LaneChangeModel;
15  
16  /**
17   * Factory to create {@code LaneBasedCFLCTacticalPlanner}.
18   * <p>
19   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
21   * </p>
22   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
23   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
24   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
25   */
26  
27  public class LaneBasedCfLcTacticalPlannerFactory
28          implements LaneBasedTacticalPlannerFactory<LaneBasedCfLcTacticalPlanner>, Serializable
29  {
30  
31      /** */
32      private static final long serialVersionUID = 20160811L;
33  
34      /** The car following model. */
35      private GtuFollowingModelOld carFollowingModel;
36  
37      /** The lane change model. */
38      private LaneChangeModel laneChangeModel;
39  
40      /**
41       * Constructor with fixed stateless car-following and lane change model.
42       * @param carFollowingModel car following model
43       * @param laneChangeModel lane change model
44       */
45      public LaneBasedCfLcTacticalPlannerFactory(final GtuFollowingModelOld carFollowingModel,
46              final LaneChangeModel laneChangeModel)
47      {
48          this.carFollowingModel = carFollowingModel;
49          this.laneChangeModel = laneChangeModel;
50      }
51  
52      @Override
53      public final LaneBasedCfLcTacticalPlanner create(final LaneBasedGtu gtu) throws GtuException
54      {
55          return new LaneBasedCfLcTacticalPlanner(this.carFollowingModel, this.laneChangeModel, gtu);
56      }
57  
58      @Override
59      public final Parameters getParameters()
60      {
61          Parameters params = new ParameterSet().setDefaultParameters(ParameterTypes.class);
62          try
63          {
64              params.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
65          }
66          catch (ParameterException pe)
67          {
68              throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
69          }
70          return params;
71      }
72  
73      @Override
74      public final String toString()
75      {
76          return "LaneBasedCFLCTacticalPlannerFactory [car-following=" + this.carFollowingModel + ", lane changing="
77                  + this.laneChangeModel + "]";
78      }
79  
80  }