Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
Worker.h
1#pragma once
2
3#include <filesystem>
4
5#include "SolverIO.h"
6#include "antares-xpansion/benders/output/OutputWriter.h"
7#include "antares-xpansion/multisolver_interface/Solver.h"
8#include "antares-xpansion/xpansion_interfaces/ILogger.h"
9#include "common.h"
10
17class Worker {
18 public:
19 Worker(VariableMap variable_map, std::filesystem::path path_to_mps,
20 Logger logger);
21 void init(const std::string &solver_name, int log_level,
22 SolverLogManager &solver_log_manager, ProblemsFormat format);
23 virtual ~Worker() = default;
24
25 void get_value(double &lb) const;
26
27 void get_splex_num_of_ite_last(int &result) const;
28
29 void free();
30 void write_basis(const std::filesystem::path &filename) const;
31 [[nodiscard]] virtual std::shared_ptr<SolverAbstract> solver() const;
32
33 public:
34 std::filesystem::path _path_to_mps;
35 VariableMap
37 Int2Str
40 public:
41 void solve(int &lp_status, const std::string &outputroot,
42 const std::string &output_master_mps_file_name,
43 Writer writer) const;
44 int RowIndex(const std::string &row_name) const;
45 void ChangeRhs(int id_row, double val) const;
46 void GetRhs(double *val, int id_row) const;
47 void AddRows(std::vector<char> const &qrtype_p,
48 std::vector<double> const &rhs_p,
49 std::vector<double> const &range_p,
50 std::vector<int> const &mstart_p,
51 std::vector<int> const &mclind_p,
52 std::vector<double> const &dmatval_p,
53 const std::vector<std::string> &row_names) const;
54
60 int Getnrows() const;
61
62 int Getncols() const;
63
64 public:
65 std::shared_ptr<SolverAbstract> _solver =
66 nullptr;
67 bool _is_master = false;
68
69 Logger logger_;
70
71 private:
72 void read_prob(SolverAbstract * problem,
73 const std::filesystem::path &path) const;
74 SolverIO solver_io_;
75 void writeProb(const std::filesystem::path& out) const;
76};
Definition SolverAbstract.h:170
Definition SolverIO.h:7
Definition SolverAbstract.h:16
Mother-class Worker.
Definition Worker.h:17
std::shared_ptr< SolverAbstract > _solver
Definition Worker.h:65
VariableMap _name_to_id
Definition Worker.h:36
void get_splex_num_of_ite_last(int &result) const
Get the number of iteration needed to solve a problem.
Definition Worker.cpp:108
void init(const std::string &solver_name, int log_level, SolverLogManager &solver_log_manager, ProblemsFormat format)
Initialization of a problem.
Definition Worker.cpp:38
Int2Str _id_to_name
Definition Worker.h:38
int Getnrows() const
Returns the number of rows (constraints)
Definition Worker.cpp:139
void get_value(double &lb) const
Return the optimal value of a problem.
Definition Worker.cpp:22
void free()
Free the problem.
Definition Worker.cpp:10
void solve(int &lp_status, const std::string &outputroot, const std::string &output_master_mps_file_name, Writer writer) const
Method to solve a problem.
Definition Worker.cpp:65