package org.opentrafficsim.road.gtu.following;
import java.util.Collection;
import org.djunits.value.vdouble.scalar.Acceleration;
import org.djunits.value.vdouble.scalar.Length;
import org.djunits.value.vdouble.scalar.Speed;
import org.djunits.value.vdouble.scalar.Time;
import org.opentrafficsim.core.network.NetworkException;
import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
/**
* GTU following model interface.
* GTU following models following this interface compute an acceleration.
*
* Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
* BSD-style license. See OpenTrafficSim License.
*
* @version $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
* initial version Jul 2, 2014
* @author Peter Knoppers
*/
public interface GTUFollowingModel
{
/**
* Compute the acceleration that would be used to follow a leader.
* TODO We should probably add a be ready to stop before argument to prevent vehicles that cannot see their leader,
* or should slow down for a crossing from accelerating to unsafe speeds.
* @param follower LaneBasedGTU; the GTU for which acceleration is computed
* @param leaderSpeed DoubleScalar.Abs<SpeedUnit>; the speed of the leader
* @param headway DoubleScalar.Rel<LengthUnit>; the headway of the leader
* @param speedLimit DoubleScalarAbs<SpeedUnit>; the local speed limit
* @return AccelerationStep; the result of application of the GTU following model
* @throws NetworkException on network inconsistency
*/
AccelerationStep computeAcceleration(final LaneBasedGTU follower, final Speed leaderSpeed,
final Length.Rel headway, final Speed speedLimit) throws NetworkException;
/**
* Compute the acceleration that would be used to follow a leader.
* TODO We should probably add a be ready to stop before argument to prevent vehicles that cannot see their leader,
* or should slow down for a crossing from accelerating to unsafe speeds.
* @param followerSpeed DoubleScalar.Abs<SpeedUnit>; the speed of the follower at the current time
* @param followerMaximumSpeed DoubleScalar.Abs<SpeedUnit>; the maximum speed that the follower is capable of driving
* at
* @param leaderSpeed DoubleScalar.Abs<SpeedUnit>; the speed of the follower at the current time
* @param headway DoubleScalar.Rel<LengthUnit>; the net headway (distance between the front of the follower to
* the rear of the leader) at the current time
* @param speedLimit DoubleScalar.Abs<SpeedUnit>; the local speed limit
* @return DoubleScalar.Abs<AccelerationUnit>; the acceleration (or, if negative, deceleration) resulting from
* application of the GTU following model
*/
Acceleration computeAcceleration(final Speed followerSpeed, Speed followerMaximumSpeed, final Speed leaderSpeed,
final Length.Rel headway, final Speed speedLimit);
/**
* Compute the lowest accelerations (or most severe decelerations) that would be used if a referenceGTU is present
* (inserted, or not removed) in a set of other GTUs.
* If any GTU in the set of otherGTUs has a null headway (indicating that the other GTU is in fact parallel to the
* referenceGTU), prohibitive decelerations shall be returned.
* Two AccelerationStep values are returned in a DualAccelerationStep.
* TODO We should probably add a be ready to stop before argument to prevent vehicles that cannot see their leader,
* or should slow down for a crossing from accelerating to unsafe speeds.
* @param referenceGTU LaneBasedGTU; the GTU for which the accelerations are computed
* @param otherGTUs Collection<HeadwayGTU>; the other GTUs. A negative headway value indicates that the other GTU is a
* follower. NB. If the referenceGTU is contained in this Collection, it is ignored.
* @param speedLimit DoubleScalar.Abs<SpeedUnit>; the local speed limit
* @return DualAccelerationStep; the result with the lowest accelerations (or most severe decelerations) of application of
* the GTU following model of the referenceGTU for each leader and follower
* @throws NetworkException on network inconsistency
*/
DualAccelerationStep computeAcceleration(final LaneBasedGTU referenceGTU, final Collection
* At the returned headway, the follower would decelerate with it's maximum comfortable deceleration.
* @param followerSpeed DoubleScalar.Abs<SpeedUnit>; speed of the follower
* @param leaderSpeed DoubleScalar.Abs<SpeedUnit>; speed of the leader
* @param precision DoubleScalar.Rel<LengthUnit>; the required precision of the result (must be > 0)
* @param speedLimit DoubleScalar.Abs<SpeedUnit>; the local speed limit
* @param followerMaximumSpeed DoubleScalar.Abs<SpeedUnit>; the maximum speed that the follower can drive at
* @return DoubleScalar.Rel<LengthUnit>
*/
Length.Rel minimumHeadway(Speed followerSpeed, Speed leaderSpeed, Length.Rel precision, Speed speedLimit,
Speed followerMaximumSpeed);
/**
* Return the maximum safe deceleration for use in gap acceptance models. This is the deceleration that may be enforced upon
* a new follower due to entering a road or changing into an adjacent lane. The result shall be a positive value. In
* most car following models this value is named b.
* @return DoubleScalar.Abs<AccelerationUnit>; must be a positive value!
*/
Acceleration maximumSafeDeceleration();
/**
* Return the step size of this GTU following model.
* @return DoubleScalar.Rel<TimeUnit>; the step size of the GTU following model
*/
Time.Rel getStepSize();
/**
* Return the name of this GTU following model.
* @return String; just the name of the GTU following model
*/
String getName();
/**
* Return complete textual information about this instantiation of this GTU following model.
* @return String; the name and parameter values of the GTU following model
*/
String getLongName();
}