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://tudelft.nl/staff/p.knoppers-1">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 Acceleration; the acceleration that will be returned by the computeAcceleration methods
41       * @param duration 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 Duration; 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 Acceleration; the acceleration of this FixedAccelerationModel
61       */
62      public final Acceleration getAcceleration()
63      {
64          return this.acceleration;
65      }
66  
67      /** {@inheritDoc} */
68      @Override
69      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
70              final Speed leaderSpeed, final Length headway, final Speed speedLimit, final Duration stepSize)
71      {
72          return this.acceleration;
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final Acceleration computeAcceleration(final Speed followerSpeed, final Speed followerMaximumSpeed,
78              final Speed leaderSpeed, final Length headway, final Speed speedLimit)
79      {
80          return this.acceleration;
81      }
82  
83      /** {@inheritDoc} */
84      @Override
85      public final Acceleration getMaximumSafeDeceleration()
86      {
87          // TODO should be specified in constructor
88          return new Acceleration(2, AccelerationUnit.METER_PER_SECOND_2);
89      }
90  
91      /** {@inheritDoc} */
92      @Override
93      public final Duration getStepSize()
94      {
95          return this.duration;
96      }
97  
98      /** {@inheritDoc} */
99      @Override
100     public final String getName()
101     {
102         return "Fixed";
103     }
104 
105     /** {@inheritDoc} */
106     @Override
107     public final String getLongName()
108     {
109         return "Fixed GTU following model";
110     }
111 
112     /** {@inheritDoc} */
113     @Override
114     public final String toString()
115     {
116         return "FixedAccelerationModel " + this.duration + ", " + this.acceleration;
117     }
118 
119     /** {@inheritDoc} */
120     @Override
121     public final void setA(final Acceleration a)
122     {
123         //
124     }
125 
126     /** {@inheritDoc} */
127     @Override
128     public final void setT(final Duration t)
129     {
130         //
131     }
132 
133     /** {@inheritDoc} */
134     @Override
135     public final void setFspeed(final double fSpeed)
136     {
137         //
138     }
139 
140     // The following is inherited from CarFollowingModel
141 
142     /** {@inheritDoc} */
143     @Override
144     public final Speed desiredSpeed(final Parameters parameters, final SpeedLimitInfo speedInfo) throws ParameterException
145     {
146         return null;
147     }
148 
149     /** {@inheritDoc} */
150     @Override
151     public final Length desiredHeadway(final Parameters parameters, final Speed speed) throws ParameterException
152     {
153         return null;
154     }
155 
156     /** {@inheritDoc} */
157     @Override
158     public final Acceleration followingAcceleration(final Parameters parameters, final Speed speed,
159             final SpeedLimitInfo speedInfo, final PerceptionIterable<? extends Headway> leaders) throws ParameterException
160     {
161         return null;
162     }
163 
164 }