|
MTCT
Design Automation and Optimization for ETCS Railway Networks
|
#include <GeneralSimulator.hpp>
Public Member Functions | |
| GeneralSimulator (instances::GeneralProblemInstanceWithScheduleAndRoutes &instance, std::vector< cda_rail::index_set > ttd_sections) | |
| Constructs a simulator from a mutable instance reference. | |
| GeneralSimulator (instances::GeneralProblemInstanceWithScheduleAndRoutes &instance, std::vector< cda_rail::index_set > ttd_sections, std::vector< cda_rail::index_vector > train_edges, std::vector< cda_rail::index_vector > ttd_orders, std::vector< cda_rail::index_vector > vertex_orders, std::vector< std::vector< double > > stop_positions) | |
| Constructs a simulator from explicit state vectors. | |
| virtual | ~GeneralSimulator ()=default |
| Virtual destructor. | |
| GeneralSimulator (GeneralSimulator const &)=default | |
| Copy constructor. | |
| GeneralSimulator (GeneralSimulator &&)=default | |
| Move constructor. | |
| GeneralSimulator & | operator= (GeneralSimulator const &)=default |
| Copy assignment operator. | |
| GeneralSimulator & | operator= (GeneralSimulator &&)=default |
| Move assignment operator. | |
| virtual instances::GeneralProblemInstanceWithScheduleAndRoutes const * | get_instance () const |
| Provides access to the problem instance for this simulator. | |
| const std::vector< cda_rail::index_set > & | get_ttd_sections () const |
| Retrieves the TTD sections considered by the simulator. | |
| const std::vector< cda_rail::index_vector > & | get_train_edges () const |
| Accesses the edge sequences for all trains. | |
| const cda_rail::index_vector & | get_train_edges_of_tr (size_t train_id) const |
| Returns the current edge sequence for one train. | |
| const std::vector< cda_rail::index_vector > & | get_ttd_orders () const |
| Retrieves the ordering vectors for all TTD sections. | |
| const cda_rail::index_vector & | get_ttd_orders_of_ttd (size_t ttd_index) const |
| Returns the train order for one TTD section. | |
| std::optional< size_t > | get_ttd (Network::EdgeInput const &edge) const |
| Returns the TTD section containing an edge, if any. | |
| const std::vector< cda_rail::index_vector > & | get_vertex_orders () const |
| Accesses the train ordering for each vertex. | |
| const cda_rail::index_vector & | get_vertex_orders_of_vertex (Network::VertexInput const &vertex) const |
| Returns the train order stored for a vertex. | |
| const std::vector< std::vector< double > > & | get_stop_positions () const |
| Accesses all trains' scheduled stop positions. | |
| const std::vector< double > & | get_stop_positions_of_tr (size_t train_id) const |
| Returns the stop positions of one train. | |
| double | train_edge_length (size_t tr) const |
| Returns the length of the current edge sequence of a train. | |
| double | get_edge_position (size_t train_id, size_t edge_id) const |
| Returns the route position at which an edge ends, i.e., the position of its target vertex. | |
| size_t | get_edge_at_position (size_t train_id, double position) const |
| Returns the edge that contains a route position. | |
| bool | is_route_end_valid_stop_pos (size_t tr, const cda_rail::index_vector &edges) const |
| Checks whether a route end can serve as the next stop position. | |
| bool | is_current_pos_valid_stop_position (size_t tr) const |
| Checks whether the train's current last edge is a valid stop position. | |
| SimulatorState | get_simulator_state () const |
| The full simulator state. | |
| void | set_simulator_state (SimulatorState state) |
| Replaces the full simulator state. | |
| void | set_train_edges (std::vector< cda_rail::index_vector > tr_edges) |
| Replaces all train edge sequences. | |
| void | set_train_edges_of_tr (size_t train_id, cda_rail::index_vector edges) |
| Replaces the edge sequence of one train. | |
| void | append_train_edge_to_tr (size_t train_id, cda_rail::Network::EdgeInput const &edge) |
| Appends one edge to a train edge sequence. | |
| void | set_ttd_orders (std::vector< cda_rail::index_vector > orders) |
| Replaces all TTD train orders. | |
| void | set_ttd_orders_of_ttd (size_t ttd_index, cda_rail::index_vector orders) |
| Replaces the order stored for one TTD section. | |
| void | set_vertex_orders (std::vector< cda_rail::index_vector > orders) |
| Replaces all vertex train orders. | |
| void | set_vertex_orders_of_vertex (cda_rail::Network::VertexInput const &vertex, cda_rail::index_vector orders) |
| Replaces the train order stored for one vertex. | |
| void | set_stop_positions (std::vector< std::vector< double > > positions) |
| Replaces all stop-position vectors. | |
| void | set_stop_positions_of_tr (size_t train_id, std::vector< double > positions) |
| Replaces the stop positions of one train. | |
| void | append_stop_position_to_tr (size_t train_id, double position) |
| Appends one stop position to a train. | |
| void | append_stop_edge_to_tr (size_t train_id, size_t edge) |
| Appends a stop edge reference to a train. | |
| void | append_current_stop_position_of_tr (size_t train_id) |
| Appends the current route-end position as a stop for a train. | |
| bool | is_final_state () const |
| Checks whether the current simulator state is terminal. | |
| virtual SimulatorResults | simulate (double dt, bool late_entry_possible, bool limit_speed_by_leaving_edges, bool save_trajectories, bool block_vertices_after_disappearing) const =0 |
| Simulates train movements given the current routing, ordering, and stopping configuration. | |
| SimulatorResults | simulate (double dt=6.0, bool late_entry_possible=false, bool limit_speed_by_leaving_edges=true, bool save_trajectories=false) const |
| Simulates with default values, in particular a time step of 6 seconds and blocking the last vertex of a partial route. | |
| virtual std::optional< SimulatorState > | first_come_first_served_state (double dt, bool late_entry_possible, bool limit_speed_by_leaving_edges) const |
| Decides every order that the current state leaves open first come, first served. | |
| cda_rail::index_set | trains_on_path (cda_rail::index_vector const &edges, bool also_reverse_path=false) const |
| Returns the trains whose current routes contain a path. | |
| cda_rail::index_set | trains_on_path (cda_rail::index_vector const &edges, std::vector< cda_rail::index_vector > const &tr_edges, bool also_reverse_path=false) const |
| Returns the trains from provided routes that contain a path. | |
Static Public Member Functions | |
| static cda_rail::index_set | trains_on_path (cda_rail::index_vector const &edges, std::vector< cda_rail::index_vector > const &tr_edges, Network const &network, bool also_reverse_path=false) |
| Returns the trains from provided routes that contain a path. | |
Protected Member Functions | |
| GeneralSimulator (std::shared_ptr< const cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes > instance, std::vector< cda_rail::index_set > ttd_sections) | |
| Constructs a simulator from shared instance data. | |
| GeneralSimulator (std::shared_ptr< const cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes > instance, std::vector< cda_rail::index_set > ttd_sections, std::vector< cda_rail::index_vector > train_edges, std::vector< cda_rail::index_vector > ttd_orders, std::vector< cda_rail::index_vector > vertex_orders, std::vector< std::vector< double > > stop_positions) | |
| Constructs a simulator from shared instance data and explicit state. | |
| double | tr_braking_distance (size_t tr, double v) const |
| Computes braking distance for a train at a given speed. | |
| std::vector< double > | edge_milestones (size_t tr) const |
| Returns cumulative edge milestones for a train route. | |
| bool | is_on_route (size_t tr, size_t edge_id) const |
| Checks whether an edge is on a train's current route. | |
| std::vector< std::unordered_set< size_t > > | tr_on_edges () const |
| Returns, for each edge, the trains currently using it. | |
This abstract class defines the interface for a general simulator to simulate train trajectories given all routing, ordering, and stopping information. It can, e.g., be used within search algorithms like A* for objective evaluation. This abstract class defines all necessary functions to be implemented and provides some general helper functions.
|
protected |
Constructs a simulator from shared instance data.
| instance | Shared problem instance. |
| ttd_sections | TTD sections used by the simulator. |
|
protected |
Constructs a simulator from shared instance data and explicit state.
| instance | Shared problem instance. |
| ttd_sections | TTD sections used by the simulator. |
| train_edges | Per-train edge sequences. |
| ttd_orders | Per-TTD train orders. |
| vertex_orders | Per-vertex train orders. |
| stop_positions | Per-train stop positions. |
| cda_rail::simulator::GeneralSimulator::GeneralSimulator | ( | instances::GeneralProblemInstanceWithScheduleAndRoutes & | instance, |
| std::vector< cda_rail::index_set > | ttd_sections ) |
Constructs a simulator from a mutable instance reference.
| instance | Problem instance. |
| ttd_sections | TTD sections used by the simulator. |
| cda_rail::simulator::GeneralSimulator::GeneralSimulator | ( | instances::GeneralProblemInstanceWithScheduleAndRoutes & | instance, |
| std::vector< cda_rail::index_set > | ttd_sections, | ||
| std::vector< cda_rail::index_vector > | train_edges, | ||
| std::vector< cda_rail::index_vector > | ttd_orders, | ||
| std::vector< cda_rail::index_vector > | vertex_orders, | ||
| std::vector< std::vector< double > > | stop_positions ) |
Constructs a simulator from explicit state vectors.
| instance | Problem instance. |
| ttd_sections | TTD sections used by the simulator. |
| train_edges | Per-train edge sequences. |
| ttd_orders | Per-TTD train orders. |
| vertex_orders | Per-vertex train orders. |
| stop_positions | Per-train stop positions. |
|
virtualdefault |
Virtual destructor.
Ensures proper cleanup when derived class instances are deleted through base class pointers.
|
default |
Copy constructor.
|
default |
Move constructor.
| void cda_rail::simulator::GeneralSimulator::append_current_stop_position_of_tr | ( | size_t | train_id | ) |
Appends the current route-end position as a stop for a train.
| void cda_rail::simulator::GeneralSimulator::append_stop_edge_to_tr | ( | size_t | train_id, |
| size_t | edge ) |
Appends a stop edge reference to a train.
| void cda_rail::simulator::GeneralSimulator::append_stop_position_to_tr | ( | size_t | train_id, |
| double | position ) |
Appends one stop position to a train.
| void cda_rail::simulator::GeneralSimulator::append_train_edge_to_tr | ( | size_t | train_id, |
| cda_rail::Network::EdgeInput const & | edge ) |
Appends one edge to a train edge sequence.
|
nodiscardprotected |
|
nodiscardvirtual |
Decides every order that the current state leaves open first come, first served.
The routes and stops are taken as they are, and the trains of every order of the state keep their relative order. Every train that is not yet in the order of a TTD section, entry or exit vertex of its route is inserted into that order once it gets there in the simulation, i.e., once it needs it for its moving authority: behind the trains that got there before it, and hence ahead of the trains of the state that have not gotten there yet.
| dt | See simulate. |
| late_entry_possible | See simulate. |
| limit_speed_by_leaving_edges | See simulate. |
| cda_rail::exceptions::ConsistencyException | If the simulator does not support this. |
Reimplemented in cda_rail::simulator::GreedySimulator.
|
nodiscard |
|
nodiscard |
|
inlinenodiscardvirtual |
Provides access to the problem instance for this simulator.
Reimplemented in cda_rail::simulator::EventSimulator, and cda_rail::simulator::GreedySimulator.
|
inlinenodiscard |
The full simulator state.
|
inlinenodiscard |
Accesses all trains' scheduled stop positions.
|
nodiscard |
Returns the stop positions of one train.
| train_id | Train index. |
|
inlinenodiscard |
Accesses the edge sequences for all trains.
|
nodiscard |
|
nodiscard |
Returns the TTD section containing an edge, if any.
| edge | Edge descriptor. |
|
inlinenodiscard |
Retrieves the ordering vectors for all TTD sections.
|
nodiscard |
Returns the train order for one TTD section.
| ttd_index | TTD section index. |
|
inlinenodiscard |
Retrieves the TTD sections considered by the simulator.
|
inlinenodiscard |
Accesses the train ordering for each vertex.
|
nodiscard |
|
inlinenodiscard |
Checks whether the train's current last edge is a valid stop position.
| tr | Train ID. |
This function checks if the current last edge can be used as a stop for a specific train. A stop is possible, if the train length back from the target vertex is fully within the next station.
| tr | The id of the train to check. |
|
nodiscard |
Checks whether the current simulator state is terminal.
|
nodiscardprotected |
|
inlinenodiscard |
Checks whether a route end can serve as the next stop position.
| tr | Train index. |
| edges | Current route edges. |
|
default |
Move assignment operator.
|
default |
Copy assignment operator.
| void cda_rail::simulator::GeneralSimulator::set_simulator_state | ( | SimulatorState | state | ) |
Replaces the full simulator state.
| void cda_rail::simulator::GeneralSimulator::set_stop_positions | ( | std::vector< std::vector< double > > | positions | ) |
Replaces all stop-position vectors.
| void cda_rail::simulator::GeneralSimulator::set_stop_positions_of_tr | ( | size_t | train_id, |
| std::vector< double > | positions ) |
Replaces the stop positions of one train.
| void cda_rail::simulator::GeneralSimulator::set_train_edges | ( | std::vector< cda_rail::index_vector > | tr_edges | ) |
Replaces all train edge sequences.
| void cda_rail::simulator::GeneralSimulator::set_train_edges_of_tr | ( | size_t | train_id, |
| cda_rail::index_vector | edges ) |
Replaces the edge sequence of one train.
| void cda_rail::simulator::GeneralSimulator::set_ttd_orders | ( | std::vector< cda_rail::index_vector > | orders | ) |
Replaces all TTD train orders.
| void cda_rail::simulator::GeneralSimulator::set_ttd_orders_of_ttd | ( | size_t | ttd_index, |
| cda_rail::index_vector | orders ) |
Replaces the order stored for one TTD section.
| void cda_rail::simulator::GeneralSimulator::set_vertex_orders | ( | std::vector< cda_rail::index_vector > | orders | ) |
Replaces all vertex train orders.
| void cda_rail::simulator::GeneralSimulator::set_vertex_orders_of_vertex | ( | cda_rail::Network::VertexInput const & | vertex, |
| cda_rail::index_vector | orders ) |
Replaces the train order stored for one vertex.
|
nodiscardpure virtual |
Simulates train movements given the current routing, ordering, and stopping configuration.
For partial routes, it is assumed that trains instantaneously stop at their route end, where they disappear.
| dt | Time step of the greedy simulator in seconds. The event-based simulator uses it as the minimal time after which a train following another one is simulated again. |
| late_entry_possible | Whether trains may enter later than scheduled. |
| limit_speed_by_leaving_edges | Whether leaving edges constrain speed. |
| save_trajectories | Whether to retain detailed trajectories. |
| block_vertices_after_disappearing | Whether trains block their last vertex after disappearing on a partial route. |
Implemented in cda_rail::simulator::EventSimulator, and cda_rail::simulator::GreedySimulator.
|
inlinenodiscard |
Simulates with default values, in particular a time step of 6 seconds and blocking the last vertex of a partial route.
|
nodiscardprotected |
Computes braking distance for a train at a given speed.
| tr | Train index. |
| v | Speed. |
|
nodiscardprotected |
Returns, for each edge, the trains currently using it.
|
nodiscard |
|
inlinenodiscard |
Returns the trains whose current routes contain a path.
| edges | Path edges to test. |
| also_reverse_path | Whether to also test the reverse path. |
|
inlinenodiscard |
Returns the trains from provided routes that contain a path.
| edges | Path edges to test. |
| tr_edges | Per-train edge sequences. |
| also_reverse_path | Whether to also test the reverse path. |
|
staticnodiscard |
Returns the trains from provided routes that contain a path.
| edges | Path edges to test. |
| tr_edges | Per-train edge sequences. |
| network | Network used for reverse-path lookup. |
| also_reverse_path | Whether to also test the reverse path. |