3#include "ClpSimplex.hpp"
4#include "CoinHelperFunctions.hpp"
5#include "CoinIndexedVector.hpp"
6#include "antares-xpansion/multisolver_interface/SolverAbstract.h"
11 CLP_PRIMAL_INFEASIBLE,
27 static int _NumberOfProblems;
33 const std::string name_ =
"CLP";
54 explicit SolverClp(
const std::shared_ptr<const SolverAbstract> toCopy);
79 virtual void init()
override;
80 virtual void free()
override;
88 virtual void write_prob_mps(
const std::filesystem::path& filename)
override;
89 virtual void write_prob_lp(
const std::filesystem::path& filename)
override;
90 void save_prob(
const std::filesystem::path& filename)
override;
91 virtual void write_basis(
const std::filesystem::path& filename)
override;
93 virtual void read_prob_mps(
const std::filesystem::path& filename)
override;
94 virtual void read_prob_lp(
const std::filesystem::path& filename)
override;
95 void restore_prob(
const std::filesystem::path& filename)
override;
96 virtual void read_basis(
const std::filesystem::path& filename)
override;
110 virtual void get_obj(
double* obj,
int first,
int last)
const override;
112 void set_obj(
const double* obj,
int first,
int last)
override;
119 int last)
const override;
120 virtual void get_row_type(
char* qrtype,
int first,
int last)
const override;
121 virtual void get_rhs(
double* rhs,
int first,
int last)
const override;
122 virtual void get_rhs_range(
double* range,
int first,
int last)
const override;
123 virtual void get_col_type(
char* coltype,
int first,
int last)
const override;
124 virtual void get_lb(
double* lb,
int fisrt,
int last)
const override;
125 virtual void get_ub(
double* ub,
int fisrt,
int last)
const override;
129 virtual std::vector<std::string>
get_row_names(
int first,
int last)
override;
131 virtual std::vector<std::string>
get_col_names(
int first,
int last)
override;
140 virtual void del_rows(
int first,
int last)
override;
148 const double* dmatval,
149 const std::vector<std::string>& row_names)
override;
155 const double* dmatval,
158 const std::vector<std::string>& col_names)
override;
159 virtual void add_name(
int type,
const char* cnames,
int indice)
override;
160 virtual void add_names(
int type,
161 const std::vector<std::string>& cnames,
164 virtual void chg_obj(
const std::vector<int>& mindex,
const std::vector<double>& obj)
override;
166 virtual void chg_bounds(
const std::vector<int>& mindex,
167 const std::vector<char>& qbtype,
168 const std::vector<double>& bnd);
169 virtual void chg_col_type(
const std::vector<int>& mindex,
170 const std::vector<char>& qctype)
override;
171 virtual void chg_rhs(
int id_row,
double val)
override;
172 virtual void chg_coef(
int id_row,
int id_col,
double val)
override;
173 virtual void chg_row_name(
int id_row,
const std::string& name)
override;
174 virtual void chg_col_name(
int id_col,
const std::string& name)
override;
205 virtual void get_basis(
int* rstatus,
int* cstatus)
const override;
209 virtual void get_lp_sol(
double* primals,
double* duals,
double* reduced_costs)
const override;
210 virtual void get_mip_sol(
double* primals)
override;
219 virtual void set_algorithm(
const std::string& algo)
override;
Definition SolverAbstract.h:200
std::shared_ptr< SolverAbstract > Ptr
Definition SolverAbstract.h:215
Definition SolverClp.h:22
virtual void set_threads(int n_threads) override
Sets the maximum number of threads used to perform optimization.
Definition SolverClp.cpp:717
virtual 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 SolverClp.cpp:203
virtual std::vector< std::string > get_col_names() override
Returns the names of columns.
Definition SolverClp.cpp:343
virtual void set_algorithm(const std::string &algo) override
Sets algorithm used by solver to solve LP's.
Definition SolverClp.cpp:705
SolverClp()
Default constructor of a CLP solver.
Definition SolverClp.cpp:22
virtual void write_prob_lp(const std::filesystem::path &filename) override
writes an optimization problem in a LP file
Definition SolverClp.cpp:92
virtual void write_prob_mps(const std::filesystem::path &filename) override
writes an optimization problem in a MPS file
Definition SolverClp.cpp:82
virtual void write_basis(const std::filesystem::path &filename) override
Writes the current basis to a file for later input into the optimizer.
Definition SolverClp.cpp:97
virtual int solve_lp() override
Solves a problem as LP.
Definition SolverClp.cpp:559
virtual void chg_col_type(const std::vector< int > &mindex, const std::vector< char > &qctype) override
Change type of some columns.
Definition SolverClp.cpp:474
virtual void free() override
Frees all the datas contained in the Solver environment.
Definition SolverClp.cpp:73
virtual int get_n_integer_vars() const override
returns number of integer variables in the problem
Definition SolverClp.cpp:157
virtual void get_ub(double *ub, int fisrt, int last) const override
Returns the upper bounds for variables in a given range.
Definition SolverClp.cpp:272
virtual void get_col_type(char *coltype, int first, int last) const override
Returns the column types for the columns in a given range.
Definition SolverClp.cpp:237
virtual void get_row_type(char *qrtype, int first, int last) const override
Returns the row types for the rows in a given range.
Definition SolverClp.cpp:216
virtual void chg_obj(const std::vector< int > &mindex, const std::vector< double > &obj) override
Change coefficients in objective function.
Definition SolverClp.cpp:431
virtual void chg_bounds(const std::vector< int > &mindex, const std::vector< char > &qbtype, const std::vector< double > &bnd)
Change bounds of some variables.
Definition SolverClp.cpp:446
virtual 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 SolverClp.cpp:389
virtual void read_basis(const std::filesystem::path &filename) override
Instructs the optimizer to read in a previously saved basis from a file.
Definition SolverClp.cpp:127
virtual void get_mip_sol(double *primals) override
Get MIP solution of a problem (available after method "solve_mip")
Definition SolverClp.cpp:677
virtual double get_lp_value() const override
Get the optimal value of a LP problem (available after method "solve_lp" )
Definition SolverClp.cpp:635
virtual void get_obj(double *obj, int first, int last) const override
returns the objective function coefficients for the columns in a given range
Definition SolverClp.cpp:171
virtual int get_splex_num_of_ite_last() const override
Get the number of simplex iterations done in the last resolution of the problem.
Definition SolverClp.cpp:640
virtual void get_lb(double *lb, int fisrt, int last) const override
Returns the lower bounds for variables in a given range.
Definition SolverClp.cpp:262
virtual int get_ncols() const override
returns number of columns of the problem
Definition SolverClp.cpp:142
virtual void set_optimality_gap(double gap) override
Sets the optimality gap.
Definition SolverClp.cpp:722
virtual void chg_coef(int id_row, int id_col, double val) override
Change a coefficient in the matrix.
Definition SolverClp.cpp:537
virtual std::string get_solver_name() const override
Returns the solver used.
Definition SolverClp.h:63
virtual void init() override
Initializes a problem.
Definition SolverClp.cpp:68
virtual void add_name(int type, const char *cnames, int indice) override
Adds a name to a row or a column.
Definition SolverClp.cpp:418
virtual int get_nrows() const override
returns number of rows of the problem
Definition SolverClp.cpp:147
virtual void get_rhs(double *rhs, int first, int last) const override
Returns the right-hand sides of the rows in a given range.
Definition SolverClp.cpp:224
virtual void chg_obj_direction(const bool minimize) override
Change the problem's objective function sense to minimize or maximize.
Definition SolverClp.cpp:440
virtual std::vector< std::string > get_row_names() override
Returns the names of rows.
Definition SolverClp.cpp:326
void restore_prob(const std::filesystem::path &filename) override
Definition SolverClp.cpp:745
virtual void chg_row_name(int id_row, const std::string &name) override
Change the name of a constraint.
Definition SolverClp.cpp:543
void set_obj_to_zero() override
Set the objective function coefficients to zero.
Definition SolverClp.cpp:181
virtual void set_simplex_iter(int iter) override
Sets the maximum number of simplex iterations the solver can perform.
Definition SolverClp.cpp:727
virtual void read_prob_mps(const std::filesystem::path &filename) override
reads an optimization problem contained in a MPS file
Definition SolverClp.cpp:111
virtual int get_col_index(const std::string &name) override
Returns the index of column named "name".
Definition SolverClp.cpp:298
virtual void copy_prob(const SolverAbstract::Ptr fictif_solv) override
copy an existing problem
Definition SolverClp.cpp:132
virtual double get_mip_value() const override
Get the optimal value of a MIP problem (available after method "solve_mip")
Definition SolverClp.cpp:630
void set_obj(const double *obj, int first, int last) override
Set the objective function coefficients for the columns in a given range.
Definition SolverClp.cpp:188
virtual void del_rows(int first, int last) override
Deletes rows between index first and last.
Definition SolverClp.cpp:353
virtual void chg_col_name(int id_col, const std::string &name) override
Change the name of a variable.
Definition SolverClp.cpp:549
void save_prob(const std::filesystem::path &filename) override
Definition SolverClp.cpp:736
virtual 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 SolverClp.cpp:231
virtual int get_row_index(const std::string &name) override
Returns the index of row named "name".
Definition SolverClp.cpp:282
void set_output_log_level(int loglevel) final
Sets log level of the solver.
Definition SolverClp.cpp:693
virtual int get_nelems() const override
returns number of non zeros elements in the matrix, excluding objective
Definition SolverClp.cpp:152
virtual void read_prob_lp(const std::filesystem::path &filename) override
reads an optimization problem contained in a MPS file
Definition SolverClp.cpp:122
virtual int solve_mip() override
Solves a problem as MIP.
Definition SolverClp.cpp:585
virtual int get_number_of_instances() override
Returns number of instances of solver currently in memory.
Definition SolverClp.cpp:54
virtual void get_basis(int *rstatus, int *cstatus) const override
Returns the current basis into the user’s data arrays.
Definition SolverClp.cpp:615
virtual void chg_rhs(int id_row, double val) override
Change rhs of a row.
Definition SolverClp.cpp:502
virtual 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 SolverClp.cpp:645
virtual 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 SolverClp.cpp:363
Definition SolverAbstract.h:17