MTCT
Design Automation and Optimization for ETCS Railway Networks
Loading...
Searching...
No Matches
cda_rail Namespace Reference

Namespaces

namespace  exceptions
namespace  instances
namespace  simulator
namespace  solver
namespace  vss

Classes

struct  Vertex
 Represents a vertex (node) in the railway network graph. More...
struct  Edge
 Represents a directed edge in the railway network graph. More...
class  Network
 Directed multigraph representing a railway network. More...
struct  ConflictPair
 One overlap interval between two routes. More...
class  Route
 Ordered list of network edges that a train follows. More...
class  RouteMap
 Collection of named train routes built on top of a railway network. More...
struct  Station
 Represents a station as a named set of network tracks (edge indices). More...
class  StationList
 Container and persistence API for named stations. More...
class  ScheduledStop
 Scheduling information for a stop within a timetable. More...
class  Schedule
 Specific schedule object with fixed entry/exit constraints. More...
class  Timetable
 The trains of an instance together with what they are to do. More...
class  Train
 Properties and characteristics of a train. More...
class  TrainList
 Container for trains with name-based indexing. More...
class  FixedSizeVector
 A heap-allocated, fixed-size array whose capacity cannot change after construction. More...
class  MultiArray
 A dynamically-shaped N-dimensional array stored in row-major order. More...

Typedefs

using index_vector = std::vector<size_t>
using index_set = std::unordered_set<size_t>

Enumerations

enum class  VertexType : std::uint8_t { NoBorder = 0 , VSS = 1 , TTD = 2 , NoBorderVSS = 3 }
 Which kind of block border a vertex is. More...
enum class  SolutionStatus : std::uint8_t {
  Optimal = 0 , Feasible = 1 , Infeasible = 2 , Timeout = 3 ,
  Unknown = 4
}
 What a solver was able to say about the instance it was given. More...
enum class  OptimalityStrategy : std::uint8_t { Optimal = 0 , TradeOff = 1 , Feasible = 2 }
 How hard a solver tries to prove optimality. More...
enum class  VelocityRefinementStrategy : std::uint8_t { None = 0 , MinOneStep = 1 }
 How the discrete velocities of a vertex are chosen. More...
enum class  MATimingStrategy : std::uint8_t { ExtremeProfiles = 0 }
 Strategy selector for MA timing from train rear. More...

Functions

constexpr std::string solution_status_to_string (SolutionStatus const status)
 The name of status, as it is reported, exported and imported.
double braking_distance (double v, double d)
 Helpers for 1D train motion under constant-acceleration bounds.
double max_braking_pos_after_dt_linear_movement (double v_0, double v_max, double a, double d, double dt)
 Computes the maximal forward shift of the braking point after dt.
double min_travel_time (double v_1, double v_2, double v_m, double a, double d, double s)
 Returns the minimal time to traverse an edge of length s.
double min_travel_time_flexible_exit_speed (double v_1, double v_m, double a, double s)
 Returns the minimal travel time when starting with v_1 and no constraint on exit velocity (besides staying below maximal speed).
double min_travel_time_from_start (double v_1, double v_2, double v_m, double a, double d, double s, double x)
 Returns minimal time to reach position x from the edge start.
double min_travel_time_to_end (double v_1, double v_2, double v_m, double a, double d, double s, double x)
 Returns minimal remaining time from position x to edge end.
double max_travel_time (double v_1, double v_2, double v_m, double a, double d, double s, bool stopping_allowed)
 Returns maximal traversal time for an edge.
double max_travel_time_no_stopping (double v_1, double v_2, double v_m, double a, double d, double s)
 Returns maximal traversal time without allowing a full stop.
double max_travel_time_stopping_allowed (double v_1, double v_2, double a, double d, double s)
 Returns maximal traversal time when stopping is allowed.
double max_travel_time_from_start (double v_1, double v_2, double v_m, double a, double d, double s, double x, bool stopping_allowed)
 Returns maximal time to reach position x from edge start.
double max_travel_time_from_start_no_stopping (double v_1, double v_2, double v_m, double a, double d, double s, double x)
 Returns maximal time to reach x without allowing a full stop.
double max_travel_time_from_start_stopping_allowed (double v_1, double v_2, double a, double d, double s, double x)
 Returns maximal time to reach x when stopping is allowed.
double max_travel_time_to_end (double v_1, double v_2, double v_m, double a, double d, double s, double x, bool stopping_allowed)
 Returns maximal remaining time from x to edge end.
double max_travel_time_to_end_no_stopping (double v_1, double v_2, double v_m, double a, double d, double s, double x)
 Returns maximal remaining time from x to end without stopping.
double max_travel_time_to_end_stopping_allowed (double v_1, double v_2, double a, double d, double s, double x)
 Returns maximal remaining time from x to end when stopping is allowed.
double max_travel_time_inverse (double v_0, double t, double dt, double d, double s)
 Let v_0/s_0 vel/pos at t_0, v_1/s_1 at t_1 and v_2/s_2 at t_2. Find maximal v_1, such that:
double max_travel_time_to_stop_at_end_after_one_time_step (double v_0, double dt, double d, double s)
 Assuming v_0/s_0 at t_0, v_1/s_1 at t_0+dt and v_2/s_2 at t_2:
double minimal_line_speed (double v_1, double v_2, double v_min, double a, double d, double s)
 Returns the minimum line speed reached on the maximal-time profile.
double maximal_line_speed (double v_1, double v_2, double v_max, double a, double d, double s)
 Returns the maximum line speed reached on the minimal-time profile.
double get_line_speed (double v_1, double v_2, double v_min, double v_max, double a, double d, double s, double t, bool allow_too_short_time=false)
 Finds a line speed that yields traversal time t.
double time_on_edge (double v_1, double v_2, double v_line, double a, double d, double s)
 Computes traversal time for a fixed line speed profile.
double pos_on_edge_at_time (double v_1, double v_2, double v_line, double a, double d, double s, double t)
 Returns position on the edge at time t for a fixed line speed profile.
double vel_on_edge_at_time (double v_1, double v_2, double v_line, double a, double d, double s, double t)
 Returns velocity on the edge at time t for a fixed line speed profile.
double min_time_to_push_ma_forward (double v_0, double a, double d, double s)
 Minimal time to move the moving-authority point forward by s.
double min_time_to_push_ma_backward (double v_0, double a, double d, double s)
 Minimal time to move the moving-authority point backward by s.
double min_time_to_push_ma_fully_backward (double v_0, double a, double d)
 Minimal time to move MA fully backward to the initial train front.
double min_time_from_front_to_ma_point (double v_1, double v_2, double v_m, double a, double d, double s, double obd)
 Minimal time from train front to a target MA point.
double max_time_from_front_to_ma_point (double v_1, double v_2, double v_m, double a, double d, double s, double obd, bool stopping_allowed)
 Maximal time from train front to a target MA point.
double max_time_from_front_to_ma_point_no_stopping (double v_1, double v_2, double v_m, double a, double d, double s, double obd)
 Maximal time from train front to MA point without full stop.
double max_time_from_front_to_ma_point_stopping_allowed (double v_1, double v_2, double a, double d, double s, double obd)
 Maximal time from train front to MA point when stopping is allowed.
double min_time_from_rear_to_ma_point (double v_1, double v_2, double v_min, double v_max, double a, double d, double s, double obd, MATimingStrategy strategy=MATimingStrategy::ExtremeProfiles)
 Minimal time from train rear to MA point under a strategy.
double max_time_from_rear_to_ma_point (double v_1, double v_2, double v_min, double v_max, double a, double d, double s, double obd, MATimingStrategy strategy=MATimingStrategy::ExtremeProfiles)
 Maximal time from train rear to MA point under a strategy.
double min_time_profile_from_rear_to_ma_point (double v_1, double v_2, double v_m, double a, double d, double s, double obd)
 Rear-to-MA time under a single minimum-time speed profile.
double max_time_profile_from_rear_to_ma_point (double v_1, double v_2, double v_m, double a, double d, double s, double obd)
 Rear-to-MA time under a single maximum-time no-stopping profile.
void check_consistency_of_eom_input (double &v_1, double &v_2, double &a, double &d, double &s, double &x)
 Normalizes and validates common EOM inputs in place.
bool possible_by_eom (double v_1, double v_2, double a, double d, double s)
 Checks whether speed transition is feasible by equations of motion.
std::pair< double, double > get_min_travel_time_acceleration_change_points (double v_1, double v_2, double v_m, double a, double d, double s)
 Returns profile change-point distances for minimum-time motion.
std::pair< double, double > get_max_travel_time_acceleration_change_points (double v_1, double v_2, double v_m, double a, double d, double s)
 Returns profile change-point distances for maximum-time motion.
double time_to_travel_distance_with_constant_acceleration (double v_0, double a, double s)
 Computes the time to travel s at constant acceleration.
template<typename T>
bool operator== (const FixedSizeVector< T > &lhs, const std::vector< T > &rhs)
 Equality comparison between a FixedSizeVector and a std::vector.
template<typename T>
bool operator== (const std::vector< T > &lhs, const FixedSizeVector< T > &rhs)
 Equality comparison between a std::vector and a FixedSizeVector.
template<typename T>
void swap (FixedSizeVector< T > &lhs, FixedSizeVector< T > &rhs) noexcept
 ADL-reachable swap for FixedSizeVector.
template<std::floating_point T>
bool approx_equal (T const a, T const b, T const factor=10)
 Determines if two floating-point values are approximately equal using a machine-epsilon-scaled tolerance.
void round_small_numbers_to_zero_inplace (double &val, double const tol=EPS)
 Sets a value to zero if its absolute magnitude is less than a tolerance threshold.
double round_to_given_tolerance (double const value, double const tolerance)
 Rounds a value to the nearest multiple of a given tolerance.
std::vector< cda_rail::index_vector > subsets_of_size_k_indices (size_t n, size_t k)
 Generates all subsets of size k of the index set {0, 1, ..., n - 1}.
std::vector< std::pair< size_t, size_t > > subsets_of_size_2_indices (size_t n)
 Generates all unordered index pairs from {0, 1, ..., n - 1}.
void initialize_plog (bool debug_input, bool overwrite_severity=false)
 Initializes the global plog console logger and adjusts its severity.
bool is_directory_and_create (const std::filesystem::path &p)
 Ensures that a filesystem path exists as a directory.
double relu (double val)
 Returns the positive part of a scalar.
template<typename Clock, typename Duration1, typename Duration2>
double get_time_difference_in_seconds (std::chrono::time_point< Clock, Duration1 > const &start, std::chrono::time_point< Clock, Duration2 > const &end)
double get_last_time_step_before (double t, double dt, bool t_inclusive)
 return last time step before t
double get_first_time_step_after (double t, double dt, bool t_inclusive)
 return first time step after t
size_t get_last_time_index_before (double t, double dt, bool t_inclusive)
 return the index of the last time step before t
size_t get_first_time_index_after (double t, double dt, bool t_inclusive)
 return the index of the first time step after t
std::string concatenate_string_views (std::initializer_list< std::string_view > parts)
 Concatenates multiple string views into a single string.
bool case_insensitive_str_equal (std::string_view a, std::string_view b)
 Compares two strings for equality, ignoring case.
void to_bool_optional_inplace (std::string_view s_view, std::optional< bool > &b)
 Parses a textual boolean value into an optional in place.
std::string sanitize (std::string s)
 Replaces every non-alphanumeric character by a hyphen.

Variables

constexpr double INF = std::numeric_limits<double>::max() / 3
constexpr double EPS = 1000 * std::numeric_limits<double>::epsilon()
constexpr double GRB_EPS = 1e-4
constexpr double V_MIN = 0.3
constexpr double STOP_TOLERANCE = 10
constexpr double ABS_PWL_ERROR = 10
constexpr double LINE_SPEED_ACCURACY = 0.1
constexpr double LINE_SPEED_TIME_ACCURACY = 0.1
constexpr double MIN_NON_ZERO = 0.1
constexpr double MIN_OCCUPIED_LENGTH = 1

Typedef Documentation

◆ index_set

using cda_rail::index_set = std::unordered_set<size_t>

◆ index_vector

using cda_rail::index_vector = std::vector<size_t>

Enumeration Type Documentation

◆ MATimingStrategy

enum class cda_rail::MATimingStrategy : std::uint8_t
strong

Strategy selector for MA timing from train rear.

Enumerator
ExtremeProfiles 

◆ OptimalityStrategy

enum class cda_rail::OptimalityStrategy : std::uint8_t
strong

How hard a solver tries to prove optimality.

Optimal solves to optimality, TradeOff stops at the first solution found, and Feasible additionally asks the solver itself to focus on finding one.

Enumerator
Optimal 
TradeOff 
Feasible 

◆ SolutionStatus

enum class cda_rail::SolutionStatus : std::uint8_t
strong

What a solver was able to say about the instance it was given.

Enumerator
Optimal 
Feasible 
Infeasible 
Timeout 
Unknown 

◆ VelocityRefinementStrategy

enum class cda_rail::VelocityRefinementStrategy : std::uint8_t
strong

How the discrete velocities of a vertex are chosen.

None uses an equidistant grid of the desired accuracy. MinOneStep refines it further where needed, so that two consecutive velocities can be reached from one another on the shortest neighboring edge.

Enumerator
None 
MinOneStep 

◆ VertexType

enum class cda_rail::VertexType : std::uint8_t
strong

Which kind of block border a vertex is.

  • NoBorder: no border at all, the incident edges belong to the same unbreakable (TTD) section.
  • VSS: border of a virtual subsection.
  • TTD: border of a train detection section.
  • NoBorderVSS: no border in the given network, but a possible position of a VSS border, which is where discretize splits an edge.
Enumerator
NoBorder 
VSS 
TTD 
NoBorderVSS 

Function Documentation

◆ approx_equal()

template<std::floating_point T>
bool cda_rail::approx_equal ( T const a,
T const b,
T const factor = 10 )
nodiscard

Determines if two floating-point values are approximately equal using a machine-epsilon-scaled tolerance.

Template Parameters
TFloating-point type of the compared values.
Parameters
aFirst value.
bSecond value.
factorScaling factor applied to std::numeric_limits<T>::epsilon().
Returns
true if |a - b| < factor * epsilon, otherwise false.
Precondition
factor >= 0 for a meaningful tolerance interpretation.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf the factor is negative.

◆ braking_distance()

double cda_rail::braking_distance ( double v,
double d )

Helpers for 1D train motion under constant-acceleration bounds.

All functions in this header use a simplified longitudinal motion model: acceleration is piecewise constant and limited to +a (accelerating), 0 (coasting), or -d (braking). This yields quadratic kinematic relations in position, speed, and time.

Typical use case: edge length and boundary speeds are known (v_1, v_2, s), while the intermediate speed profile is not. This API provides physically consistent profile choices, especially:

  • minimum-time envelopes,
  • maximum-time envelopes (with or without full stop),
  • line-speed and moving-authority timing relations.

Terminology used below:

  • braking distance at speed v: v^2 / (2*d).
  • braking point (or moving-authority point): position where the train would come to rest if full braking started immediately.

Computes braking distance for constant deceleration.

Uses the kinematic relation bd = v^2 / (2 * d) where v is the current speed and d is the available deceleration.

Parameters
vVelocity in m/s.
dDeceleration in m/s^2.
Returns
Braking distance in metres.
Precondition
v >= 0 and d > 0.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf v is negative or d is not strictly positive.

◆ case_insensitive_str_equal()

bool cda_rail::case_insensitive_str_equal ( std::string_view a,
std::string_view b )
inline

Compares two strings for equality, ignoring case.

Parameters
aFirst string to compare.
bSecond string to compare.
Returns
true if the strings are equal when compared case-insensitively, false otherwise.

◆ check_consistency_of_eom_input()

void cda_rail::check_consistency_of_eom_input ( double & v_1,
double & v_2,
double & a,
double & d,
double & s,
double & x )

Normalizes and validates common EOM inputs in place.

Small values near zero are rounded to zero (using project tolerance), then consistency checks are applied.

Parameters
v_1Entry speed in m/s (updated in place).
v_2Exit speed in m/s (updated in place).
aAcceleration in m/s^2 (updated in place).
dDeceleration in m/s^2 (updated in place).
sTotal edge length in metres (updated in place).
xPosition on edge in metres (updated in place).
Precondition
Inputs should be finite real values.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf any value is negative after rounding, if a <= 0 or d <= 0, if x > s, or if the entry and exit speeds are not feasible over s.

◆ concatenate_string_views()

std::string cda_rail::concatenate_string_views ( std::initializer_list< std::string_view > parts)
nodiscard

Concatenates multiple string views into a single string.

Parameters
partsString fragments to concatenate in the given order.
Returns
String containing all fragments from parts appended in order. The length of the returned string equals the sum of the fragment lengths.

◆ get_first_time_index_after()

size_t cda_rail::get_first_time_index_after ( double t,
double dt,
bool t_inclusive )
nodiscard

return the index of the first time step after t

Time itself is continuous, only the discretized models index the time steps. This is the index k belonging to get_first_time_step_after(t, dt, t_inclusive), i.e., the returned index multiplied by dt gives back the time.

Parameters
tTime t
dtTimestep
t_inclusiveCan t itself be returned?
Returns
min (k s.th. k*dt >= t) if t_inclusive is true, otherwise min (k s.th. k*dt > t)
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf t is negative or dt is non-positive.

◆ get_first_time_step_after()

double cda_rail::get_first_time_step_after ( double t,
double dt,
bool t_inclusive )
nodiscard

return first time step after t

Parameters
tTime t
dtTimestep
t_inclusiveCan t itself be returned?
Returns
min (k * dt s.th. k*dt >= t) if t_inclusive is true, otherwise min (k
  • dt s.th. k*dt > t)

◆ get_last_time_index_before()

size_t cda_rail::get_last_time_index_before ( double t,
double dt,
bool t_inclusive )
nodiscard

return the index of the last time step before t

Time itself is continuous, only the discretized models index the time steps. This is the index k belonging to get_last_time_step_before(t, dt, t_inclusive), i.e., the returned index multiplied by dt gives back the time.

A time within EPS of a time step is treated as lying on it, hence there is no index for a non-inclusive t within EPS of 0.

Parameters
tTime t
dtTimestep
t_inclusiveCan t itself be returned?
Returns
max (k s.th. k*dt <= t) if t_inclusive is true, otherwise max (k s.th. k*dt < t)
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf t is negative, dt is non-positive, or no non-negative index exists.

◆ get_last_time_step_before()

double cda_rail::get_last_time_step_before ( double t,
double dt,
bool t_inclusive )
nodiscard

return last time step before t

A time within EPS of a time step is treated as lying on it.

Parameters
tTime t
dtTimestep
t_inclusiveCan t itself be returned?
Returns
max (k * dt s.th. k*dt <= t) if t_inclusive is true, otherwise max (k
  • dt s.th. k*dt < t)

◆ get_line_speed()

double cda_rail::get_line_speed ( double v_1,
double v_2,
double v_min,
double v_max,
double a,
double d,
double s,
double t,
bool allow_too_short_time = false )

Finds a line speed that yields traversal time t.

The function searches line speed in [minimal_line_speed, maximal_line_speed] via bisection. If t exceeds the maximal feasible no-stop travel time, returns 0 as a sentinel for "no feasible line speed".

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_minLower bound for candidate line speed in m/s.
v_maxUpper bound for candidate line speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
tDesired traversal time in seconds.
allow_too_short_timeIf true, a t that is shorter than the fastest possible traversal time is not rejected but answered with maximal_line_speed. This is only intended for times stemming from a solution that was obtained up to an absolute MIP gap and may hence be marginally faster than physically possible. By default such a t is treated as an error.
Returns
Feasible line speed in m/s, or 0 if no finite no-stop solution exists for t.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf intermediate EOM checks fail for the provided parameters, or if t is shorter than the fastest possible travel time and allow_too_short_time is false.

◆ get_max_travel_time_acceleration_change_points()

std::pair< double, double > cda_rail::get_max_travel_time_acceleration_change_points ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s )
nodiscard

Returns profile change-point distances for maximum-time motion.

Returned pair {s_1, s_2} marks transition points between decelerate / cruise / accelerate phases (or the corresponding mirrored behavior when speeds are below v_m). If no cruise phase exists, s_1 == s_2.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s (v_m >= 0).
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Pair of change-point distances in metres.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf EOM consistency fails or v_m is negative.

◆ get_min_travel_time_acceleration_change_points()

std::pair< double, double > cda_rail::get_min_travel_time_acceleration_change_points ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s )
nodiscard

Returns profile change-point distances for minimum-time motion.

Returned pair {s_1, s_2} marks transition points between accelerate / cruise / decelerate phases. If no cruise phase exists, s_1 == s_2.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mUpper speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Pair of change-point distances in metres.
Precondition
v_m > 0 and v_m >= max(v_1, v_2).
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf EOM consistency fails or v_m violates preconditions.

◆ get_time_difference_in_seconds()

template<typename Clock, typename Duration1, typename Duration2>
double cda_rail::get_time_difference_in_seconds ( std::chrono::time_point< Clock, Duration1 > const & start,
std::chrono::time_point< Clock, Duration2 > const & end )
inlinenodiscard

◆ initialize_plog()

void cda_rail::initialize_plog ( bool debug_input,
bool overwrite_severity = false )

Initializes the global plog console logger and adjusts its severity.

Parameters
debug_inputIf true, configures debug logging; otherwise configures info logging when an update is applied.
overwrite_severityIf true, updates the maximum severity even when a logger already exists. After the call, a global plog logger instance exists.

◆ is_directory_and_create()

bool cda_rail::is_directory_and_create ( const std::filesystem::path & p)
nodiscard

Ensures that a filesystem path exists as a directory.

Parameters
pPath to the directory.
Returns
true if p is empty, already denotes a directory, or the directory was created successfully; otherwise false. If the function returns true and p is non-empty, p denotes an existing directory.

◆ max_braking_pos_after_dt_linear_movement()

double cda_rail::max_braking_pos_after_dt_linear_movement ( double v_0,
double v_max,
double a,
double d,
double dt )

Computes the maximal forward shift of the braking point after dt.

The train is assumed to accelerate linearly for dt seconds, capped at v_max, and then brake immediately with deceleration d.

Returned value =

  • distance traveled during the acceleration phase over dt, plus
  • braking distance at the reached speed.
Parameters
v_0Initial speed in m/s.
v_maxSpeed cap in m/s.
aAcceleration in m/s^2.
dDeceleration in m/s^2.
dtTime horizon in seconds.
Returns
Maximum reachable braking-point position relative to the current front position (in metres) after dt.
Precondition
dt >= 0, v_0 >= 0, v_max >= v_0, a > 0, d > 0.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf any precondition is violated.

◆ max_time_from_front_to_ma_point()

double cda_rail::max_time_from_front_to_ma_point ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double obd,
bool stopping_allowed )

Maximal time from train front to a target MA point.

Dispatches to stopping or non-stopping variant based on stopping_allowed.

Uses the same MA-point encoding via obd as min_time_from_front_to_ma_point(...).

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s if stopping is not allowed.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
stopping_allowedIf true, a full stop may occur before reaching the MA point.
Returns
Maximal time in seconds; may be infinity when stopping is allowed.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf obd is negative.
cda_rail::exceptions::ConsistencyExceptionIf EOM consistency fails.

◆ max_time_from_front_to_ma_point_no_stopping()

double cda_rail::max_time_from_front_to_ma_point_no_stopping ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double obd )

Maximal time from train front to MA point without full stop.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
Returns
Maximal finite time in seconds.
Precondition
Same consistency requirements as max_travel_time_no_stopping(...).
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf obd is negative.
cda_rail::exceptions::ConsistencyExceptionIf EOM consistency fails.

◆ max_time_from_front_to_ma_point_stopping_allowed()

double cda_rail::max_time_from_front_to_ma_point_stopping_allowed ( double v_1,
double v_2,
double a,
double d,
double s,
double obd )

Maximal time from train front to MA point when stopping is allowed.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
Returns
Maximal time in seconds; may be infinity.
Precondition
Same consistency requirements as max_travel_time_stopping_allowed(...).
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf obd is negative.
cda_rail::exceptions::ConsistencyExceptionIf EOM consistency fails.

◆ max_time_from_rear_to_ma_point()

double cda_rail::max_time_from_rear_to_ma_point ( double v_1,
double v_2,
double v_min,
double v_max,
double a,
double d,
double s,
double obd,
cda_rail::MATimingStrategy strategy = MATimingStrategy::ExtremeProfiles )

Maximal time from train rear to MA point under a strategy.

For ExtremeProfiles, both extreme speed envelopes (using v_min and v_max) are evaluated and the larger resulting time is returned.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_minLower bound used for the extreme-profile evaluation in m/s.
v_maxUpper bound used for the extreme-profile evaluation in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
strategyStrategy to combine profile times.
Returns
Maximal rear-to-MA time in seconds.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf strategy is not supported.
cda_rail::exceptions::InvalidInputExceptionIf delegated MA helper input checks fail.
cda_rail::exceptions::ConsistencyExceptionIf delegated EOM checks fail.

◆ max_time_profile_from_rear_to_ma_point()

double cda_rail::max_time_profile_from_rear_to_ma_point ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double obd )

Rear-to-MA time under a single maximum-time no-stopping profile.

Computed as: max_travel_time_no_stopping(...) - max_time_from_front_to_ma_point_no_stopping(...).

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
Returns
Time in seconds from train rear to MA point for this profile.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf obd is negative.
cda_rail::exceptions::ConsistencyExceptionIf delegated EOM checks fail.

◆ max_travel_time()

double cda_rail::max_travel_time ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
bool stopping_allowed )

Returns maximal traversal time for an edge.

Dispatches to the stopping or non-stopping variant based on stopping_allowed.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s if stopping is not allowed.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
stopping_allowedIf true, full stop may occur on the edge.
Returns
Maximal feasible traversal time in seconds; may be infinity.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are infeasible.

◆ max_travel_time_from_start()

double cda_rail::max_travel_time_from_start ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double x,
bool stopping_allowed )

Returns maximal time to reach position x from edge start.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s if stopping is not allowed.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
stopping_allowedIf true, full stop may occur.
Returns
Maximal time in seconds to reach x; may be infinity.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_from_start_no_stopping()

double cda_rail::max_travel_time_from_start_no_stopping ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double x )

Returns maximal time to reach x without allowing a full stop.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
Returns
Maximal finite time in seconds to reach x.
Precondition
v_1 >= 0, v_2 >= 0, a > 0, d > 0, s >= 0, 0 <= x <= s, and transition from v_1 to v_2 over s is physically feasible.
v_m >= 0.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_from_start_stopping_allowed()

double cda_rail::max_travel_time_from_start_stopping_allowed ( double v_1,
double v_2,
double a,
double d,
double s,
double x )

Returns maximal time to reach x when stopping is allowed.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
Returns
Maximal time in seconds; may be infinity once a full stop is reachable before (or at) x.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_inverse()

double cda_rail::max_travel_time_inverse ( double v_0,
double t,
double dt,
double d,
double s )

Let v_0/s_0 vel/pos at t_0, v_1/s_1 at t_1 and v_2/s_2 at t_2. Find maximal v_1, such that:

  • s_2-s_0 = s (remaining distance)
  • t_2-t_1 = t (desired travel time after moving one time step)
  • t_1-t_0 = dt (time step)
Parameters
v_0Initial velocity in m/s.
tTarget time in s.
dtTime step in s.
dMaximum deceleration in m/s^2.
sDesired travel distance in metres.
Returns
Maximal v_1
Precondition
All values >0
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf an input is non-positive. v_0 may be 0.

◆ max_travel_time_no_stopping()

double cda_rail::max_travel_time_no_stopping ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s )

Returns maximal traversal time without allowing a full stop.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Maximal finite traversal time in seconds.
Precondition
Same consistency requirements as max_travel_time_from_start_no_stopping with x = s.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_stopping_allowed()

double cda_rail::max_travel_time_stopping_allowed ( double v_1,
double v_2,
double a,
double d,
double s )

Returns maximal traversal time when stopping is allowed.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Maximal traversal time in seconds; returns infinity if the train can come to a full stop before the constrained continuation point.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_to_end()

double cda_rail::max_travel_time_to_end ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double x,
bool stopping_allowed )

Returns maximal remaining time from x to edge end.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s if stopping is not allowed.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
stopping_allowedIf true, full stop may occur.
Returns
Maximal remaining time in seconds; may be infinity.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_to_end_no_stopping()

double cda_rail::max_travel_time_to_end_no_stopping ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double x )

Returns maximal remaining time from x to end without stopping.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mLower speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
Returns
Maximal finite remaining time in seconds.
Precondition
Same consistency requirements as max_travel_time_from_start_no_stopping(...).
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_to_end_stopping_allowed()

double cda_rail::max_travel_time_to_end_stopping_allowed ( double v_1,
double v_2,
double a,
double d,
double s,
double x )

Returns maximal remaining time from x to end when stopping is allowed.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
Returns
Maximal remaining time in seconds; may be infinity.
Precondition
Same consistency requirements as max_travel_time_from_start_stopping_allowed(...).
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ max_travel_time_to_stop_at_end_after_one_time_step()

double cda_rail::max_travel_time_to_stop_at_end_after_one_time_step ( double v_0,
double dt,
double d,
double s )

Assuming v_0/s_0 at t_0, v_1/s_1 at t_0+dt and v_2/s_2 at t_2:

  • v_2 = 0
  • s_2 - s_0 = s
  • What is t_2-t_1 (t_1 = t_0+dt)
Parameters
v_0Initial velocity in m/s.
dtTime step in s.
dMaximal deceleration in m/s^2.
sDistance until stop position.
Returns
Maximal time as described.

◆ maximal_line_speed()

double cda_rail::maximal_line_speed ( double v_1,
double v_2,
double v_max,
double a,
double d,
double s )

Returns the maximum line speed reached on the minimal-time profile.

If the edge is too short to reach v_max, the returned value is the actual turning speed reached by the profile.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_maxDesired upper line speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Reached maximum line speed in m/s.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are invalid.

◆ min_time_from_front_to_ma_point()

double cda_rail::min_time_from_front_to_ma_point ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double obd )

Minimal time from train front to a target MA point.

This function uses the same MA convention as the tests and implementation: the target MA point is encoded by overlap braking distance obd. Intuitively, obd measures how much of the final braking-distance reference remains after accounting for the MA point location.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mUpper speed bound for the minimum-time profile in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
Returns
Minimal time in seconds until train front reaches the MA point.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf obd is negative.
cda_rail::exceptions::ConsistencyExceptionIf the requested MA point is inconsistent with the speed profile or edge geometry.

◆ min_time_from_rear_to_ma_point()

double cda_rail::min_time_from_rear_to_ma_point ( double v_1,
double v_2,
double v_min,
double v_max,
double a,
double d,
double s,
double obd,
cda_rail::MATimingStrategy strategy = MATimingStrategy::ExtremeProfiles )

Minimal time from train rear to MA point under a strategy.

For ExtremeProfiles, both extreme speed envelopes (using v_min and v_max) are evaluated and the smaller resulting time is returned.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_minLower bound used for the extreme-profile evaluation in m/s.
v_maxUpper bound used for the extreme-profile evaluation in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
strategyStrategy to combine profile times.
Returns
Minimal rear-to-MA time in seconds.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf strategy is not supported.
cda_rail::exceptions::InvalidInputExceptionIf delegated MA helper input checks fail.
cda_rail::exceptions::ConsistencyExceptionIf delegated EOM checks fail.

◆ min_time_profile_from_rear_to_ma_point()

double cda_rail::min_time_profile_from_rear_to_ma_point ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double obd )

Rear-to-MA time under a single minimum-time speed profile.

Computed as: min_travel_time(...) - min_time_from_front_to_ma_point(...).

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mUpper speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
obdOverlap braking distance in metres (obd >= 0).
Returns
Time in seconds from train rear to MA point for this profile.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf obd is negative.
cda_rail::exceptions::ConsistencyExceptionIf delegated EOM checks fail.

◆ min_time_to_push_ma_backward()

double cda_rail::min_time_to_push_ma_backward ( double v_0,
double a,
double d,
double s )

Minimal time to move the moving-authority point backward by s.

"Backward" means reducing MA overlap by s relative to the current state.

Parameters
v_0Initial speed in m/s.
aAcceleration in m/s^2 (may be zero).
dDeceleration in m/s^2.
sDesired MA backward shift in metres.
Returns
Minimal time in seconds.
Precondition
v_0 >= 0, a >= 0, d > 0, s >= 0, and s <= v_0^2 / (2 * d).
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf inputs violate the preconditions.

◆ min_time_to_push_ma_forward()

double cda_rail::min_time_to_push_ma_forward ( double v_0,
double a,
double d,
double s )

Minimal time to move the moving-authority point forward by s.

"Forward" refers to increasing MA distance from the train's initial MA, accounting for both train displacement and the changed braking distance.

Parameters
v_0Initial speed in m/s.
aAcceleration in m/s^2 (may be zero).
dDeceleration in m/s^2.
sRequired MA forward shift in metres.
Returns
Minimal time in seconds.
Precondition
v_0 >= 0, a >= 0, d > 0, s >= 0.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf inputs violate the preconditions.

◆ min_time_to_push_ma_fully_backward()

double cda_rail::min_time_to_push_ma_fully_backward ( double v_0,
double a,
double d )

Minimal time to move MA fully backward to the initial train front.

Equivalent to min_time_to_push_ma_backward(v_0, a, d, v_0^2/(2*d)).

Parameters
v_0Initial speed in m/s.
aAcceleration in m/s^2 (may be zero).
dDeceleration in m/s^2.
Returns
Minimal time in seconds.
Precondition
v_0 >= 0, a >= 0, d > 0.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf inputs violate the preconditions.

◆ min_travel_time()

double cda_rail::min_travel_time ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s )

Returns the minimal time to traverse an edge of length s.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mUpper speed bound (line speed) in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Minimal feasible traversal time in seconds.
Precondition
Same consistency requirements as min_travel_time_from_start(...) with x = s.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf the speed profile or input range is not feasible under equations of motion.

◆ min_travel_time_flexible_exit_speed()

double cda_rail::min_travel_time_flexible_exit_speed ( double v_1,
double v_m,
double a,
double s )

Returns the minimal travel time when starting with v_1 and no constraint on exit velocity (besides staying below maximal speed).

Parameters
v_1Entry speed in m/s.
v_mMaximal speed in m/s,
aAcceleration in m/s^2.
sDistance in m.
Returns
Minimal travel time.

◆ min_travel_time_from_start()

double cda_rail::min_travel_time_from_start ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double x )

Returns minimal time to reach position x from the edge start.

The profile is the time-optimal one under acceleration bound a, deceleration bound d, and speed cap v_m.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mUpper speed bound (line speed) in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres (0 at start, s at end).
Returns
Minimal time in seconds to reach x.
Precondition
v_1 >= 0, v_2 >= 0, a > 0, d > 0, s >= 0, 0 <= x <= s, and transition from v_1 to v_2 over s is physically feasible.
v_m > 0 and v_m >= max(v_1, v_2).
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ min_travel_time_to_end()

double cda_rail::min_travel_time_to_end ( double v_1,
double v_2,
double v_m,
double a,
double d,
double s,
double x )

Returns minimal remaining time from position x to edge end.

Equivalent to reversing direction and swapping acceleration/deceleration.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_mUpper speed bound (line speed) in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
xDistance from start in metres.
Returns
Minimal time in seconds from x to the edge end.
Precondition
Same feasibility requirements as min_travel_time_from_start(...).
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are inconsistent or infeasible.

◆ minimal_line_speed()

double cda_rail::minimal_line_speed ( double v_1,
double v_2,
double v_min,
double a,
double d,
double s )

Returns the minimum line speed reached on the maximal-time profile.

If the edge is too short to reach v_min, the returned value is the actual turning speed reached by the profile.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_minDesired lower line speed bound in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Reached minimum line speed in m/s.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf inputs are invalid.

◆ operator==() [1/2]

template<typename T>
bool cda_rail::operator== ( const FixedSizeVector< T > & lhs,
const std::vector< T > & rhs )

Equality comparison between a FixedSizeVector and a std::vector.

Template Parameters
TElement type.
Parameters
lhsLeft-hand FixedSizeVector.
rhsRight-hand std::vector.
Returns
true if both containers have the same size and identical elements at every index, otherwise false.

◆ operator==() [2/2]

template<typename T>
bool cda_rail::operator== ( const std::vector< T > & lhs,
const FixedSizeVector< T > & rhs )

Equality comparison between a std::vector and a FixedSizeVector.

Template Parameters
TElement type.
Parameters
lhsLeft-hand std::vector.
rhsRight-hand FixedSizeVector.
Returns
true if both containers have the same size and identical elements at every index, otherwise false.

◆ pos_on_edge_at_time()

double cda_rail::pos_on_edge_at_time ( double v_1,
double v_2,
double v_line,
double a,
double d,
double s,
double t )

Returns position on the edge at time t for a fixed line speed profile.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_lineIntermediate line speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
tTime in seconds from edge entry.
Returns
Position in metres from edge start.
Precondition
Inputs must define a feasible time_on_edge(...) profile.
t must not exceed total travel time (up to numerical tolerance).
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf t is inconsistent with the total profile duration or input domain checks fail.
cda_rail::exceptions::ConsistencyExceptionIf profile realization fails in time_on_edge(...).

◆ possible_by_eom()

bool cda_rail::possible_by_eom ( double v_1,
double v_2,
double a,
double d,
double s )

Checks whether speed transition is feasible by equations of motion.

For acceleration (v_2 >= v_1), checks against acceleration bound a. For deceleration (v_2 < v_1), checks against deceleration bound d.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sDistance in metres.
Returns
true if transition is feasible within tolerance.

◆ relu()

double cda_rail::relu ( double val)
nodiscard

Returns the positive part of a scalar.

Parameters
valInput value.
Returns
val if it is positive, otherwise 0.

◆ round_small_numbers_to_zero_inplace()

void cda_rail::round_small_numbers_to_zero_inplace ( double & val,
double const tol = EPS )
inline

Sets a value to zero if its absolute magnitude is less than a tolerance threshold.

If the absolute value of val is less than tol, val is set to zero; otherwise, val remains unchanged.

Parameters
valReference to the value to normalize.
tolAbsolute tolerance threshold.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf tol is negative.

◆ round_to_given_tolerance()

double cda_rail::round_to_given_tolerance ( double const value,
double const tolerance )
inlinenodiscard

Rounds a value to the nearest multiple of a given tolerance.

Parameters
valueValue to round.
tolerancePositive rounding step.
Returns
Value rounded to the nearest multiple of tolerance, up to floating-point round-off.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf tolerance is not strictly positive.

◆ sanitize()

std::string cda_rail::sanitize ( std::string s)

Replaces every non-alphanumeric character by a hyphen.

Used for names that are built from user-provided names, e.g., the variable names of an exported model.

Parameters
sString to sanitize.
Returns
The sanitized string, which has the same length as s.

◆ solution_status_to_string()

std::string cda_rail::solution_status_to_string ( SolutionStatus const status)
nodiscardconstexpr

The name of status, as it is reported, exported and imported.

◆ subsets_of_size_2_indices()

std::vector< std::pair< size_t, size_t > > cda_rail::subsets_of_size_2_indices ( size_t n)
nodiscard

Generates all unordered index pairs from {0, 1, ..., n - 1}.

Parameters
nSize of the underlying index set.
Returns
Vector containing all pairs (i, j) with 0 <= i < j < n.
Precondition
n >= 2.
Exceptions
std::invalid_argumentIf n < 2.

◆ subsets_of_size_k_indices()

std::vector< cda_rail::index_vector > cda_rail::subsets_of_size_k_indices ( size_t n,
size_t k )
nodiscard

Generates all subsets of size k of the index set {0, 1, ..., n - 1}.

Parameters
nSize of the underlying index set.
kRequired subset size.
Returns
Vector containing all k-element index subsets.
Precondition
k <= n.
Exceptions
std::invalid_argumentIf k > n. Returns an empty vector if k == 0.

◆ swap()

template<typename T>
void cda_rail::swap ( FixedSizeVector< T > & lhs,
FixedSizeVector< T > & rhs )
noexcept

ADL-reachable swap for FixedSizeVector.

Template Parameters
TElement type.
Parameters
lhsFirst vector.
rhsSecond vector.

◆ time_on_edge()

double cda_rail::time_on_edge ( double v_1,
double v_2,
double v_line,
double a,
double d,
double s )

Computes traversal time for a fixed line speed profile.

Profile structure:

  • speed change from v_1 to v_line,
  • optional cruising at v_line,
  • speed change from v_line to v_2.
Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_lineIntermediate line speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
Returns
Total traversal time in seconds.
Precondition
v_1 >= 0, v_2 >= 0, v_line > 0, a > 0, d > 0, s >= 0.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf input domain checks fail.
cda_rail::exceptions::ConsistencyExceptionIf the profile cannot be realized over distance s.

◆ time_to_travel_distance_with_constant_acceleration()

double cda_rail::time_to_travel_distance_with_constant_acceleration ( double v_0,
double a,
double s )
nodiscard

Computes the time to travel s at constant acceleration.

Solves s = v_0 * t + a * t^2 / 2 for t, where a may be negative, and falls back to s / v_0 if it is (numerically) zero.

Parameters
v_0Initial speed in m/s.
aConstant acceleration in m/s^2.
sDistance in metres.
Returns
Travel time in seconds.

◆ to_bool_optional_inplace()

void cda_rail::to_bool_optional_inplace ( std::string_view s_view,
std::optional< bool > & b )

Parses a textual boolean value into an optional in place.

Recognized true/false spellings are interpreted case-insensitively. Empty input clears the optional.

Parameters
s_viewInput string view to parse.
bOptional boolean updated in place.

◆ vel_on_edge_at_time()

double cda_rail::vel_on_edge_at_time ( double v_1,
double v_2,
double v_line,
double a,
double d,
double s,
double t )

Returns velocity on the edge at time t for a fixed line speed profile.

Parameters
v_1Entry speed in m/s.
v_2Exit speed in m/s.
v_lineIntermediate line speed in m/s.
aMaximum acceleration in m/s^2.
dMaximum deceleration in m/s^2.
sEdge length in metres.
tTime in seconds from edge entry.
Returns
Instantaneous speed in m/s.
Precondition
Inputs must define a feasible time_on_edge(...) profile.
t must not exceed total travel time (up to numerical tolerance).
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf t is inconsistent with the total profile duration or input domain checks fail.
cda_rail::exceptions::ConsistencyExceptionIf profile realization fails in time_on_edge(...).

Variable Documentation

◆ ABS_PWL_ERROR

double cda_rail::ABS_PWL_ERROR = 10
constexpr

◆ EPS

double cda_rail::EPS = 1000 * std::numeric_limits<double>::epsilon()
constexpr

◆ GRB_EPS

double cda_rail::GRB_EPS = 1e-4
constexpr

◆ INF

double cda_rail::INF = std::numeric_limits<double>::max() / 3
constexpr

◆ LINE_SPEED_ACCURACY

double cda_rail::LINE_SPEED_ACCURACY = 0.1
constexpr

◆ LINE_SPEED_TIME_ACCURACY

double cda_rail::LINE_SPEED_TIME_ACCURACY = 0.1
constexpr

◆ MIN_NON_ZERO

double cda_rail::MIN_NON_ZERO = 0.1
constexpr

◆ MIN_OCCUPIED_LENGTH

double cda_rail::MIN_OCCUPIED_LENGTH = 1
constexpr

◆ STOP_TOLERANCE

double cda_rail::STOP_TOLERANCE = 10
constexpr

◆ V_MIN

double cda_rail::V_MIN = 0.3
constexpr