LaneBasedGTUFollowingTacticalPlannerFactory.java

  1. package org.opentrafficsim.road.gtu.lane.tactical;

  2. import java.io.Serializable;

  3. import org.djunits.unit.LengthUnit;
  4. import org.djunits.value.vdouble.scalar.Length;
  5. import org.opentrafficsim.base.parameters.ParameterException;
  6. import org.opentrafficsim.base.parameters.ParameterSet;
  7. import org.opentrafficsim.base.parameters.ParameterTypes;
  8. import org.opentrafficsim.base.parameters.Parameters;
  9. import org.opentrafficsim.core.gtu.GTUException;
  10. import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
  11. import org.opentrafficsim.road.gtu.lane.tactical.following.GTUFollowingModelOld;

  12. /**
  13.  * <p>
  14.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  15.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
  16.  * <p>
  17.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version Aug 7, 2016 <br>
  18.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  19.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  20.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  21.  */

  22. public class LaneBasedGTUFollowingTacticalPlannerFactory
  23.         implements LaneBasedTacticalPlannerFactory<LaneBasedGTUFollowingTacticalPlanner>, Serializable
  24. {

  25.     /** */
  26.     private static final long serialVersionUID = 20160811L;

  27.     /** The car following model. */
  28.     private GTUFollowingModelOld carFollowingModel;

  29.     /**
  30.      * Constructor with fixed stateless car-following and lane change model.
  31.      * @param carFollowingModel GTUFollowingModelOld; car following model
  32.      */
  33.     public LaneBasedGTUFollowingTacticalPlannerFactory(final GTUFollowingModelOld carFollowingModel)
  34.     {
  35.         this.carFollowingModel = carFollowingModel;
  36.     }

  37.     /** {@inheritDoc} */
  38.     @Override
  39.     public final Parameters getParameters()
  40.     {
  41.         Parameters params = new ParameterSet().setDefaultParameters(ParameterTypes.class);
  42.         try
  43.         {
  44.             params.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
  45.         }
  46.         catch (ParameterException pe)
  47.         {
  48.             throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
  49.         }
  50.         return params;
  51.     }

  52.     /** {@inheritDoc} */
  53.     @Override
  54.     public final LaneBasedGTUFollowingTacticalPlanner create(final LaneBasedGTU gtu) throws GTUException
  55.     {
  56.         return new LaneBasedGTUFollowingTacticalPlanner(this.carFollowingModel, gtu);
  57.     }

  58.     /** {@inheritDoc} */
  59.     @Override
  60.     public final String toString()
  61.     {
  62.         return "LaneBasedGTUFollowingTacticalPlanner [car-following=" + this.carFollowingModel + "]";
  63.     }

  64. }