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

A solution that says which routes the trains take. More...

#include <GeneralProblemInstance.hpp>

Inheritance diagram for cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes:
cda_rail::instances::SolGeneralProblemInstance cda_rail::instances::SolGeneralPerformanceOptimizationInstance cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance

Public Member Functions

 SolGeneralProblemInstanceWithScheduleAndRoutes (GeneralProblemInstanceWithScheduleAndRoutes const &instance)
 Creates a solution wrapper from a problem instance.
 SolGeneralProblemInstanceWithScheduleAndRoutes (GeneralProblemInstanceWithScheduleAndRoutes const &instance, SolutionStatus status, double obj, bool has_sol)
 Initializes a solution wrapper around a copy of the provided instance.
 SolGeneralProblemInstanceWithScheduleAndRoutes (const SolGeneralProblemInstanceWithScheduleAndRoutes &)=default
SolGeneralProblemInstanceWithScheduleAndRoutes & operator= (const SolGeneralProblemInstanceWithScheduleAndRoutes &)=default
 SolGeneralProblemInstanceWithScheduleAndRoutes (SolGeneralProblemInstanceWithScheduleAndRoutes &&) noexcept=default
SolGeneralProblemInstanceWithScheduleAndRoutes & operator= (SolGeneralProblemInstanceWithScheduleAndRoutes &&) noexcept=default
 ~SolGeneralProblemInstanceWithScheduleAndRoutes () override=default
void load_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const &parameter_identifier) override
 Loads the route-aware part of a solution from disk.
void load_solution (const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory) override
 Loads a solution from the specified working directory and solution subdirectory.
GeneralProblemInstanceWithScheduleAndRoutes const * get_instance () const override
 Accesses the underlying schedule-and-routes problem instance.
RouteMap const & get_const_solution_routes () const
 Retrieves the solution routes.
double route_length (const std::string &train_name) const
 Computes the total length of a train's solution route.
void reset_routes ()
 Resets solution routes to the instance's fixed routes.
void add_empty_route (const std::string &train_name)
 Adds an empty solution 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 solution route.
void push_front_edge_to_route (const std::string &train_name, Network::EdgeInput const &edge_input)
 Adds an edge to the front of the solution route for a train.
void remove_first_edge_from_route (const std::string &train_name)
 Removes the first edge from a train's route in the solution.
void remove_last_edge_from_route (const std::string &train_name)
 Removes the last edge from a train's route in the solution.
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 solution route.
void export_solution (const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier) const override
 Exports the solution without saving the underlying instance.
void export_solution (const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory) const override
 Exports the solution without saving the problem instance.
virtual void export_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory, bool save_instance, std::optional< std::string > const &parameter_identifier) const
bool check_consistency () const override
 Checks whether the solution routes are consistent with the instance.
void export_solution (const std::string &path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={}) const
 Exports the solution to the specified directory.
void export_solution (const char *path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={}) const
 Exports the solution to the specified directory and subdirectory.
void load_solution (const std::string &path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={})
 Loads a solution from the specified path.
void load_solution (const char *path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={})
 Loads a solution from the specified location.
Public Member Functions inherited from cda_rail::instances::SolGeneralProblemInstance
std::filesystem::path get_export_path (const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier) const
 Computes the file path for exporting a solution.
SolutionStatus get_status () const
 Retrieves the current solution status.
double get_obj () const
 Gets the objective value of the solution.
double get_lower_bound () const
 Gets the lower bound on the objective value of the solution.
bool has_solution () const
 Indicates whether a solution has been found.
void set_status (SolutionStatus new_status)
 Sets the solution status.
void set_obj (double new_obj)
 Sets the objective value of the solution.
void set_lower_bound (double new_lb)
 Sets the lower bound of the objective value of the solution.
void set_solution_found ()
 Marks the solution as found.
void set_solution_not_found ()
 Marks that no solution has been found.
void load_solution (const std::string &path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={})
 Loads a solution from the specified path.
void load_solution (const char *path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={})
 Loads a solution from the specified location.
void export_solution (const std::string &path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={}) const
 Exports the solution to the specified directory.
void export_solution (const char *path, std::string_view const solutionSubdirectory, std::optional< std::string > const &parameter_identifier={}) const
 Exports the solution to the specified directory and subdirectory.
virtual ~SolGeneralProblemInstance ()=default
 Virtual destructor.
 SolGeneralProblemInstance (SolGeneralProblemInstance const &)=default
SolGeneralProblemInstance & operator= (SolGeneralProblemInstance const &)=default
 SolGeneralProblemInstance (SolGeneralProblemInstance &&) noexcept=default
SolGeneralProblemInstance & operator= (SolGeneralProblemInstance &&) noexcept=default

Protected Member Functions

 SolGeneralProblemInstanceWithScheduleAndRoutes (std::shared_ptr< GeneralProblemInstanceWithScheduleAndRoutes > instance_ptr)
 Initializes a solution wrapper for a schedule-and-routes problem instance.
 SolGeneralProblemInstanceWithScheduleAndRoutes (std::shared_ptr< GeneralProblemInstanceWithScheduleAndRoutes > instance_ptr, SolutionStatus status, double obj, bool has_sol)
 Initializes a solution instance with an existing problem instance and solution metadata.
Protected Member Functions inherited from cda_rail::instances::SolGeneralProblemInstance
 SolGeneralProblemInstance (std::shared_ptr< GeneralProblemInstance > instance_ptr)
 Creates a solution wrapper around the given problem instance.
 SolGeneralProblemInstance (std::shared_ptr< GeneralProblemInstance > instance_ptr, SolutionStatus status, double obj, bool has_sol)
 Constructs a solution instance with problem instance and solution metadata.
virtual nlohmann::json get_general_solution_data () const
 Serializes solution-wide metadata to JSON.
virtual void set_general_solution_data (const nlohmann::json &data)
 Loads solution-wide metadata from JSON.
GeneralProblemInstance const * get_uncast_instance_pointer () const
 Retrieves the underlying problem instance pointer.

Detailed Description

A solution that says which routes the trains take.

The routes are initialized to those of the instance and are filled in by the solver wherever the instance leaves them open.

Constructor & Destructor Documentation

◆ SolGeneralProblemInstanceWithScheduleAndRoutes() [1/6]

cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::SolGeneralProblemInstanceWithScheduleAndRoutes ( std::shared_ptr< GeneralProblemInstanceWithScheduleAndRoutes > instance_ptr)
inlineexplicitprotected

Initializes a solution wrapper for a schedule-and-routes problem instance.

Parameters
instance_ptrThe problem instance to wrap.

◆ SolGeneralProblemInstanceWithScheduleAndRoutes() [2/6]

cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::SolGeneralProblemInstanceWithScheduleAndRoutes ( std::shared_ptr< GeneralProblemInstanceWithScheduleAndRoutes > instance_ptr,
SolutionStatus status,
double obj,
bool has_sol )
inlineprotected

Initializes a solution instance with an existing problem instance and solution metadata.

◆ SolGeneralProblemInstanceWithScheduleAndRoutes() [3/6]

cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::SolGeneralProblemInstanceWithScheduleAndRoutes ( GeneralProblemInstanceWithScheduleAndRoutes const & instance)
inlineexplicit

Creates a solution wrapper from a problem instance.

◆ SolGeneralProblemInstanceWithScheduleAndRoutes() [4/6]

cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::SolGeneralProblemInstanceWithScheduleAndRoutes ( GeneralProblemInstanceWithScheduleAndRoutes const & instance,
SolutionStatus status,
double obj,
bool has_sol )
inline

Initializes a solution wrapper around a copy of the provided instance.

Parameters
instanceProblem instance to wrap.
statusSolution status.
objObjective value of the solution.
has_solWhether a solution exists.

◆ SolGeneralProblemInstanceWithScheduleAndRoutes() [5/6]

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

◆ SolGeneralProblemInstanceWithScheduleAndRoutes() [6/6]

cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::SolGeneralProblemInstanceWithScheduleAndRoutes ( SolGeneralProblemInstanceWithScheduleAndRoutes && )
defaultnoexcept

◆ ~SolGeneralProblemInstanceWithScheduleAndRoutes()

cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::~SolGeneralProblemInstanceWithScheduleAndRoutes ( )
overridedefault

Member Function Documentation

◆ add_empty_route()

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

Adds an empty solution route for a train.

Parameters
train_nameName of the train.

◆ check_consistency()

bool cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::check_consistency ( ) const
nodiscardoverridevirtual

Checks whether the solution routes are consistent with the instance.

Returns
true if the solution is consistent, otherwise false.

Reimplemented from cda_rail::instances::SolGeneralProblemInstance.

Reimplemented in cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.

◆ export_solution() [1/5]

void cda_rail::instances::SolGeneralProblemInstance::export_solution ( const char * path,
std::string_view const solutionSubdirectory,
std::optional< std::string > const & parameter_identifier = {} ) const
inline

Exports the solution to the specified directory and subdirectory.

Parameters
pathDirectory path where the solution will be exported.
solutionSubdirectorySubdirectory name for organizing solutions.
parameter_identifierOptional identifier appended to the solution name.

◆ export_solution() [2/5]

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::export_solution ( const std::filesystem::path & working_directory,
std::string_view const solutionSubdirectory ) const
inlineoverridevirtual

Exports the solution without saving the problem instance.

Exports only the solution data (routes) to the specified directory without exporting the underlying problem instance.

Parameters
working_directoryRoot working directory for the solution export.
solutionSubdirectorySubdirectory within the solutions folder for this solution.

Reimplemented from cda_rail::instances::SolGeneralProblemInstance.

Reimplemented in cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.

◆ export_solution() [3/5]

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::export_solution ( const std::filesystem::path & working_directory,
std::string_view const solutionSubdirectory,
std::optional< std::string > const & parameter_identifier ) const
inlineoverridevirtual

Exports the solution without saving the underlying instance.

Parameters
working_directoryThe base directory for solution exports.
solutionSubdirectoryThe subdirectory for this solution.
parameter_identifierOptional identifier to include in the export path.

Reimplemented from cda_rail::instances::SolGeneralProblemInstance.

Reimplemented in cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.

◆ export_solution() [4/5]

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::export_solution ( const std::filesystem::path & working_directory,
std::string_view solution_subdirectory,
bool save_instance,
std::optional< std::string > const & parameter_identifier ) const
virtual

◆ export_solution() [5/5]

void cda_rail::instances::SolGeneralProblemInstance::export_solution ( const std::string & path,
std::string_view const solutionSubdirectory,
std::optional< std::string > const & parameter_identifier = {} ) const
inline

Exports the solution to the specified directory.

Parameters
pathDirectory path where the solution will be exported.
solutionSubdirectorySolution subdirectory name.
parameter_identifierOptional parameter identifier appended to the export path.

◆ get_const_solution_routes()

RouteMap const & cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::get_const_solution_routes ( ) const
inlinenodiscard

Retrieves the solution routes.

Returns
const RouteMap& The solution routes.

◆ get_instance()

GeneralProblemInstanceWithScheduleAndRoutes const * cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::get_instance ( ) const
inlinenodiscardoverridevirtual

Accesses the underlying schedule-and-routes problem instance.

Returns
GeneralProblemInstanceWithScheduleAndRoutes const* Const pointer to the underlying instance.

Reimplemented from cda_rail::instances::SolGeneralProblemInstance.

◆ load_solution() [1/4]

void cda_rail::instances::SolGeneralProblemInstance::load_solution ( const char * path,
std::string_view const solutionSubdirectory,
std::optional< std::string > const & parameter_identifier = {} )
inline

Loads a solution from the specified location.

Parameters
pathWorking directory path.
solutionSubdirectorySubdirectory containing solutions.
parameter_identifierOptional identifier to append to the instance name when constructing the solution path.

◆ load_solution() [2/4]

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::load_solution ( const std::filesystem::path & working_directory,
std::string_view const solutionSubdirectory )
inlineoverridevirtual

Loads a solution from the specified working directory and solution subdirectory.

Parameters
working_directoryThe root directory containing solutions.
solutionSubdirectoryThe solution subdirectory within the working directory.

Reimplemented from cda_rail::instances::SolGeneralProblemInstance.

Reimplemented in cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.

◆ load_solution() [3/4]

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::load_solution ( const std::filesystem::path & working_directory,
std::string_view solution_subdirectory,
std::optional< std::string > const & parameter_identifier )
overridevirtual

Loads the route-aware part of a solution from disk.

Reimplemented from cda_rail::instances::SolGeneralProblemInstance.

Reimplemented in cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.

◆ load_solution() [4/4]

void cda_rail::instances::SolGeneralProblemInstance::load_solution ( const std::string & path,
std::string_view const solutionSubdirectory,
std::optional< std::string > const & parameter_identifier = {} )
inline

Loads a solution from the specified path.

Parameters
pathWorking directory path.
solutionSubdirectorySubdirectory containing solution files.
parameter_identifierOptional identifier appended to the instance name when locating solution files.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ push_back_edge_to_route()

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::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 solution route.

Parameters
train_nameName of the train.
edge_inputThe edge to append.

◆ push_front_edge_to_route()

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

Adds an edge to the front of the solution route for a train.

Parameters
train_nameName of the train whose solution route is modified.
edge_inputThe edge to prepend to the route.

◆ remove_first_edge_from_route()

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

Removes the first edge from a train's route in the solution.

Parameters
train_nameThe name of the train whose route is to be modified.

◆ remove_last_edge_from_route()

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

Removes the last edge from a train's route in the solution.

Parameters
train_nameName of the train.

◆ reset_routes()

void cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes::reset_routes ( )

Resets solution routes to the instance's fixed routes.

◆ route_edge_pos()

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

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

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

◆ route_length()

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

Computes the total length of a train's solution route.

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

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