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     @Override
115     public final String toString()
116     {
117         return "FixedAccelerationModel " + this.duration + ", " + this.acceleration;
118     }
119     
120     /** {@inheritDoc} */
121     @Override
122     public final void setA(final Acceleration a)
123     {
124         //
125     }
126 
127     /** {@inheritDoc} */
128     @Override
129     public final void setT(final Duration t)
130     {
131         //
132     }
133     
134     /** {@inheritDoc} */
135     @Override
136     public final void setFspeed(final double fSpeed)
137     {
138         //
139     }
140 
141     // The following is inherited from CarFollowingModel
142 
143     /** {@inheritDoc} */
144     @Override
145     public final Speed desiredSpeed(final BehavioralCharacteristics behavioralCharacteristics, final SpeedLimitInfo speedInfo)
146         throws ParameterException
147     {
148         return null;
149     }
150 
151     /** {@inheritDoc} */
152     @Override
153     public final Length desiredHeadway(final BehavioralCharacteristics behavioralCharacteristics, final Speed speed)
154         throws ParameterException
155     {
156         return null;
157     }
158 
159     /** {@inheritDoc} */
160     @Override
161     public final Acceleration followingAcceleration(final BehavioralCharacteristics behavioralCharacteristics,
162         final Speed speed, final SpeedLimitInfo speedInfo, final SortedMap<Length, Speed> leaders) throws ParameterException
163     {
164         return null;
165     }
166 
167 }