PandA-2024.02
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
meilp_solver Class Referenceabstract

Base class providing several methods to encapsulate the interface to several ilp solver. More...

#include <meilp_solver.hpp>

Inheritance diagram for meilp_solver:
Inheritance graph
[legend]

Public Types

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...
 

Public Member Functions

virtual ~meilp_solver ()
 virtual destructor More...
 
virtual void make (int nvars)=0
 ??? More...
 
virtual int solve ()=0
 Solve the linear problem. More...
 
virtual int solve_ilp ()=0
 Solve the integer linear problem. More...
 
virtual void add_row (std::map< int, double > &i_coeffs, double i_rhs, ilp_sign i_sign, const std::string &name)=0
 Add a constraint to the ilp formulation. More...
 
virtual void objective_add (std::map< int, double > &i_coeffs, ilp_dir dir)=0
 Set the objective function. More...
 
virtual void set_binary (int i)
 Set a variable to have only binary values. More...
 
virtual void set_int (int i)=0
 Set a variable to have only integer 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...
 
virtual void get_vars_solution (std::map< int, double > &vars) const =0
 Return the solution of the problem. More...
 
virtual int get_number_constraints () const =0
 Return the number of constraints. More...
 
virtual int get_number_variables () const =0
 Return the number of variables. More...
 
virtual void set_col_name (int var, const std::string &name)=0
 Set name of a variable (column) More...
 
virtual std::string get_col_name (int var)=0
 Get name of a variable (column) More...
 
virtual int add_empty_column ()=0
 Add an empty column ??? 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...
 
virtual void print_to_file (const std::string &file_name)=0
 Print the problem. More...
 

Static Public Member Functions

static meilp_solverRef create_solver (supported_solvers solver_type)
 Factory static member function. More...
 

Protected Member Functions

 meilp_solver ()
 Constructor. More...
 
void resize (size_t count)
 
virtual void copy (const std::map< int, double > &i_coeffs)
 
virtual void set_all_bounds ()=0
 Set the lower and upper of the variables using lower_bounds and upper_bounds. More...
 
virtual void print (std::ostream &os)=0
 Print the problem. More...
 

Protected Attributes

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...
 

Private Attributes

size_t nel
 number of elements in the constraint buffer More...
 

Detailed Description

Base class providing several methods to encapsulate the interface to several ilp solver.

Definition at line 73 of file meilp_solver.hpp.

Member Enumeration Documentation

◆ ilp_dir

Type of objective function.

Enumerator
min 

Minimization.

max 

Maximization.

Definition at line 163 of file meilp_solver.hpp.

◆ ilp_sign

Possible operator in constraints.

Enumerator

Greater then.

Less then.

Equal to.

Definition at line 79 of file meilp_solver.hpp.

◆ supported_solvers

List of currently supported solvers.

Definition at line 147 of file meilp_solver.hpp.

Constructor & Destructor Documentation

◆ meilp_solver()

meilp_solver::meilp_solver ( )
protected

Constructor.

Definition at line 64 of file meilp_solver.cpp.

◆ ~meilp_solver()

meilp_solver::~meilp_solver ( )
virtual

virtual destructor

Definition at line 69 of file meilp_solver.cpp.

References int_buffer, nel, and real_buffer.

Member Function Documentation

◆ add_empty_column()

virtual int meilp_solver::add_empty_column ( )
pure virtual

Add an empty column ???

Implemented in glpk_solver.

◆ add_row()

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

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

Implemented in glpk_solver.

◆ copy()

void meilp_solver::copy ( const std::map< int, double > &  i_coeffs)
protectedvirtual
Parameters
i_coeffs

Definition at line 101 of file meilp_solver.cpp.

References index, int_buffer, real_buffer, and resize().

Referenced by glpk_solver::add_row().

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

◆ create_solver()

meilp_solverRef meilp_solver::create_solver ( supported_solvers  solver_type)
static

Factory static member function.

Given the supported enum create a specialization of meilp_solver

Parameters
solver_typeis the solver.
Returns
the solver object.

Definition at line 113 of file meilp_solver.cpp.

References THROW_ERROR.

Referenced by SDCScheduling::InternalExec(), and setMaximumSeconds().

Here is the caller graph for this function:

◆ get_col_name()

virtual std::string meilp_solver::get_col_name ( int  var)
pure virtual

Get name of a variable (column)

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

Implemented in glpk_solver.

◆ get_number_constraints()

virtual int meilp_solver::get_number_constraints ( ) const
pure virtual

Return the number of constraints.

Returns
the number of constraints

Implemented in glpk_solver.

◆ get_number_variables()

virtual int meilp_solver::get_number_variables ( ) const
pure virtual

Return the number of variables.

Returns
the number of variables

Implemented in glpk_solver.

◆ get_vars_solution()

virtual void meilp_solver::get_vars_solution ( std::map< int, double > &  vars) const
pure virtual

Return the solution of the problem.

Parameters
varsis where solution are stored

Implemented in glpk_solver.

◆ make()

virtual void meilp_solver::make ( int  nvars)
pure virtual

???

Parameters
nvars

Implemented in glpk_solver.

◆ objective_add()

virtual void meilp_solver::objective_add ( std::map< int, double > &  i_coeffs,
ilp_dir  dir 
)
pure virtual

Set the objective function.

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

Implemented in glpk_solver.

◆ print()

virtual void meilp_solver::print ( std::ostream &  os)
protectedpure virtual

Print the problem.

Parameters
osis the stream on which problem has to be printed

Implemented in glpk_solver.

◆ print_to_file()

virtual void meilp_solver::print_to_file ( const std::string &  file_name)
pure virtual

Print the problem.

Parameters
file_nameis the name of the file to be written

Implemented in glpk_solver.

Referenced by setMaximumSeconds().

Here is the caller graph for this function:

◆ resize()

void meilp_solver::resize ( size_t  count)
protected
Parameters
count

Definition at line 78 of file meilp_solver.cpp.

References int_buffer, nel, real_buffer, and THROW_ASSERT.

Referenced by copy().

Here is the caller graph for this function:

◆ set_all_bounds()

virtual void meilp_solver::set_all_bounds ( )
protectedpure virtual

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

Implemented in glpk_solver.

◆ set_binary()

void meilp_solver::set_binary ( int  i)
virtual

Set a variable to have only binary values.

Parameters
iis the variable

Definition at line 136 of file meilp_solver.cpp.

References set_bnds(), and set_int().

Here is the call graph for this function:

◆ set_bnds()

void meilp_solver::set_bnds ( int  var,
double  lowbo,
double  upbo 
)
virtual

Set lower and upper bound of a variable.

Parameters
varis the variables
lowbois the lower bound
upbois the upper bound

Definition at line 142 of file meilp_solver.cpp.

References lower_bounds, and upper_bounds.

Referenced by set_binary().

Here is the caller graph for this function:

◆ set_col_name()

virtual void meilp_solver::set_col_name ( int  var,
const std::string &  name 
)
pure virtual

Set name of a variable (column)

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

Implemented in glpk_solver.

◆ set_debug_level()

void meilp_solver::set_debug_level ( int  dl)

Set the verbosity (debug_level)

Definition at line 91 of file meilp_solver.cpp.

References debug_level, and dl.

Referenced by setMaximumSeconds().

Here is the caller graph for this function:

◆ set_int()

virtual void meilp_solver::set_int ( int  i)
pure virtual

Set a variable to have only integer values.

Parameters
iis the variables

Implemented in glpk_solver.

Referenced by set_binary().

Here is the caller graph for this function:

◆ set_lowbo()

void meilp_solver::set_lowbo ( int  var,
double  bound 
)
virtual

Set lower bound of a variable.

Parameters
varis the variable
boundis the lower bound

Definition at line 148 of file meilp_solver.cpp.

References lower_bounds.

◆ set_priority()

void meilp_solver::set_priority ( const std::map< int, int > &  _priority)

Set the variable priority.

Parameters
_priorityis mapping between index variable and priority

Definition at line 96 of file meilp_solver.cpp.

References priority.

Referenced by setMaximumSeconds().

Here is the caller graph for this function:

◆ set_upbo()

void meilp_solver::set_upbo ( int  var,
double  bound 
)
virtual

Set upper bound of a variable.

Parameters
varis the variable
boundis the upper bound

Definition at line 153 of file meilp_solver.cpp.

References upper_bounds.

◆ setMaximumSeconds()

void meilp_solver::setMaximumSeconds ( int  MAX_t)
inline

???

Definition at line 280 of file meilp_solver.hpp.

References create_solver(), dl, print_to_file(), set_debug_level(), and set_priority().

Here is the call graph for this function:

◆ solve()

virtual int meilp_solver::solve ( )
pure virtual

Solve the linear problem.

Implemented in glpk_solver.

◆ solve_ilp()

virtual int meilp_solver::solve_ilp ( )
pure virtual

Solve the integer linear problem.

Implemented in glpk_solver.

Field Documentation

◆ debug_level

int meilp_solver::debug_level
protected

debug_level

Definition at line 104 of file meilp_solver.hpp.

Referenced by glpk_solver::make(), set_debug_level(), glpk_solver::solve(), and glpk_solver::solve_ilp().

◆ int_buffer

int* meilp_solver::int_buffer
protected

indexes in the constraint buffer

Definition at line 95 of file meilp_solver.hpp.

Referenced by glpk_solver::add_row(), copy(), resize(), and ~meilp_solver().

◆ lower_bounds

CustomUnorderedMap<int, double> meilp_solver::lower_bounds
protected

The lower bound of the variables. They will be really set by solve method.

Definition at line 110 of file meilp_solver.hpp.

Referenced by glpk_solver::set_all_bounds(), set_bnds(), and set_lowbo().

◆ MAX_time

int meilp_solver::MAX_time
protected

Time-out value.

Definition at line 101 of file meilp_solver.hpp.

Referenced by glpk_solver::make().

◆ nel

size_t meilp_solver::nel
private

number of elements in the constraint buffer

Definition at line 88 of file meilp_solver.hpp.

Referenced by resize(), and ~meilp_solver().

◆ priority

std::map<int, int> meilp_solver::priority
protected

variables priority

Definition at line 107 of file meilp_solver.hpp.

Referenced by set_priority().

◆ real_buffer

double* meilp_solver::real_buffer
protected

values in the constraint buffer

Definition at line 92 of file meilp_solver.hpp.

Referenced by glpk_solver::add_row(), copy(), resize(), and ~meilp_solver().

◆ unique_column_id

int meilp_solver::unique_column_id
protected

unique column identifier

Definition at line 98 of file meilp_solver.hpp.

◆ upper_bounds

CustomUnorderedMap<int, double> meilp_solver::upper_bounds
protected

The upper bound of the variables. They will be really set by solve method.

Definition at line 113 of file meilp_solver.hpp.

Referenced by glpk_solver::set_all_bounds(), set_bnds(), and set_upbo().


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

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