Class OperationalPlan
java.lang.Object
org.opentrafficsim.core.gtu.plan.operational.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-2019 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
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOperationalPlan.AccelerationSegmentThe segment of an operational plan in which the acceleration is constant.static classOperationalPlan.SegmentThe segment of an operational plan contains a part of the speed profile of a movement in which some of the variables determining movement (speed, acceleration) are constant.static classOperationalPlan.SpeedSegmentThe segment of an operational plan in which the speed is constant. -
Field Summary
Fields Modifier and Type Field Description static doubleDRIFTING_SPEED_SIThe drifting speed. -
Constructor Summary
Constructors Constructor Description OperationalPlan(GTU gtu, DirectedPoint waitPoint, Time startTime, Duration duration)Build a plan where the GTU will wait for a certain time.OperationalPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, List<OperationalPlan.Segment> operationalPlanSegmentList)Construct an operational plan. -
Method Summary
Modifier and Type Method Description booleanequals(Object obj)AccelerationgetAcceleration(Duration time)Calculate the acceleration of the GTU after the given duration since the start of the plan.AccelerationgetAcceleration(Time time)Calculate the acceleration of the GTU at the given time.DirectedPointgetEndLocation()Provide the end location of this operational plan as a DirectedPoint.SpeedgetEndSpeed()TimegetEndTime()Return the time it will take to complete the entire operational plan.DirectedPointgetLocation(Duration time)Calculate the location after the given duration since the start of the plan.DirectedPointgetLocation(Time time)Calculate the location at the given time.DirectedPointgetLocation(Time time, RelativePosition pos)Calculate the location after the given duration since the start of the plan.List<OperationalPlan.Segment>getOperationalPlanSegmentList()Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.OTSLine3DgetPath()Return the path that will be traveled.SpeedgetSpeed(Duration time)Calculate the speed of the GTU after the given duration since the start of the plan.SpeedgetSpeed(Time time)Calculate the speed of the GTU at the given time.SpeedgetStartSpeed()Return the start speed of the entire plan.TimegetStartTime()Return the (absolute) start time of the operational plan.DurationgetTotalDuration()Return the time it will take to complete the entire operational plan.LengthgetTotalLength()Return the distance the entire operational plan will cover.LengthgetTraveledDistance(Duration duration)Calculate the distance traveled as part of this plan after the given duration since the start of the plan.LengthgetTraveledDistance(Time time)Calculate the distance traveled as part of this plan at the given absolute time.doublegetTraveledDistanceSI(Duration duration)Calculate the distance traveled as part of this plan after the given duration since the start of the plan.doublegetTraveledDistanceSI(Time time)Calculate the distance traveled as part of this plan at the given absolute time.inthashCode()TimetimeAtDistance(Length distance)Return the time when the GTU will reach the given distance.TimetimeAtPoint(DirectedPoint point, boolean upstream)Calculates when the GTU will be at the given point.StringtoString()
-
Field Details
-
DRIFTING_SPEED_SI
public static final double DRIFTING_SPEED_SIThe drifting speed. Speeds under this value will be cropped to zero.- See Also:
- Constant Field Values
-
-
Constructor Details
-
OperationalPlan
public OperationalPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, List<OperationalPlan.Segment> operationalPlanSegmentList) throws OperationalPlanExceptionConstruct an operational plan.- Parameters:
gtu- GTU; the GTU for debugging purposespath- OTSLine3D; the path to follow from a certain time till a certain time. The path should have <i>at least</i> the lengthstartTime- Time; the absolute start time when we start executing the pathstartSpeed- Speed; the GTU speed when we start executing the pathoperationalPlanSegmentList- 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 OperationalPlanExceptionBuild a plan where the GTU will wait for a certain time.- Parameters:
gtu- GTU; the GTU for debugging purposeswaitPoint- DirectedPoint; the point at which the GTU will waitstartTime- Time; the current time or a time in the future when the plan should startduration- Duration; the waiting time- Throws:
OperationalPlanException- when construction of a waiting path fails
-
-
Method Details
-
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
Return the (absolute) start time of the operational plan.- Returns:
- startTime
-
getStartSpeed
Return the start speed of the entire plan.- Returns:
- startSpeed
-
getEndSpeed
- Returns:
- the end speed when completing the entire plan.
-
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
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
Return the distance the entire operational plan will cover.- Returns:
- the distance of the entire operational plan
-
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
Provide the end location of this operational plan as a DirectedPoint.- Returns:
- the end location
-
timeAtDistance
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
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
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
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
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
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
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 OperationalPlanExceptionCalculate the location after the given duration since the start of the plan.- Parameters:
time- Time; the relative time to look for a locationpos- 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
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
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
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
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 degreesupstream- boolean; true if the point is upstream of the path- Returns:
- Time; time at point
-
getTraveledDistance
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() -
equals
-
toString
-