|
MTCT
Design Automation and Optimization for ETCS Railway Networks
|
Base of every solution object. More...
#include <GeneralProblemInstance.hpp>
Public Member Functions | |
| std::filesystem::path | get_export_path (const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory, std::optional< std::string > const ¶meter_identifier) const |
| Computes the file path for exporting a solution. | |
| virtual GeneralProblemInstance const * | get_instance () const |
| Provides access to the problem instance. | |
| 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. | |
| virtual void | load_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const ¶meter_identifier) |
| virtual void | load_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory) |
| Loads a solution from the specified working directory and solution subdirectory. | |
| void | load_solution (const std::string &path, std::string_view const solutionSubdirectory, std::optional< std::string > const ¶meter_identifier={}) |
| Loads a solution from the specified path. | |
| void | load_solution (const char *path, std::string_view const solutionSubdirectory, std::optional< std::string > const ¶meter_identifier={}) |
| Loads a solution from the specified location. | |
| virtual void | export_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const ¶meter_identifier) const |
| virtual void | export_solution (const std::filesystem::path &working_directory, std::string_view solution_subdirectory) const |
| Exports the solution without a parameter identifier. | |
| void | export_solution (const std::string &path, std::string_view const solutionSubdirectory, std::optional< std::string > const ¶meter_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 ¶meter_identifier={}) const |
| Exports the solution to the specified directory and subdirectory. | |
| virtual bool | check_consistency () const |
| Checks whether the stored solution metadata is consistent. | |
| 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 | |
| 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. | |
Base of every solution object.
A solution owns a copy of the instance it belongs to, so that it stays interpretable on its own, and stores what the solver was able to achieve, namely its status, its objective value and the best bound it proved.
|
inlineexplicitprotected |
Creates a solution wrapper around the given problem instance.
|
inlineprotected |
Constructs a solution instance with problem instance and solution metadata.
| instance_ptr | Problem instance. |
| status | Solution status. |
| obj | Objective value. |
| has_sol | Whether a solution exists. |
|
virtualdefault |
Virtual destructor.
|
default |
|
defaultnoexcept |
|
nodiscardvirtual |
Checks whether the stored solution metadata is consistent.
Reimplemented in cda_rail::instances::SolGeneralPerformanceOptimizationInstance, cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes, and cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.
|
inline |
Exports the solution to the specified directory and subdirectory.
| path | Directory path where the solution will be exported. |
| solutionSubdirectory | Subdirectory name for organizing solutions. |
| parameter_identifier | Optional identifier appended to the solution name. |
|
inlinevirtual |
Exports the solution without a parameter identifier.
| working_directory | The root directory for solution exports. |
| solution_subdirectory | The subdirectory path for organizing solutions. |
Reimplemented in cda_rail::instances::SolGeneralPerformanceOptimizationInstance, cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes, and cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.
|
virtual |
|
inline |
Exports the solution to the specified directory.
| path | Directory path where the solution will be exported. |
| solutionSubdirectory | Solution subdirectory name. |
| parameter_identifier | Optional parameter identifier appended to the export path. |
|
inlinenodiscard |
Computes the file path for exporting a solution.
Constructs a path of the form working_directory/solutions/<solutionSubdirectory>/<instance_subdirectory>/<instance_name>, with -<parameter_identifier> appended to the instance name if provided.
| parameter_identifier | Optional identifier appended to the instance name. |
|
nodiscardprotectedvirtual |
Serializes solution-wide metadata to JSON.
Reimplemented in cda_rail::instances::SolGeneralPerformanceOptimizationInstance.
|
inlinenodiscardvirtual |
Provides access to the problem instance.
Reimplemented in cda_rail::instances::SolGeneralPerformanceOptimizationInstance, and cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes.
|
inlinenodiscard |
Gets the lower bound on the objective value of the solution.
|
inlinenodiscard |
Gets the objective value of the solution.
|
inlinenodiscard |
Retrieves the current solution status.
|
inlinenodiscardprotected |
Retrieves the underlying problem instance pointer.
|
inlinenodiscard |
Indicates whether a solution has been found.
|
inline |
Loads a solution from the specified location.
| path | Working directory path. |
| solutionSubdirectory | Subdirectory containing solutions. |
| parameter_identifier | Optional identifier to append to the instance name when constructing the solution path. |
|
inlinevirtual |
Loads a solution from the specified working directory and solution subdirectory.
| working_directory | The base working directory path. |
| solution_subdirectory | The subdirectory containing the solution. |
Reimplemented in cda_rail::instances::SolGeneralPerformanceOptimizationInstance, cda_rail::instances::SolGeneralProblemInstanceWithScheduleAndRoutes, and cda_rail::instances::SolVSSGeneralPerformanceOptimizationInstance.
|
virtual |
|
inline |
Loads a solution from the specified path.
| path | Working directory path. |
| solutionSubdirectory | Subdirectory containing solution files. |
| parameter_identifier | Optional identifier appended to the instance name when locating solution files. |
|
defaultnoexcept |
|
default |
|
protectedvirtual |
Loads solution-wide metadata from JSON.
| data | JSON object containing general solution fields. |
Reimplemented in cda_rail::instances::SolGeneralPerformanceOptimizationInstance.
|
inline |
Sets the lower bound of the objective value of the solution.
| new_obj | The lower bound. |
|
inline |
Sets the objective value of the solution.
| new_obj | The new objective value. |
|
inline |
Marks the solution as found.
|
inline |
Marks that no solution has been found.
|
inline |
Sets the solution status.