View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.following;
2   
3   import org.djunits.unit.AccelerationUnit;
4   import org.djunits.value.vdouble.scalar.Acceleration;
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.djunits.value.vdouble.scalar.Speed;
7   import org.djunits.value.vdouble.scalar.Time;
8   
9   /**
10   * Fixed GTU following model. This GTU following model does not react in any way to other GTUs. Instead it has a predetermined
11   * acceleration for a predetermined duration.<br>
12   * Primary use is testing of lane based GTU movement.
13   * <p>
14   * Copyright (c) 2013-2015 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/license.html">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision: 1378 $, $LastChangedDate: 2015-09-03 13:38:01 +0200 (Thu, 03 Sep 2015) $, by $Author: averbraeck $,
18   *          initial version 6 feb. 2015 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
21   */
22  public class FixedAccelerationModel extends AbstractGTUFollowingModelMobil
23  {
24      /** Acceleration that will be returned in GTUFollowingModelResult by computeAcceleration. */
25      private Acceleration acceleration;
26  
27      /** Valid until time that will be returned in GTUFollowingModelResult by computeAcceleration. */
28      private Time.Rel duration;
29  
30      /**
31       * Create a new FixedAccelerationModel.
32       * @param acceleration Acceleration; the acceleration that will be returned by the computeAcceleration methods
33       * @param duration Time.Rel; the duration that the acceleration will be maintained
34       */
35      public FixedAccelerationModel(final Acceleration acceleration, final Time.Rel duration)
36      {
37          this.acceleration = acceleration;
38          this.duration = duration;
39      }
40  
41      /**
42       * Retrieve the duration of this FixedAccelerationModel.
43       * @return Time.Rel; the duration of this FixedAccelerationModel
44       */
45      public final Time.Rel getDuration()
46      {
47          return this.duration;
48      }
49  
50      /**
51       * Retrieve the acceleration of this FixedAccelerationModel.
52       * @return Acceleration; the acceleration of this FixedAccelerationModel
53       */
54      public final Acceleration getAcceleration()
55      {
56          return this.acceleration;
57      }
58  
59      /** {@inheritDoc} */
60      @Override
61      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
62          final Speed leaderSpeed, final Length.Rel headway, final Speed speedLimit, final Time.Rel stepSize)
63      {
64          return this.acceleration;
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
70          final Speed leaderSpeed, final Length.Rel headway, final Speed speedLimit)
71      {
72          return this.acceleration;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final Acceleration getMaximumSafeDeceleration()
78      {
79          // TODO should be specified in constructor
80          return new Acceleration(2, AccelerationUnit.METER_PER_SECOND_2);
81      }
82  
83      /** {@inheritDoc} */
84      @Override
85      public final Time.Rel getStepSize()
86      {
87          return this.duration;
88      }
89  
90      /** {@inheritDoc} */
91      @Override
92      public final String getName()
93      {
94          return "Fixed";
95      }
96  
97      /** {@inheritDoc} */
98      @Override
99      public final String getLongName()
100     {
101         return "Fixed GTU following model";
102     }
103 
104     /** {@inheritDoc} */
105     public final String toString()
106     {
107         return "FixedAccelerationModel " + this.duration + ", " + this.acceleration;
108     }
109 
110 }