|
| const nlohmann::json & | get_solver_data () const |
| | The solver data of the last solve, as written to solver_data.json if the solution is exported, so that it can be exported later. Null before the first solve.
|
| const T & | get_instance () const |
| | Accesses the problem instance stored in this solver.
|
| T & | editable_instance () |
| | Provides mutable access to the problem instance.
|
| S | solve () |
| | Solves the problem instance using default configuration.
|
| S | solve (int time_limit, bool debug_input) |
| | Solves the problem instance.
|
| virtual S | solve (int time_limit, bool debug_input, bool overwrite_severity)=0 |
| | Solves the problem instance, which every solver implements.
|
| virtual | ~GeneralSolver ()=default |
| | Virtual destructor.
|
|
| void | solve_init_general (bool debug_input, bool overwrite_severity) |
| | Initializes logging and records solver start time.
|
| | GeneralSolver ()=default |
| | Constructs a solver with a default-initialized problem instance.
|
| | GeneralSolver (T instance) |
| | Constructs a solver from a problem instance.
|
template<typename... Args>
requires (sizeof...(Args) > 0 && !IsSingleInstanceArgument<Args...>::value && std::constructible_from<T, Args...>) |
| | GeneralSolver (Args &&... args) |
| | Constructs a GeneralSolver with arguments for the problem instance constructor.
|
| nlohmann::json | solver_data (FurtherData const &further_data) const |
| | Solver data, i.e., timing and further information (e.g. iterations, nodes, etc.), as written to solver_data.json.
|
| void | export_solver_data (std::filesystem::path const &export_directory, FurtherData const &further_data={}) |
| | Exports solver data, see solver_data, into solver_data.json.
|
| std::optional< std::filesystem::path > | export_general_solution (S &solution, const GeneralSolutionSettings &solution_settings, FurtherData const &further_data={}) |
| | Exports the solution together with the solver data if requested.
|
template<typename T, typename S>
class cda_rail::solver::GeneralSolver< T, S >
Base of every solver, connecting an instance type to its solution type.
Besides holding the instance, this is where everything that is not specific to a solving approach lives, namely the initialization of the logging, the measured times, and the export of the solution together with the solver data.
- Template Parameters
-
| T | The problem instance type, a child of GeneralProblemInstance. |
| S | The solution type belonging to it, a child of SolGeneralProblemInstance. |
template<typename T, typename S>
Exports the solution together with the solver data if requested.
The solution is written to the standard solution path, i.e., working_directory/solutions/solution_subdirectory/instance_subdirectory/ instance_name[-parameter_identifier]. Nothing is exported if the export option is GeneralExportOption::NoExport. If an evaluation time step is given and the solution type supports it, the solution is evaluated before it is exported, so that the evaluation is part of solution afterwards. If the evaluation fails, the solution is exported without it. The solver data is kept in any case, see get_solver_data.
- Parameters
-
| solution | The solution to export |
| solution_settings | Settings describing where and what to export |
| further_data | Additional solver-specific data for solver_data.json |
- Returns
- The export directory if an export happened, std::nullopt otherwise