![]() |
aGrUM
0.16.0
|
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 107 of file LrsWrapper.h.
|
private |
Shortcut for dynamic matrix using vectors.
Definition at line 110 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 144 of file LrsWrapper.h.
gum::credal::LRSWrapper< GUM_SCALAR >::LRSWrapper | ( | ) |
Default Constructor.
Definition at line 32 of file LrsWrapper_tpl.h.
gum::credal::LRSWrapper< GUM_SCALAR >::~LRSWrapper | ( | ) |
|
private |
The function that redirects standard cout to /dev/null.
Definition at line 721 of file LrsWrapper_tpl.h.
|
private |
The function that restores standard cout.
Definition at line 735 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 561 of file LrsWrapper_tpl.h.
References gum::Rational< GUM_SCALAR >::continuedFracFirst().
|
private |
Free lrs space.
Definition at line 692 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 502 of file LrsWrapper_tpl.h.
References BASE.
|
private |
Initialize lrs structs and first basis according to flags.
Definition at line 596 of file LrsWrapper_tpl.h.
References GUM_ERROR.
void gum::credal::LRSWrapper< GUM_SCALAR >::computeVolume | ( | ) |
Computes a polytope ( pseudo ) volume from it's V-representation.
Definition at line 369 of file LrsWrapper_tpl.h.
References BASE, and GUM_ERROR.
void gum::credal::LRSWrapper< GUM_SCALAR >::elimRedundVrep | ( | ) |
V-Redundancy elimination.
Eliminates redundant vertices from a polytope V-representation input __input
.
Definition at line 423 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::InferenceEngine< GUM_SCALAR >::_updateCredalSets().
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 184 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal().
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 214 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::solve().
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 239 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::InferenceEngine< GUM_SCALAR >::_updateCredalSets().
auto gum::credal::LRSWrapper< GUM_SCALAR >::getInput | ( | ) | const |
Get the intput matrix of the problem.
__intput
matrix. Definition at line 53 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 58 of file LrsWrapper_tpl.h.
Referenced by gum::credal::InferenceEngine< GUM_SCALAR >::_updateCredalSets(), gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal(), and gum::credal::lp::LpInterface< GUM_SCALAR >::solve().
const unsigned int & gum::credal::LRSWrapper< GUM_SCALAR >::getVerticesNumber | ( | ) | const |
Get the number of vertices of this polytope.
__vertices
. Definition at line 63 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 68 of file LrsWrapper_tpl.h.
References GUM_ERROR.
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 283 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal(), and gum::credal::lp::LpInterface< GUM_SCALAR >::solve().
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 152 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal().
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 80 of file LrsWrapper_tpl.h.
References GUM_ERROR.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal(), and gum::credal::lp::LpInterface< GUM_SCALAR >::solve().
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.
References GUM_ERROR.
Referenced by gum::credal::MultipleInferenceEngine< GUM_SCALAR, BNInferenceEngine >::__updateThreadCredalSets(), and gum::credal::InferenceEngine< GUM_SCALAR >::_updateCredalSets().
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 132 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 359 of file LrsWrapper_tpl.h.
References GUM_ERROR.
|
private |
Cardinality of the variable.
Definition at line 121 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 114 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 125 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 133 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 118 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 137 of file LrsWrapper.h.
|
private |
The number of vertices of the polytope.
Definition at line 128 of file LrsWrapper.h.
|
private |
The volume of the polytope, if computed, 0 otherwise.
Definition at line 156 of file LrsWrapper.h.