|
| | GreedySimulator (cda_rail::instances::GeneralPerformanceOptimizationInstance const &instance, std::vector< cda_rail::index_set > ttd_sections) |
| | Constructs a greedy simulator from an instance and TTD sections.
|
| | GreedySimulator (cda_rail::instances::GeneralPerformanceOptimizationInstance const &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 greedy simulator with explicit state vectors.
|
| | GreedySimulator (GreedySimulator const &)=default |
| | Copy constructor.
|
| | GreedySimulator (GreedySimulator &&) noexcept=default |
| | Move constructor.
|
| GreedySimulator & | operator= (GreedySimulator const &)=default |
| | Copy assignment operator.
|
| GreedySimulator & | operator= (GreedySimulator &&) noexcept=default |
| | Move assignment operator.
|
| | ~GreedySimulator () override=default |
| | Virtual destructor.
|
| instances::GeneralPerformanceOptimizationInstance const * | get_instance () const override |
| | Retrieves the typed performance optimization instance.
|
| void | set_position_bound (PositionBoundFunction bound, index_set trains_with_feasible_bound={}) |
| | Restricts the trains to the positions given by bound.
|
| SimulatorResults | simulate (double dt, bool late_entry_possible, bool limit_speed_by_leaving_edges, bool save_trajectories, bool block_vertices_after_disappearing) const override |
| | Runs the greedy simulation in time steps of length dt.
|
| std::optional< SimulatorState > | first_come_first_served_state (double dt, bool late_entry_possible, bool limit_speed_by_leaving_edges) const override |
| | Decides every open order first come, first served, see GeneralSimulator::first_come_first_served_state.
|
| 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.
|
| | 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.
|
| 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.
|
| 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.
|
| 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.
|
Simulates the trains of a moving block instance greedily.
Every train drives as fast as the moving block separation, its own dynamics, and the orders of the state allow, so that the simulated trajectories are the best ones for the given routing, ordering, and stopping decisions. The simulation advances in time steps of the given length until every train has left the network, or until nothing moves any more, see CYCLE_LIMIT.
As in the moving block MILP, a train leaves the network once its rear has passed its exit vertex, which is when its scheduled exit time and speed apply. Until then, it occupies its last edge, beyond whose end the route continues at the edge's speed limit. A train only waits within the network, i.e., at the latest with its front at the exit vertex, unless it is kept behind a solution, see set_position_bound.
| std::optional< cda_rail::simulator::SimulatorState > cda_rail::simulator::GreedySimulator::first_come_first_served_state |
( |
double | dt, |
|
|
bool | late_entry_possible, |
|
|
bool | limit_speed_by_leaving_edges ) const |
|
nodiscardoverridevirtual |
Decides every open order first come, first served, see GeneralSimulator::first_come_first_served_state.
A train gets to a TTD section, or to its exit vertex, once its moving authority would extend into the section, respectively up to the end of its route, i.e., once the order is checked for it, and to its entry vertex once it is due to enter. Trains getting somewhere within the same time step get there in the order in which the simulation handles them, entering ones by their entry times.
Two trains that use a stretch of track in opposite directions would block each other if each one entered it from its end. Hence, the stretch, namely every TTD section and vertex from the one at which a train gets to the shared track up to the one at which it leaves it, is given to the train that gets to it first: this train gets to all of them at once. If the other train got to one of them before, or the given state lets it pass one of them before this train, the other train came first and gets to the others before. Since a train of the given state that has not gotten somewhere yet is no obstacle, a stretch of which each train holds one end by the given state still goes to the train getting to it first.
If a train misses its entry time that way, it passes before the train that kept it from entering last, at every TTD section and vertex at which the given state leaves their order open, and the orders are decided anew. Since every such retry adds a train to an order of the given state, there are only finitely many.
Reimplemented from cda_rail::simulator::GeneralSimulator.