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