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

An instance consisting of a network, a timetable, and routes. More...

#include <GeneralProblemInstance.hpp>

Inheritance diagram for cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes:
cda_rail::instances::GeneralProblemInstance cda_rail::instances::GeneralPerformanceOptimizationInstance

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 > &sections, 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 > &sections, 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 &section, 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

Detailed Description

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.

Constructor & Destructor Documentation

◆ GeneralProblemInstanceWithScheduleAndRoutes() [1/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( )
protecteddefault

Constructs an empty problem instance with schedule and routes.

◆ GeneralProblemInstanceWithScheduleAndRoutes() [2/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( Network network)
inlineexplicitprotected

Initializes the instance with a network.

Parameters
networkThe network for this instance.

◆ GeneralProblemInstanceWithScheduleAndRoutes() [3/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( Network network,
Timetable timetable,
RouteMap routes )
inlineexplicitprotected

Initializes the instance with a network, timetable, and routes.

◆ GeneralProblemInstanceWithScheduleAndRoutes() [4/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( std::string_view instance_name,
std::string_view instance_subdirectory,
std::filesystem::path const & working_directory )
protected

Loads a full problem instance from disk.

Parameters
instance_nameInstance name.
instance_subdirectoryInstance subdirectory.
working_directoryBase working directory.

◆ GeneralProblemInstanceWithScheduleAndRoutes() [5/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( std::string_view const instanceName,
std::string_view const instanceSubdirectory,
std::string const & working_directory )
inlineprotected

Constructs a problem instance by loading from a working directory.

Parameters
instanceNameThe name of the problem instance.
instanceSubdirectoryThe subdirectory within the working directory containing instance data.
working_directoryThe root working directory path.

◆ GeneralProblemInstanceWithScheduleAndRoutes() [6/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( std::string_view const instanceName,
std::string_view const instanceSubdirectory,
char const *const workingDirectory )
inlineprotected

Constructs an instance by loading data from the working directory.

Parameters
instanceNameName of the instance.
instanceSubdirectorySubdirectory within the working directory containing instance data.
workingDirectoryBase directory path.

◆ GeneralProblemInstanceWithScheduleAndRoutes() [7/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( const GeneralProblemInstanceWithScheduleAndRoutes & )
default

◆ GeneralProblemInstanceWithScheduleAndRoutes() [8/8]

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::GeneralProblemInstanceWithScheduleAndRoutes ( GeneralProblemInstanceWithScheduleAndRoutes && )
defaultnoexcept

Move constructor.

◆ ~GeneralProblemInstanceWithScheduleAndRoutes()

cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::~GeneralProblemInstanceWithScheduleAndRoutes ( )
overridedefault

Member Function Documentation

◆ add_empty_route()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::add_empty_route ( const std::string & train_name)
inline

Adds an empty route for a train.

Parameters
train_nameName of the train for which to add an empty route.

◆ add_empty_station()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::add_empty_station ( const std::string & name)
inline

Adds an empty station to the timetable.

Parameters
nameThe name of the station to add.

◆ add_track_to_station()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::add_track_to_station ( const std::string & name,
Network::EdgeInput const & track )
inline

Adds a track to a station.

Parameters
nameThe station name.
trackThe edge input to add as a track.

◆ add_train() [1/2]

size_t cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::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 )
inline

Adds a train with the specified properties to the timetable.

Parameters
train_nameName identifier for the train.
lengthLength of the train.
max_speedMaximum speed.
accelerationAcceleration rate.
decelerationDeceleration rate.
timWhether train integrity monitoring is available.
entry_timeTime when the train enters the network.
initial_velocityVelocity upon entry.
entry_vertexVertex where the train enters.
exit_timeTime when the train exits the network.
exit_velocityVelocity upon exit.
exit_vertexVertex where the train exits.
Returns
Index of the newly added train.

◆ add_train() [2/2]

size_t cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::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 )
inline

Adds a train to the timetable.

Parameters
train_nameName identifier for the train.
lengthLength of the train.
max_speedMaximum speed.
accelerationAcceleration rate.
decelerationDeceleration rate.
entry_timeTime when the train enters the network.
initial_velocityVelocity upon entry.
entry_vertexVertex where the train enters.
exit_timeTime when the train exits the network.
exit_velocityVelocity upon exit.
exit_vertexVertex where the train exits.
Returns
Index of the newly added train in the timetable.

◆ all_trains_on_edge() [1/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::all_trains_on_edge ( RouteMap const & route_map,
size_t edge_id,
bool fixed_routes = true,
bool error_if_not_route = true ) const
nodiscard

Returns all trains whose routes use the specified edge.

Parameters
route_mapRoute map to inspect.
edge_idEdge index.
fixed_routesWhether to restrict the check to fixed routes.
error_if_not_routeWhether to treat missing routes as errors.
Returns
Index set of all trains using the edge under the chosen route map.

◆ all_trains_on_edge() [2/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::all_trains_on_edge ( size_t edge_id,
bool fixed_routes = true,
bool error_if_not_route = true ) const
inlinenodiscard

Returns the indices of all trains using a given edge.

Parameters
edge_idThe edge to query.
fixed_routesIf true, queries fixed routes; otherwise queries solution routes.
error_if_not_routeIf true, throws an error if the edge is not in any train's route.
Returns
An index set of train indices using the edge.

◆ check_consistency() [1/2]

bool cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::check_consistency ( ) const
inlinenodiscardoverridevirtual

Checks that the instance is internally consistent, requiring all trains to have routes.

Returns
true if the instance is consistent, false otherwise.

Implements cda_rail::instances::GeneralProblemInstance.

◆ check_consistency() [2/2]

bool cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::check_consistency ( bool every_train_must_have_route) const
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.

Parameters
every_train_must_have_routeWhether every train must have a route.
Returns
true if the instance is consistent under the requested rule.

Reimplemented in cda_rail::instances::GeneralPerformanceOptimizationInstance.

◆ edges_used_by_train() [1/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::edges_used_by_train ( const std::string & train_name,
bool fixed_routes,
bool error_if_no_route = true ) const
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().

Parameters
train_nameName of the train.
fixed_routesWhether to use fixed routes.
error_if_no_routeWhether to throw if no route exists.
Returns
Set of used edge indices.

◆ edges_used_by_train() [2/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::edges_used_by_train ( size_t train_id,
bool fixed_routes,
bool error_if_no_route = true ) const
inlinenodiscard

Retrieves the edges used by a train identified by index.

Parameters
train_idIndex of the train.
fixed_routesWhether to use fixed routes.
error_if_no_routeIf true, throws when the train has no assigned route.
Returns
An index set of edges used by the train.

◆ editable_schedule() [1/2]

Schedule & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::editable_schedule ( const std::string & name)
inline

Retrieves mutable access to the schedule of a train by name.

Returns
Schedule& Mutable reference to the schedule of the named train.

◆ editable_schedule() [2/2]

Schedule & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::editable_schedule ( size_t const index)
inline

Gets the schedule of a train by its index for editing.

Returns
Schedule& A reference to the editable schedule of the train.

◆ editable_train() [1/2]

Train & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::editable_train ( const std::string & name)
inline

Retrieves mutable access to a train by name.

Returns
Train& Mutable reference to the train with the given name.

◆ editable_train() [2/2]

Train & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::editable_train ( size_t const index)
inline

Gets a train by its index in the schedule.

Returns
Train& A reference to the editable train at the given index.

◆ export_instance() [1/4]

virtual void cda_rail::instances::GeneralProblemInstance::export_instance ( char const *const workingDirectory) const
inlinevirtual

Exports the instance to the specified working directory.

Parameters
workingDirectoryPath where the instance will be exported.

Reimplemented from cda_rail::instances::GeneralProblemInstance.

◆ export_instance() [2/4]

virtual void cda_rail::instances::GeneralProblemInstance::export_instance ( const std::string & working_directory) const
inlinevirtual

Exports the instance to the specified working directory.

Parameters
working_directoryPath to the directory where the instance is exported.

Reimplemented from cda_rail::instances::GeneralProblemInstance.

◆ export_instance() [3/4]

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::export_instance ( std::filesystem::path const & working_directory) const
inlineoverridevirtual

Exports the instance to the specified working directory without saving the network.

Parameters
working_directoryThe target directory for the export.

Implements cda_rail::instances::GeneralProblemInstance.

◆ export_instance() [4/4]

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::export_instance ( std::filesystem::path const & working_directory,
bool save_network ) const
virtual

Exports the instance and optionally its network.

Parameters
working_directoryBase export directory.
save_networkWhether to export the network alongside the instance.

Reimplemented in cda_rail::instances::GeneralPerformanceOptimizationInstance.

◆ get_const_network()

const auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_network ( ) const
inlinenodiscard

Provides read-only access to the network.

Returns
const Network& A const reference to the network.

◆ get_const_routes()

const auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_routes ( ) const
inlinenodiscard

Provides read-only access to the routes.

Returns
A const reference to the RouteMap.

◆ get_const_schedule() [1/2]

const auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_schedule ( const std::string & train_name) const
inlinenodiscard

Retrieves the schedule for a specified train.

Parameters
train_nameName of the train.
Returns
Const reference to the train's schedule.

◆ get_const_schedule() [2/2]

const auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_schedule ( size_t index) const
inlinenodiscard

Retrieves the schedule for a train.

Parameters
indexThe index of the train.
Returns
The schedule for the train at the specified index.

◆ get_const_station_list()

const StationList & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_station_list ( ) const
inlinenodiscard

Provides the list of all stations.

Returns
Const reference to the StationList.

◆ get_const_timetable()

const auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_timetable ( ) const
inlinenodiscard

Accesses the timetable.

Returns
Const reference to the timetable.

◆ get_const_train_list()

const TrainList & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_const_train_list ( ) const
inlinenodiscard

Provides const access to the list of trains in the instance.

Returns
const TrainList& Reference to the train list.

◆ get_crossing_overlaps()

std::vector< ConflictPair > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_crossing_overlaps ( const std::string & train1,
const std::string & train2 ) const
inlinenodiscard

Identifies crossing conflicts between two trains' routes.

Parameters
train1Name of the first train.
train2Name of the second train.
Returns
std::vector<ConflictPair> containing all crossing conflicts between the two trains' routes.

◆ get_editable_network()

auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_editable_network ( )
inlinenodiscard

Provides editable access to the underlying network.

Returns
Network& A reference to the underlying network.

◆ get_editable_routes()

auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_editable_routes ( )
inlinenodiscardprotected

Provides editable access to the route map.

Returns
RouteMap& Reference to the route map.

◆ get_editable_timetable()

auto & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_editable_timetable ( )
inlinenodiscardprotected

Provides editable access to the timetable.

Returns
Reference to the timetable.

◆ get_last_stop_position_on_route()

std::optional< double > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_last_stop_position_on_route ( size_t tr_id,
const std::string & station_name ) const
nodiscard

Returns the last reachable stop position of a station on a route.

Parameters
tr_idTrain index.
station_nameName of the station.
Returns
Last route position on which the train can stop at the station, or std::nullopt if no such position exists on the current route.

◆ get_parallel_overlaps()

std::vector< ConflictPair > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_parallel_overlaps ( const std::string & train1,
const std::string & train2 ) const
inlinenodiscard

Identifies parallel overlaps between two trains.

Parameters
train1Name of the first train.
train2Name of the second train.
Returns
A vector of conflict pairs representing the parallel overlaps between the trains.

◆ get_reverse_overlaps()

std::vector< ConflictPair > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_reverse_overlaps ( const std::string & train1,
const std::string & train2 ) const
inlinenodiscard

Identifies sections where two trains travel in opposite directions.

Parameters
train1Name of the first train.
train2Name of the second train.
Returns
A vector of conflict pairs representing sections where the trains traverse the same edges in opposite directions.

◆ get_stop_tracks()

std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_stop_tracks ( size_t tr,
const std::string & station_name,
const cda_rail::index_set & edges_to_consider = {} ) const
inlinenodiscard

Retrieves the stop tracks for a train at a specified station.

Parameters
trTrain index.
station_nameName of the station.
edges_to_considerOptional set of edge IDs to filter the results. If empty, all edges are considered.
Returns
A vector of pairs, each containing a track ID and its corresponding stop edge sequences.

◆ get_ttd_overlaps()

std::vector< ConflictPair > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::get_ttd_overlaps ( const std::string & train1,
const std::string & train2 ) const
inlinenodiscard

Identifies time-to-distance overlaps between two trains.

Parameters
train1Name of the first train.
train2Name of the second train.
Returns
std::vector<ConflictPair> Conflicts where the trains overlap in time and distance.

◆ has_route_for_every_train()

bool cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::has_route_for_every_train ( ) const
nodiscard

Checks whether every train has an assigned route.

Returns
true if each train has a route, otherwise false.

◆ insert_stop() [1/2]

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::insert_stop ( size_t train_index,
std::string const & station_name,
double service_time,
double service_duration )
inline

Inserts a stop into a train's schedule.

Parameters
train_indexIndex of the train.
station_nameName of the station.
service_timeService time at the station.
service_durationDuration of the service at the station.

◆ insert_stop() [2/2]

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::insert_stop ( std::string const & train_name,
std::string const & station_name,
double service_time,
double service_duration )
inline

Inserts a stop for a train at a specified station.

Parameters
service_timeThe scheduled time for the service stop.
service_durationThe duration of the service stop.

◆ is_obviously_infeasible()

cda_rail::instances::GeneralProblemInstance::FeasibilityCheck cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::is_obviously_infeasible ( bool late_entry_allowed) const
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.

Parameters
late_entry_allowedWhether 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.

◆ is_route_end_valid_stop_pos()

bool cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::is_route_end_valid_stop_pos ( size_t tr,
const cda_rail::index_vector & edges,
size_t next_stop_id ) const
nodiscard

Checks whether a route end is a valid stopping position.

Parameters
trTrain index.
edgesCurrent route edges.
next_stop_idIndex of the next scheduled stop.
Returns
true if the route end can serve as a stop position.

◆ operator=() [1/2]

GeneralProblemInstanceWithScheduleAndRoutes & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::operator= ( const GeneralProblemInstanceWithScheduleAndRoutes & )
default

◆ operator=() [2/2]

GeneralProblemInstanceWithScheduleAndRoutes & cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::operator= ( GeneralProblemInstanceWithScheduleAndRoutes && )
defaultnoexcept

◆ possible_stop_vertices() [1/2]

std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::possible_stop_vertices ( const std::string & train_name,
const std::string & station_name,
const cda_rail::index_set & edges_to_consider = {} ) const
inlinenodiscard

Finds possible vertices where a train can stop at a station.

Parameters
train_nameThe name of the train.
station_nameThe name of the station.
edges_to_considerOptional set of edges to consider.
Returns
Possible stop vertices, organized by track.

◆ possible_stop_vertices() [2/2]

std::vector< std::pair< size_t, std::vector< cda_rail::index_vector > > > cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::possible_stop_vertices ( size_t tr,
const std::string & station_name,
const cda_rail::index_set & edges_to_consider = {} ) const
nodiscard

Computes feasible stop-edge paths for a train at a station.

Parameters
trTrain index.
station_nameName of the station.
edges_to_considerOptional subset of edges to consider.
Returns
Possible stop vertices, organized by track.

◆ push_back_edge_to_route()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::push_back_edge_to_route ( const std::string & train_name,
Network::EdgeInput const & edge_input )
inline

Appends an edge to the end of a train's route.

Parameters
train_nameThe name of the train whose route to modify.
edge_inputThe edge to append to the route.

◆ push_front_edge_to_route()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::push_front_edge_to_route ( const std::string & train_name,
Network::EdgeInput const & edge_input )
inline

Adds an edge to the front of a train's route.

Parameters
train_nameName of the train.
edge_inputThe edge to add to the front of the route.

◆ remove_first_edge_from_route()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::remove_first_edge_from_route ( const std::string & train_name)
inline

Removes the first edge from a train's route.

Parameters
train_nameThe name of the train.

◆ remove_last_edge_from_route()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::remove_last_edge_from_route ( const std::string & train_name)
inline

Removes the last edge from a train's route.

Parameters
train_nameThe name of the train whose route should be modified.

◆ route_edge_pos() [1/2]

Route::EdgePosition cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::route_edge_pos ( const std::string & train_name,
const cda_rail::index_vector & edges ) const
inlinenodiscard

Determines the position of edges on a train's route.

Parameters
train_nameName of the train.
edgesCollection of edge indices to locate.
Returns
Route::EdgePosition The position of the edges on the route.

◆ route_edge_pos() [2/2]

Route::EdgePosition cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::route_edge_pos ( const std::string & train_name,
Network::EdgeInput const & edge ) const
inlinenodiscard

Determines the position of an edge on a train's route.

Parameters
train_nameThe name of the train.
edgeThe edge to locate on the route.
Returns
The position of the edge on the route.

◆ route_length()

double cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::route_length ( const std::string & train_name) const
inlinenodiscard

Computes the total length of a train's route.

Parameters
train_nameName of the train.
Returns
double The total length of the train's route.

◆ sections_used_by_train() [1/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::sections_used_by_train ( const std::string & tr_name,
const std::vector< cda_rail::index_set > & sections,
bool fixed_routes,
bool error_if_no_route = true ) const
nodiscard

Returns the queried sections used by a train.

Parameters
tr_nameName of the train.
sectionsSections to test.
fixed_routesWhether to use fixed routes.
error_if_no_routeWhether to throw if no route exists.
Returns
Set of section indices used by the train.

◆ sections_used_by_train() [2/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::sections_used_by_train ( size_t tr_id,
const std::vector< cda_rail::index_set > & sections,
bool fixed_routes,
bool error_if_no_route = true ) const
inlinenodiscard

Retrieves sections used by a train specified by index.

Parameters
sectionsSections to consider when determining usage.
fixed_routesIf true, uses the fixed route; if false, includes all possible routes.
error_if_no_routeIf true, throws if the train has no route; if false, returns an empty set.
Returns
Sections used by the train.

◆ set_routes()

void cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::set_routes ( RouteMap routes)
inline

Replaces all routes of the instance.

Parameters
routesThe new route map.

◆ trains_in_section()

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::trains_in_section ( const cda_rail::index_set & section,
bool fix_routes = true,
bool error_if_no_route = true ) const
nodiscard

Returns the trains that use a section.

Parameters
sectionSection represented as an edge set.
fix_routesWhether to use fixed routes.
error_if_no_routeWhether to throw for trains without routes.
Returns
Set of train indices using the section.

◆ trains_on_edge() [1/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::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
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().

Parameters
route_mapRoute map to inspect.
edge_idEdge index.
fixed_routesWhether to restrict the check to fixed routes.
trains_to_considerSubset of train indices to test.
error_if_not_routeWhether to treat missing routes as errors.
Returns
Index set of trains from trains_to_consider that use the edge.

◆ trains_on_edge() [2/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::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
inlinenodiscard

Identifies which trains use the specified edge.

Parameters
fixed_routesWhether to consider fixed routes.
trains_to_considerThe set of trains to examine.
error_if_not_routeIf true, raises an error for trains without a route; if false, skips them.
Returns
Index set of trains from trains_to_consider that use the edge.

◆ vertices_used_by_train() [1/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::vertices_used_by_train ( const std::string & tr_name,
bool fixed_routes,
bool error_if_no_route = true ) const
nodiscard

Returns the vertices used by a train.

Parameters
tr_nameName of the train.
fixed_routesWhether to use fixed routes.
error_if_no_routeWhether to throw if no route exists.
Returns
Set of used vertex indices.

◆ vertices_used_by_train() [2/2]

cda_rail::index_set cda_rail::instances::GeneralProblemInstanceWithScheduleAndRoutes::vertices_used_by_train ( size_t tr_id,
bool fixed_routes,
bool error_if_no_route = true ) const
inlinenodiscard

Retrieves all vertices used by a train identified by its index.

Parameters
tr_idTrain index.
fixed_routesWhether to consider only fixed routes.
error_if_no_routeIf true, throw if the train has no route; otherwise, return an empty set.
Returns
Set of vertex indices used by the train.

◆ SolGeneralProblemInstanceWithScheduleAndRoutes

friend class SolGeneralProblemInstanceWithScheduleAndRoutes
friend

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