View Javadoc
1   package org.opentrafficsim.road.gtu.generator.od;
2   
3   import org.djunits.value.vdouble.scalar.Acceleration;
4   import org.opentrafficsim.base.parameters.ParameterTypes;
5   import org.opentrafficsim.core.gtu.GTUException;
6   import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterFactoryByType;
7   import org.opentrafficsim.core.network.Node;
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  
18  import nl.tudelft.simulation.jstats.streams.StreamInterface;
19  
20  /**
21   * Supplies a strategical planner factory within DefaultGTUCharacteristicsGeneratorOD.
22   * <p>
23   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
24   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
25   * <p>
26   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 26 mrt. 2018 <br>
27   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
28   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
29   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
30   */
31  public interface StrategicalPlannerFactorySupplierOD
32  {
33  
34      /**
35       * Supplies a strategical factory.
36       * @param origin Node; origin
37       * @param destination Node; destination
38       * @param category Category; category (GTU type, route, or more)
39       * @param randomStream StreamInterface; stream for random numbers
40       * @return LaneBasedGTUCharacteristics
41       * @throws GTUException if characteristics could not be generated for the GTUException
42       */
43      LaneBasedStrategicalPlannerFactory<?> getFactory(Node origin, Node destination, Category category,
44              StreamInterface randomStream) throws GTUException;
45  
46      /**
47       * Returns a standard implementation for LMRS.
48       * @return standard implementation for LMRS
49       */
50      static StrategicalPlannerFactorySupplierOD lmrs()
51      {
52          return new StrategicalPlannerFactorySupplierOD()
53          {
54              /** {@inheritDoc} */
55              @Override
56              public LaneBasedStrategicalPlannerFactory<?> getFactory(final Node origin, final Node destination,
57                      final Category category, final StreamInterface randomStream) throws GTUException
58              {
59                  ParameterFactoryByType params = new ParameterFactoryByType();
60                  params.addParameter(ParameterTypes.A, Acceleration.createSI(0.4));
61                  return new LaneBasedStrategicalRoutePlannerFactory(
62                          new LMRSFactory(new IDMPlusFactory(randomStream), new DefaultLMRSPerceptionFactory()), params,
63                          RouteGeneratorOD.getDefaultRouteSupplier(randomStream));
64              }
65          };
66      }
67  
68      /**
69       * Returns a {@code StrategicalPlannerFactorySupplierOD} using a {@code LaneBasedStrategicalRoutePlannerFactory} with a
70       * tactical planner factory based on the given supplier. Simulations using this strategical level can be more easily
71       * specified in this manner.
72       * @param tacticalPlannerFactorySupplierOD TacticalPlannerFactorySupplierOD; tactical planner factory based on OD
73       *            information
74       * @return strategical factory with default strategical layer and specified tactical layer
75       */
76      static StrategicalPlannerFactorySupplierOD route(final TacticalPlannerFactorySupplierOD tacticalPlannerFactorySupplierOD)
77      {
78          return new StrategicalPlannerFactorySupplierOD()
79          {
80              /** {@inheritDoc} */
81              @Override
82              public LaneBasedStrategicalPlannerFactory<?> getFactory(final Node origin, final Node destination,
83                      final Category category, final StreamInterface randomStream) throws GTUException
84              {
85                  return new LaneBasedStrategicalRoutePlannerFactory(
86                          tacticalPlannerFactorySupplierOD.getFactory(origin, destination, category, randomStream));
87              }
88          };
89      }
90  
91      /**
92       * Interface for tactical factory supplier based on OD information. This class is used by strategical factories where only
93       * the strategical level is specified but where the lower levels can be specified.
94       * <p>
95       * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
96       * <br>
97       * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
98       * <p>
99       * @version $Revision$, $LastChangedDate$, by $Author$, initial version 8 jan. 2019 <br>
100      * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
101      * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
102      * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
103      */
104     public interface TacticalPlannerFactorySupplierOD
105     {
106         /**
107          * Returns a tactical planner factory based on OD information.
108          * @param origin Node; origin
109          * @param destination Node; destination
110          * @param category Category; OD category
111          * @param randomStream StreamInterface; random stream
112          * @return tactical planner factory based on OD information
113          */
114         LaneBasedTacticalPlannerFactory<? extends LaneBasedTacticalPlanner> getFactory(Node origin, Node destination,
115                 Category category, StreamInterface randomStream);
116     }
117 
118 }