View Javadoc
1   package org.opentrafficsim.road.gtu.generator;
2   
3   import java.io.Serializable;
4   
5   import org.djunits.unit.DurationUnit;
6   import org.djunits.unit.LengthUnit;
7   import org.djunits.unit.SpeedUnit;
8   import org.djunits.value.vdouble.scalar.Duration;
9   import org.djunits.value.vdouble.scalar.Length;
10  import org.djunits.value.vdouble.scalar.Speed;
11  import org.djunits.value.vdouble.scalar.Time;
12  import org.opentrafficsim.core.gtu.GTUDirectionality;
13  import org.opentrafficsim.core.gtu.GTUType;
14  import org.opentrafficsim.core.gtu.animation.GTUColorer;
15  import org.opentrafficsim.core.network.OTSNetwork;
16  import org.opentrafficsim.core.network.route.RouteGenerator;
17  import org.opentrafficsim.core.units.distributions.ContinuousDistDoubleScalar;
18  import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlanner;
19  import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlannerFactory;
20  import org.opentrafficsim.road.network.lane.Lane;
21  
22  import nl.tudelft.simulation.dsol.SimRuntimeException;
23  import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface;
24  
25  /**
26   * Generate GTUs.
27   * <p>
28   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
29   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
30   * <p>
31   * @version $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
32   *          initial version Feb 2, 2015 <br>
33   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
34   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
35   */
36  public class GTUGeneratorIndividual extends AbstractGTUGenerator implements Serializable
37  {
38      /** */
39      private static final long serialVersionUID = 20160000L;
40  
41      /** Simulator to schedule next arrival events. */
42      private final DEVSSimulatorInterface.TimeDoubleUnit simulator;
43  
44      /** Distribution of the length of the GTU. */
45      private final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> lengthDist;
46  
47      /** Distribution of the width of the GTU. */
48      private final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> widthDist;
49  
50      /** Distribution of the maximum speed of the GTU. */
51      private final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> maximumSpeedDist;
52  
53      /**
54       * @param name the name of the generator
55       * @param gtuType the type of GTU to generate
56       * @param gtuClass the gtu class to instantiate
57       * @param initialSpeedDist distribution of the initial speed of the GTU
58       * @param interarrivelTimeDist distribution of the interarrival time
59       * @param maxGTUs maximum number of GTUs to generate
60       * @param startTime start time of generation (delayed start)
61       * @param endTime end time of generation
62       * @param simulator simulator to schedule next arrival events
63       * @param lengthDist distribution of the length of the GTU
64       * @param widthDist distribution of the width of the GTU
65       * @param maximumSpeedDist distribution of the maximum speed of the GTU
66       * @param lane Lane on which newly GTUs are placed
67       * @param position position on the lane, relative to the design line of the link
68       * @param direction the direction on the lane in which the GTU has to be generated (DIR_PLUS, or DIR_MINUS)
69       * @param gtuColorer the GTUColorer to use
70       * @param strategicalPlannerFactory the lane-based strategical planner factory to use
71       * @param routeGenerator route generator
72       * @param network the network to register the GTU into
73       * @throws SimRuntimeException when simulation scheduling fails
74       */
75      @SuppressWarnings("checkstyle:parameternumber")
76      public GTUGeneratorIndividual(final String name, final DEVSSimulatorInterface.TimeDoubleUnit simulator, final GTUType gtuType,
77              final Class<?> gtuClass, final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> initialSpeedDist,
78              final ContinuousDistDoubleScalar.Rel<Duration, DurationUnit> interarrivelTimeDist,
79              final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> lengthDist,
80              final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> widthDist,
81              final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> maximumSpeedDist, final long maxGTUs, final Time startTime,
82              final Time endTime, final Lane lane, final Length position, final GTUDirectionality direction,
83              final GTUColorer gtuColorer,
84              final LaneBasedStrategicalPlannerFactory<? extends LaneBasedStrategicalPlanner> strategicalPlannerFactory,
85              final RouteGenerator routeGenerator, final OTSNetwork network) throws SimRuntimeException
86      {
87          super(name, simulator, gtuType, gtuClass, initialSpeedDist, interarrivelTimeDist, maxGTUs, startTime, endTime, lane,
88                  position, direction, gtuColorer, strategicalPlannerFactory, routeGenerator, network);
89          this.simulator = simulator;
90          this.lengthDist = lengthDist;
91          this.widthDist = widthDist;
92          this.maximumSpeedDist = maximumSpeedDist;
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public final DEVSSimulatorInterface.TimeDoubleUnit getSimulator()
98      {
99          return this.simulator;
100     }
101 
102     /**
103      * @return lengthDist.
104      */
105     @Override
106     public final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> getLengthDist()
107     {
108         return this.lengthDist;
109     }
110 
111     /**
112      * @return widthDist.
113      */
114     @Override
115     public final ContinuousDistDoubleScalar.Rel<Length, LengthUnit> getWidthDist()
116     {
117         return this.widthDist;
118     }
119 
120     /**
121      * @return maximumSpeedDist.
122      */
123     @Override
124     public final ContinuousDistDoubleScalar.Rel<Speed, SpeedUnit> getMaximumSpeedDist()
125     {
126         return this.maximumSpeedDist;
127     }
128 
129     /** {@inheritDoc} */
130     @Override
131     public final String toString()
132     {
133         return "GTUGeneratorIndividual [lengthDist=" + this.lengthDist + ", widthDist=" + this.widthDist + ", maximumSpeedDist="
134                 + this.maximumSpeedDist + "]";
135     }
136 
137 }