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