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