![]() |
aGrUM
0.16.0
|
Class representing a linear program. More...
#include <agrum/CN/LpInterface.h>
Public Member Functions | |
LpCol | addCol () |
Insert a new column, i.e. More... | |
std::vector< LpCol > | addCols (const unsigned int &cols) |
Insert new columns, i.e. More... | |
void | addRow (const LpExpr &expr) |
Add rows to the linear program according to a given expression ( which must be at least an inequality ). More... | |
void | addRow (LpExpr &&expr) |
Add rows to the linear program according to a given expression ( which must be at least an inequality ). More... | |
void | addPositivity () |
Add positivity constraints for all variables. More... | |
void | addSumIsOne () |
Add sum of variables is 1 constraints. More... | |
void | addProba () |
Add positivity constraints and sum of variables is 1 ( probability constraints ) More... | |
std::vector< std::vector< GUM_SCALAR > > | solve () |
Solve the linear program (H-representation of the polytope) by enumeration (of the polytope vertices) using lexicographic reverse search (lrs). More... | |
std::vector< LpCol > | getCols () const |
Get the variables of the LP. More... | |
std::string | toString () const |
Get the string representation of a calling linear program. More... | |
void | clear () |
Reset the rows (inequalities) and columns (variables) of the LP as if it was created. More... | |
void | clearRows () |
Reset the rows (inequalities) of the LP but not the columns (variables are kept). More... | |
Constructor / Destructor | |
LpInterface () | |
Default constructor, empty problem. More... | |
LpInterface (const LpInterface< GUM_SCALAR > &from) | |
Copy constructor. More... | |
LpInterface (LpInterface< GUM_SCALAR > &&from) | |
Move copy constructor. More... | |
~LpInterface () | |
Default destructor. More... | |
Compound assignment operator | |
LpInterface< GUM_SCALAR > & | operator= (const LpInterface< GUM_SCALAR > &from) |
Copy compound assignment. More... | |
LpInterface< GUM_SCALAR > & | operator= (LpInterface< GUM_SCALAR > &&from) |
Move coumpound assignment. More... | |
Friends | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, const LpInterface< T > &lpi) |
Overload of << to use with output streams ( such as std::cout << ). More... | |
Class representing a linear program.
Definition at line 49 of file LpInterface.h.
gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface | ( | ) |
Default constructor, empty problem.
class LpInterface
Definition at line 750 of file LpInterface_tpl.h.
gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface | ( | const LpInterface< GUM_SCALAR > & | from | ) |
Copy constructor.
from | The LpInterface to be copied. |
Definition at line 757 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__rows.
gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface | ( | LpInterface< GUM_SCALAR > && | from | ) |
Move copy constructor.
from | The temporary LpInterface to be moved. |
Definition at line 770 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, and gum::credal::lp::LpInterface< GUM_SCALAR >::__rows.
gum::credal::lp::LpInterface< GUM_SCALAR >::~LpInterface | ( | ) |
Default destructor.
Definition at line 778 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, and gum::credal::lp::LpInterface< GUM_SCALAR >::operator=().
LpCol gum::credal::lp::LpInterface< GUM_SCALAR >::addCol | ( | ) |
Insert a new column, i.e.
a new variable.
Definition at line 826 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols.
std::vector< LpCol > gum::credal::lp::LpInterface< GUM_SCALAR >::addCols | ( | const unsigned int & | cols | ) |
Insert new columns, i.e.
new variables.
cols | the constant reference to the number of variables we want. |
Definition at line 836 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, and GUM_ERROR.
void gum::credal::lp::LpInterface< GUM_SCALAR >::addPositivity | ( | ) |
Add positivity constraints for all variables.
Definition at line 903 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__positivity, and gum::credal::lp::LpInterface< GUM_SCALAR >::addRow().
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addProba().
void gum::credal::lp::LpInterface< GUM_SCALAR >::addProba | ( | ) |
Add positivity constraints and sum of variables is 1 ( probability constraints )
Definition at line 927 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__positivity, gum::credal::lp::LpInterface< GUM_SCALAR >::__sumIsOne, gum::credal::lp::LpInterface< GUM_SCALAR >::addPositivity(), gum::credal::lp::LpInterface< GUM_SCALAR >::addRow(), and gum::credal::lp::LpInterface< GUM_SCALAR >::addSumIsOne().
void gum::credal::lp::LpInterface< GUM_SCALAR >::addRow | ( | const LpExpr & | expr | ) |
Add rows to the linear program according to a given expression ( which must be at least an inequality ).
expr | the constant reference to the expression to convert to rows. |
Definition at line 851 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpExpr::__ileft, gum::credal::lp::LpExpr::__iright, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, GUM_ERROR, and gum::credal::lp::LpExpr::toString().
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addPositivity(), gum::credal::lp::LpInterface< GUM_SCALAR >::addProba(), and gum::credal::lp::LpInterface< GUM_SCALAR >::addSumIsOne().
void gum::credal::lp::LpInterface< GUM_SCALAR >::addRow | ( | LpExpr && | expr | ) |
Add rows to the linear program according to a given expression ( which must be at least an inequality ).
expr | the temporary expression to move to rows. |
Definition at line 873 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpExpr::__imiddle, gum::credal::lp::LpExpr::__mCoeffs, gum::credal::lp::LpExpr::__mValue, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, and GUM_ERROR.
void gum::credal::lp::LpInterface< GUM_SCALAR >::addSumIsOne | ( | ) |
Add sum of variables is 1 constraints.
Definition at line 913 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__sumIsOne, and gum::credal::lp::LpInterface< GUM_SCALAR >::addRow().
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addProba().
void gum::credal::lp::LpInterface< GUM_SCALAR >::clear | ( | ) |
Reset the rows (inequalities) and columns (variables) of the LP as if it was created.
Definition at line 1005 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__positivity, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, and gum::credal::lp::LpInterface< GUM_SCALAR >::__sumIsOne.
void gum::credal::lp::LpInterface< GUM_SCALAR >::clearRows | ( | ) |
Reset the rows (inequalities) of the LP but not the columns (variables are kept).
Definition at line 1023 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__positivity, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, and gum::credal::lp::LpInterface< GUM_SCALAR >::__sumIsOne.
std::vector< LpCol > gum::credal::lp::LpInterface< GUM_SCALAR >::getCols | ( | ) | const |
Get the variables of the LP.
Definition at line 981 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols.
LpInterface< GUM_SCALAR > & gum::credal::lp::LpInterface< GUM_SCALAR >::operator= | ( | const LpInterface< GUM_SCALAR > & | from | ) |
Copy compound assignment.
from | The LpInterface to be copied. |
Definition at line 787 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__positivity, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, and gum::credal::lp::LpInterface< GUM_SCALAR >::__sumIsOne.
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::~LpInterface().
LpInterface< GUM_SCALAR > & gum::credal::lp::LpInterface< GUM_SCALAR >::operator= | ( | LpInterface< GUM_SCALAR > && | from | ) |
Move coumpound assignment.
from | The temporary LpInterface to be moved. |
Definition at line 809 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__positivity, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, and gum::credal::lp::LpInterface< GUM_SCALAR >::__sumIsOne.
std::vector< std::vector< GUM_SCALAR > > gum::credal::lp::LpInterface< GUM_SCALAR >::solve | ( | ) |
Solve the linear program (H-representation of the polytope) by enumeration (of the polytope vertices) using lexicographic reverse search (lrs).
Only works with bounded polyhedron (polytopes) and not unbounded ones (i.e. defined by vertices and rays).
Definition at line 955 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, gum::credal::lp::LpInterface< GUM_SCALAR >::__rows, gum::credal::LRSWrapper< GUM_SCALAR >::fillMatrix(), gum::credal::LRSWrapper< GUM_SCALAR >::getOutput(), gum::credal::LRSWrapper< GUM_SCALAR >::H2V(), and gum::credal::LRSWrapper< GUM_SCALAR >::setUpH().
std::string gum::credal::lp::LpInterface< GUM_SCALAR >::toString | ( | ) | const |
Get the string representation of a calling linear program.
Definition at line 986 of file LpInterface_tpl.h.
References gum::credal::lp::LpInterface< GUM_SCALAR >::__cols, and gum::credal::lp::LpInterface< GUM_SCALAR >::__rows.
|
friend |
Overload of <<
to use with output streams ( such as std::cout << ).
out | the reference to the caller, i.e. left side of << . |
lpi | the constant reference to the linear program whose representation we want. |
Definition at line 820 of file LpInterface_tpl.h.
|
private |
Variables of the problem.
Definition at line 754 of file LpInterface.h.
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addCol(), gum::credal::lp::LpInterface< GUM_SCALAR >::addCols(), gum::credal::lp::LpInterface< GUM_SCALAR >::addPositivity(), gum::credal::lp::LpInterface< GUM_SCALAR >::addProba(), gum::credal::lp::LpInterface< GUM_SCALAR >::addRow(), gum::credal::lp::LpInterface< GUM_SCALAR >::addSumIsOne(), gum::credal::lp::LpInterface< GUM_SCALAR >::clear(), gum::credal::lp::LpInterface< GUM_SCALAR >::getCols(), gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface(), gum::credal::lp::LpInterface< GUM_SCALAR >::operator=(), gum::credal::lp::LpInterface< GUM_SCALAR >::solve(), and gum::credal::lp::LpInterface< GUM_SCALAR >::toString().
|
private |
true
if addPositivity() has been called, false
otherwise.
Definition at line 758 of file LpInterface.h.
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addPositivity(), gum::credal::lp::LpInterface< GUM_SCALAR >::addProba(), gum::credal::lp::LpInterface< GUM_SCALAR >::clear(), gum::credal::lp::LpInterface< GUM_SCALAR >::clearRows(), and gum::credal::lp::LpInterface< GUM_SCALAR >::operator=().
|
private |
Rows of the problem.
Definition at line 752 of file LpInterface.h.
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addRow(), gum::credal::lp::LpInterface< GUM_SCALAR >::clear(), gum::credal::lp::LpInterface< GUM_SCALAR >::clearRows(), gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface(), gum::credal::lp::LpInterface< GUM_SCALAR >::operator=(), gum::credal::lp::LpInterface< GUM_SCALAR >::solve(), gum::credal::lp::LpInterface< GUM_SCALAR >::toString(), and gum::credal::lp::LpInterface< GUM_SCALAR >::~LpInterface().
|
private |
true
if addSumIsOne() has been called, false
otherwise.
Definition at line 761 of file LpInterface.h.
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::addProba(), gum::credal::lp::LpInterface< GUM_SCALAR >::addSumIsOne(), gum::credal::lp::LpInterface< GUM_SCALAR >::clear(), gum::credal::lp::LpInterface< GUM_SCALAR >::clearRows(), and gum::credal::lp::LpInterface< GUM_SCALAR >::operator=().