|
MTCT
Design Automation and Optimization for ETCS Railway Networks
|
An instance consisting of a network, a timetable, and routes. More...
#include <GeneralProblemInstance.hpp>
Public Member Functions | |
| GeneralProblemInstanceWithScheduleAndRoutes (const GeneralProblemInstanceWithScheduleAndRoutes &)=default | |
| GeneralProblemInstanceWithScheduleAndRoutes & | operator= (const GeneralProblemInstanceWithScheduleAndRoutes &)=default |
| GeneralProblemInstanceWithScheduleAndRoutes (GeneralProblemInstanceWithScheduleAndRoutes &&) noexcept=default | |
| Move constructor. | |
| GeneralProblemInstanceWithScheduleAndRoutes & | operator= (GeneralProblemInstanceWithScheduleAndRoutes &&) noexcept=default |
| ~GeneralProblemInstanceWithScheduleAndRoutes () override=default | |
| bool | is_route_end_valid_stop_pos (size_t tr, const cda_rail::index_vector &edges, size_t next_stop_id) const |
| Checks whether a route end is a valid stopping position. | |
| virtual void | export_instance (std::filesystem::path const &working_directory, bool save_network) const |
| Exports the instance and optionally its network. | |
| void | export_instance (std::filesystem::path const &working_directory) const override |
| Exports the instance to the specified working directory without saving the network. | |
| const auto & | get_const_network () const |
| Provides read-only access to the network. | |
| const auto & | get_const_timetable () const |
| Accesses the timetable. | |
| const auto & | get_const_routes () const |
| Provides read-only access to the routes. | |
| auto & | get_editable_network () |
| Provides editable access to the underlying network. | |
| Train & | editable_train (size_t const index) |
| Gets a train by its index in the schedule. | |
| Train & | editable_train (const std::string &name) |
| Retrieves mutable access to a train by name. | |
| Schedule & | editable_schedule (size_t const index) |
| Gets the schedule of a train by its index for editing. | |
| Schedule & | editable_schedule (const std::string &name) |
| Retrieves mutable access to the schedule of a train by name. | |
| const StationList & | get_const_station_list () const |
| Provides the list of all stations. | |
| const TrainList & | get_const_train_list () const |
| Provides const access to the list of trains in the instance. | |
| const auto & | get_const_schedule (size_t index) const |
| Retrieves the schedule for a train. | |
| const auto & | get_const_schedule (const std::string &train_name) const |
| Retrieves the schedule for a specified train. | |
| bool | has_route_for_every_train () const |
| Checks whether every train has an assigned route. | |
| double | route_length (const std::string &train_name) const |
| Computes the total length of a train's route. | |
| std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > | get_stop_tracks (size_t tr, const std::string &station_name, const cda_rail::index_set &edges_to_consider={}) const |
| Retrieves the stop tracks for a train at a specified station. | |
| std::optional< double > | get_last_stop_position_on_route (size_t tr_id, const std::string &station_name) const |
| Returns the last reachable stop position of a station on a route. | |
| std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > | possible_stop_vertices (size_t tr, const std::string &station_name, const cda_rail::index_set &edges_to_consider={}) const |
| Computes feasible stop-edge paths for a train at a station. | |
| std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > | possible_stop_vertices (const std::string &train_name, const std::string &station_name, const cda_rail::index_set &edges_to_consider={}) const |
| Finds possible vertices where a train can stop at a station. | |
| cda_rail::index_set | edges_used_by_train (const std::string &train_name, bool fixed_routes, bool error_if_no_route=true) const |
| Returns the edges used by a train. | |
| cda_rail::index_set | edges_used_by_train (size_t train_id, bool fixed_routes, bool error_if_no_route=true) const |
| Retrieves the edges used by a train identified by index. | |
| cda_rail::index_set | vertices_used_by_train (const std::string &tr_name, bool fixed_routes, bool error_if_no_route=true) const |
| Returns the vertices used by a train. | |
| cda_rail::index_set | vertices_used_by_train (size_t tr_id, bool fixed_routes, bool error_if_no_route=true) const |
| Retrieves all vertices used by a train identified by its index. | |
| cda_rail::index_set | sections_used_by_train (const std::string &tr_name, const std::vector< cda_rail::index_set > §ions, bool fixed_routes, bool error_if_no_route=true) const |
| Returns the queried sections used by a train. | |
| cda_rail::index_set | sections_used_by_train (size_t tr_id, const std::vector< cda_rail::index_set > §ions, bool fixed_routes, bool error_if_no_route=true) const |
| Retrieves sections used by a train specified by index. | |
| cda_rail::index_set | trains_in_section (const cda_rail::index_set §ion, bool fix_routes=true, bool error_if_no_route=true) const |
| Returns the trains that use a section. | |
| cda_rail::index_set | trains_on_edge (size_t edge_id, bool fixed_routes, const cda_rail::index_set &trains_to_consider, bool error_if_not_route=true) const |
| Identifies which trains use the specified edge. | |
| cda_rail::index_set | trains_on_edge (RouteMap const &route_map, size_t edge_id, bool fixed_routes, const cda_rail::index_set &trains_to_consider, bool error_if_not_route=true) const |
| Identifies which trains from a subset use the specified edge. | |
| cda_rail::index_set | all_trains_on_edge (size_t edge_id, bool fixed_routes=true, bool error_if_not_route=true) const |
| Returns the indices of all trains using a given edge. | |
| cda_rail::index_set | all_trains_on_edge (RouteMap const &route_map, size_t edge_id, bool fixed_routes=true, bool error_if_not_route=true) const |
| Returns all trains whose routes use the specified edge. | |
| size_t | add_train (std::string const &train_name, double length, double max_speed, double acceleration, double deceleration, bool tim, double entry_time, double initial_velocity, Network::VertexInput const &entry_vertex, double exit_time, double exit_velocity, Network::VertexInput const &exit_vertex) |
| Adds a train with the specified properties to the timetable. | |
| size_t | add_train (std::string const &train_name, double length, double max_speed, double acceleration, double deceleration, double entry_time, double initial_velocity, Network::VertexInput const &entry_vertex, double exit_time, double exit_velocity, Network::VertexInput const &exit_vertex) |
| Adds a train to the timetable. | |
| void | add_empty_station (const std::string &name) |
| Adds an empty station to the timetable. | |
| void | add_track_to_station (const std::string &name, Network::EdgeInput const &track) |
| Adds a track to a station. | |
| void | insert_stop (size_t train_index, std::string const &station_name, double service_time, double service_duration) |
| Inserts a stop into a train's schedule. | |
| void | insert_stop (std::string const &train_name, std::string const &station_name, double service_time, double service_duration) |
| Inserts a stop for a train at a specified station. | |
| void | set_routes (RouteMap routes) |
| Replaces all routes of the instance. | |
| void | add_empty_route (const std::string &train_name) |
| Adds an empty route for a train. | |
| void | push_back_edge_to_route (const std::string &train_name, Network::EdgeInput const &edge_input) |
| Appends an edge to the end of a train's route. | |
| void | push_front_edge_to_route (const std::string &train_name, Network::EdgeInput const &edge_input) |
| Adds an edge to the front of a train's route. | |
| void | remove_first_edge_from_route (const std::string &train_name) |
| Removes the first edge from a train's route. | |
| void | remove_last_edge_from_route (const std::string &train_name) |
| Removes the last edge from a train's route. | |
| Route::EdgePosition | route_edge_pos (const std::string &train_name, Network::EdgeInput const &edge) const |
| Determines the position of an edge on a train's route. | |
| Route::EdgePosition | route_edge_pos (const std::string &train_name, const cda_rail::index_vector &edges) const |
| Determines the position of edges on a train's route. | |
| std::vector< ConflictPair > | get_parallel_overlaps (const std::string &train1, const std::string &train2) const |
| Identifies parallel overlaps between two trains. | |
| std::vector< ConflictPair > | get_ttd_overlaps (const std::string &train1, const std::string &train2) const |
| Identifies time-to-distance overlaps between two trains. | |
| std::vector< ConflictPair > | get_reverse_overlaps (const std::string &train1, const std::string &train2) const |
| Identifies sections where two trains travel in opposite directions. | |
| std::vector< ConflictPair > | get_crossing_overlaps (const std::string &train1, const std::string &train2) const |
| Identifies crossing conflicts between two trains' routes. | |
| bool | check_consistency () const override |
| Checks that the instance is internally consistent, requiring all trains to have routes. | |
| virtual bool | check_consistency (bool every_train_must_have_route) const |
| Checks consistency while optionally allowing trains without routes. | |
| FeasibilityCheck | is_obviously_infeasible (bool late_entry_allowed) const override |
| Checks the instance for reasons that make it infeasible by itself. | |
| virtual void | export_instance (const std::string &working_directory) const |
| Exports the instance to the specified working directory. | |
| virtual void | export_instance (char const *const workingDirectory) const |
| Exports the instance to the specified working directory. | |
| Public Member Functions inherited from cda_rail::instances::GeneralProblemInstance | |
| virtual | ~GeneralProblemInstance ()=default |
| Virtual destructor. | |
| GeneralProblemInstance (const GeneralProblemInstance &)=default | |
| Copy constructor. | |
| GeneralProblemInstance & | operator= (const GeneralProblemInstance &)=default |
| Copy assignment operator. | |
| GeneralProblemInstance (GeneralProblemInstance &&) noexcept=default | |
| Move constructor. | |
| GeneralProblemInstance & | operator= (GeneralProblemInstance &&) noexcept=default |
| Move assignment operator. | |
| const std::string & | get_instance_name () const |
| Gets the instance name. | |
| const std::string & | get_instance_subdirectory () const |
| Provides the instance subdirectory. | |
| void | set_instance_name (std::string_view const instanceName) |
| Sets the instance name. | |
| void | set_instance_subdirectory (std::string_view const instanceSubdirectory) |
| Sets the instance subdirectory. | |
Protected Member Functions | |
| GeneralProblemInstanceWithScheduleAndRoutes ()=default | |
| Constructs an empty problem instance with schedule and routes. | |
| GeneralProblemInstanceWithScheduleAndRoutes (Network network) | |
| Initializes the instance with a network. | |
| GeneralProblemInstanceWithScheduleAndRoutes (Network network, Timetable timetable, RouteMap routes) | |
| Initializes the instance with a network, timetable, and routes. | |
| GeneralProblemInstanceWithScheduleAndRoutes (std::string_view instance_name, std::string_view instance_subdirectory, std::filesystem::path const &working_directory) | |
| Loads a full problem instance from disk. | |
| GeneralProblemInstanceWithScheduleAndRoutes (std::string_view const instanceName, std::string_view const instanceSubdirectory, std::string const &working_directory) | |
| Constructs a problem instance by loading from a working directory. | |
| GeneralProblemInstanceWithScheduleAndRoutes (std::string_view const instanceName, std::string_view const instanceSubdirectory, char const *const workingDirectory) | |
| Constructs an instance by loading data from the working directory. | |
| auto & | get_editable_timetable () |
| Provides editable access to the timetable. | |
| auto & | get_editable_routes () |
| Provides editable access to the route map. | |
| Protected Member Functions inherited from cda_rail::instances::GeneralProblemInstance | |
| GeneralProblemInstance ()=default | |
| Initializes the instance with empty name and subdirectory. | |
| GeneralProblemInstance (std::string_view const instanceName, std::string_view const instanceSubdirectory) | |
| Initializes the instance with a name and subdirectory. | |
Friends | |
| class | SolGeneralProblemInstanceWithScheduleAndRoutes |
An instance consisting of a network, a timetable, and routes.
This is what every problem of this tool is posed on. The routes are optional in the sense that a solver may be free to choose them, which is why an instance can be consistent with routes missing, see check_consistency.
|
protecteddefault |
Constructs an empty problem instance with schedule and routes.
|
inlineexplicitprotected |
Initializes the instance with a network.
| network | The network for this instance. |
|
inlineexplicitprotected |
Initializes the instance with a network, timetable, and routes.
|
protected |
Loads a full problem instance from disk.
| instance_name | Instance name. |
| instance_subdirectory | Instance subdirectory. |
| working_directory | Base working directory. |
|
inlineprotected |
Constructs a problem instance by loading from a working directory.
| instanceName | The name of the problem instance. |
| instanceSubdirectory | The subdirectory within the working directory containing instance data. |
| working_directory | The root working directory path. |
|
inlineprotected |
Constructs an instance by loading data from the working directory.
| instanceName | Name of the instance. |
| instanceSubdirectory | Subdirectory within the working directory containing instance data. |
| workingDirectory | Base directory path. |
|
default |
|
defaultnoexcept |
Move constructor.
|
overridedefault |
|
inline |
Adds an empty route for a train.
| train_name | Name of the train for which to add an empty route. |
|
inline |
Adds an empty station to the timetable.
| name | The name of the station to add. |
|
inline |
Adds a track to a station.
| name | The station name. |
| track | The edge input to add as a track. |
|
inline |
Adds a train with the specified properties to the timetable.
| train_name | Name identifier for the train. |
| length | Length of the train. |
| max_speed | Maximum speed. |
| acceleration | Acceleration rate. |
| deceleration | Deceleration rate. |
| tim | Whether train integrity monitoring is available. |
| entry_time | Time when the train enters the network. |
| initial_velocity | Velocity upon entry. |
| entry_vertex | Vertex where the train enters. |
| exit_time | Time when the train exits the network. |
| exit_velocity | Velocity upon exit. |
| exit_vertex | Vertex where the train exits. |
|
inline |
Adds a train to the timetable.
| train_name | Name identifier for the train. |
| length | Length of the train. |
| max_speed | Maximum speed. |
| acceleration | Acceleration rate. |
| deceleration | Deceleration rate. |
| entry_time | Time when the train enters the network. |
| initial_velocity | Velocity upon entry. |
| entry_vertex | Vertex where the train enters. |
| exit_time | Time when the train exits the network. |
| exit_velocity | Velocity upon exit. |
| exit_vertex | Vertex where the train exits. |
|
nodiscard |
Returns all trains whose routes use the specified edge.
| route_map | Route map to inspect. |
| edge_id | Edge index. |
| fixed_routes | Whether to restrict the check to fixed routes. |
| error_if_not_route | Whether to treat missing routes as errors. |
|
inlinenodiscard |
Returns the indices of all trains using a given edge.
| edge_id | The edge to query. |
| fixed_routes | If true, queries fixed routes; otherwise queries solution routes. |
| error_if_not_route | If true, throws an error if the edge is not in any train's route. |
|
inlinenodiscardoverridevirtual |
Checks that the instance is internally consistent, requiring all trains to have routes.
Implements cda_rail::instances::GeneralProblemInstance.
|
nodiscardvirtual |
Checks consistency while optionally allowing trains without routes.
Besides the timetable and the routes, this requires the network to let no train reverse, see Network::has_reversal_free_successors.
| every_train_must_have_route | Whether every train must have a route. |
Reimplemented in cda_rail::instances::GeneralPerformanceOptimizationInstance.
|
nodiscard |
Returns the edges used by a train.
Without a fixed route, these are all edges the train can use, i.e., all edges on some path from its entry to its exit vertex, see Network::edges_on_paths_between().
| train_name | Name of the train. |
| fixed_routes | Whether to use fixed routes. |
| error_if_no_route | Whether to throw if no route exists. |
|
inlinenodiscard |
Retrieves the edges used by a train identified by index.
| train_id | Index of the train. |
| fixed_routes | Whether to use fixed routes. |
| error_if_no_route | If true, throws when the train has no assigned route. |
|
inline |
Retrieves mutable access to the schedule of a train by name.
|
inline |
Gets the schedule of a train by its index for editing.
|
inline |
Retrieves mutable access to a train by name.
|
inline |
Gets a train by its index in the schedule.
|
inlinevirtual |
Exports the instance to the specified working directory.
| workingDirectory | Path where the instance will be exported. |
Reimplemented from cda_rail::instances::GeneralProblemInstance.
|
inlinevirtual |
Exports the instance to the specified working directory.
| working_directory | Path to the directory where the instance is exported. |
Reimplemented from cda_rail::instances::GeneralProblemInstance.
|
inlineoverridevirtual |
Exports the instance to the specified working directory without saving the network.
| working_directory | The target directory for the export. |
Implements cda_rail::instances::GeneralProblemInstance.
|
virtual |
Exports the instance and optionally its network.
| working_directory | Base export directory. |
| save_network | Whether to export the network alongside the instance. |
Reimplemented in cda_rail::instances::GeneralPerformanceOptimizationInstance.
|
inlinenodiscard |
Provides read-only access to the network.
|
inlinenodiscard |
Provides read-only access to the routes.
|
inlinenodiscard |
Retrieves the schedule for a specified train.
| train_name | Name of the train. |
|
inlinenodiscard |
Retrieves the schedule for a train.
| index | The index of the train. |
|
inlinenodiscard |
Provides the list of all stations.
|
inlinenodiscard |
Accesses the timetable.
|
inlinenodiscard |
Provides const access to the list of trains in the instance.
|
inlinenodiscard |
Identifies crossing conflicts between two trains' routes.
| train1 | Name of the first train. |
| train2 | Name of the second train. |
|
inlinenodiscard |
Provides editable access to the underlying network.
|
inlinenodiscardprotected |
Provides editable access to the route map.
|
inlinenodiscardprotected |
Provides editable access to the timetable.
|
nodiscard |
Returns the last reachable stop position of a station on a route.
| tr_id | Train index. |
| station_name | Name of the station. |
|
inlinenodiscard |
Identifies parallel overlaps between two trains.
| train1 | Name of the first train. |
| train2 | Name of the second train. |
|
inlinenodiscard |
Identifies sections where two trains travel in opposite directions.
| train1 | Name of the first train. |
| train2 | Name of the second train. |
|
inlinenodiscard |
Retrieves the stop tracks for a train at a specified station.
| tr | Train index. |
| station_name | Name of the station. |
| edges_to_consider | Optional set of edge IDs to filter the results. If empty, all edges are considered. |
|
inlinenodiscard |
Identifies time-to-distance overlaps between two trains.
| train1 | Name of the first train. |
| train2 | Name of the second train. |
|
nodiscard |
Checks whether every train has an assigned route.
|
inline |
Inserts a stop into a train's schedule.
| train_index | Index of the train. |
| station_name | Name of the station. |
| service_time | Service time at the station. |
| service_duration | Duration of the service at the station. |
|
inline |
Inserts a stop for a train at a specified station.
| service_time | The scheduled time for the service stop. |
| service_duration | The duration of the service stop. |
|
nodiscardoverridevirtual |
Checks the instance for reasons that make it infeasible by itself.
Only necessary conditions are checked, e.g. whether every train can reach its stations and its exit vertex at all. An instance that passes this check may still turn out to be infeasible once the trains are considered together, which no check can tell without solving the instance.
| late_entry_allowed | Whether trains may enter later than scheduled. If they may not, the scheduled entry times themselves can be checked against each other as well. |
Implements cda_rail::instances::GeneralProblemInstance.
|
nodiscard |
Checks whether a route end is a valid stopping position.
| tr | Train index. |
| edges | Current route edges. |
| next_stop_id | Index of the next scheduled stop. |
|
default |
|
defaultnoexcept |
|
inlinenodiscard |
Finds possible vertices where a train can stop at a station.
| train_name | The name of the train. |
| station_name | The name of the station. |
| edges_to_consider | Optional set of edges to consider. |
|
nodiscard |
Computes feasible stop-edge paths for a train at a station.
| tr | Train index. |
| station_name | Name of the station. |
| edges_to_consider | Optional subset of edges to consider. |
|
inline |
Appends an edge to the end of a train's route.
| train_name | The name of the train whose route to modify. |
| edge_input | The edge to append to the route. |
|
inline |
Adds an edge to the front of a train's route.
| train_name | Name of the train. |
| edge_input | The edge to add to the front of the route. |
|
inline |
Removes the first edge from a train's route.
| train_name | The name of the train. |
|
inline |
Removes the last edge from a train's route.
| train_name | The name of the train whose route should be modified. |
|
inlinenodiscard |
Determines the position of edges on a train's route.
| train_name | Name of the train. |
| edges | Collection of edge indices to locate. |
|
inlinenodiscard |
Determines the position of an edge on a train's route.
| train_name | The name of the train. |
| edge | The edge to locate on the route. |
|
inlinenodiscard |
Computes the total length of a train's route.
| train_name | Name of the train. |
|
nodiscard |
Returns the queried sections used by a train.
| tr_name | Name of the train. |
| sections | Sections to test. |
| fixed_routes | Whether to use fixed routes. |
| error_if_no_route | Whether to throw if no route exists. |
|
inlinenodiscard |
Retrieves sections used by a train specified by index.
| sections | Sections to consider when determining usage. |
| fixed_routes | If true, uses the fixed route; if false, includes all possible routes. |
| error_if_no_route | If true, throws if the train has no route; if false, returns an empty set. |
|
inline |
Replaces all routes of the instance.
| routes | The new route map. |
|
nodiscard |
Returns the trains that use a section.
| section | Section represented as an edge set. |
| fix_routes | Whether to use fixed routes. |
| error_if_no_route | Whether to throw for trains without routes. |
|
nodiscard |
Identifies which trains from a subset use the specified edge.
A train without a fixed route uses the edge if it is among the edges it can use, see edges_used_by_train().
| route_map | Route map to inspect. |
| edge_id | Edge index. |
| fixed_routes | Whether to restrict the check to fixed routes. |
| trains_to_consider | Subset of train indices to test. |
| error_if_not_route | Whether to treat missing routes as errors. |
|
inlinenodiscard |
Identifies which trains use the specified edge.
| fixed_routes | Whether to consider fixed routes. |
| trains_to_consider | The set of trains to examine. |
| error_if_not_route | If true, raises an error for trains without a route; if false, skips them. |
|
nodiscard |
Returns the vertices used by a train.
| tr_name | Name of the train. |
| fixed_routes | Whether to use fixed routes. |
| error_if_no_route | Whether to throw if no route exists. |
|
inlinenodiscard |
Retrieves all vertices used by a train identified by its index.
| tr_id | Train index. |
| fixed_routes | Whether to consider only fixed routes. |
| error_if_no_route | If true, throw if the train has no route; otherwise, return an empty set. |
|
friend |