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

Specific schedule object with fixed entry/exit constraints. More...

#include <Timetable.hpp>

Public Member Functions

 Schedule (double entry_time, double initial_velocity, size_t entry_vertex, double exit_time, double exit_velocity, size_t exit_vertex, std::vector< ScheduledStop > stops={})
 Constructs a schedule with fixed entry/exit constraints.
double get_entry_time () const
 Provides the entry time.
double get_exit_time () const
 Gets the scheduled exit time.
double get_initial_velocity () const
 Obtains the initial velocity.
double get_exit_velocity () const
 Obtains the exit velocity.
size_t get_entry_vertex () const
 Determines the network vertex where the train enters.
size_t get_exit_vertex () const
 Gets the exit vertex of the schedule.
std::vector< ScheduledStop > const & get_stops () const
 Retrieves the scheduled stops for this train.
size_t get_station_index (std::string const &station_name) const
 Returns the index of a scheduled stop by station name.
void set_entry_time (double const newEntryTime)
 Sets the entry time.
void set_exit_time (double const newExitTime)
 Sets the exit time.
void set_initial_velocity (double const newInitialVelocity)
 Updates the initial velocity.
void set_exit_velocity (double const newExitVelocity)
 Sets the exit velocity.
void set_entry_vertex (size_t const newEntryVertex)
 Sets the entry vertex.
void set_entry_vertex (size_t const newEntryVertex, Network const &network)
 Sets the entry vertex id after validating it against a network.
void set_exit_vertex (size_t const newExitVertex)
 Sets the exit vertex id.
void set_exit_vertex (size_t const newExitVertex, Network const &network)
 Sets the exit vertex id after validating it against a network.
void set_stops (std::vector< ScheduledStop > new_stops)
 Replaces the stop list for this schedule.
void insert_stop (ScheduledStop new_stop)
 Inserts one stop while preserving stop-list invariants.
void remove_stop (std::string const &station_name, bool throw_exception_if_not_existent=true)
 Removes a stop by station name.
void sort_stops_by_service_time ()
 Sorts the scheduled stops by service time.

Friends

class Timetable

Detailed Description

Specific schedule object with fixed entry/exit constraints.

Stores timing, velocity, path endpoints, and an ordered list of scheduled stops for one train.

Invariant
m_entry_time >= 0.
m_exit_time >= m_entry_time.
m_initial_velocity >= 0.
m_exit_velocity >= 0.
m_stops is ordered by service time

Constructor & Destructor Documentation

◆ Schedule()

cda_rail::Schedule::Schedule ( double entry_time,
double initial_velocity,
size_t entry_vertex,
double exit_time,
double exit_velocity,
size_t exit_vertex,
std::vector< ScheduledStop > stops = {} )

Constructs a schedule with fixed entry/exit constraints.

Precondition
entryTime >= 0.
exitTime >= entryTime.
initialVelocity >= 0.
exitVelocity >= 0.
stops are ordered by service time and cover pairwise distinct stations
Parameters
entry_timeEarliest allowed entry time.
initial_velocityInitial velocity at entry.
entry_vertexEntry vertex id.
exit_timeDesired exit time.
exit_velocityDesired velocity at exit.
exit_vertexExit vertex id.
stopsOrdered scheduled stops for this train.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf any of the preconditions is violated.

Member Function Documentation

◆ get_entry_time()

double cda_rail::Schedule::get_entry_time ( ) const
inlinenodiscard

Provides the entry time.

Returns
The entry time.

◆ get_entry_vertex()

size_t cda_rail::Schedule::get_entry_vertex ( ) const
inlinenodiscard

Determines the network vertex where the train enters.

Returns
The entry vertex ID.

◆ get_exit_time()

double cda_rail::Schedule::get_exit_time ( ) const
inlinenodiscard

Gets the scheduled exit time.

Returns
The exit time constraint.

◆ get_exit_velocity()

double cda_rail::Schedule::get_exit_velocity ( ) const
inlinenodiscard

Obtains the exit velocity.

Returns
The exit velocity.

◆ get_exit_vertex()

size_t cda_rail::Schedule::get_exit_vertex ( ) const
inlinenodiscard

Gets the exit vertex of the schedule.

Returns
The exit vertex ID.

◆ get_initial_velocity()

double cda_rail::Schedule::get_initial_velocity ( ) const
inlinenodiscard

Obtains the initial velocity.

Returns
The initial velocity of the train at entry.

◆ get_station_index()

size_t cda_rail::Schedule::get_station_index ( std::string const & station_name) const
nodiscard

Returns the index of a scheduled stop by station name.

Parameters
station_nameName of the stop station.
Returns
Index of the matching stop in get_stops().
Exceptions
cda_rail::exceptions::StationNotExistentExceptionIf the station does not appear in the schedule.

◆ get_stops()

std::vector< ScheduledStop > const & cda_rail::Schedule::get_stops ( ) const
inlinenodiscard

Retrieves the scheduled stops for this train.

Returns
Const reference to the vector of scheduled stops, ordered by service time.

◆ insert_stop()

void cda_rail::Schedule::insert_stop ( ScheduledStop new_stop)

Inserts one stop while preserving stop-list invariants.

Inserts the stop such that the list remains ordered by service time. If other stops have the same service time, the new stop is inserted after them.

Precondition
The station of new_stop does not already exist in this schedule.
Parameters
new_stopStop to insert.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf the station already appears in the current stop list.

◆ remove_stop()

void cda_rail::Schedule::remove_stop ( std::string const & station_name,
bool throw_exception_if_not_existent = true )

Removes a stop by station name.

Parameters
station_nameName of the station whose stop should be removed.
throw_exception_if_not_existentIf true, throw when no stop with station_name exists; if false, perform no action in that case.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf no matching stop exists and throw_exception_if_not_existent is true.

◆ set_entry_time()

void cda_rail::Schedule::set_entry_time ( double const newEntryTime)
inline

Sets the entry time.

Parameters
newEntryTimeNew entry time.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf newEntryTime is negative.

◆ set_entry_vertex() [1/2]

void cda_rail::Schedule::set_entry_vertex ( size_t const newEntryVertex)
inline

Sets the entry vertex.

Parameters
newEntryVertexNew entry vertex id.

◆ set_entry_vertex() [2/2]

void cda_rail::Schedule::set_entry_vertex ( size_t const newEntryVertex,
Network const & network )
inline

Sets the entry vertex id after validating it against a network.

Parameters
newEntryVertexNew entry vertex id.
networkNetwork used for vertex existence validation.
Exceptions
cda_rail::exceptions::VertexNotExistentExceptionIf newEntryVertex does not exist in network.

◆ set_exit_time()

void cda_rail::Schedule::set_exit_time ( double const newExitTime)
inline

Sets the exit time.

Precondition
newExitTime >= m_entry_time.
Parameters
newExitTimeNew exit time.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf newExitTime is smaller than the current entry time.

◆ set_exit_velocity()

void cda_rail::Schedule::set_exit_velocity ( double const newExitVelocity)
inline

Sets the exit velocity.

Parameters
newExitVelocityNew exit velocity.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf the exit velocity is negative.

◆ set_exit_vertex() [1/2]

void cda_rail::Schedule::set_exit_vertex ( size_t const newExitVertex)
inline

Sets the exit vertex id.

Parameters
newExitVertexNew exit vertex id.

◆ set_exit_vertex() [2/2]

void cda_rail::Schedule::set_exit_vertex ( size_t const newExitVertex,
Network const & network )
inline

Sets the exit vertex id after validating it against a network.

Parameters
newExitVertexNew exit vertex id.
networkNetwork used for vertex existence validation.
Exceptions
cda_rail::exceptions::VertexNotExistentExceptionIf newExitVertex does not exist in network.

◆ set_initial_velocity()

void cda_rail::Schedule::set_initial_velocity ( double const newInitialVelocity)
inline

Updates the initial velocity.

Parameters
newInitialVelocityThe new initial velocity.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf the value is negative.

◆ set_stops()

void cda_rail::Schedule::set_stops ( std::vector< ScheduledStop > new_stops)
inline

Replaces the stop list for this schedule.

Parameters
new_stopsNew stop list to replace the current one.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf the stop list is not sorted by service time or contains duplicate stations.

◆ sort_stops_by_service_time()

void cda_rail::Schedule::sort_stops_by_service_time ( )
inline

Sorts the scheduled stops by service time.

Stops with equal service times keep their order, since that is the order in which they are served.

◆ Timetable

friend class Timetable
friend

The documentation for this class was generated from the following files: