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