![]() |
aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
|
Class template acting as a wrapper for Lexicographic Reverse Search by David Avis. More...
#include <agrum/CN/LrsWrapper.h>
Public Member Functions | |
Constructors / Destructors | |
LRSWrapper () | |
Default Constructor. More... | |
~LRSWrapper () | |
Default Destructor. More... | |
Getters and setters | |
const matrix & | getInput () const |
Get the intput matrix of the problem. More... | |
const matrix & | getOutput () const |
Get the output matrix solution of the problem. More... | |
const unsigned int & | getVerticesNumber () const |
Get the number of vertices of this polytope. More... | |
const GUM_SCALAR & | getVolume () const |
Get the volume of the polytope that has been computed. More... | |
setUp / tearDown | |
void | setUpH (const Size &card) |
Sets up an H-representation. More... | |
void | setUpV (const Size &card, const Size &vertices) |
Sets up a V-representation. More... | |
void | tearDown () |
Reset the wrapper as if it was built. More... | |
void | nextHInput () |
Reset the wrapper for next computation for a H-representation with the same variable cardinality and number of inequalities. More... | |
Input filling methods | |
void | fillH (const GUM_SCALAR &min, const GUM_SCALAR &max, const Size &modal) |
Creates the H-representation of min <= p(X=modal | .) <= max and add it to the problem input input__ . More... | |
void | fillMatrix (const std::vector< std::vector< GUM_SCALAR > > &matrix) |
Fill the H-representation from the matrix given in argument. More... | |
void | fillV (const std::vector< GUM_SCALAR > &vertex) |
Creates the V-representation of a polytope by adding a vertex to the problem input input__ . More... | |
lrs algorithms | |
void | H2V () |
H-representation to V-representation. More... | |
void | V2H () |
V-representation to H-representation. More... | |
void | computeVolume () |
Computes a polytope ( pseudo ) volume from it's V-representation. More... | |
void | elimRedundVrep () |
V-Redundancy elimination. More... | |
Class template acting as a wrapper for Lexicographic Reverse Search by David Avis.
GUM_SCALAR | A floating type ( float, double, long double ... ). |
Definition at line 106 of file LrsWrapper.h.
|
private |
Shortcut for dynamic matrix using vectors.
Definition at line 109 of file LrsWrapper.h.
|
strongprivate |
The possible states of the LrsWrapper.
Some functions will throw an exception if the state is not correct. It allows the user to avoid making - invisible - mistakes.
Enumerator | |
---|---|
none | |
Hup | |
Vup | |
H2Vready | |
V2Hready |
Definition at line 143 of file LrsWrapper.h.
gum::credal::LRSWrapper< GUM_SCALAR >::LRSWrapper | ( | ) |
Default Constructor.
Definition at line 31 of file LrsWrapper_tpl.h.
gum::credal::LRSWrapper< GUM_SCALAR >::~LRSWrapper | ( | ) |
void gum::credal::LRSWrapper< GUM_SCALAR >::computeVolume | ( | ) |
Computes a polytope ( pseudo ) volume from it's V-representation.
Definition at line 370 of file LrsWrapper_tpl.h.
|
private |
The function that redirects standard cout to /dev/null.
Definition at line 724 of file LrsWrapper_tpl.h.
|
private |
The function that restores standard cout.
Definition at line 738 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::elimRedundVrep | ( | ) |
V-Redundancy elimination.
Eliminates redundant vertices from a polytope V-representation input input__
.
Definition at line 424 of file LrsWrapper_tpl.h.
|
private |
Fill lrs_dictionnary and datas from input__
using integer rationals.
Build polyhedron constraints and objective. Rational< GUM_SCALAR >::continuedFrac is the default algorithm used to approximate reals by integer rationals.
Definition at line 562 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::fillH | ( | const GUM_SCALAR & | min, |
const GUM_SCALAR & | max, | ||
const Size & | modal | ||
) |
Creates the H-representation of min <= p(X=modal | .) <= max and add it to the problem input input__
.
min | The lower value of p(X=modal | .). |
max | The upper value of p(X=modal | .). |
modal | The modality on which we put constraints. |
Definition at line 185 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::fillMatrix | ( | const std::vector< std::vector< GUM_SCALAR > > & | matrix | ) |
Fill the H-representation from the matrix given in argument.
matrix | The H-representation of the polytope of the form 0 <= -b
|
Definition at line 215 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::fillV | ( | const std::vector< GUM_SCALAR > & | vertex | ) |
Creates the V-representation of a polytope by adding a vertex to the problem input input__
.
vertex | The vertex we wish to add to the V-representation of the polytope. |
Definition at line 240 of file LrsWrapper_tpl.h.
|
private |
Free lrs space.
Definition at line 695 of file LrsWrapper_tpl.h.
auto gum::credal::LRSWrapper< GUM_SCALAR >::getInput | ( | ) | const |
Get the intput matrix of the problem.
intput__
matrix. Definition at line 52 of file LrsWrapper_tpl.h.
|
private |
Translate a single output from lrs.
Only vertices are supposed to be read at this step.
Nin | Input numerators in mp format (returned by lrs). |
Din | Input denominators in mp format (returned by lrs). |
Num | Output integer numerators. |
Den | Output integer denominators. |
Definition at line 503 of file LrsWrapper_tpl.h.
auto gum::credal::LRSWrapper< GUM_SCALAR >::getOutput | ( | ) | const |
Get the output matrix solution of the problem.
output__
matrix. Definition at line 57 of file LrsWrapper_tpl.h.
const unsigned int & gum::credal::LRSWrapper< GUM_SCALAR >::getVerticesNumber | ( | ) | const |
Get the number of vertices of this polytope.
vertices__
. Definition at line 62 of file LrsWrapper_tpl.h.
const GUM_SCALAR & gum::credal::LRSWrapper< GUM_SCALAR >::getVolume | ( | ) | const |
Get the volume of the polytope that has been computed.
Definition at line 67 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::H2V | ( | ) |
H-representation to V-representation.
Computes the V-representation of a polytope, i.e. it's vertices, from it's H-representation, i.e. the hyper-plan inequalities.
Definition at line 284 of file LrsWrapper_tpl.h.
|
private |
Initialize lrs structs and first basis according to flags.
Definition at line 599 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::nextHInput | ( | ) |
Reset the wrapper for next computation for a H-representation with the same variable cardinality and number of inequalities.
Usefull when creating credal networks specified as intervals over modalities.
Reset wrapper state state__
to it's previous state and clear output matrix output__
. Keeps the cardinality card__
of the variable and therefor the input matrix intput__
structure.
Definition at line 153 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::setUpH | ( | const Size & | card | ) |
Sets up an H-representation.
Initialize input matrix input__
to correct dimensions and wrapper state state__
to states__::Hup
.
card | A constant reference to the cardinality of the variable. |
Definition at line 79 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::setUpV | ( | const Size & | card, |
const Size & | vertices | ||
) |
Sets up a V-representation.
Initialize input matrix input__
to correct dimensions and wrapper state state__
to states__::Vup
.
card | A constant reference to the cardinality of the variable. |
vertices | A constant reference to the number of vertices of the polytope. |
Definition at line 107 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::tearDown | ( | ) |
Reset the wrapper as if it was built.
Reset wrapper state state__
to states__::none
and clear all member datas.
Definition at line 133 of file LrsWrapper_tpl.h.
void gum::credal::LRSWrapper< GUM_SCALAR >::V2H | ( | ) |
V-representation to H-representation.
Computes the H-representation of a polytope from it's V-representation.
Definition at line 360 of file LrsWrapper_tpl.h.
|
private |
Cardinality of the variable.
Definition at line 120 of file LrsWrapper.h.
|
private |
Structure for holding static problem data of lrs.
Definition at line 185 of file LrsWrapper.h.
|
private |
Structure for holding current dictionary and indices of lrs.
Definition at line 182 of file LrsWrapper.h.
|
private |
Definition at line 200 of file LrsWrapper.h.
|
private |
Definition at line 202 of file LrsWrapper.h.
|
private |
Input matrix - either a V-representation or an H-representation.
Definition at line 113 of file LrsWrapper.h.
|
private |
To keep track of which constraints over modalities have been inserted.
When the set is full, the state changes from up to ready.
Definition at line 124 of file LrsWrapper.h.
|
private |
To keep track of inserted vertices and total.
When set is full, the state changes from up to ready.
Definition at line 132 of file LrsWrapper.h.
|
private |
Holds lrs input linearities if any are found.
Definition at line 193 of file LrsWrapper.h.
|
private |
One line of output of lrs : aither a ray, a vertex, a facet or a linearity.
Definition at line 190 of file LrsWrapper.h.
|
mutableprivate |
File descriptor of standard cout.
Lrs writes a lot of stuff on standard cout. oldCout__ is used to save the current cout before redirecting it to /dev/null when calling lrs. The standard cout is restored when lrs is done.
Definition at line 176 of file LrsWrapper.h.
|
private |
Output matrix - either a V-representation or an H-representation.
Definition at line 117 of file LrsWrapper.h.
|
private |
Definition at line 204 of file LrsWrapper.h.
|
private |
To print an enum field name instead of it's value.
Used with GUM_ERROR.
Definition at line 160 of file LrsWrapper.h.
|
private |
The current state of the LrsWrapper.
Definition at line 153 of file LrsWrapper.h.
|
private |
In case we have lower = upper for all modalities, a point probability, there is no need to use lrs.
Definition at line 136 of file LrsWrapper.h.
|
private |
The number of vertices of the polytope.
Definition at line 127 of file LrsWrapper.h.
|
private |
The volume of the polytope, if computed, 0 otherwise.
Definition at line 156 of file LrsWrapper.h.