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

The same solution, together with the VSS borders it needs. More...

#include <GeneralPerformanceOptimizationInstance.hpp>

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

Public Member Functions

 SolVSSGeneralPerformanceOptimizationInstance (const GeneralPerformanceOptimizationInstance &instance)
 Constructs a solution instance with VSS support from a performance optimization instance.
 SolVSSGeneralPerformanceOptimizationInstance (const GeneralPerformanceOptimizationInstance &instance, SolutionStatus status, double obj, bool has_sol)
void add_vss_pos (cda_rail::Network::EdgeInput const &edge_input, double pos, bool reverse_edge=true)
void set_vss_pos (cda_rail::Network::EdgeInput const &edge_input, std::vector< double > pos)
void reset_vss_pos (cda_rail::Network::EdgeInput const &edge_input)
std::vector< double > get_vss_pos (cda_rail::Network::EdgeInput const &edge_input) const
std::vector< double > get_valid_border_stops (const std::string &train_name) const
void export_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory, bool export_instance, std::optional< std::string > const &parameter_identifier) const override
 Exports the solution, optionally including the instance data.
bool check_consistency () const override
 Checks whether the stored performance-optimization solution is consistent.
void load_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const &parameter_identifier) override
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 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.
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.
Public Member Functions inherited from cda_rail::instances::SolGeneralPerformanceOptimizationInstance
 SolGeneralPerformanceOptimizationInstance (const GeneralPerformanceOptimizationInstance &instance)
 Initializes a solution object for a performance optimization problem instance.
 SolGeneralPerformanceOptimizationInstance (const GeneralPerformanceOptimizationInstance &instance, SolutionStatus status, double obj, bool has_sol)
 Constructs a solution instance with metadata for the given optimization problem.
 SolGeneralPerformanceOptimizationInstance (SolGeneralPerformanceOptimizationInstance const &)=default
 Constructs a copy of an existing solution instance.
SolGeneralPerformanceOptimizationInstance & operator= (SolGeneralPerformanceOptimizationInstance const &)=default
 SolGeneralPerformanceOptimizationInstance (SolGeneralPerformanceOptimizationInstance &&) noexcept=default
SolGeneralPerformanceOptimizationInstance & operator= (SolGeneralPerformanceOptimizationInstance &&) noexcept=default
 ~SolGeneralPerformanceOptimizationInstance () override=default
 Virtual destructor.
GeneralPerformanceOptimizationInstance const * get_instance () const override
 Retrieves the underlying problem instance.
double get_train_pos (const std::string &tr_name, double t) const
 Returns the stored position of a train at a given time.
EdgeTimeBound get_edge_and_time_bounds (const std::string &tr_name, double t) const
 Returns the containing edge and surrounding time bounds.
PosVelBound get_exact_pos_and_vel_bounds (const std::string &tr_name, double t) const
 Returns exact lower and upper bounds on position and velocity.
std::optional< PosVel > get_approximate_train_pos_and_vel (const std::string &tr_name, double t) const
 Returns an approximate position/velocity pair if available.
double get_train_speed (const std::string &tr_name, double t) const
 Returns the stored train speed at a given time.
std::vector< double > get_train_times (const std::string &tr_name) const
 Returns all recorded times for one train.
cda_rail::index_vector get_train_order (size_t edge_index) const
 Returns train order on a given edge.
std::vector< TrainDirection > get_train_order_with_reverse (size_t edge_index) const
 Returns train order on a given edge together with orientation.
double get_time_at_pos (const std::string &tr_name, double pos, bool ub=false) const
 Returns the time at which a train reaches a route position.
double get_exit_time (const std::string &tr_name) const
 Returns the stored exit time of a train.
std::vector< double > get_stop_times (const std::string &tr_name) const
 Returns all stored stop times of a train.
double get_stop_time (const std::string &tr_name, const std::string &station_name) const
 Returns one stored stop time identified by station name.
double get_stop_time (const std::string &tr_name, size_t stop_index) const
 Returns one stored stop time identified by stop index.
void add_train_pos (const std::string &tr_name, double t, double pos)
 Stores a train position sample.
void add_train_speed (const std::string &tr_name, double t, double speed)
 Stores a train speed sample.
void set_train_exit_time (const std::string &tr_name, double t)
 Stores the exit time of a train.
void set_train_stop_time (const std::string &tr_name, size_t stop_idx, double stop_time)
 Stores one stop time identified by stop index.
void set_train_stop_time (const std::string &tr_name, std::string const &station_name, double stop_time)
 Stores one stop time identified by station name.
void set_train_stop_times (const std::string &tr_name, std::vector< double > stop_times)
 Replaces all stop times of one train.
void set_exit_times (const std::vector< double > &exit_times)
 Replaces all stored exit times.
void set_stop_times (const std::vector< std::vector< double > > &stop_times)
 Replaces all stored stop times.
void evaluate (double dt)
 Simulates the decisions of this solution greedily and stores the resulting delays, which are exported with the solution.
const std::optional< SolutionEvaluation > & get_evaluation () const
 Returns the result of the last evaluate(), if any.
Public Member Functions inherited from cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes
 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
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::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

EvaluationSetup get_evaluation_setup () const override
 Prepares the simulation of evaluate() without moving block.
Protected Member Functions inherited from cda_rail::instances::SolGeneralPerformanceOptimizationInstance
nlohmann::json get_general_solution_data () const override
 Adds the evaluation, if any, to the solution-wide metadata.
void set_general_solution_data (const nlohmann::json &data) override
 Loads the solution-wide metadata including the evaluation.
Protected Member Functions inherited from cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes
 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.
GeneralProblemInstance const * get_uncast_instance_pointer () const
 Retrieves the underlying problem instance pointer.

Detailed Description

The same solution, together with the VSS borders it needs.

This is what the VSS generation solvers return: in addition to the trajectories, the positions of the VSS borders are stored per edge, measured from the source vertex of that edge.

Constructor & Destructor Documentation

◆ SolVSSGeneralPerformanceOptimizationInstance() [1/2]

cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::SolVSSGeneralPerformanceOptimizationInstance ( const GeneralPerformanceOptimizationInstance & instance)
inlineexplicit

Constructs a solution instance with VSS support from a performance optimization instance.

Parameters
instanceThe performance optimization instance to base this solution on.

◆ SolVSSGeneralPerformanceOptimizationInstance() [2/2]

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

Member Function Documentation

◆ add_vss_pos()

void cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::add_vss_pos ( cda_rail::Network::EdgeInput const & edge_input,
double pos,
bool reverse_edge = true )

◆ check_consistency()

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

Checks whether the stored performance-optimization solution is consistent.

Returns
true if the solution data is consistent, otherwise false.

Reimplemented from cda_rail::instances::SolGeneralPerformanceOptimizationInstance.

◆ export_solution() [1/3]

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::SolGeneralPerformanceOptimizationInstance.

◆ export_solution() [2/3]

void cda_rail::instances::SolGeneralPerformanceOptimizationInstance::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 instance.

Reimplemented from cda_rail::instances::SolGeneralPerformanceOptimizationInstance.

◆ export_solution() [3/3]

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

Exports the solution, optionally including the instance data.

Parameters
working_directoryBase export directory.
solution_subdirectorySolution subdirectory.
save_instanceWhether to export the instance as well.
parameter_identifierOptional parameter identifier for the export path.

Reimplemented from cda_rail::instances::SolGeneralPerformanceOptimizationInstance.

◆ get_evaluation_setup()

cda_rail::instances::SolGeneralPerformanceOptimizationInstance::EvaluationSetup cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::get_evaluation_setup ( ) const
nodiscardoverrideprotectedvirtual

Prepares the simulation of evaluate() without moving block.

The edges are split at the VSS borders of this solution, and every resulting section between two borders becomes a block section.

Returns
The split instance, its block sections, and the routes of this solution in that instance.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf a train has no train integrity monitoring, which is not implemented.

Reimplemented from cda_rail::instances::SolGeneralPerformanceOptimizationInstance.

◆ get_valid_border_stops()

std::vector< double > cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::get_valid_border_stops ( const std::string & train_name) const
nodiscard

◆ get_vss_pos()

std::vector< double > cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::get_vss_pos ( cda_rail::Network::EdgeInput const & edge_input) const
nodiscard

◆ load_solution() [1/2]

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::SolGeneralPerformanceOptimizationInstance.

◆ load_solution() [2/2]

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

◆ reset_vss_pos()

void cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::reset_vss_pos ( cda_rail::Network::EdgeInput const & edge_input)

◆ set_vss_pos()

void cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance::set_vss_pos ( cda_rail::Network::EdgeInput const & edge_input,
std::vector< double > pos )

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