Class OperationalPlan

java.lang.Object
org.opentrafficsim.core.gtu.plan.operational.OperationalPlan

public class OperationalPlan extends Object
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-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.djunits.value.vdouble.scalar.Acceleration
    The drifting speed.
    static final org.djunits.value.vdouble.scalar.Speed
    The drifting speed.
    static final org.djunits.value.vdouble.scalar.Length
    Minimum distance of an operational plan path; anything shorter will be truncated to 0.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OperationalPlan(Gtu gtu, OtsLine2d path, org.djunits.value.vdouble.scalar.Duration startTime, Segments segments)
    Construct an operational plan.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    final org.djunits.value.vdouble.scalar.Acceleration
    getAcceleration(org.djunits.value.vdouble.scalar.Duration time)
    Calculate the acceleration of the GTU at the given time.
    final org.djunits.value.vdouble.scalar.Acceleration
    getAccelerationFromStart(org.djunits.value.vdouble.scalar.Duration duration)
    Calculate the acceleration of the GTU after the given duration since the start of the plan.
    org.djunits.value.vdouble.scalar.Duration
    getDurationAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance)
    Calculates the duration at which the given distance is traveled.
    Provide the end location of this operational plan as a DirectedPoint.
    org.djunits.value.vdouble.scalar.Duration
    Return the time at which the entire operational plan is completed.
    getLocation(org.djunits.value.vdouble.scalar.Duration time)
    Calculate the location at the given time.
    getLocation(org.djunits.value.vdouble.scalar.Duration time, RelativePosition pos)
    Calculate the location after the given duration since the start of the plan.
    getLocationFromStart(org.djunits.value.vdouble.scalar.Duration duration)
    Calculate the location after the given duration since the start of the plan.
    Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.
    Return the path that will be traveled.
    final org.djunits.value.vdouble.scalar.Speed
    getSpeed(org.djunits.value.vdouble.scalar.Duration time)
    Calculate the speed of the GTU at the given time.
    final org.djunits.value.vdouble.scalar.Speed
    getSpeedFromStart(org.djunits.value.vdouble.scalar.Duration duration)
    Calculate the speed of the GTU after the given duration since the start of the plan.
    org.djunits.value.vdouble.scalar.Speed
    Return the end speed of the operational plan.
    org.djunits.value.vdouble.scalar.Duration
    Return the start time of the operational plan.
    org.djunits.value.vdouble.scalar.Duration
    getTimeAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance)
    Calculates the time at which the given distance is traveled.
    org.djunits.value.vdouble.scalar.Duration
    Return the duration it will take to complete the entire operational plan.
    org.djunits.value.vdouble.scalar.Length
    Return the distance the entire operational plan will cover.
    org.djunits.value.vdouble.scalar.Length
    getTraveledDistance(org.djunits.value.vdouble.scalar.Duration time)
    Calculate the distance traveled as part of this plan at the given absolute time.
    final org.djunits.value.vdouble.scalar.Length
    getTraveledDistanceFromStart(org.djunits.value.vdouble.scalar.Duration duration)
    Calculate the distance traveled as part of this plan after the given duration since the start of the plan.
    int
     
    standStill(Gtu gtu, DirectedPoint2d point, org.djunits.value.vdouble.scalar.Duration startTime, org.djunits.value.vdouble.scalar.Duration duration)
    Creates a stand-still plan at a point.
    final org.djunits.value.vdouble.scalar.Duration
    timeAtDistance(org.djunits.value.vdouble.scalar.Length distance)
    Return the time when the GTU will reach the given distance.
    final org.djunits.value.vdouble.scalar.Duration
    timeAtPoint(DirectedPoint2d point, boolean upstream)
    Calculates when the GTU will be at the given point.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DRIFTING_SPEED

      public static final org.djunits.value.vdouble.scalar.Speed DRIFTING_SPEED
      The drifting speed. Speeds under this value will be cropped to zero.
    • DRIFTING_ACCELERATION

      public static final org.djunits.value.vdouble.scalar.Acceleration DRIFTING_ACCELERATION
      The drifting speed. Accelerations under this value will be cropped to zero.
    • MINIMUM_CREDIBLE_PATH_LENGTH

      public static final org.djunits.value.vdouble.scalar.Length MINIMUM_CREDIBLE_PATH_LENGTH
      Minimum distance of an operational plan path; anything shorter will be truncated to 0.
  • Constructor Details

    • OperationalPlan

      public OperationalPlan(Gtu gtu, OtsLine2d path, org.djunits.value.vdouble.scalar.Duration startTime, Segments segments)
      Construct an operational plan. The plan will be as long as the minimum of the path or segments allow.
      Parameters:
      gtu - the GTU for debugging purposes
      path - the path to follow from a certain time till a certain time. The path should have <i>at least</i> the length
      startTime - start time
      segments - the segments that make up the longitudinal dynamics
  • Method Details

    • standStill

      public static OperationalPlan standStill(Gtu gtu, DirectedPoint2d point, org.djunits.value.vdouble.scalar.Duration startTime, org.djunits.value.vdouble.scalar.Duration duration)
      Creates a stand-still plan at a point. A 1m path in the direction of the point is created.
      Parameters:
      gtu - GTU.
      point - point.
      startTime - start time.
      duration - duration.
      Returns:
      stand-still plan.
    • getPath

      public OtsLine2d 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 org.djunits.value.vdouble.scalar.Duration getStartTime()
      Return the start time of the operational plan.
      Returns:
      the start time of the operational plan
    • getStartSpeed

      public org.djunits.value.vdouble.scalar.Speed getStartSpeed()
      Return the end speed of the operational plan.
      Returns:
      the end speed of the operational plan
    • getOperationalPlanSegmentList

      public ImmutableList<Segment> getOperationalPlanSegmentList()
      Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.
      Returns:
      ImmutableList<OperationalPlan.Segment>; segmentList
    • getTotalDuration

      public org.djunits.value.vdouble.scalar.Duration getTotalDuration()
      Return the duration it will take to complete the entire operational plan.
      Returns:
      the duration it will take to complete the entire operational plan
    • getTotalLength

      public org.djunits.value.vdouble.scalar.Length getTotalLength()
      Return the distance the entire operational plan will cover.
      Returns:
      the distance of the entire operational plan
    • getEndTime

      public org.djunits.value.vdouble.scalar.Duration getEndTime()
      Return the time at which the entire operational plan is completed.
      Returns:
      the time at which the entire operational plan is completed
    • getEndLocation

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

      public final org.djunits.value.vdouble.scalar.Duration timeAtDistance(org.djunits.value.vdouble.scalar.Length distance)
      Return the time when the GTU will reach the given distance.
      Parameters:
      distance - the distance to calculate the time for
      Returns:
      the simulation time at which the distance will be traveled within the current plan
    • getLocationFromStart

      public final DirectedPoint2d getLocationFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException
      Calculate the location after the given duration since the start of the plan.
      Parameters:
      duration - duration relative to start of the plan
      Returns:
      the location after the given duration since the start of the plan.
      Throws:
      OperationalPlanException - when the duration is after the validity of the operational plan
    • getLocation

      public final DirectedPoint2d getLocation(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException
      Calculate the location at the given time.
      Parameters:
      time - simulation time
      Returns:
      the location at the given time.
      Throws:
      OperationalPlanException - when the time is after the validity of the operational plan
    • getLocation

      public final DirectedPoint2d getLocation(org.djunits.value.vdouble.scalar.Duration time, RelativePosition pos) throws OperationalPlanException
      Calculate the location after the given duration since the start of the plan.
      Parameters:
      time - simulation time
      pos - 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
    • getSpeedFromStart

      public final org.djunits.value.vdouble.scalar.Speed getSpeedFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException
      Calculate the speed of the GTU after the given duration since the start of the plan.
      Parameters:
      duration - duration relative to start of the plan
      Returns:
      the location after the given duration since the start of the plan.
      Throws:
      OperationalPlanException - when the duration is after the validity of the operational plan
    • getSpeed

      public final org.djunits.value.vdouble.scalar.Speed getSpeed(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException
      Calculate the speed of the GTU at the given time.
      Parameters:
      time - simulation time
      Returns:
      the location at the given time.
      Throws:
      OperationalPlanException - when the time is after the validity of the operational plan
    • getAccelerationFromStart

      public final org.djunits.value.vdouble.scalar.Acceleration getAccelerationFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException
      Calculate the acceleration of the GTU after the given duration since the start of the plan.
      Parameters:
      duration - duration relative to start of the plan
      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 org.djunits.value.vdouble.scalar.Acceleration getAcceleration(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException
      Calculate the acceleration of the GTU at the given time.
      Parameters:
      time - simulation time
      Returns:
      the location at the given time.
      Throws:
      OperationalPlanException - when the time is after the validity of the operational plan
    • getTraveledDistanceFromStart

      public final org.djunits.value.vdouble.scalar.Length getTraveledDistanceFromStart(org.djunits.value.vdouble.scalar.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 relative to start of the plan
      Returns:
      the distance traveled as part of this plan after the given duration since the start of the plan.
      Throws:
      OperationalPlanException - when the duration is after the validity of the operational plan
    • getTraveledDistance

      public org.djunits.value.vdouble.scalar.Length getTraveledDistance(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException
      Calculate the distance traveled as part of this plan at the given absolute time.
      Parameters:
      time - simulation time
      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
    • getDurationAtDistance

      public org.djunits.value.vdouble.scalar.Duration getDurationAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance) throws OperationalPlanException
      Calculates the duration at which the given distance is traveled.
      Parameters:
      traveledDistance - traveled distance
      Returns:
      duration since start of the plan at which the given distance is traveled
      Throws:
      OperationalPlanException - if the traveled distance is beyond the plan length
    • getTimeAtDistance

      public org.djunits.value.vdouble.scalar.Duration getTimeAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance) throws OperationalPlanException
      Calculates the time at which the given distance is traveled.
      Parameters:
      traveledDistance - traveled distance
      Returns:
      simulation time at which the given distance is traveled
      Throws:
      OperationalPlanException - if the traveled distance is beyond the plan length
    • timeAtPoint

      public final org.djunits.value.vdouble.scalar.Duration timeAtPoint(DirectedPoint2d 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 - point with angle, which will be projected to the path at 90 degrees
      upstream - true if the point is upstream of the path
      Returns:
      simulation time at point
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object