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  
14  /**
15   * <p>
16   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
18   * <p>
19   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Aug 7, 2016 <br>
20   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
22   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
23   */
24  
25  public class LaneBasedGTUFollowingTacticalPlannerFactory implements
26      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      /** {@inheritDoc} */
45      @Override
46      public final BehavioralCharacteristics getDefaultBehavioralCharacteristics()
47      {
48          BehavioralCharacteristics bc =  new BehavioralCharacteristics().setDefaultParameters(ParameterTypes.class);
49          try
50          {
51              bc.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
52          }
53          catch (ParameterException pe)
54          {
55              throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
56          }
57          return bc;
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public final LaneBasedGTUFollowingTacticalPlanner create(final LaneBasedGTU gtu) throws GTUException
63      {
64          return new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModel, gtu);
65      }
66  
67      /** {@inheritDoc} */
68      public final String toString()
69      {
70          return "LaneBasedGTUFollowingTacticalPlanner [car-following=" + this.carFollowingModel + "]";
71      }
72      
73  }