StrategicalPlannerFactorySupplierOD.java

  1. package org.opentrafficsim.road.gtu.generator.od;

  2. import org.djunits.value.vdouble.scalar.Acceleration;
  3. import org.opentrafficsim.base.parameters.ParameterTypes;
  4. import org.opentrafficsim.core.gtu.GTUException;
  5. import org.opentrafficsim.core.gtu.GTUType.DEFAULTS;
  6. import org.opentrafficsim.core.network.Node;
  7. import org.opentrafficsim.core.parameters.ParameterFactoryByType;
  8. import org.opentrafficsim.road.gtu.lane.tactical.LaneBasedTacticalPlanner;
  9. import org.opentrafficsim.road.gtu.lane.tactical.LaneBasedTacticalPlannerFactory;
  10. import org.opentrafficsim.road.gtu.lane.tactical.following.IDMPlusFactory;
  11. import org.opentrafficsim.road.gtu.lane.tactical.lmrs.DefaultLMRSPerceptionFactory;
  12. import org.opentrafficsim.road.gtu.lane.tactical.lmrs.LMRSFactory;
  13. import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlannerFactory;
  14. import org.opentrafficsim.road.gtu.strategical.od.Category;
  15. import org.opentrafficsim.road.gtu.strategical.route.LaneBasedStrategicalRoutePlannerFactory;
  16. import org.opentrafficsim.road.gtu.strategical.route.RouteGeneratorOD;

  17. import nl.tudelft.simulation.jstats.streams.StreamInterface;

  18. /**
  19.  * Supplies a strategical planner factory within DefaultGTUCharacteristicsGeneratorOD.
  20.  * <p>
  21.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  22.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  23.  * <p>
  24.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 26 mrt. 2018 <br>
  25.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  26.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  27.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  28.  */
  29. public interface StrategicalPlannerFactorySupplierOD
  30. {

  31.     /**
  32.      * Supplies a strategical factory.
  33.      * @param origin Node; origin
  34.      * @param destination Node; destination
  35.      * @param category Category; category (GTU type, route, or more)
  36.      * @param randomStream StreamInterface; stream for random numbers
  37.      * @return LaneBasedGTUCharacteristics
  38.      * @throws GTUException if characteristics could not be generated for the GTUException
  39.      */
  40.     LaneBasedStrategicalPlannerFactory<?> getFactory(Node origin, Node destination, Category category,
  41.             StreamInterface randomStream) throws GTUException;

  42.     /**
  43.      * Returns a standard implementation for LMRS.
  44.      * @return standard implementation for LMRS
  45.      */
  46.     static StrategicalPlannerFactorySupplierOD lmrs()
  47.     {
  48.         return new StrategicalPlannerFactorySupplierOD()
  49.         {
  50.             /** {@inheritDoc} */
  51.             @Override
  52.             public LaneBasedStrategicalPlannerFactory<?> getFactory(final Node origin, final Node destination,
  53.                     final Category category, final StreamInterface randomStream) throws GTUException
  54.             {
  55.                 ParameterFactoryByType params = new ParameterFactoryByType();
  56.                 params.addParameter(origin.getNetwork().getGtuType(DEFAULTS.TRUCK), ParameterTypes.A,
  57.                         Acceleration.instantiateSI(0.4));
  58.                 return new LaneBasedStrategicalRoutePlannerFactory(
  59.                         new LMRSFactory(new IDMPlusFactory(randomStream), new DefaultLMRSPerceptionFactory()), params,
  60.                         RouteGeneratorOD.getDefaultRouteSupplier(randomStream));
  61.             }
  62.         };
  63.     }

  64.     /**
  65.      * Returns a {@code StrategicalPlannerFactorySupplierOD} using a {@code LaneBasedStrategicalRoutePlannerFactory} with a
  66.      * tactical planner factory based on the given supplier. Simulations using this strategical level can be more easily
  67.      * specified in this manner.
  68.      * @param tacticalPlannerFactorySupplierOD TacticalPlannerFactorySupplierOD; tactical planner factory based on OD
  69.      *            information
  70.      * @return strategical factory with default strategical layer and specified tactical layer
  71.      */
  72.     static StrategicalPlannerFactorySupplierOD route(final TacticalPlannerFactorySupplierOD tacticalPlannerFactorySupplierOD)
  73.     {
  74.         return new StrategicalPlannerFactorySupplierOD()
  75.         {
  76.             /** {@inheritDoc} */
  77.             @Override
  78.             public LaneBasedStrategicalPlannerFactory<?> getFactory(final Node origin, final Node destination,
  79.                     final Category category, final StreamInterface randomStream) throws GTUException
  80.             {
  81.                 return new LaneBasedStrategicalRoutePlannerFactory(
  82.                         tacticalPlannerFactorySupplierOD.getFactory(origin, destination, category, randomStream));
  83.             }
  84.         };
  85.     }

  86.     /**
  87.      * Interface for tactical factory supplier based on OD information. This class is used by strategical factories where only
  88.      * the strategical level is specified but where the lower levels can be specified.
  89.      * <p>
  90.      * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
  91.      * <br>
  92.      * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  93.      * <p>
  94.      * @version $Revision$, $LastChangedDate$, by $Author$, initial version 8 jan. 2019 <br>
  95.      * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  96.      * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  97.      * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  98.      */
  99.     public interface TacticalPlannerFactorySupplierOD
  100.     {
  101.         /**
  102.          * Returns a tactical planner factory based on OD information.
  103.          * @param origin Node; origin
  104.          * @param destination Node; destination
  105.          * @param category Category; OD category
  106.          * @param randomStream StreamInterface; random stream
  107.          * @return tactical planner factory based on OD information
  108.          */
  109.         LaneBasedTacticalPlannerFactory<? extends LaneBasedTacticalPlanner> getFactory(Node origin, Node destination,
  110.                 Category category, StreamInterface randomStream);
  111.     }

  112. }