1#ifndef CDA_RAIL_PROBLEMINSTANCES_GENERALPROBLEMINSTANCE_HPP
2#define CDA_RAIL_PROBLEMINSTANCES_GENERALPROBLEMINSTANCE_HPP
11#include "nlohmann/json_fwd.hpp"
14#include "gtest/gtest_prod.h"
31#define TEST_FRIENDS false
34class GeneralPerformanceOptimizationInstances_PointerCopyIssue_Test;
47 std::string m_instance_name{
"UnnamedInstance"};
48 std::string m_instance_subdirectory{
"UnnamedSubdirectory"};
65 std::string_view
const instanceSubdirectory)
66 : m_instance_name(instanceName),
67 m_instance_subdirectory(instanceSubdirectory) {
125 return m_instance_name;
132 return m_instance_subdirectory;
142 m_instance_name = instanceName;
154 m_instance_subdirectory = instanceSubdirectory;
179 [[nodiscard]]
virtual FeasibilityCheck
194 FRIEND_TEST(::GeneralPerformanceOptimizationInstances, PointerCopyIssue);
210 : m_network(std::move(network)) {};
217 : m_network(std::move(network)), m_timetable(std::move(timetable)),
218 m_routes(std::move(routes)) {};
227 std::string_view instance_name, std::string_view instance_subdirectory,
228 std::filesystem::path
const& working_directory);
238 std::string_view
const instanceName,
239 std::string_view
const instanceSubdirectory,
240 std::string
const& working_directory)
242 instanceName, instanceSubdirectory,
243 std::filesystem::path(working_directory)) {};
253 std::string_view
const instanceName,
254 std::string_view
const instanceSubdirectory,
255 char const*
const workingDirectory)
257 instanceName, instanceSubdirectory,
258 std::filesystem::path(workingDirectory)) {};
290 size_t next_stop_id) const;
302 virtual
void export_instance(std::filesystem::path const& working_directory,
303 bool save_network) const;
311 std::filesystem::path const& working_directory)
const override {
364 return m_timetable.editable_train(index);
372 return m_timetable.editable_train(name);
381 return m_timetable.editable_schedule(index);
389 return m_timetable.editable_schedule(name);
422 [[nodiscard]]
const auto&
442 [[nodiscard]]
double route_length(
const std::string& train_name)
const {
457 [[nodiscard]] std::vector<
458 std::pair<size_t, std::vector<cda_rail::index_vector>>>
473 [[nodiscard]] std::optional<double>
475 const std::string& station_name)
const;
485 [[nodiscard]] std::vector<
486 std::pair<size_t, std::vector<cda_rail::index_vector>>>
488 size_t tr,
const std::string& station_name,
498 [[nodiscard]] std::vector<
499 std::pair<size_t, std::vector<cda_rail::index_vector>>>
501 const std::string& train_name,
const std::string& station_name,
505 station_name, edges_to_consider);
524 bool error_if_no_route =
true)
const;
536 bool error_if_no_route =
true)
const {
552 bool error_if_no_route =
true)
const;
564 bool error_if_no_route =
true)
const {
581 const std::vector<cda_rail::index_set>& sections,
583 bool error_if_no_route =
true)
const;
595 size_t tr_id,
const std::vector<cda_rail::index_set>& sections,
596 bool fixed_routes,
bool error_if_no_route =
true)
const {
599 fixed_routes, error_if_no_route);
612 bool error_if_no_route =
true)
const;
626 bool error_if_not_route =
true)
const {
628 trains_to_consider, error_if_not_route);
646 bool error_if_not_route =
true)
const;
659 bool error_if_not_route =
true)
const {
674 bool fixed_routes =
true,
675 bool error_if_not_route =
true)
const;
697 size_t add_train(std::string
const& train_name,
double length,
698 double max_speed,
double acceleration,
double deceleration,
699 bool tim,
double entry_time,
double initial_velocity,
701 double exit_velocity,
703 return m_timetable.add_train(
704 train_name, length, max_speed, acceleration, deceleration, tim,
705 entry_time, initial_velocity, entry_vertex, exit_time, exit_velocity,
724 size_t add_train(std::string
const& train_name,
double length,
725 double max_speed,
double acceleration,
double deceleration,
726 double entry_time,
double initial_velocity,
728 double exit_velocity,
730 return m_timetable.add_train(train_name, length, max_speed, acceleration,
731 deceleration, entry_time, initial_velocity,
732 entry_vertex, exit_time, exit_velocity,
742 m_timetable.add_empty_station(name);
763 void insert_stop(
size_t train_index, std::string
const& station_name,
764 double service_time,
double service_duration) {
765 m_timetable.insert_stop(train_index, station_name, service_time,
775 std::string
const& station_name,
double service_time,
776 double service_duration) {
777 m_timetable.insert_stop(train_name, station_name, service_time,
821 m_routes.remove_first_edge(train_name);
829 m_routes.remove_last_edge(train_name);
843 .get_route(train_name)
857 .get_route(train_name)
872 [[nodiscard]] std::vector<ConflictPair>
874 const std::string& train2)
const {
886 [[nodiscard]] std::vector<ConflictPair>
899 [[nodiscard]] std::vector<ConflictPair>
901 const std::string& train2)
const {
913 [[nodiscard]] std::vector<ConflictPair>
915 const std::string& train2)
const {
942 [[nodiscard]]
virtual bool
946 [[nodiscard]] FeasibilityCheck
959 std::shared_ptr<GeneralProblemInstance> m_instance;
963 bool m_has_sol{
false};
970 std::shared_ptr<GeneralProblemInstance> instance_ptr)
971 : m_instance(std::move(instance_ptr)) {};
982 std::shared_ptr<GeneralProblemInstance> instance_ptr,
984 : m_instance(std::move(instance_ptr)), m_status(status), m_obj(obj),
985 m_has_sol(has_sol) {};
1007 return m_instance.get();
1023 const std::filesystem::path& working_directory,
1024 std::string_view
const solutionSubdirectory,
1025 std::optional<std::string>
const& parameter_identifier)
const {
1027 if (parameter_identifier.has_value()) {
1030 auto const adjusted_name = parameter_identifier.has_value()
1034 parameter_identifier.value(),
1038 working_directory /
"solutions" / solutionSubdirectory /
1049 return m_instance.get();
1063 [[nodiscard]]
double get_obj()
const {
return m_obj; };
1085 void set_obj(
double new_obj) { m_obj = new_obj; };
1102 load_solution(
const std::filesystem::path& working_directory,
1103 std::string_view solution_subdirectory,
1104 std::optional<std::string>
const& parameter_identifier);
1114 std::string_view solution_subdirectory) {
1115 load_solution(working_directory, solution_subdirectory, {});
1128 std::string_view
const solutionSubdirectory,
1129 std::optional<std::string>
const& parameter_identifier = {}) {
1130 load_solution(std::filesystem::path(path), solutionSubdirectory,
1131 parameter_identifier);
1143 std::optional<std::string>
const& parameter_identifier = {}) {
1144 load_solution(std::filesystem::path(path), solutionSubdirectory,
1145 parameter_identifier);
1150 std::string_view solution_subdirectory,
1151 std::optional<std::string>
const& parameter_identifier)
const;
1161 std::string_view solution_subdirectory)
const {
1174 const std::string& path, std::string_view
const solutionSubdirectory,
1175 std::optional<std::string>
const& parameter_identifier = {})
const {
1177 parameter_identifier);
1188 const char* path, std::string_view
const solutionSubdirectory,
1189 std::optional<std::string>
const& parameter_identifier = {})
const {
1191 parameter_identifier);
1229 cast_instance()
const {
1242 std::shared_ptr<GeneralProblemInstanceWithScheduleAndRoutes> instance_ptr)
1244 m_solution_routes(cast_instance()->get_const_routes()) {}
1250 std::shared_ptr<GeneralProblemInstanceWithScheduleAndRoutes> instance_ptr,
1254 m_solution_routes(cast_instance()->get_const_routes()) {};
1283 status, obj, has_sol) {};
1298 const std::filesystem::path& working_directory,
1299 std::string_view solution_subdirectory,
1300 std::optional<std::
string> const& parameter_identifier) override;
1311 std::string_view const solutionSubdirectory)
override {
1323 return cast_instance();
1332 return m_solution_routes;
1348 void reset_routes();
1354 void add_empty_route(
const std::string& train_name);
1364 m_solution_routes.push_back_edge(train_name, edge_input,
1375 m_solution_routes.push_front_edge(train_name, edge_input,
1385 m_solution_routes.remove_first_edge(train_name);
1393 m_solution_routes.remove_last_edge(train_name);
1407 .get_route(train_name)
1408 .edge_pos_on_route(edge,
get_instance()->get_const_network());
1420 const std::filesystem::path& working_directory,
1421 std::string_view
const solutionSubdirectory,
1422 std::optional<std::string>
const& parameter_identifier)
const override {
1424 parameter_identifier);
1438 std::string_view
const solutionSubdirectory)
const override {
1444 std::string_view solution_subdirectory,
bool save_instance,
1445 std::optional<std::string>
const& parameter_identifier)
const;
Directed multigraph representing a railway network.
Definition RailwayNetwork.hpp:163
Collection of named train routes built on top of a railway network.
Definition Route.hpp:374
Specific schedule object with fixed entry/exit constraints.
Definition Timetable.hpp:175
Container and persistence API for named stations.
Definition Station.hpp:81
Container for trains with name-based indexing.
Definition Train.hpp:200
Properties and characteristics of a train.
Definition Train.hpp:26
An instance consisting of a network, a timetable, and routes.
Definition GeneralProblemInstance.hpp:191
auto & get_editable_network()
Provides editable access to the underlying network.
Definition GeneralProblemInstance.hpp:342
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.
Definition GeneralProblemInstance.hpp:840
Train & editable_train(const std::string &name)
Retrieves mutable access to a train by name.
Definition GeneralProblemInstance.hpp:371
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.
Definition GeneralProblemInstance.hpp:535
auto & get_editable_timetable()
Provides editable access to the timetable.
Definition GeneralProblemInstance.hpp:349
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.
Definition GeneralProblemInstance.cpp:63
std::vector< ConflictPair > get_parallel_overlaps(const std::string &train1, const std::string &train2) const
Identifies parallel overlaps between two trains.
Definition GeneralProblemInstance.hpp:873
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.
Definition GeneralProblemInstance.hpp:811
Schedule & editable_schedule(size_t const index)
Gets the schedule of a train by its index for editing.
Definition GeneralProblemInstance.hpp:380
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.
Definition GeneralProblemInstance.hpp:697
void add_empty_route(const std::string &train_name)
Adds an empty route for a train.
Definition GeneralProblemInstance.hpp:792
GeneralProblemInstanceWithScheduleAndRoutes(const GeneralProblemInstanceWithScheduleAndRoutes &)=default
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.
Definition GeneralProblemInstance.hpp:500
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.
Definition GeneralProblemInstance.hpp:763
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.
Definition GeneralProblemInstance.cpp:177
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.
Definition GeneralProblemInstance.hpp:563
const auto & get_const_schedule(size_t index) const
Retrieves the schedule for a train.
Definition GeneralProblemInstance.hpp:413
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.
Definition GeneralProblemInstance.hpp:252
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.
Definition GeneralProblemInstance.hpp:724
void add_track_to_station(const std::string &name, Network::EdgeInput const &track)
Adds a track to a station.
Definition GeneralProblemInstance.hpp:750
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.
Definition GeneralProblemInstance.hpp:801
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.
Definition GeneralProblemInstance.cpp:232
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.
Definition GeneralProblemInstance.cpp:137
GeneralProblemInstanceWithScheduleAndRoutes(GeneralProblemInstanceWithScheduleAndRoutes &&) noexcept=default
Move constructor.
std::vector< ConflictPair > get_ttd_overlaps(const std::string &train1, const std::string &train2) const
Identifies time-to-distance overlaps between two trains.
Definition GeneralProblemInstance.hpp:887
const TrainList & get_const_train_list() const
Provides const access to the list of trains in the instance.
Definition GeneralProblemInstance.hpp:404
void remove_first_edge_from_route(const std::string &train_name)
Removes the first edge from a train's route.
Definition GeneralProblemInstance.hpp:820
Train & editable_train(size_t const index)
Gets a train by its index in the schedule.
Definition GeneralProblemInstance.hpp:363
const auto & get_const_routes() const
Provides read-only access to the routes.
Definition GeneralProblemInstance.hpp:336
void add_empty_station(const std::string &name)
Adds an empty station to the timetable.
Definition GeneralProblemInstance.hpp:741
void remove_last_edge_from_route(const std::string &train_name)
Removes the last edge from a train's route.
Definition GeneralProblemInstance.hpp:828
const auto & get_const_network() const
Provides read-only access to the network.
Definition GeneralProblemInstance.hpp:325
bool check_consistency() const override
Checks that the instance is internally consistent, requiring all trains to have routes.
Definition GeneralProblemInstance.hpp:929
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.
Definition GeneralProblemInstance.hpp:854
virtual void export_instance(std::filesystem::path const &working_directory, bool save_network) const
Exports the instance and optionally its network.
Definition GeneralProblemInstance.cpp:93
Schedule & editable_schedule(const std::string &name)
Retrieves mutable access to the schedule of a train by name.
Definition GeneralProblemInstance.hpp:388
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.
Definition GeneralProblemInstance.cpp:208
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.
Definition GeneralProblemInstance.hpp:658
FeasibilityCheck is_obviously_infeasible(bool late_entry_allowed) const override
Checks the instance for reasons that make it infeasible by itself.
Definition GeneralProblemInstance.cpp:323
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.
Definition GeneralProblemInstance.hpp:624
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.
Definition GeneralProblemInstance.cpp:193
const StationList & get_const_station_list() const
Provides the list of all stations.
Definition GeneralProblemInstance.hpp:396
double route_length(const std::string &train_name) const
Computes the total length of a train's route.
Definition GeneralProblemInstance.hpp:442
bool has_route_for_every_train() const
Checks whether every train has an assigned route.
Definition GeneralProblemInstance.cpp:128
GeneralProblemInstanceWithScheduleAndRoutes(Network network, Timetable timetable, RouteMap routes)
Initializes the instance with a network, timetable, and routes.
Definition GeneralProblemInstance.hpp:214
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.
Definition GeneralProblemInstance.hpp:237
std::vector< ConflictPair > get_reverse_overlaps(const std::string &train1, const std::string &train2) const
Identifies sections where two trains travel in opposite directions.
Definition GeneralProblemInstance.hpp:900
friend class SolGeneralProblemInstanceWithScheduleAndRoutes
Definition GeneralProblemInstance.hpp:192
GeneralProblemInstanceWithScheduleAndRoutes & operator=(const GeneralProblemInstanceWithScheduleAndRoutes &)=default
const auto & get_const_schedule(const std::string &train_name) const
Retrieves the schedule for a specified train.
Definition GeneralProblemInstance.hpp:423
GeneralProblemInstanceWithScheduleAndRoutes(Network network)
Initializes the instance with a network.
Definition GeneralProblemInstance.hpp:209
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.
Definition GeneralProblemInstance.hpp:594
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.
Definition GeneralProblemInstance.cpp:155
void set_routes(RouteMap routes)
Replaces all routes of the instance.
Definition GeneralProblemInstance.hpp:786
const auto & get_const_timetable() const
Accesses the timetable.
Definition GeneralProblemInstance.hpp:330
std::vector< ConflictPair > get_crossing_overlaps(const std::string &train1, const std::string &train2) const
Identifies crossing conflicts between two trains' routes.
Definition GeneralProblemInstance.hpp:914
auto & get_editable_routes()
Provides editable access to the route map.
Definition GeneralProblemInstance.hpp:355
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.
Definition GeneralProblemInstance.hpp:459
GeneralProblemInstanceWithScheduleAndRoutes()=default
Constructs an empty problem instance with schedule and routes.
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.
Definition GeneralProblemInstance.hpp:774
Base of every problem instance.
Definition GeneralProblemInstance.hpp:46
void set_instance_name(std::string_view const instanceName)
Sets the instance name.
Definition GeneralProblemInstance.hpp:140
virtual void export_instance(char const *const workingDirectory) const
Exports the instance to the specified working directory.
Definition GeneralProblemInstance.hpp:95
virtual FeasibilityCheck is_obviously_infeasible(bool late_entry_allowed) const =0
Checks the instance for reasons that make it infeasible by itself.
void set_instance_subdirectory(std::string_view const instanceSubdirectory)
Sets the instance subdirectory.
Definition GeneralProblemInstance.hpp:152
GeneralProblemInstance(GeneralProblemInstance &&) noexcept=default
Move constructor.
virtual void export_instance(const std::string &working_directory) const
Exports the instance to the specified working directory.
Definition GeneralProblemInstance.hpp:87
GeneralProblemInstance(const GeneralProblemInstance &)=default
Copy constructor.
virtual void export_instance(const std::filesystem::path &working_directory) const =0
Exports the instance to the specified working directory.
GeneralProblemInstance(std::string_view const instanceName, std::string_view const instanceSubdirectory)
Initializes the instance with a name and subdirectory.
Definition GeneralProblemInstance.hpp:64
GeneralProblemInstance()=default
Initializes the instance with empty name and subdirectory.
const std::string & get_instance_name() const
Gets the instance name.
Definition GeneralProblemInstance.hpp:124
const std::string & get_instance_subdirectory() const
Provides the instance subdirectory.
Definition GeneralProblemInstance.hpp:131
virtual ~GeneralProblemInstance()=default
Virtual destructor.
virtual bool check_consistency() const =0
Checks whether the instance is internally consistent.
GeneralProblemInstance & operator=(const GeneralProblemInstance &)=default
Copy assignment operator.
SolGeneralProblemInstanceWithScheduleAndRoutes & operator=(const SolGeneralProblemInstanceWithScheduleAndRoutes &)=default
SolGeneralProblemInstanceWithScheduleAndRoutes(SolGeneralProblemInstanceWithScheduleAndRoutes &&) noexcept=default
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.
Definition GeneralProblemInstance.hpp:1362
SolGeneralProblemInstanceWithScheduleAndRoutes(GeneralProblemInstanceWithScheduleAndRoutes const &instance, SolutionStatus status, double obj, bool has_sol)
Initializes a solution wrapper around a copy of the provided instance.
Definition GeneralProblemInstance.hpp:1277
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.
Definition GeneralProblemInstance.hpp:1373
RouteMap const & get_const_solution_routes() const
Retrieves the solution routes.
Definition GeneralProblemInstance.hpp:1331
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.
Definition GeneralProblemInstance.hpp:1249
double route_length(const std::string &train_name) const
Computes the total length of a train's solution route.
Definition GeneralProblemInstance.hpp:1341
GeneralProblemInstanceWithScheduleAndRoutes const * get_instance() const override
Accesses the underlying schedule-and-routes problem instance.
Definition GeneralProblemInstance.hpp:1322
void load_solution(const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const ¶meter_identifier) override
Loads the route-aware part of a solution from disk.
Definition GeneralProblemInstance.cpp:567
SolGeneralProblemInstanceWithScheduleAndRoutes(std::shared_ptr< GeneralProblemInstanceWithScheduleAndRoutes > instance_ptr)
Initializes a solution wrapper for a schedule-and-routes problem instance.
Definition GeneralProblemInstance.hpp:1241
SolGeneralProblemInstanceWithScheduleAndRoutes(const SolGeneralProblemInstanceWithScheduleAndRoutes &)=default
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.
Definition GeneralProblemInstance.hpp:1404
SolGeneralProblemInstanceWithScheduleAndRoutes(GeneralProblemInstanceWithScheduleAndRoutes const &instance)
Creates a solution wrapper from a problem instance.
Definition GeneralProblemInstance.hpp:1263
void export_solution(const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory) const override
Exports the solution without saving the problem instance.
Definition GeneralProblemInstance.hpp:1437
void remove_last_edge_from_route(const std::string &train_name)
Removes the last edge from a train's route in the solution.
Definition GeneralProblemInstance.hpp:1392
void remove_first_edge_from_route(const std::string &train_name)
Removes the first edge from a train's route in the solution.
Definition GeneralProblemInstance.hpp:1384
void export_solution(const std::filesystem::path &working_directory, std::string_view const solutionSubdirectory, std::optional< std::string > const ¶meter_identifier) const override
Exports the solution without saving the underlying instance.
Definition GeneralProblemInstance.hpp:1419
virtual void export_solution(const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const ¶meter_identifier) const
Definition GeneralProblemInstance.cpp:527
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.
Definition GeneralProblemInstance.hpp:1187
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.
Definition GeneralProblemInstance.hpp:1173
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.
Definition GeneralProblemInstance.hpp:1113
SolGeneralProblemInstance(std::shared_ptr< GeneralProblemInstance > instance_ptr, SolutionStatus status, double obj, bool has_sol)
Constructs a solution instance with problem instance and solution metadata.
Definition GeneralProblemInstance.hpp:981
virtual bool check_consistency() const
Checks whether the stored solution metadata is consistent.
Definition GeneralProblemInstance.cpp:497
void set_status(SolutionStatus new_status)
Sets the solution status.
Definition GeneralProblemInstance.hpp:1079
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.
Definition GeneralProblemInstance.hpp:1127
SolGeneralProblemInstance(std::shared_ptr< GeneralProblemInstance > instance_ptr)
Creates a solution wrapper around the given problem instance.
Definition GeneralProblemInstance.hpp:969
virtual ~SolGeneralProblemInstance()=default
Virtual destructor.
virtual void export_solution(const std::filesystem::path &working_directory, std::string_view solution_subdirectory) const
Exports the solution without a parameter identifier.
Definition GeneralProblemInstance.hpp:1160
virtual void set_general_solution_data(const nlohmann::json &data)
Loads solution-wide metadata from JSON.
Definition GeneralProblemInstance.cpp:469
void set_solution_not_found()
Marks that no solution has been found.
Definition GeneralProblemInstance.hpp:1099
void set_obj(double new_obj)
Sets the objective value of the solution.
Definition GeneralProblemInstance.hpp:1085
double get_lower_bound() const
Gets the lower bound on the objective value of the solution.
Definition GeneralProblemInstance.hpp:1069
SolGeneralProblemInstance & operator=(SolGeneralProblemInstance const &)=default
GeneralProblemInstance const * get_uncast_instance_pointer() const
Retrieves the underlying problem instance pointer.
Definition GeneralProblemInstance.hpp:1006
virtual void load_solution(const std::filesystem::path &working_directory, std::string_view solution_subdirectory, std::optional< std::string > const ¶meter_identifier)
Definition GeneralProblemInstance.cpp:509
virtual GeneralProblemInstance const * get_instance() const
Provides access to the problem instance.
Definition GeneralProblemInstance.hpp:1048
bool has_solution() const
Indicates whether a solution has been found.
Definition GeneralProblemInstance.hpp:1075
double get_obj() const
Gets the objective value of the solution.
Definition GeneralProblemInstance.hpp:1063
virtual nlohmann::json get_general_solution_data() const
Serializes solution-wide metadata to JSON.
Definition GeneralProblemInstance.cpp:457
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.
Definition GeneralProblemInstance.hpp:1142
SolGeneralProblemInstance(SolGeneralProblemInstance const &)=default
void set_lower_bound(double new_lb)
Sets the lower bound of the objective value of the solution.
Definition GeneralProblemInstance.hpp:1091
SolGeneralProblemInstance(SolGeneralProblemInstance &&) noexcept=default
void set_solution_found()
Marks the solution as found.
Definition GeneralProblemInstance.hpp:1095
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.
Definition GeneralProblemInstance.hpp:1022
SolutionStatus get_status() const
Retrieves the current solution status.
Definition GeneralProblemInstance.hpp:1056
void throw_if_invalid_folder_name(std::string_view const folderName)
Validates that a folder name is portable across Linux, Windows, and macOS.
Definition CustomExceptions.hpp:407
Definition GeneralPerformanceOptimizationInstance.hpp:41
Definition CustomExceptions.hpp:15
std::unordered_set< size_t > index_set
Definition Definitions.hpp:22
std::vector< size_t > index_vector
Definition Definitions.hpp:21
SolutionStatus
What a solver was able to say about the instance it was given.
Definition Definitions.hpp:55
@ Unknown
Definition Definitions.hpp:60
std::string concatenate_string_views(std::initializer_list< std::string_view > parts)
Concatenates multiple string views into a single string.
Definition StringHelper.cpp:11
Start and end position of one edge within the route.
Definition Route.hpp:46
The outcome of is_obviously_infeasible, with its reason.
Definition GeneralProblemInstance.hpp:163
std::string reason
Definition GeneralProblemInstance.hpp:165
bool is_obviously_infeasible
Definition GeneralProblemInstance.hpp:164