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-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
21   * <p>
22   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Aug 2, 2016 <br>
23   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
24   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
25   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
26   */
27  
28  public class LaneBasedCFLCTacticalPlannerFactory
29          implements LaneBasedTacticalPlannerFactory<LaneBasedCFLCTacticalPlanner>, Serializable
30  {
31  
32      /** */
33      private static final long serialVersionUID = 20160811L;
34  
35      /** The car following model. */
36      private GTUFollowingModelOld carFollowingModel;
37  
38      /** The lane change model. */
39      private LaneChangeModel laneChangeModel;
40  
41      /**
42       * Constructor with fixed stateless car-following and lane change model.
43       * @param carFollowingModel GTUFollowingModelOld; car following model
44       * @param laneChangeModel LaneChangeModel; lane change model
45       */
46      public LaneBasedCFLCTacticalPlannerFactory(final GTUFollowingModelOld carFollowingModel,
47              final LaneChangeModel laneChangeModel)
48      {
49          this.carFollowingModel = carFollowingModel;
50          this.laneChangeModel = laneChangeModel;
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public final LaneBasedCFLCTacticalPlanner create(final LaneBasedGTU gtu) throws GTUException
56      {
57          return new LaneBasedCFLCTacticalPlanner(this.carFollowingModel, this.laneChangeModel, gtu);
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public final Parameters getParameters()
63      {
64          Parameters params = new ParameterSet().setDefaultParameters(ParameterTypes.class);
65          try
66          {
67              params.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
68          }
69          catch (ParameterException pe)
70          {
71              throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
72          }
73          return params;
74      }
75  
76      /** {@inheritDoc} */
77      @Override
78      public final String toString()
79      {
80          return "LaneBasedCFLCTacticalPlannerFactory [car-following=" + this.carFollowingModel + ", lane changing="
81                  + this.laneChangeModel + "]";
82      }
83  
84  }