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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
22   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
23   * </p>
24   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
25   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
26   */
27  public class FixedAccelerationModel extends AbstractGtuFollowingModelMobil implements Serializable
28  {
29      /** */
30      private static final long serialVersionUID = 20150206L;
31  
32      /** Acceleration that will be returned in GtuFollowingModelResult by computeAcceleration. */
33      private Acceleration acceleration;
34  
35      /** Valid until time that will be returned in GtuFollowingModelResult by computeAcceleration. */
36      private Duration duration;
37  
38      /**
39       * Create a new FixedAccelerationModel.
40       * @param acceleration the acceleration that will be returned by the computeAcceleration methods
41       * @param duration the duration that the acceleration will be maintained
42       */
43      public FixedAccelerationModel(final Acceleration acceleration, final Duration duration)
44      {
45          this.acceleration = acceleration;
46          this.duration = duration;
47      }
48  
49      /**
50       * Retrieve the duration of this FixedAccelerationModel.
51       * @return the duration of this FixedAccelerationModel
52       */
53      public final Duration getDuration()
54      {
55          return this.duration;
56      }
57  
58      /**
59       * Retrieve the acceleration of this FixedAccelerationModel.
60       * @return the acceleration of this FixedAccelerationModel
61       */
62      public final Acceleration getAcceleration()
63      {
64          return this.acceleration;
65      }
66  
67      @Override
68      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
69              final Speed leaderSpeed, final Length headway, final Speed speedLimit, final Duration stepSize)
70      {
71          return this.acceleration;
72      }
73  
74      @Override
75      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
76              final Speed leaderSpeed, final Length headway, final Speed speedLimit)
77      {
78          return this.acceleration;
79      }
80  
81      @Override
82      public final Acceleration getMaximumSafeDeceleration()
83      {
84          // TODO should be specified in constructor
85          return new Acceleration(2, AccelerationUnit.METER_PER_SECOND_2);
86      }
87  
88      @Override
89      public final Duration getStepSize()
90      {
91          return this.duration;
92      }
93  
94      @Override
95      public final String getName()
96      {
97          return "Fixed";
98      }
99  
100     @Override
101     public final String getLongName()
102     {
103         return "Fixed GTU following model";
104     }
105 
106     @Override
107     public final String toString()
108     {
109         return "FixedAccelerationModel " + this.duration + ", " + this.acceleration;
110     }
111 
112     @Override
113     public final void setA(final Acceleration a)
114     {
115         //
116     }
117 
118     @Override
119     public final void setT(final Duration t)
120     {
121         //
122     }
123 
124     @Override
125     public final void setFspeed(final double fSpeed)
126     {
127         //
128     }
129 
130     // The following is inherited from CarFollowingModel
131 
132     @Override
133     public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException
134     {
135         return null;
136     }
137 
138     @Override
139     public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException
140     {
141         return null;
142     }
143 
144     @Override
145     public final Acceleration followingAcceleration(final Parameters parameters, final Speed speed,
146             final SpeedLimitInfo speedInfo, final PerceptionIterable<? extends Headway> leaders) throws ParameterException
147     {
148         return null;
149     }
150 
151 }