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-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   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
23   */
24  
25  public class LaneBasedGtuFollowingTacticalPlannerFactory
26          implements LaneBasedTacticalPlannerFactory<LaneBasedGtuFollowingTacticalPlanner>, Serializable
27  {
28  
29      /** */
30      private static final long serialVersionUID = 20160811L;
31  
32      /** The car following model. */
33      private GtuFollowingModelOld carFollowingModel;
34  
35      /**
36       * Constructor with fixed stateless car-following and lane change model.
37       * @param carFollowingModel car following model
38       */
39      public LaneBasedGtuFollowingTacticalPlannerFactory(final GtuFollowingModelOld carFollowingModel)
40      {
41          this.carFollowingModel = carFollowingModel;
42      }
43  
44      @Override
45      public final Parameters getParameters()
46      {
47          Parameters params = new ParameterSet().setDefaultParameters(ParameterTypes.class);
48          try
49          {
50              params.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
51          }
52          catch (ParameterException pe)
53          {
54              throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
55          }
56          return params;
57      }
58  
59      @Override
60      public final LaneBasedGtuFollowingTacticalPlanner create(final LaneBasedGtu gtu) throws GtuException
61      {
62          return new LaneBasedGtuFollowingTacticalPlanner(this.carFollowingModel, gtu);
63      }
64  
65      @Override
66      public final String toString()
67      {
68          return "LaneBasedGtuFollowingTacticalPlanner [car-following=" + this.carFollowingModel + "]";
69      }
70  
71  }