PandA-2024.02
glpk_solver.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
46 #ifndef GLPK_SOLVER_HPP
47 #define GLPK_SOLVER_HPP
48 
49 #include "custom_map.hpp"
50 #include "meilp_solver.hpp"
51 #include <iosfwd>
52 #include <string>
53 
54 #include "config_HAVE_GLPK.hpp"
56 #include "config_HAVE_GLPK_NESTED.hpp"
57 #if HAVE_GLPK_NESTED
58 #include <glpk/glpk.h>
59 #else
60 #include <glpk.h>
61 #endif
62 
63 class glpk_solver : public meilp_solver
64 {
65  private:
66  glp_prob* lp;
67 
71  glp_smcp* scp;
72 
76  glp_iocp* iocp;
77 
81  glp_bfcp* bfcp;
82 
90  void set_all_bounds() override;
91 
95  void set_all_bounds_new();
96 
101  void print(std::ostream& os) override;
102 
103  public:
104  glpk_solver();
105  ~glpk_solver() override;
106  void make(int nvars) override;
107  int solve() override;
108  int solve_ilp() override;
109  void add_row(std::map<int, double>& i_coeffs, double i_rhs, ilp_sign i_sign, const std::string& name) override;
110  void objective_add(std::map<int, double>& i_coeffs, ilp_dir dir) override;
111 
112  void set_int(int i) override;
113  void get_vars_solution(std::map<int, double>& vars) const override;
114  int get_number_constraints() const override;
115  int get_number_variables() const override;
116  void set_col_name(int var, const std::string& name) override;
117 
123  std::string get_col_name(int var) override;
124 
125  int add_empty_column() override;
126 
131  void print_to_file(const std::string& file_name) override;
132 };
133 #endif
int solve() override
Solve the linear problem.
void set_all_bounds() override
Set the lower and upper of the variables using lower_bounds and upper_bounds.
glp_iocp * iocp
integer solver control parameter
Definition: glpk_solver.hpp:76
void objective_add(std::map< int, double > &i_coeffs, ilp_dir dir) override
Set the objective function.
int solve_ilp() override
Solve the integer linear problem.
~glpk_solver() override
Definition: glpk_solver.cpp:75
int add_empty_column() override
Add an empty column ???
void set_col_name(int var, const std::string &name) override
Set name of a variable (column)
void set_all_bounds_new()
Set the lower and upper of the variables using lower_bounds and upper_bounds.
redefinition of map to manage ordered/unordered structures
glp_prob * lp
Definition: glpk_solver.hpp:66
bool mip_solution
it is true when solve_ilp() has been executed, false otherwise
Definition: glpk_solver.hpp:86
void print(std::ostream &os) override
Print the problem.
void print_to_file(const std::string &file_name) override
Print the problem.
ilp_dir
Type of objective function.
void set_int(int i) override
Set a variable to have only integer values.
glp_bfcp * bfcp
basis factorization control parameters
Definition: glpk_solver.hpp:81
int get_number_constraints() const override
Return the number of constraints.
Autoheader include.
Definition: glpk_solver.hpp:63
void make(int nvars) override
???
Definition: glpk_solver.cpp:97
glp_smcp * scp
simplex_control_params
Definition: glpk_solver.hpp:71
Base class providing several methods to encapsulate the interface to several ilp solver.
std::string get_col_name(int var) override
Get name of a variable (column)
void get_vars_solution(std::map< int, double > &vars) const override
Return the solution of the problem.
ilp_sign
Possible operator in constraints.
int get_number_variables() const override
Return the number of variables.
void add_row(std::map< int, double > &i_coeffs, double i_rhs, ilp_sign i_sign, const std::string &name) override
Add a constraint to the ilp formulation.
This class provide an interface to different solvers.

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13