![]() |
aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
|
Class representing a linear program. More...
#include <agrum/CN/LpInterface.h>
Public Member Functions | |
| LpCol | addCol () |
| Insert a new column, i.e. | |
| std::vector< LpCol > | addCols (const unsigned int &cols) |
| Insert new columns, i.e. | |
| void | addRow (const LpExpr &expr) |
| Add rows to the linear program according to a given expression ( which must be at least an inequality ). | |
| void | addRow (LpExpr &&expr) |
| Add rows to the linear program according to a given expression ( which must be at least an inequality ). | |
| void | addPositivity () |
| Add positivity constraints for all variables. | |
| void | addSumIsOne () |
| Add sum of variables is 1 constraints. | |
| void | addProba () |
| Add positivity constraints and sum of variables is 1 ( probability constraints ). | |
| 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). | |
| std::vector< LpCol > | getCols () const |
| Get the variables of the LP. | |
| std::string | toString () const |
| Get the string representation of a calling linear program. | |
| void | clear () |
| Reset the rows (inequalities) and columns (variables) of the LP as if it was created. | |
| void | clearRows () |
| Reset the rows (inequalities) of the LP but not the columns (variables are kept). | |
Constructor / Destructor | |
| LpInterface () | |
| Default constructor, empty problem. | |
| LpInterface (const LpInterface< GUM_SCALAR > &from) | |
| Copy constructor. | |
| LpInterface (LpInterface< GUM_SCALAR > &&from) | |
| Move copy constructor. | |
| ~LpInterface () | |
| Default destructor. | |
Compound assignment operator | |
| LpInterface< GUM_SCALAR > & | operator= (const LpInterface< GUM_SCALAR > &from) |
| Copy compound assignment. | |
| LpInterface< GUM_SCALAR > & | operator= (LpInterface< GUM_SCALAR > &&from) |
| Move coumpound assignment. | |
Private Attributes | |
| std::vector< LpRow * > | _rows_ |
| Rows of the problem. | |
| std::vector< LpCol > | _cols_ |
| Variables of the problem. | |
| bool | _positivity_ |
true if addPositivity() has been called, false otherwise. | |
| bool | _sumIsOne_ |
true if addSumIsOne() has been called, false otherwise. | |
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 << ). | |
Class representing a linear program.
Definition at line 624 of file LpInterface.h.
| gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface | ( | ) |
Default constructor, empty problem.
class LpInterface
Definition at line 110 of file LpInterface_tpl.h.
References LpInterface(), _positivity_, and _sumIsOne_.
Referenced by LpInterface(), LpInterface(), LpInterface(), ~LpInterface(), operator<<, operator=(), and operator=().
| gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface | ( | const LpInterface< GUM_SCALAR > & | from | ) |
Copy constructor.
| from | The LpInterface to be copied. |
Definition at line 117 of file LpInterface_tpl.h.
References LpInterface(), _cols_, _positivity_, _rows_, and _sumIsOne_.
| gum::credal::lp::LpInterface< GUM_SCALAR >::LpInterface | ( | LpInterface< GUM_SCALAR > && | from | ) |
Move copy constructor.
| from | The temporary LpInterface to be moved. |
Definition at line 128 of file LpInterface_tpl.h.
References LpInterface(), _cols_, _positivity_, _rows_, and _sumIsOne_.
| gum::credal::lp::LpInterface< GUM_SCALAR >::~LpInterface | ( | ) |
Default destructor.
Definition at line 136 of file LpInterface_tpl.h.
References LpInterface(), and _rows_.
| LpCol gum::credal::lp::LpInterface< GUM_SCALAR >::addCol | ( | ) |
| 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 193 of file LpInterface_tpl.h.
References gum::credal::lp::LpCol::LpCol(), _cols_, and GUM_ERROR.
| void gum::credal::lp::LpInterface< GUM_SCALAR >::addPositivity | ( | ) |
Add positivity constraints for all variables.
Definition at line 256 of file LpInterface_tpl.h.
References _cols_, _positivity_, and addRow().
Referenced by addProba().
| void gum::credal::lp::LpInterface< GUM_SCALAR >::addProba | ( | ) |
Add positivity constraints and sum of variables is 1 ( probability constraints ).
Definition at line 280 of file LpInterface_tpl.h.
References _cols_, _positivity_, _sumIsOne_, addPositivity(), addRow(), and 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 208 of file LpInterface_tpl.h.
References gum::credal::lp::LpRow::LpRow(), _cols_, gum::credal::lp::LpExpr::_ileft_, gum::credal::lp::LpExpr::_iright_, _rows_, GUM_ERROR, and gum::credal::lp::LpExpr::toString().
Referenced by addPositivity(), addProba(), and 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 228 of file LpInterface_tpl.h.
References gum::credal::lp::LpRow::LpRow(), _cols_, gum::credal::lp::LpExpr::_imiddle_, gum::credal::lp::LpExpr::_mCoeffs_, gum::credal::lp::LpExpr::_mValue_, _rows_, and GUM_ERROR.
| void gum::credal::lp::LpInterface< GUM_SCALAR >::addSumIsOne | ( | ) |
Add sum of variables is 1 constraints.
Definition at line 266 of file LpInterface_tpl.h.
References _cols_, _sumIsOne_, and addRow().
Referenced by 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 358 of file LpInterface_tpl.h.
References _cols_, _positivity_, _rows_, and _sumIsOne_.
Referenced by operator=().
| 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 376 of file LpInterface_tpl.h.
References _positivity_, _rows_, and _sumIsOne_.
| std::vector< LpCol > gum::credal::lp::LpInterface< GUM_SCALAR >::getCols | ( | ) | const |
Get the variables of the LP.
Definition at line 334 of file LpInterface_tpl.h.
References _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 145 of file LpInterface_tpl.h.
References LpInterface(), gum::credal::lp::LpRow::LpRow(), _cols_, _positivity_, _rows_, _sumIsOne_, and clear().
| 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 167 of file LpInterface_tpl.h.
References LpInterface(), _cols_, _positivity_, _rows_, and _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 308 of file LpInterface_tpl.h.
References _cols_, _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 339 of file LpInterface_tpl.h.
References _cols_, and _rows_.
Referenced by operator<<.
|
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 178 of file LpInterface_tpl.h.
References LpInterface(), operator<<, and toString().
Referenced by operator<<.
|
private |
Variables of the problem.
Definition at line 774 of file LpInterface.h.
Referenced by LpInterface(), LpInterface(), addCol(), addCols(), addPositivity(), addProba(), addRow(), addRow(), addSumIsOne(), clear(), getCols(), operator=(), operator=(), solve(), and toString().
|
private |
true if addPositivity() has been called, false otherwise.
Definition at line 778 of file LpInterface.h.
Referenced by LpInterface(), LpInterface(), LpInterface(), addPositivity(), addProba(), clear(), clearRows(), operator=(), and operator=().
|
private |
Rows of the problem.
Definition at line 772 of file LpInterface.h.
Referenced by LpInterface(), LpInterface(), ~LpInterface(), addRow(), addRow(), clear(), clearRows(), operator=(), operator=(), solve(), and toString().
|
private |
true if addSumIsOne() has been called, false otherwise.
Definition at line 781 of file LpInterface.h.
Referenced by LpInterface(), LpInterface(), LpInterface(), addProba(), addSumIsOne(), clear(), clearRows(), operator=(), and operator=().