LaneBasedCFLCTacticalPlannerFactory.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. import org.opentrafficsim.road.gtu.lane.tactical.lanechangemobil.LaneChangeModel;

  13. /**
  14.  * Factory to create {@code LaneBasedCFLCTacticalPlanner}.
  15.  * <p>
  16.  * Copyright (c) 2013-2018 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/docs/current/license.html">OpenTrafficSim License</a>.
  18.  * <p>
  19.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version Aug 2, 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. public class LaneBasedCFLCTacticalPlannerFactory
  25.         implements LaneBasedTacticalPlannerFactory<LaneBasedCFLCTacticalPlanner>, Serializable
  26. {

  27.     /** */
  28.     private static final long serialVersionUID = 20160811L;

  29.     /** The car following model. */
  30.     private GTUFollowingModelOld carFollowingModel;

  31.     /** The lane change model. */
  32.     private LaneChangeModel laneChangeModel;

  33.     /**
  34.      * Constructor with fixed stateless car-following and lane change model.
  35.      * @param carFollowingModel car following model
  36.      * @param laneChangeModel lane change model
  37.      */
  38.     public LaneBasedCFLCTacticalPlannerFactory(final GTUFollowingModelOld carFollowingModel,
  39.             final LaneChangeModel laneChangeModel)
  40.     {
  41.         this.carFollowingModel = carFollowingModel;
  42.         this.laneChangeModel = laneChangeModel;
  43.     }

  44.     /** {@inheritDoc} */
  45.     @Override
  46.     public final LaneBasedCFLCTacticalPlanner create(final LaneBasedGTU gtu) throws GTUException
  47.     {
  48.         return new LaneBasedCFLCTacticalPlanner(this.carFollowingModel, this.laneChangeModel, gtu);
  49.     }

  50.     /** {@inheritDoc} */
  51.     @Override
  52.     public final Parameters getParameters()
  53.     {
  54.         Parameters params = new ParameterSet().setDefaultParameters(ParameterTypes.class);
  55.         try
  56.         {
  57.             params.setParameter(ParameterTypes.LOOKAHEAD, new Length(250, LengthUnit.SI));
  58.         }
  59.         catch (ParameterException pe)
  60.         {
  61.             throw new RuntimeException("Parameter type 'LOOKAHEAD' could not be set.", pe);
  62.         }
  63.         return params;
  64.     }

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     public final String toString()
  68.     {
  69.         return "LaneBasedCFLCTacticalPlannerFactory [car-following=" + this.carFollowingModel + ", lane changing="
  70.                 + this.laneChangeModel + "]";
  71.     }

  72. }