View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.following;
2   
3   import java.io.Serializable;
4   import java.util.SortedMap;
5   
6   import org.djunits.unit.AccelerationUnit;
7   import org.djunits.value.vdouble.scalar.Acceleration;
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.opentrafficsim.core.gtu.behavioralcharacteristics.BehavioralCharacteristics;
12  import org.opentrafficsim.core.gtu.behavioralcharacteristics.ParameterException;
13  import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
14  
15  /**
16   * Fixed GTU following model. This GTU following model does not react in any way to other GTUs. Instead it has a predetermined
17   * acceleration for a predetermined duration.<br>
18   * Primary use is testing of lane based GTU movement.
19   * <p>
20   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
22   * <p>
23   * @version $Revision: 1378 $, $LastChangedDate: 2015-09-03 13:38:01 +0200 (Thu, 03 Sep 2015) $, by $Author: averbraeck $,
24   *          initial version 6 feb. 2015 <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   */
28  public class FixedAccelerationModel extends AbstractGTUFollowingModelMobil implements Serializable
29  {
30      /** */
31      private static final long serialVersionUID = 20150206L;
32  
33      /** Acceleration that will be returned in GTUFollowingModelResult by computeAcceleration. */
34      private Acceleration acceleration;
35  
36      /** Valid until time that will be returned in GTUFollowingModelResult by computeAcceleration. */
37      private Duration duration;
38  
39      /**
40       * Create a new FixedAccelerationModel.
41       * @param acceleration Acceleration; the acceleration that will be returned by the computeAcceleration methods
42       * @param duration Duration; the duration that the acceleration will be maintained
43       */
44      public FixedAccelerationModel(final Acceleration acceleration, final Duration duration)
45      {
46          this.acceleration = acceleration;
47          this.duration = duration;
48      }
49  
50      /**
51       * Retrieve the duration of this FixedAccelerationModel.
52       * @return Duration; the duration of this FixedAccelerationModel
53       */
54      public final Duration getDuration()
55      {
56          return this.duration;
57      }
58  
59      /**
60       * Retrieve the acceleration of this FixedAccelerationModel.
61       * @return Acceleration; the acceleration of this FixedAccelerationModel
62       */
63      public final Acceleration getAcceleration()
64      {
65          return this.acceleration;
66      }
67  
68      /** {@inheritDoc} */
69      @Override
70      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
71          final Speed leaderSpeed, final Length headway, final Speed speedLimit, final Duration stepSize)
72      {
73          return this.acceleration;
74      }
75  
76      /** {@inheritDoc} */
77      @Override
78      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
79          final Speed leaderSpeed, final Length headway, final Speed speedLimit)
80      {
81          return this.acceleration;
82      }
83  
84      /** {@inheritDoc} */
85      @Override
86      public final Acceleration getMaximumSafeDeceleration()
87      {
88          // TODO should be specified in constructor
89          return new Acceleration(2, AccelerationUnit.METER_PER_SECOND_2);
90      }
91  
92      /** {@inheritDoc} */
93      @Override
94      public final Duration getStepSize()
95      {
96          return this.duration;
97      }
98  
99      /** {@inheritDoc} */
100     @Override
101     public final String getName()
102     {
103         return "Fixed";
104     }
105 
106     /** {@inheritDoc} */
107     @Override
108     public final String getLongName()
109     {
110         return "Fixed GTU following model";
111     }
112 
113     /** {@inheritDoc} */
114     public final String toString()
115     {
116         return "FixedAccelerationModel " + this.duration + ", " + this.acceleration;
117     }
118 
119     // The following is inherited from CarFollowingModel
120 
121     /** {@inheritDoc} */
122     @Override
123     public final Speed desiredSpeed(final BehavioralCharacteristics behavioralCharacteristics, final SpeedLimitInfo speedInfo)
124         throws ParameterException
125     {
126         return null;
127     }
128 
129     /** {@inheritDoc} */
130     @Override
131     public final Length desiredHeadway(final BehavioralCharacteristics behavioralCharacteristics, final Speed speed)
132         throws ParameterException
133     {
134         return null;
135     }
136 
137     /** {@inheritDoc} */
138     @Override
139     public final Acceleration followingAcceleration(final BehavioralCharacteristics behavioralCharacteristics,
140         final Speed speed, final SpeedLimitInfo speedInfo, final SortedMap<Length, Speed> leaders) throws ParameterException
141     {
142         return null;
143     }
144 
145 }