50#ifndef __LRSWrapper_WRAPPER__H__
51#define __LRSWrapper_WRAPPER__H__
63#include <unordered_set>
77# define FORMAT "%4.4lu"
78# define MAXD 2147483647L
85# define MAXD 9223372036854775807L
86# define BASE 1000000000L
87# define FORMAT "%9.9lu"
95typedef __int64 int64_t;
96typedef unsigned __int64 uint64_t;
103#define enumStringify(name) #name
118 template <
typename GUM_SCALAR >
121 using matrix =
typename std::vector< std::vector< GUM_SCALAR > >;
250 std::vector< int64_t >& Num,
251 std::vector< int64_t >& Den)
const;
375 void fillH(
const GUM_SCALAR& min,
const GUM_SCALAR& max,
const Size& modal);
394 void fillV(
const std::vector< GUM_SCALAR >& vertex);
#define enumStringify(name)
std::unordered_set< int > _insertedModals_
To keep track of which constraints over modalities have been inserted.
_states_ _state_
The current state of the LrsWrapper.
const matrix & getOutput() const
Get the output matrix solution of the problem.
typename std::vector< std::vector< GUM_SCALAR > > matrix
Shortcut for dynamic matrix using vectors.
lrs_mp_vector _lrsOutput_
One line of output of lrs : aither a ray, a vertex, a facet or a linearity.
std::vector< std::vector< GUM_SCALAR > > _insertedVertices_
To keep track of inserted vertices and total.
const char * _setUpStateNames_[5]
To print an enum field name instead of it's value.
void setUpV(const Size &card, const Size &vertices)
Sets up a V-representation.
void H2V()
H-representation to V-representation.
void computeVolume()
Computes a polytope ( pseudo ) volume from it's V-representation.
lrs_mp_matrix _Lin_
Holds lrs input linearities if any are found.
void _initLrs_()
Initialize lrs structs and first basis according to flags.
std::vector< GUM_SCALAR > _vertex_
In case we have lower = upper for all modalities, a point probability, there is no need to use lrs.
lrs_dat * _dat_
Structure for holding static problem data of lrs.
void elimRedundVrep()
V-Redundancy elimination.
void fillMatrix(const std::vector< std::vector< GUM_SCALAR > > &matrix)
Fill the H-representation from the matrix given in argument.
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_.
const matrix & getInput() const
Get the intput matrix of the problem.
matrix _output_
Output matrix - either a V-representation or an H-representation.
void _getLRSWrapperOutput_(lrs_mp Nin, lrs_mp Din, std::vector< int64_t > &Num, std::vector< int64_t > &Den) const
Translate a single output from lrs.
unsigned int _vertices_
The number of vertices of the polytope.
LRSWrapper()
Default Constructor.
_states_
The possible states of the LrsWrapper.
void fillV(const std::vector< GUM_SCALAR > &vertex)
Creates the V-representation of a polytope by adding a vertex to the problem input _input_.
unsigned int _card_
Cardinality of the variable.
void _fill_() const
Fill lrs_dictionnary and datas from _input_ using integer rationals.
void V2H()
V-representation to H-representation.
GUM_SCALAR _volume_
The volume of the polytope, if computed, 0 otherwise.
void _freeLrs_()
Free lrs space.
void tearDown()
Reset the wrapper as if it was built.
matrix _input_
Input matrix - either a V-representation or an H-representation.
const unsigned int & getVerticesNumber() const
Get the number of vertices of this polytope.
lrs_dic * _dic_
Structure for holding current dictionary and indices of lrs.
const GUM_SCALAR & getVolume() const
Get the volume of the polytope that has been computed.
~LRSWrapper()
Default Destructor.
int _oldCout_
File descriptor of standard cout.
void setUpH(const Size &card)
Sets up an H-representation.
void nextHInput()
Reset the wrapper for next computation for a H-representation with the same variable cardinality and ...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
gum is the global namespace for all aGrUM entities
Class template used to approximate decimal numbers by rationals.