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://tudelft.nl/staff/p.knoppers-1">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 GtuFollowingModelOld; car following model
43       * @param laneChangeModel 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      /** {@inheritDoc} */
53      @Override
54      public final LaneBasedCfLcTacticalPlanner create(final LaneBasedGtu gtu) throws GtuException
55      {
56          return new LaneBasedCfLcTacticalPlanner(this.carFollowingModel, this.laneChangeModel, gtu);
57      }
58  
59      /** {@inheritDoc} */
60      @Override
61      public final Parameters getParameters()
62      {
63          Parameters params = new ParameterSet().setDefaultParameters(ParameterTypes.class);
64          try
65          {
66              params.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
67          }
68          catch (ParameterException pe)
69          {
70              throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
71          }
72          return params;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final String toString()
78      {
79          return "LaneBasedCFLCTacticalPlannerFactory [car-following=" + this.carFollowingModel + ", lane changing="
80                  + this.laneChangeModel + "]";
81      }
82  
83  }