PandA-2024.02
Public Member Functions | Private Member Functions | Private Attributes
glpk_solver Class Reference

Autoheader include. More...

#include <glpk_solver.hpp>

Inheritance diagram for glpk_solver:
Inheritance graph
[legend]
Collaboration diagram for glpk_solver:
Collaboration graph
[legend]

Public Member Functions

 glpk_solver ()
 
 ~glpk_solver () override
 
void make (int nvars) override
 ??? More...
 
int solve () override
 Solve the linear problem. More...
 
int solve_ilp () override
 Solve the integer linear problem. More...
 
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. More...
 
void objective_add (std::map< int, double > &i_coeffs, ilp_dir dir) override
 Set the objective function. More...
 
void set_int (int i) override
 Set a variable to have only integer values. More...
 
void get_vars_solution (std::map< int, double > &vars) const override
 Return the solution of the problem. More...
 
int get_number_constraints () const override
 Return the number of constraints. More...
 
int get_number_variables () const override
 Return the number of variables. More...
 
void set_col_name (int var, const std::string &name) override
 Set name of a variable (column) More...
 
std::string get_col_name (int var) override
 Get name of a variable (column) More...
 
int add_empty_column () override
 Add an empty column ??? More...
 
void print_to_file (const std::string &file_name) override
 Print the problem. More...
 
- Public Member Functions inherited from meilp_solver
virtual ~meilp_solver ()
 virtual destructor More...
 
virtual void set_binary (int i)
 Set a variable to have only binary values. More...
 
virtual void set_bnds (int var, double lowbo, double upbo)
 Set lower and upper bound of a variable. More...
 
virtual void set_lowbo (int var, double bound)
 Set lower bound of a variable. More...
 
virtual void set_upbo (int var, double bound)
 Set upper bound of a variable. More...
 
void setMaximumSeconds (int MAX_t)
 ??? More...
 
void set_debug_level (int dl)
 Set the verbosity (debug_level) More...
 
void set_priority (const std::map< int, int > &_priority)
 Set the variable priority. More...
 

Private Member Functions

void set_all_bounds () override
 Set the lower and upper of the variables using lower_bounds and upper_bounds. More...
 
void set_all_bounds_new ()
 Set the lower and upper of the variables using lower_bounds and upper_bounds. More...
 
void print (std::ostream &os) override
 Print the problem. More...
 

Private Attributes

glp_prob * lp
 
glp_smcp * scp
 simplex_control_params More...
 
glp_iocp * iocp
 integer solver control parameter More...
 
glp_bfcp * bfcp
 basis factorization control parameters More...
 
bool mip_solution
 it is true when solve_ilp() has been executed, false otherwise More...
 

Additional Inherited Members

- Public Types inherited from meilp_solver
enum  ilp_sign { G, L, E }
 Possible operator in constraints. More...
 
enum  supported_solvers
 List of currently supported solvers. More...
 
enum  ilp_dir { min, max }
 Type of objective function. More...
 
- Static Public Member Functions inherited from meilp_solver
static meilp_solverRef create_solver (supported_solvers solver_type)
 Factory static member function. More...
 
- Protected Member Functions inherited from meilp_solver
 meilp_solver ()
 Constructor. More...
 
void resize (size_t count)
 
virtual void copy (const std::map< int, double > &i_coeffs)
 
- Protected Attributes inherited from meilp_solver
double * real_buffer
 values in the constraint buffer More...
 
int * int_buffer
 indexes in the constraint buffer More...
 
int unique_column_id
 unique column identifier More...
 
int MAX_time
 Time-out value. More...
 
int debug_level
 debug_level More...
 
std::map< int, int > priority
 variables priority More...
 
CustomUnorderedMap< int, double > lower_bounds
 The lower bound of the variables. They will be really set by solve method. More...
 
CustomUnorderedMap< int, double > upper_bounds
 The upper bound of the variables. They will be really set by solve method. More...
 

Detailed Description

Autoheader include.

Definition at line 63 of file glpk_solver.hpp.

Constructor & Destructor Documentation

◆ glpk_solver()

glpk_solver::glpk_solver ( )

Definition at line 70 of file glpk_solver.cpp.

◆ ~glpk_solver()

glpk_solver::~glpk_solver ( )
override

Definition at line 75 of file glpk_solver.cpp.

References bfcp, iocp, lp, and scp.

Member Function Documentation

◆ add_empty_column()

int glpk_solver::add_empty_column ( )
overridevirtual

Add an empty column ???

Implements meilp_solver.

Definition at line 729 of file glpk_solver.cpp.

References lp.

◆ add_row()

void glpk_solver::add_row ( std::map< int, double > &  i_coeffs,
double  i_rhs,
ilp_sign  i_sign,
const std::string &  name 
)
overridevirtual

Add a constraint to the ilp formulation.

Parameters
i_coeffsare the coefficients of the variables in the left part
i_rhsis the constant in the right part
i_signis the operator in the constraints
nameis the name of the constraint

Implements meilp_solver.

Definition at line 608 of file glpk_solver.cpp.

References meilp_solver::copy(), meilp_solver::E, meilp_solver::G, meilp_solver::int_buffer, meilp_solver::L, lp, meilp_solver::real_buffer, THROW_ASSERT, and THROW_UNREACHABLE.

Here is the call graph for this function:

◆ get_col_name()

std::string glpk_solver::get_col_name ( int  var)
overridevirtual

Get name of a variable (column)

Parameters
varis the index of the variables return the name of the variable

Implements meilp_solver.

Definition at line 724 of file glpk_solver.cpp.

References lp.

◆ get_number_constraints()

int glpk_solver::get_number_constraints ( ) const
overridevirtual

Return the number of constraints.

Returns
the number of constraints

Implements meilp_solver.

Definition at line 642 of file glpk_solver.cpp.

References lp.

◆ get_number_variables()

int glpk_solver::get_number_variables ( ) const
overridevirtual

Return the number of variables.

Returns
the number of variables

Implements meilp_solver.

Definition at line 647 of file glpk_solver.cpp.

References lp.

◆ get_vars_solution()

void glpk_solver::get_vars_solution ( std::map< int, double > &  vars) const
overridevirtual

Return the solution of the problem.

Parameters
varsis where solution are stored

Implements meilp_solver.

Definition at line 701 of file glpk_solver.cpp.

References lp, and mip_solution.

◆ make()

void glpk_solver::make ( int  nvars)
overridevirtual

???

Parameters
nvars

Implements meilp_solver.

Definition at line 97 of file glpk_solver.cpp.

References bfcp, meilp_solver::debug_level, DEBUG_LEVEL_MINIMUM, DEBUG_LEVEL_PEDANTIC, iocp, lp, meilp_solver::MAX_time, scp, and THROW_ERROR.

◆ objective_add()

void glpk_solver::objective_add ( std::map< int, double > &  i_coeffs,
ilp_dir  dir 
)
overridevirtual

Set the objective function.

Parameters
I_coeffsare the coefficients of the variables in the objective function
diris the type of objective function

Implements meilp_solver.

Definition at line 652 of file glpk_solver.cpp.

References lp, meilp_solver::max, meilp_solver::min, THROW_ASSERT, and THROW_ERROR.

◆ print()

void glpk_solver::print ( std::ostream &  os)
overrideprivatevirtual

Print the problem.

Parameters
osis the stream on which problem has to be printed

Setting the bounds

Implements meilp_solver.

Definition at line 674 of file glpk_solver.cpp.

References lp, and set_all_bounds().

Referenced by solve(), and solve_ilp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_to_file()

void glpk_solver::print_to_file ( const std::string &  file_name)
overridevirtual

Print the problem.

Parameters
file_nameis the name of the file to be written

Setting the bounds

Implements meilp_solver.

Definition at line 685 of file glpk_solver.cpp.

References lp, and set_all_bounds().

Here is the call graph for this function:

◆ set_all_bounds()

void glpk_solver::set_all_bounds ( )
overrideprivatevirtual

Set the lower and upper of the variables using lower_bounds and upper_bounds.

Implements meilp_solver.

Definition at line 734 of file glpk_solver.cpp.

References meilp_solver::lower_bounds, lp, THROW_ASSERT, THROW_ERROR, and meilp_solver::upper_bounds.

Referenced by print(), print_to_file(), solve(), and solve_ilp().

Here is the caller graph for this function:

◆ set_all_bounds_new()

void glpk_solver::set_all_bounds_new ( )
private

Set the lower and upper of the variables using lower_bounds and upper_bounds.

◆ set_col_name()

void glpk_solver::set_col_name ( int  var,
const std::string &  name 
)
overridevirtual

Set name of a variable (column)

Parameters
varis the index of the variables
nameis the name of the variable

Implements meilp_solver.

Definition at line 718 of file glpk_solver.cpp.

References lp.

◆ set_int()

void glpk_solver::set_int ( int  i)
overridevirtual

Set a variable to have only integer values.

Parameters
iis the variables

Implements meilp_solver.

Definition at line 696 of file glpk_solver.cpp.

References lp.

◆ solve()

int glpk_solver::solve ( )
overridevirtual

Solve the linear problem.

Setting the bounds

Printing the problem

Implements meilp_solver.

Definition at line 153 of file glpk_solver.cpp.

References meilp_solver::debug_level, DEBUG_LEVEL_VERBOSE, INT_MAX, lp, mip_solution, print(), PRINT_MSG, scp, and set_all_bounds().

Here is the call graph for this function:

◆ solve_ilp()

int glpk_solver::solve_ilp ( )
overridevirtual

Solve the integer linear problem.

Setting the bounds

Printing the problem

Implements meilp_solver.

Definition at line 376 of file glpk_solver.cpp.

References bfcp, meilp_solver::debug_level, DEBUG_LEVEL_VERBOSE, iocp, lp, mip_solution, print(), PRINT_MSG, scp, and set_all_bounds().

Here is the call graph for this function:

Field Documentation

◆ bfcp

glp_bfcp* glpk_solver::bfcp
private

basis factorization control parameters

Definition at line 81 of file glpk_solver.hpp.

Referenced by make(), solve_ilp(), and ~glpk_solver().

◆ iocp

glp_iocp* glpk_solver::iocp
private

integer solver control parameter

Definition at line 76 of file glpk_solver.hpp.

Referenced by make(), solve_ilp(), and ~glpk_solver().

◆ lp

glp_prob* glpk_solver::lp
private

◆ mip_solution

bool glpk_solver::mip_solution
private

it is true when solve_ilp() has been executed, false otherwise

Definition at line 86 of file glpk_solver.hpp.

Referenced by get_vars_solution(), solve(), and solve_ilp().

◆ scp

glp_smcp* glpk_solver::scp
private

simplex_control_params

Definition at line 71 of file glpk_solver.hpp.

Referenced by make(), solve(), solve_ilp(), and ~glpk_solver().


The documentation for this class was generated from the following files:

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