Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
NOOPSolver.h
1//
2// Created by marechaljas on 02/05/2022.
3//
4
5#ifndef ANTARESXPANSION_TESTS_CPP_LP_NAMER_NOOPSOLVER_H_
6#define ANTARESXPANSION_TESTS_CPP_LP_NAMER_NOOPSOLVER_H_
7
8#include "antares-xpansion/multisolver_interface/SolverAbstract.h"
9
11{
12public:
13 SolverAbstract* clone() const override
14 {
15 return new NOOPSolver(*this);
16 }
17
19 {
20 return 0;
21 }
22
23 std::string get_solver_name() const override
24 {
25 return std::string();
26 }
27
28 void init() override
29 {
30 }
31
32 void free() override
33 {
34 }
35
36 void write_prob_mps(const std::filesystem::path& filename) override
37 {
38 }
39
40 void write_prob_lp(const std::filesystem::path& filename) override
41 {
42 }
43
44 void read_prob_mps(const std::filesystem::path& filename) override
45 {
46 }
47
48 void read_prob_lp(const std::filesystem::path& filename) override
49 {
50 }
51
52 int get_ncols() const override
53 {
54 return 0;
55 }
56
57 int get_nrows() const override
58 {
59 return 0;
60 }
61
62 int get_nelems() const override
63 {
64 return 0;
65 }
66
67 int get_n_integer_vars() const override
68 {
69 return 0;
70 }
71
72 void get_obj(double* obj, int first, int last) const override
73 {
74 }
75
76 void set_obj_to_zero() override
77 {
78 }
79
80 void set_obj(const double* obj, int first, int last) override
81 {
82 }
83
84 void get_rows(int* mstart,
85 int* mclind,
86 double* dmatval,
87 int size,
88 int* nels,
89 int first,
90 int last) const override
91 {
92 }
93
94 void get_row_type(char* qrtype, int first, int last) const override
95 {
96 }
97
98 void get_rhs(double* rhs, int first, int last) const override
99 {
100 }
101
102 void get_rhs_range(double* range, int first, int last) const override
103 {
104 }
105
106 void get_cols(int* mstart,
107 int* mrwind,
108 double* dmatval,
109 int size,
110 int* nels,
111 int first,
112 int last) const override
113 {
114 }
115
116 void get_col_type(char* coltype, int first, int last) const override
117 {
118 }
119
120 void get_lb(double* lb, int fisrt, int last) const override
121 {
122 }
123
124 void get_ub(double* ub, int fisrt, int last) const override
125 {
126 }
127
128 int get_row_index(const std::string& name) override
129 {
130 return 0;
131 }
132
133 int get_col_index(const std::string& name) override
134 {
135 return 0;
136 }
137
138 std::vector<std::string> get_row_names(int first, int last) const override
139 {
140 return std::vector<std::string>();
141 }
142
143 std::vector<std::string> get_row_names() override
144 {
145 return std::vector<std::string>();
146 }
147
148 std::vector<std::string> get_col_names(int first, int last) const override
149 {
150 return std::vector<std::string>();
151 }
152
153 std::vector<std::string> get_col_names() override
154 {
155 return std::vector<std::string>();
156 }
157
158 void del_rows(int first, int last) override
159 {
160 }
161
162 void del_cols(int first, int last) override
163 {
164 }
165
166 void add_rows(int newrows,
167 int newnz,
168 const char* qrtype,
169 const double* rhs,
170 const double* range,
171 const int* mstart,
172 const int* mclind,
173 const double* dmatval,
174 const std::vector<std::string>& row_names) override
175 {
176 }
177
178 void add_cols(int newcol,
179 int newnz,
180 const double* objx,
181 const int* mstart,
182 const int* mrwind,
183 const double* dmatval,
184 const double* bdl,
185 const double* bdu,
186 const std::vector<std::string>& col_names) override
187 {
188 }
189
190 void add_name(int type, const char* cnames, int indice) override
191 {
192 }
193
194 void add_names(int type, const std::vector<std::string>& cnames, int first, int end) override
195 {
196 }
197
198 void chg_obj(const std::vector<int>& mindex, const std::vector<double>& obj) override
199 {
200 }
201
202 void chg_obj_direction(const bool minimize) override
203 {
204 }
205
206 void chg_bounds(const std::vector<int>& mindex,
207 const std::vector<char>& qbtype,
208 const std::vector<double>& bnd) override
209 {
210 }
211
212 void chg_col_type(const std::vector<int>& mindex, const std::vector<char>& qctype) override
213 {
214 }
215
216 void chg_rhs(int id_row, double val) override
217 {
218 }
219
220 void chg_coef(int id_row, int id_col, double val) override
221 {
222 }
223
224 void chg_row_name(int id_row, const std::string& name) override
225 {
226 }
227
228 void chg_col_name(int id_col, const std::string& name) override
229 {
230 }
231
232 int solve_lp() override
233 {
234 return 0;
235 }
236
237 int solve_mip() override
238 {
239 return 0;
240 }
241
242 void get_basis(int* rstatus, int* cstatus) const override
243 {
244 }
245
246 double get_mip_value() const override
247 {
248 return 0;
249 }
250
251 double get_lp_value() const override
252 {
253 return 0;
254 }
255
256 int get_splex_num_of_ite_last() const override
257 {
258 return 0;
259 }
260
261 void get_lp_sol(double* primals, double* duals, double* reduced_costs) const override
262 {
263 }
264
265 void get_mip_sol(double* primals) override
266 {
267 }
268
269 void set_output_log_level(int loglevel) override
270 {
271 }
272
273 void set_algorithm(const std::string& algo) override
274 {
275 }
276
277 void set_threads(int n_threads) override
278 {
279 }
280
281 void set_optimality_gap(double gap) override
282 {
283 }
284
285 void set_simplex_iter(int iter) override
286 {
287 }
288
289 void write_basis(const std::filesystem::path& filename) override
290 {
291 }
292
293 void read_basis(const std::filesystem::path& filename) override
294 {
295 }
296
297 void set_basis(std::span<int> rstatus, std::span<int> cstatus) override {};
298
299 void save_prob(const std::filesystem::path& filename) override
300 {
301 }
302
303 void restore_prob(const std::filesystem::path& filename) override
304 {
305 }
306
307 void get_presolve_map(int* rowmap, int* colmap) const override
308 {
309 }
310
311 void mark_indices_to_keep_presolve(int nrows, int ncols, int* rowind, int* colind) override
312 {
313 }
314
315 void presolve_only() override
316 {
317 }
318};
319
320#endif // ANTARESXPANSION_TESTS_CPP_LP_NAMER_NOOPSOLVER_H_
321
323{
324public:
325 void get_col_type(char* coltype, int begin, int end) const override
326 {
327 std::copy_n(col_types.begin(), end - begin + 1, coltype);
328 }
329
330 void get_lb(double* lb, int begin, int end) const override
331 {
332 std::copy_n(lbs.begin(), end - begin + 1, lb);
333 }
334
335 void get_ub(double* ub, int begin, int end) const override
336 {
337 std::copy_n(ubs.begin(), end - begin + 1, ub);
338 }
339
340protected:
341 std::vector<char> col_types;
342 std::vector<double> lbs;
343 std::vector<double> ubs;
344};
Definition NOOPSolver.h:323
void get_lb(double *lb, int begin, int end) const override
Returns the lower bounds for variables in a given range.
Definition NOOPSolver.h:330
void get_col_type(char *coltype, int begin, int end) const override
Returns the column types for the columns in a given range.
Definition NOOPSolver.h:325
void get_ub(double *ub, int begin, int end) const override
Returns the upper bounds for variables in a given range.
Definition NOOPSolver.h:335
Definition NOOPSolver.h:11
void chg_col_type(const std::vector< int > &mindex, const std::vector< char > &qctype) override
Change type of some columns.
Definition NOOPSolver.h:212
void get_rhs_range(double *range, int first, int last) const override
Returns the right hand side range values for the rows in a given range.
Definition NOOPSolver.h:102
void set_threads(int n_threads) override
Sets the maximum number of threads used to perform optimization.
Definition NOOPSolver.h:277
int get_row_index(const std::string &name) override
Returns the index of row named "name".
Definition NOOPSolver.h:128
void set_simplex_iter(int iter) override
Sets the maximum number of simplex iterations the solver can perform.
Definition NOOPSolver.h:285
void chg_bounds(const std::vector< int > &mindex, const std::vector< char > &qbtype, const std::vector< double > &bnd) override
Change bounds of some variables.
Definition NOOPSolver.h:206
int get_nelems() const override
returns number of non zeros elements in the matrix, excluding objective
Definition NOOPSolver.h:62
void read_basis(const std::filesystem::path &filename) override
Instructs the optimizer to read in a previously saved basis from a file.
Definition NOOPSolver.h:293
void add_name(int type, const char *cnames, int indice) override
Adds a name to a row or a column.
Definition NOOPSolver.h:190
int get_ncols() const override
returns number of columns of the problem
Definition NOOPSolver.h:52
void get_rows(int *mstart, int *mclind, double *dmatval, int size, int *nels, int first, int last) const override
get coefficients of rows from index first to last
Definition NOOPSolver.h:84
void read_prob_mps(const std::filesystem::path &filename) override
reads an optimization problem contained in a MPS file
Definition NOOPSolver.h:44
void set_algorithm(const std::string &algo) override
Sets algorithm used by solver to solve LP's.
Definition NOOPSolver.h:273
int get_number_of_instances() override
Returns number of instances of solver currently in memory.
Definition NOOPSolver.h:18
void init() override
Initializes a problem.
Definition NOOPSolver.h:28
void chg_rhs(int id_row, double val) override
Change rhs of a row.
Definition NOOPSolver.h:216
void chg_obj(const std::vector< int > &mindex, const std::vector< double > &obj) override
Change coefficients in objective function.
Definition NOOPSolver.h:198
void chg_col_name(int id_col, const std::string &name) override
Change the name of a variable.
Definition NOOPSolver.h:228
void get_ub(double *ub, int fisrt, int last) const override
Returns the upper bounds for variables in a given range.
Definition NOOPSolver.h:124
void chg_row_name(int id_row, const std::string &name) override
Change the name of a constraint.
Definition NOOPSolver.h:224
double get_lp_value() const override
Get the optimal value of a LP problem (available after method "solve_lp" )
Definition NOOPSolver.h:251
void get_lp_sol(double *primals, double *duals, double *reduced_costs) const override
Get LP solution of a problem (available after method "solve_lp")
Definition NOOPSolver.h:261
void set_obj_to_zero() override
Set the objective function coefficients to zero.
Definition NOOPSolver.h:76
int solve_lp() override
Solves a problem as LP.
Definition NOOPSolver.h:232
std::string get_solver_name() const override
Returns the solver used.
Definition NOOPSolver.h:23
void get_cols(int *mstart, int *mrwind, double *dmatval, int size, int *nels, int first, int last) const override
get coefficients of cols from index first to last
Definition NOOPSolver.h:106
void get_lb(double *lb, int fisrt, int last) const override
Returns the lower bounds for variables in a given range.
Definition NOOPSolver.h:120
void get_row_type(char *qrtype, int first, int last) const override
Returns the row types for the rows in a given range.
Definition NOOPSolver.h:94
void get_mip_sol(double *primals) override
Get MIP solution of a problem (available after method "solve_mip")
Definition NOOPSolver.h:265
void set_optimality_gap(double gap) override
Sets the optimality gap.
Definition NOOPSolver.h:281
int get_n_integer_vars() const override
returns number of integer variables in the problem
Definition NOOPSolver.h:67
void set_obj(const double *obj, int first, int last) override
Set the objective function coefficients for the columns in a given range.
Definition NOOPSolver.h:80
void del_cols(int first, int last) override
Deletes col at index first and last.
Definition NOOPSolver.h:162
void restore_prob(const std::filesystem::path &filename) override
read an optimisation problem from a file
Definition NOOPSolver.h:303
double get_mip_value() const override
Get the optimal value of a MIP problem (available after method "solve_mip")
Definition NOOPSolver.h:246
void presolve_only() override
Presolve the problem (to be implemented by derived classes)
Definition NOOPSolver.h:315
std::vector< std::string > get_col_names(int first, int last) const override
Returns the names of columns from index first to last cannot be declared as const because of some sol...
Definition NOOPSolver.h:148
int get_col_index(const std::string &name) override
Returns the index of column named "name".
Definition NOOPSolver.h:133
void get_rhs(double *rhs, int first, int last) const override
Returns the right-hand sides of the rows in a given range.
Definition NOOPSolver.h:98
void read_prob_lp(const std::filesystem::path &filename) override
reads an optimization problem contained in a MPS file
Definition NOOPSolver.h:48
std::vector< std::string > get_row_names() override
Returns the names of rows.
Definition NOOPSolver.h:143
void write_basis(const std::filesystem::path &filename) override
Writes the current basis to a file for later input into the optimizer.
Definition NOOPSolver.h:289
void mark_indices_to_keep_presolve(int nrows, int ncols, int *rowind, int *colind) override
Mark indices to keep during presolve (to be implemented by derived classes)
Definition NOOPSolver.h:311
void get_obj(double *obj, int first, int last) const override
returns the objective function coefficients for the columns in a given range
Definition NOOPSolver.h:72
void save_prob(const std::filesystem::path &filename) override
write an optimisation problem in a file
Definition NOOPSolver.h:299
void get_basis(int *rstatus, int *cstatus) const override
Returns the current basis into the user's data arrays.
Definition NOOPSolver.h:242
void set_output_log_level(int loglevel) override
Sets log level of the solver.
Definition NOOPSolver.h:269
int solve_mip() override
Solves a problem as MIP.
Definition NOOPSolver.h:237
std::vector< std::string > get_col_names() override
Returns the names of columns.
Definition NOOPSolver.h:153
void write_prob_mps(const std::filesystem::path &filename) override
writes an optimization problem in a MPS file
Definition NOOPSolver.h:36
void add_cols(int newcol, int newnz, const double *objx, const int *mstart, const int *mrwind, const double *dmatval, const double *bdl, const double *bdu, const std::vector< std::string > &col_names) override
Adds new columns to the problem.
Definition NOOPSolver.h:178
void chg_coef(int id_row, int id_col, double val) override
Change a coefficient in the matrix.
Definition NOOPSolver.h:220
void chg_obj_direction(const bool minimize) override
Change the problem's objective function sense to minimize or maximize.
Definition NOOPSolver.h:202
void get_presolve_map(int *rowmap, int *colmap) const override
Get the presolve map (to be implemented by derived classes)
Definition NOOPSolver.h:307
int get_nrows() const override
returns number of rows of the problem
Definition NOOPSolver.h:57
void write_prob_lp(const std::filesystem::path &filename) override
writes an optimization problem in a LP file
Definition NOOPSolver.h:40
std::vector< std::string > get_row_names(int first, int last) const override
Returns the names of row from index first to last cannot be declared as const because of some solver ...
Definition NOOPSolver.h:138
int get_splex_num_of_ite_last() const override
Get the number of simplex iterations done in the last resolution of the problem.
Definition NOOPSolver.h:256
void del_rows(int first, int last) override
Deletes rows between index first and last.
Definition NOOPSolver.h:158
void free() override
Frees all the datas contained in the Solver environment.
Definition NOOPSolver.h:32
void get_col_type(char *coltype, int first, int last) const override
Returns the column types for the columns in a given range.
Definition NOOPSolver.h:116
void add_rows(int newrows, int newnz, const char *qrtype, const double *rhs, const double *range, const int *mstart, const int *mclind, const double *dmatval, const std::vector< std::string > &row_names) override
Adds rows to the problem.
Definition NOOPSolver.h:166
Definition SolverAbstract.h:203