Class OperationalPlan

  • All Implemented Interfaces:
    Serializable

    public class OperationalPlan
    extends Object
    implements Serializable
    An Operational plan describes a path through the world with a speed profile that a GTU intends to follow. The OperationalPlan can be updated or replaced at any time (including before it has been totally executed), for which a tactical planner is responsible. The operational plan is implemented using segments of the movement (time, location, speed, acceleration) that the GTU will use to plan its location and movement. Within an OperationalPlan the GTU cannot reverse direction along the path of movement. This ensures that the timeAtDistance method will never have to select among several valid solutions.

    Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Nov 14, 2015
    Author:
    Alexander Verbraeck, Peter Knoppers
    See Also:
    Serialized Form
    • Field Detail

      • MAX_DELTA_SI

        static final double MAX_DELTA_SI
        The maximum difference in the length of the path and the calculated driven distance implied by the segment list. The same constant is also used as a maximum between speeds of segments that should align in terms of speed.
        See Also:
        Constant Field Values
      • DRIFTING_SPEED_SI

        public static final double DRIFTING_SPEED_SI
        The drifting speed. Speeds under this value will be cropped to zero.
        See Also:
        Constant Field Values
    • Constructor Detail

      • OperationalPlan

        public OperationalPlan​(GTU gtu,
                               OTSLine3D path,
                               Time startTime,
                               Speed startSpeed,
                               List<OperationalPlan.Segment> operationalPlanSegmentList)
                        throws OperationalPlanException
        Construct an operational plan.
        Parameters:
        gtu - GTU; the GTU for debugging purposes
        path - OTSLine3D; the path to follow from a certain time till a certain time. The path should have <i>at least</i> the length
        startTime - Time; the absolute start time when we start executing the path
        startSpeed - Speed; the GTU speed when we start executing the path
        operationalPlanSegmentList - List<Segment>; the segments that make up the path with an acceleration, constant speed or deceleration profile
        Throws:
        OperationalPlanException - when the path is too short for the operation
      • OperationalPlan

        public OperationalPlan​(GTU gtu,
                               DirectedPoint waitPoint,
                               Time startTime,
                               Duration duration)
                        throws OperationalPlanException
        Build a plan where the GTU will wait for a certain time.
        Parameters:
        gtu - GTU; the GTU for debugging purposes
        waitPoint - DirectedPoint; the point at which the GTU will wait
        startTime - Time; the current time or a time in the future when the plan should start
        duration - Duration; the waiting time
        Throws:
        OperationalPlanException - when construction of a waiting path fails
    • Method Detail

      • getPath

        public final OTSLine3D getPath()
        Return the path that will be traveled. If the plan is a wait plan, the start point of the path is good; the end point of the path is bogus (should only be used to determine the orientation of the GTU).
        Returns:
        the path
      • getStartTime

        public final Time getStartTime()
        Return the (absolute) start time of the operational plan.
        Returns:
        startTime
      • getStartSpeed

        public final Speed getStartSpeed()
        Return the start speed of the entire plan.
        Returns:
        startSpeed
      • getEndSpeed

        public final Speed getEndSpeed()
        Returns:
        the end speed when completing the entire plan.
      • getOperationalPlanSegmentList

        public final List<OperationalPlan.Segment> getOperationalPlanSegmentList()
        Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.
        The caller MUST NOT MODIFY the returned object.
        Returns:
        operationalPlanSegmentList
      • getTotalDuration

        public final Duration getTotalDuration()
        Return the time it will take to complete the entire operational plan.
        Returns:
        the time it will take to complete the entire operational plan
      • getTotalLength

        public final Length getTotalLength()
        Return the distance the entire operational plan will cover.
        Returns:
        the distance of the entire operational plan
      • getEndTime

        public final Time getEndTime()
        Return the time it will take to complete the entire operational plan.
        Returns:
        the time it will take to complete the entire operational plan
      • getEndLocation

        public final DirectedPoint getEndLocation()
        Provide the end location of this operational plan as a DirectedPoint.
        Returns:
        the end location
      • timeAtDistance

        public final Time timeAtDistance​(Length distance)
        Return the time when the GTU will reach the given distance.
        Parameters:
        distance - Length; the distance to calculate the time for
        Returns:
        the time it will take to have traveled the given distance
      • getLocation

        public final DirectedPoint getLocation​(Time time)
                                        throws OperationalPlanException
        Calculate the location at the given time.
        Parameters:
        time - Time; the absolute time to look for a location
        Returns:
        the location at the given time.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getSpeed

        public final Speed getSpeed​(Duration time)
                             throws OperationalPlanException
        Calculate the speed of the GTU after the given duration since the start of the plan.
        Parameters:
        time - Duration; the relative time to look for a location
        Returns:
        the location after the given duration since the start of the plan.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getSpeed

        public final Speed getSpeed​(Time time)
                             throws OperationalPlanException
        Calculate the speed of the GTU at the given time.
        Parameters:
        time - Time; the absolute time to look for a location
        Returns:
        the location at the given time.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getAcceleration

        public final Acceleration getAcceleration​(Duration time)
                                           throws OperationalPlanException
        Calculate the acceleration of the GTU after the given duration since the start of the plan.
        Parameters:
        time - Duration; the relative time to look for a location
        Returns:
        the location after the given duration since the start of the plan.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getAcceleration

        public final Acceleration getAcceleration​(Time time)
                                           throws OperationalPlanException
        Calculate the acceleration of the GTU at the given time.
        Parameters:
        time - Time; the absolute time to look for a location
        Returns:
        the location at the given time.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getLocation

        public final DirectedPoint getLocation​(Duration time)
                                        throws OperationalPlanException
        Calculate the location after the given duration since the start of the plan.
        Parameters:
        time - Duration; the relative time to look for a location
        Returns:
        the location after the given duration since the start of the plan.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getLocation

        public final DirectedPoint getLocation​(Time time,
                                               RelativePosition pos)
                                        throws OperationalPlanException
        Calculate the location after the given duration since the start of the plan.
        Parameters:
        time - Time; the relative time to look for a location
        pos - RelativePosition; relative position
        Returns:
        the location after the given duration since the start of the plan.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getTraveledDistanceSI

        public final double getTraveledDistanceSI​(Duration duration)
                                           throws OperationalPlanException
        Calculate the distance traveled as part of this plan after the given duration since the start of the plan. This method returns the traveled distance as a double in SI units.
        Parameters:
        duration - Duration; the relative time to calculate the traveled distance
        Returns:
        the distance traveled as part of this plan after the given duration since the start of the plan.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getTraveledDistance

        public final Length getTraveledDistance​(Duration duration)
                                         throws OperationalPlanException
        Calculate the distance traveled as part of this plan after the given duration since the start of the plan.
        Parameters:
        duration - Duration; the relative time to calculate the traveled distance
        Returns:
        the distance traveled as part of this plan after the given duration since the start of the plan.
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • getTraveledDistanceSI

        public final double getTraveledDistanceSI​(Time time)
                                           throws OperationalPlanException
        Calculate the distance traveled as part of this plan at the given absolute time. This method returns the traveled distance as a double in SI units.
        Parameters:
        time - Time; the absolute time to calculate the traveled distance for as part of this plan
        Returns:
        the distance traveled as part of this plan at the given time
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • timeAtPoint

        public final Time timeAtPoint​(DirectedPoint point,
                                      boolean upstream)
        Calculates when the GTU will be at the given point. The point does not need to be at the traveled path, as the point is projected to the path at 90 degrees. The point may for instance be the end of a lane, which is crossed by a GTU possibly during a lane change.
        Parameters:
        point - DirectedPoint; point with angle, which will be projected to the path at 90 degrees
        upstream - boolean; true if the point is upstream of the path
        Returns:
        Time; time at point
      • getTraveledDistance

        public final Length getTraveledDistance​(Time time)
                                         throws OperationalPlanException
        Calculate the distance traveled as part of this plan at the given absolute time.
        Parameters:
        time - Time; the absolute time to calculate the traveled distance for as part of this plan
        Returns:
        the distance traveled as part of this plan at the given time
        Throws:
        OperationalPlanException - when the time is after the validity of the operational plan
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object