aGrUM  0.16.0
gum::credal::LRSWrapper< GUM_SCALAR > Class Template Reference

Class template acting as a wrapper for Lexicographic Reverse Search by David Avis. More...

#include <agrum/CN/LrsWrapper.h>

+ Collaboration diagram for gum::credal::LRSWrapper< GUM_SCALAR >:

Public Member Functions

Constructors / Destructors
 LRSWrapper ()
 Default Constructor. More...
 
 ~LRSWrapper ()
 Default Destructor. More...
 
Getters and setters
const matrixgetInput () const
 Get the intput matrix of the problem. More...
 
const matrixgetOutput () 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...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::credal::LRSWrapper< GUM_SCALAR >

Class template acting as a wrapper for Lexicographic Reverse Search by David Avis.

Template Parameters
GUM_SCALARA floating type ( float, double, long double ... ).
Author
Matthieu HOURBRACQ and Pierre-Henri WUILLEMIN

Definition at line 107 of file LrsWrapper.h.

Member Typedef Documentation

◆ matrix

template<typename GUM_SCALAR>
using gum::credal::LRSWrapper< GUM_SCALAR >::matrix = typename std::vector< std::vector< GUM_SCALAR > >
private

Shortcut for dynamic matrix using vectors.

Definition at line 110 of file LrsWrapper.h.

Member Enumeration Documentation

◆ __states

template<typename GUM_SCALAR>
enum gum::credal::LRSWrapper::__states : char
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.

144  : char {
145  none = char(0),
146  Hup = char(1),
147  Vup = char(2),
148  H2Vready = char(3),
149  V2Hready = char(4),
150  };

Constructor & Destructor Documentation

◆ LRSWrapper()

template<typename GUM_SCALAR >
gum::credal::LRSWrapper< GUM_SCALAR >::LRSWrapper ( )

Default Constructor.

Definition at line 32 of file LrsWrapper_tpl.h.

32  {
34 
35  __vertices = 0;
36  __card = 0;
37 
38  __volume = 0;
39 
40  __getVolume = false;
41  __hull = false;
42  __polytope = false;
43 
44  GUM_CONSTRUCTOR(LRSWrapper);
45  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
GUM_SCALAR __volume
The volume of the polytope, if computed, 0 otherwise.
Definition: LrsWrapper.h:156
LRSWrapper()
Default Constructor.

◆ ~LRSWrapper()

template<typename GUM_SCALAR >
gum::credal::LRSWrapper< GUM_SCALAR >::~LRSWrapper ( )

Default Destructor.

Definition at line 48 of file LrsWrapper_tpl.h.

48  {
49  GUM_DESTRUCTOR(LRSWrapper);
50  }
LRSWrapper()
Default Constructor.

Member Function Documentation

◆ __coutOff()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::__coutOff ( ) const
private

The function that redirects standard cout to /dev/null.

Definition at line 721 of file LrsWrapper_tpl.h.

721  {
722  fflush(stdout);
723 #ifdef _MSC_VER
724  freopen("NUL", "w", stdout);
725 #else // _MSC_VER
726  __oldCout = dup(1);
727 
728  int new_cout = open("/dev/null", O_WRONLY);
729  dup2(new_cout, 1);
730  close(new_cout);
731 #endif // _MSC_VER
732  }
int __oldCout
File descriptor of standard cout.
Definition: LrsWrapper.h:176

◆ __coutOn()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::__coutOn ( ) const
private

The function that restores standard cout.

Definition at line 735 of file LrsWrapper_tpl.h.

735  {
736  fflush(stdout);
737 #ifdef _MSC_VER
738  freopen("CON", "w", stdout);
739 #else // _MSC_VER
740  dup2(__oldCout, 1);
741  close(__oldCout);
742 #endif // _MSC_VER
743  }
int __oldCout
File descriptor of standard cout.
Definition: LrsWrapper.h:176

◆ __fill()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::__fill ( ) const
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().

561  {
562  std::size_t cols = __input[0].size();
563 
564  int64_t* num = new int64_t[cols]; // ISO C++ forbids variable length array,
565  // we need to do this instead
566  int64_t* den = new int64_t[cols];
567 
568  int64_t rows = int64_t(__input.size());
569 
570  int64_t numerator, denominator;
571 
572  for (int64_t row = 0; row < rows; row++) {
573  for (std::size_t col = 0; col < cols; col++) {
575  numerator, denominator, __input[std::size_t(row)][col]);
576 
577  num[col] = numerator;
578  den[col] = denominator;
579  }
580 
581  /* GE is inequality, EQ is equation */
582  /* 1L, 0L respectively */
583  lrs_set_row(__dic,
584  __dat,
585  int64_t(row + 1),
586  num,
587  den,
588  1L); // do NOT forget this + 1 on row
589  }
590 
591  delete[] num;
592  delete[] den;
593  }
lrs_dat * __dat
Structure for holding static problem data of lrs.
Definition: LrsWrapper.h:185
lrs_dic * __dic
Structure for holding current dictionary and indices of lrs.
Definition: LrsWrapper.h:182
static void continuedFracFirst(int64_t &numerator, int64_t &denominator, const GUM_SCALAR &number, const double &zero=1e-6)
Find the first best rational approximation.
Definition: rational_tpl.h:95
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
+ Here is the call graph for this function:

◆ __freeLrs()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::__freeLrs ( )
private

Free lrs space.

Definition at line 692 of file LrsWrapper_tpl.h.

692  {
693  /* free space : do not change order of next lines! */
694 
695  lrs_clear_mp_vector(__lrsOutput, __dat->n);
696 
697  if (__dat->nredundcol > 0)
698  lrs_clear_mp_matrix(__Lin, __dat->nredundcol, __dat->n);
699 
700  if (__dat->runs > 0) {
701  free(__dat->isave);
702  free(__dat->jsave);
703  }
704 
705  auto savem = __dic->m; /* need this to clear __dat*/
706 
707  lrs_free_dic(__dic, __dat); /* deallocate lrs_dic */
708 
709  __dat->m = savem;
710  lrs_free_dat(__dat);
711 
712  std::string name = "LrsWrapper:";
713  std::vector< char > chars(name.c_str(), name.c_str() + name.size() + 1u);
714 
715  lrs_close(&chars[0]);
716 
717  // __coutOn();
718  }
lrs_dat * __dat
Structure for holding static problem data of lrs.
Definition: LrsWrapper.h:185
lrs_dic * __dic
Structure for holding current dictionary and indices of lrs.
Definition: LrsWrapper.h:182
lrs_mp_matrix __Lin
Holds lrs input linearities if any are found.
Definition: LrsWrapper.h:193
lrs_mp_vector __lrsOutput
One line of output of lrs : aither a ray, a vertex, a facet or a linearity.
Definition: LrsWrapper.h:190

◆ __getLRSWrapperOutput()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::__getLRSWrapperOutput ( lrs_mp  Nin,
lrs_mp  Din,
std::vector< int64_t > &  Num,
std::vector< int64_t > &  Den 
) const
private

Translate a single output from lrs.

Only vertices are supposed to be read at this step.

Parameters
NinInput numerators in mp format (returned by lrs).
DinInput denominators in mp format (returned by lrs).
NumOutput integer numerators.
DenOutput integer denominators.

Definition at line 502 of file LrsWrapper_tpl.h.

References BASE.

506  {
507  int64_t Nsize = (Nin[0] > 0) ? Nin[0] : -Nin[0];
508  int64_t Dsize = (Din[0] > 0) ? Din[0] : -Din[0];
509 
510  int64_t num = 0L;
511  int64_t den = 0L;
512 
513  int64_t tmp;
514 
515  for (decltype(Nsize) i = Nsize - 1; i > 0; i--) {
516  tmp = Nin[i];
517 
518  for (decltype(i) j = 1; j < i; j++)
519  tmp *= BASE;
520 
521  num += tmp;
522  }
523 
524  if (!(Din[0] == 2L && Din[1] == 1L)) { /* rational */
525  for (decltype(Dsize) i = Dsize - 1; i > 0; i--) {
526  tmp = Din[i];
527 
528  for (decltype(i) j = 1; j < i; j++)
529  tmp *= BASE;
530 
531  den += tmp;
532  }
533  } else {
534  den = 1L;
535  }
536 
537  int64_t Nsign = ((Nin[0] < 0) ? -1L : 1L);
538  int64_t Dsign = ((Din[0] < 0) ? -1L : 1L);
539 
540  if ((Nsign * Dsign) == -1L) num = -num;
541 
542  Num.push_back(num);
543  Den.push_back(den);
544  }
#define BASE
Definition: LrsWrapper.h:74

◆ __initLrs()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::__initLrs ( )
private

Initialize lrs structs and first basis according to flags.

Definition at line 596 of file LrsWrapper_tpl.h.

References GUM_ERROR.

596  {
598  GUM_ERROR(OperationNotAllowed,
599  "LRSWrapper< GUM_SCALAR >::__initLrs : not ready, current state "
600  "is still : "
601  << __setUpStateNames[static_cast< int >(__state)]);
602 
603  //__coutOff();
604 
605  std::string name = "\n*LrsWrapper:";
606  std::vector< char > chars(name.c_str(), name.c_str() + name.size() + 1u);
607  // use &chars[0] as a char*
608 
609  if (!lrs_init(&chars[0])) {
610  // __coutOn();
611  GUM_ERROR(FatalError,
612  "LRSWrapper< GUM_SCALAR >::__initLrs : failed lrs_init");
613  }
614 
615  name = "LRSWrapper globals";
616  chars = std::vector< char >(name.c_str(), name.c_str() + name.size() + 1u);
617 
618  __dat = lrs_alloc_dat(&chars[0]);
619 
620  if (__dat == nullptr) {
621  // __coutOn();
622  GUM_ERROR(FatalError,
623  "LRSWrapper< GUM_SCALAR >::__initLrs : failed lrs_alloc_dat");
624  }
625 
626  __dat->n = Size(__input[0].size());
627  __dat->m = Size(__input.size());
628 
629  __dat->getvolume = (__getVolume) ? 1L : 0L;
630  __dat->hull = (__hull) ? 1L : 0L;
631  __dat->polytope = (__polytope) ? 1L : 0L;
632 
633  __lrsOutput = lrs_alloc_mp_vector(__dat->n);
634 
635  __dic = lrs_alloc_dic(__dat);
636 
637  if (__dic == nullptr) {
638  // __coutOn();
639  GUM_ERROR(FatalError,
640  "LRSWrapper< GUM_SCALAR >::__initLrs : failed lrs_alloc_dic");
641  }
642 
643  __fill();
644 
645  /* Pivot to a starting dictionary */
646  if (!lrs_getfirstbasis(&__dic, __dat, &__Lin, 0L)) {
647  // __coutOn();
648  GUM_ERROR(
649  FatalError,
650  "LRSWrapper< GUM_SCALAR >::__initLrs : failed lrs_getfirstbasis");
651  }
652 
653  /* There may have been column redundancy */
654  /* If so the linearity space is obtained and redundant */
655  /* columns are removed. User can access linearity space */
656  /* from lrs_mp_matrix Lin dimensions nredundcol x d+1 */
657 
658  decltype(__dat->nredundcol) startcol = 0;
659 
660  if (__dat->homogeneous && __dat->hull) {
661  startcol++; /* col zero not treated as redundant */
662 
663  if (!__dat->restart) {
664  // __coutOn();
665 
666  for (decltype(__dat->nredundcol) col = startcol; col < __dat->nredundcol;
667  col++)
668  lrs_printoutput(__dat, __Lin[col]);
669 
670  GUM_ERROR(FatalError,
671  "LRSWrapper< GUM_SCALAR >::__initLrs : redundant columns !");
672  }
673  }
674  /*
675  if ( __dat->nredundcol > 0 ) {
676  __coutOn();
677 
678  for ( decltype( __dat->nredundcol ) col = 0, end =
679  __dat->nredundcol;
680  col < end;
681  col++ )
682  lrs_printoutput( __dat, __Lin[col] );
683 
684  GUM_ERROR(
685  FatalError,
686  "LRSWrapper< GUM_SCALAR >::__initLrs : redundant columns !" );
687  }
688  */
689  }
lrs_dat * __dat
Structure for holding static problem data of lrs.
Definition: LrsWrapper.h:185
lrs_dic * __dic
Structure for holding current dictionary and indices of lrs.
Definition: LrsWrapper.h:182
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
lrs_mp_matrix __Lin
Holds lrs input linearities if any are found.
Definition: LrsWrapper.h:193
lrs_mp_vector __lrsOutput
One line of output of lrs : aither a ray, a vertex, a facet or a linearity.
Definition: LrsWrapper.h:190
void __fill() const
Fill lrs_dictionnary and datas from __input using integer rationals.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ computeVolume()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::computeVolume ( )

Computes a polytope ( pseudo ) volume from it's V-representation.

Warning
Volume can only be computed using V-representation. H-representation volume computation is not predictable.
Probabilistic polytopes are not full dimensional : they lie in the simplex' hyper plane, therefor a pseudo-volume will be computed by projecting the polytope. The projection used is the lexicographically smallest coordinate subspace.

Definition at line 369 of file LrsWrapper_tpl.h.

References BASE, and GUM_ERROR.

369  {
370  if (!__state == __states::V2Hready)
371  GUM_ERROR(OperationNotAllowed,
372  "LRSWrapper< GUM_SCALAR >::computeVolume : "
373  "volume is only for V-representation or "
374  "fillV has not been called with all "
375  "vertices, current state is still : "
377 
378  // __coutOff();
379 
380  __getVolume = true;
381 
382  __initLrs();
383 
384  do {
385  for (decltype(__dic->d) col = 0, end = __dic->d; col <= end; col++)
386  lrs_getsolution(__dic, __dat, __lrsOutput, col);
387  } while (lrs_getnextbasis(&__dic, __dat, 0L));
388 
389  int64_t Nsize =
390  (__dat->Nvolume[0] > 0) ? __dat->Nvolume[0] : -__dat->Nvolume[0];
391  int64_t Dsize =
392  (__dat->Dvolume[0] > 0) ? __dat->Dvolume[0] : -__dat->Dvolume[0];
393 
394  int64_t num = 0L, den = 0L;
395  int64_t tmp;
396 
397  for (decltype(Nsize) i = Nsize - 1; i > 0; i--) {
398  tmp = __dat->Nvolume[i];
399 
400  for (decltype(i) j = 1; j < i; j++)
401  tmp *= BASE;
402 
403  num += tmp;
404  }
405 
406  for (decltype(Dsize) i = Dsize - 1; i > 0; i--) {
407  tmp = __dat->Dvolume[i];
408 
409  for (decltype(i) j = 1; j < i; j++)
410  tmp *= BASE;
411 
412  den += tmp;
413  }
414 
415  __volume = num * 1.0 / den;
416 
417  __freeLrs();
418 
419  // __coutOn();
420  }
lrs_dat * __dat
Structure for holding static problem data of lrs.
Definition: LrsWrapper.h:185
#define BASE
Definition: LrsWrapper.h:74
void __initLrs()
Initialize lrs structs and first basis according to flags.
lrs_dic * __dic
Structure for holding current dictionary and indices of lrs.
Definition: LrsWrapper.h:182
void __freeLrs()
Free lrs space.
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
lrs_mp_vector __lrsOutput
One line of output of lrs : aither a ray, a vertex, a facet or a linearity.
Definition: LrsWrapper.h:190
GUM_SCALAR __volume
The volume of the polytope, if computed, 0 otherwise.
Definition: LrsWrapper.h:156
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ elimRedundVrep()

template<typename GUM_SCALAR >
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().

423  {
425  GUM_ERROR(
426  OperationNotAllowed,
427  "LRSWrapper< GUM_SCALAR >::elimRedundVrep : only for "
428  "V-representation or fillV has not been called with all vertices, "
429  "current state is still : "
430  << __setUpStateNames[static_cast< int >(__state)]);
431 
432  // __coutOff();
433 
434  __initLrs();
435 
436  int64_t* redineq; /* redineq[i]=0 if ineq i non-red,1 if red,2 linearity */
437 
438  /*********************************************************************************/
439  /* Test each row of the dictionary to see if it is redundant */
440  /*********************************************************************************/
441 
442  /* note some of these may have been changed in getting initial dictionary
443  */
444  auto m = __dic->m_A;
445  auto d = __dic->d;
446  /* number of linearities in input */ /* should be 0 ! */
447  auto nlinearity = __dat->nlinearity;
448  auto lastdv = __dat->lastdv;
449 
450  /* linearities are not considered for redundancy */
451  redineq = (int64_t*)calloc(std::size_t(m + 1), sizeof(int64_t));
452 
453  for (decltype(nlinearity) i = 0; i < nlinearity; i++)
454  redineq[__dat->linearity[i]] = 2L;
455 
456  /* rows 0..lastdv are cost, decision variables, or linearities */
457  /* other rows need to be tested */
458 
459  for (decltype(m + d) index = lastdv + 1, end = m + d; index <= end;
460  index++) {
461  /* input inequality number of current index */
462  auto ineq =
463  __dat->inequality[index - lastdv]; /* the input inequality number corr.
464  to this index */
465 
466  redineq[ineq] = checkindex(__dic, __dat, index);
467  }
468 
469  /* linearities */
470  if (nlinearity > 0)
471  GUM_ERROR(FatalError,
472  "LRSWrapper< GUM_SCALAR >::elimRedundVrep : not "
473  "reading a vertex but a linearity !");
474 
475  /* count number of non-redundant inequalities */
476  /*
477  auto nredund = nlinearity;
478  for ( decltype ( m ) i = 1; i <= m; i++ )
479  if ( redineq[ i ] == 0 )
480  nredund++;
481  */
482 
483  //__vertices = nredund;
484  //__output = std::vector< std::vector< GUM_SCALAR > > ( nredund,
485  // std::vector<
486  // GUM_SCALAR > ( __dat->n - 1 ) );
487 
488  for (decltype(m) i = 1; i <= m; i++)
489  if (redineq[i] == 0)
490  __output.push_back(
491  std::vector< GUM_SCALAR >(++__input[std::size_t(i - 1)].begin(),
492  __input[std::size_t(i - 1)].end()));
493 
494  __vertices = (unsigned int)__output.size();
495 
496  __freeLrs();
497 
498  // __coutOn();
499  }
lrs_dat * __dat
Structure for holding static problem data of lrs.
Definition: LrsWrapper.h:185
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
void __initLrs()
Initialize lrs structs and first basis according to flags.
lrs_dic * __dic
Structure for holding current dictionary and indices of lrs.
Definition: LrsWrapper.h:182
void __freeLrs()
Free lrs space.
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ fillH()

template<typename GUM_SCALAR >
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.

Parameters
minThe lower value of p(X=modal | .).
maxThe upper value of p(X=modal | .).
modalThe 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().

186  {
187  if (__state != __states::Hup)
188  GUM_ERROR(
189  OperationNotAllowed,
190  "LRSWrapper< GUM_SCALAR >::fillH : setUpH or nextInput has not "
191  "been called or H-representation is complete, current state is : "
192  << __setUpStateNames[static_cast< int >(__state)]);
193 
194  if (modal >= __card)
195  GUM_ERROR(OutOfBounds,
196  "LRSWrapper< GUM_SCALAR >::fillH : modality is "
197  "greater or equal than cardinality : "
198  << modal << " >= " << __card);
199 
200  __input[modal * 2][0] = -min;
201  __input[modal * 2][modal + 1] = 1;
202 
203  __input[modal * 2 + 1][0] = max;
204  __input[modal * 2 + 1][modal + 1] = -1;
205 
206  __vertex[modal] = max;
207 
208  __insertedModals.insert(int(modal));
209 
211  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
std::vector< GUM_SCALAR > __vertex
In case we have lower = upper for all modalities, a point probability, there is no need to use lrs...
Definition: LrsWrapper.h:137
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
std::unordered_set< int > __insertedModals
To keep track of which constraints over modalities have been inserted.
Definition: LrsWrapper.h:125
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ fillMatrix()

template<typename GUM_SCALAR >
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.

Parameters
matrixThe H-representation of the polytope of the form 0 <= -b
  • Ax, A is the matrix, each column the coefficient of the variable in x.

Definition at line 214 of file LrsWrapper_tpl.h.

References GUM_ERROR.

Referenced by gum::credal::lp::LpInterface< GUM_SCALAR >::solve().

215  {
216  if (__state != __states::Hup)
217  GUM_ERROR(
218  OperationNotAllowed,
219  "LRSWrapper< GUM_SCALAR >::fillH : setUpH or nextInput has not "
220  "been called or H-representation is complete, current state is : "
221  << __setUpStateNames[static_cast< int >(__state)]);
222 
223  if (matrix[0].size() - 1 != __card)
224  GUM_ERROR(OutOfBounds,
225  "LRSWrapper< GUM_SCALAR >::fillMatrix : size is "
226  "different than cardinality : "
227  << (matrix[0].size() - 1) << " != " << __card);
228 
229  __input = matrix;
230 
231  for (unsigned int modal = 0; modal < __card; modal++) {
232  __insertedModals.insert(modal);
233  }
234 
236  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
typename std::vector< std::vector< GUM_SCALAR > > matrix
Shortcut for dynamic matrix using vectors.
Definition: LrsWrapper.h:110
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
std::unordered_set< int > __insertedModals
To keep track of which constraints over modalities have been inserted.
Definition: LrsWrapper.h:125
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ fillV()

template<typename GUM_SCALAR >
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.

Parameters
vertexThe 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().

239  {
240  if (__state != __states::Vup)
241  GUM_ERROR(
242  OperationNotAllowed,
243  "LRSWrapper< GUM_SCALAR >::fillV : setUpV or nextInput has not "
244  "been called or V-representation is complete, current state is : "
245  << __setUpStateNames[static_cast< int >(__state)]);
246 
247  if (__insertedVertices.size() == __vertices)
248  GUM_ERROR(OutOfBounds,
249  "LRSWrapper< GUM_SCALAR >::fillV : input is already full with "
250  << __vertices << " vertices.");
251 
252  bool eq = true;
253 
254  for (const auto& v : __insertedVertices) {
255  eq = true;
256 
257  for (decltype(__card) mod = 0; mod < __card; mod++)
258  if (std::fabs(v[mod] - vertex[mod]) > 1e-6) {
259  eq = false;
260  break;
261  }
262 
263  if (eq) {
264  __vertices--;
265  return;
266  // GUM_ERROR ( DuplicateElement, "LRSWrapper< GUM_SCALAR >::fillV :
267  // vertex
268  // already present : " << vertex );
269  }
270  }
271 
272  auto row = __insertedVertices.size();
273 
274  for (decltype(__card) mod = 0; mod < __card; mod++)
275  __input[row][mod + 1] = vertex[mod];
276 
277  __insertedVertices.push_back(vertex);
278 
279  if (__insertedVertices.size() == __vertices) __state = __states::V2Hready;
280  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
std::vector< std::vector< GUM_SCALAR > > __insertedVertices
To keep track of inserted vertices and total.
Definition: LrsWrapper.h:133
+ Here is the caller graph for this function:

◆ getInput()

template<typename GUM_SCALAR >
auto gum::credal::LRSWrapper< GUM_SCALAR >::getInput ( ) const

Get the intput matrix of the problem.

Returns
A constant reference to the __intput matrix.

Definition at line 53 of file LrsWrapper_tpl.h.

53  {
54  return __input;
55  }
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114

◆ getOutput()

template<typename GUM_SCALAR >
auto gum::credal::LRSWrapper< GUM_SCALAR >::getOutput ( ) const

Get the output matrix solution of the problem.

Returns
A constant reference to the __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().

58  {
59  return __output;
60  }
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
+ Here is the caller graph for this function:

◆ getVerticesNumber()

template<typename GUM_SCALAR >
const unsigned int & gum::credal::LRSWrapper< GUM_SCALAR >::getVerticesNumber ( ) const

Get the number of vertices of this polytope.

Returns
A constant reference to the number of vertices __vertices.

Definition at line 63 of file LrsWrapper_tpl.h.

63  {
64  return __vertices;
65  }
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128

◆ getVolume()

template<typename GUM_SCALAR >
const GUM_SCALAR & gum::credal::LRSWrapper< GUM_SCALAR >::getVolume ( ) const

Get the volume of the polytope that has been computed.

Warning
Volume can only be computed using V-representation. H-representation volume computation is not predictable.
Probabilistic polytopes are not full dimensional : they lie in the simplex' hyper plane, therefor a pseudo-volume will be computed by projecting the polytope. The projection used is the lexicographically smallest coordinate subspace.
Returns
A constant reference to the polytope volume.

Definition at line 68 of file LrsWrapper_tpl.h.

References GUM_ERROR.

68  {
69  if (__volume != 0)
70  return __volume;
71  else
72  GUM_ERROR(OperationNotAllowed,
73  "LRSWrapper< GUM_SCALAR >::getVolume () : "
74  "volume computation was not asked for this "
75  "credal set, call computeVolume() from a "
76  "V-representation.");
77  }
GUM_SCALAR __volume
The volume of the polytope, if computed, 0 otherwise.
Definition: LrsWrapper.h:156
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

◆ H2V()

template<typename GUM_SCALAR >
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().

283  {
285  GUM_ERROR(OperationNotAllowed,
286  "LRSWrapper< GUM_SCALAR >::H2V : fillH has not been called with "
287  "all modalities, current state is still : "
288  << __setUpStateNames[static_cast< int >(__state)]);
289 
290  // check that we have a credal set and not a precise point probability,
291  // i.e.
292  // sum of vertex elements is close to one ( floating type precision )
293  GUM_SCALAR sum = 0;
294 
295  for (const auto elem : __vertex)
296  sum += elem;
297 
298  if (std::fabs(sum - 1) < 1e-6) {
299  __output = std::vector< std::vector< GUM_SCALAR > >(1, __vertex);
300  return;
301  }
302 
303  // not precise point probability, initialize lrs
304 
305  // __coutOff();
306 
307  __initLrs();
308 
309  /* We initiate reverse search from this dictionary */
310  /* getting new dictionaries until the search is complete */
311  /* User can access each output line from output which is */
312  /* vertex/ray/facet from the lrs_mp_vector output */
313  /* prune is TRUE if tree should be pruned at current node */
314 
315  // pruning is not used
316 
317  std::vector< int64_t > Num; /* numerators of all vertices */
318  std::vector< int64_t > Den; /* denominators of all vertices */
319 
320  do {
321  for (decltype(__dic->d) col = 0, end = __dic->d; col <= end; col++)
322  if (lrs_getsolution(__dic, __dat, __lrsOutput, col)) {
323  // iszero macro could be used here for the test on right
324  if (__dat->hull
325  || ((((__lrsOutput[0])[0] == 2 || (__lrsOutput[0])[0] == -2)
326  && (__lrsOutput[0])[1] == 0)
327  ? 1L
328  : 0L)) {
329  // __coutOn();
330  /*for ( decltype(Q->n) i = 0; i < Q->n; i++ )
331  pmp ("", output[i]);*/
332  GUM_ERROR(FatalError,
333  "LRSWrapper< GUM_SCALAR >::H2V : asked for "
334  "Q-hull computation or not reading a vertex !");
335  } else
336  for (decltype(__dat->n) i = 1, end = __dat->n; i < end; i++)
338  }
339  } while (lrs_getnextbasis(&__dic, __dat, 0L));
340 
341  auto vtx = Num.size();
342  std::vector< GUM_SCALAR > vertex(__card);
343 
344  for (decltype(vtx) i = 1; i <= vtx; i++) {
345  vertex[(i - 1) % __card] = GUM_SCALAR(Num[i - 1] * 1.0 / Den[i - 1]);
346 
347  if (i % __card == 0) {
348  __output.push_back(vertex);
349  __vertices++;
350  }
351  }
352 
353  __freeLrs();
354 
355  // __coutOn();
356  }
lrs_dat * __dat
Structure for holding static problem data of lrs.
Definition: LrsWrapper.h:185
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
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.
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...
Definition: LrsWrapper.h:137
lrs_dic * __dic
Structure for holding current dictionary and indices of lrs.
Definition: LrsWrapper.h:182
void __freeLrs()
Free lrs space.
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
lrs_mp_vector __lrsOutput
One line of output of lrs : aither a ray, a vertex, a facet or a linearity.
Definition: LrsWrapper.h:190
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ nextHInput()

template<typename GUM_SCALAR >
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().

152  {
153  __insertedModals.clear();
154  __insertedVertices.clear();
155  __output.clear();
156  __vertex.clear();
157  __vertex.resize(__card, 0);
158 
159  __volume = 0;
160  __vertices = 0;
161 
162  __getVolume = false;
163  __hull = false;
164  __polytope = false;
165 
168  else if (__state == __states::V2Hready) {
170  GUM_ERROR(
171  OperationNotAllowed,
172  "LRSWrapper< GUM_SCALAR >::nextHInput : only for H-representation "
173  "as input. Previous state was : "
174  << __setUpStateNames[static_cast< int >(__state)]);
175  } else {
176  __input.clear();
178  __card = 0;
179  __vertex.clear();
180  }
181  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
std::vector< GUM_SCALAR > __vertex
In case we have lower = upper for all modalities, a point probability, there is no need to use lrs...
Definition: LrsWrapper.h:137
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
std::unordered_set< int > __insertedModals
To keep track of which constraints over modalities have been inserted.
Definition: LrsWrapper.h:125
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
GUM_SCALAR __volume
The volume of the polytope, if computed, 0 otherwise.
Definition: LrsWrapper.h:156
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
std::vector< std::vector< GUM_SCALAR > > __insertedVertices
To keep track of inserted vertices and total.
Definition: LrsWrapper.h:133
+ Here is the caller graph for this function:

◆ setUpH()

template<typename GUM_SCALAR >
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.

Parameters
cardA 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().

80  {
81  if (card < 2)
82  GUM_ERROR(OperationNotAllowed,
83  "LRSWrapper< GUM_SCALAR >::setUpH : "
84  "cardinality must be at least 2");
85 
86  tearDown();
87 
88  __input = std::vector< std::vector< GUM_SCALAR > >(
89  card * 2 + 2, std::vector< GUM_SCALAR >(card + 1, 0));
90 
91  __input[card * 2] = std::vector< GUM_SCALAR >(card + 1, -1);
92  __input[card * 2][0] = 1;
93 
94  __input[card * 2 + 1] = std::vector< GUM_SCALAR >(card + 1, 1);
95  __input[card * 2 + 1][0] = -1;
96 
97  __output = std::vector< std::vector< GUM_SCALAR > >();
98 
99  __vertex = std::vector< GUM_SCALAR >(card);
100 
102 
103  __card = (unsigned int)card;
104  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
std::vector< GUM_SCALAR > __vertex
In case we have lower = upper for all modalities, a point probability, there is no need to use lrs...
Definition: LrsWrapper.h:137
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
void tearDown()
Reset the wrapper as if it was built.
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ setUpV()

template<typename GUM_SCALAR >
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.

Parameters
cardA constant reference to the cardinality of the variable.
verticesA 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().

107  {
108  if (card < 2)
109  GUM_ERROR(OperationNotAllowed,
110  "LRSWrapper< GUM_SCALAR >::setUpV : "
111  "cardinality must be at least 2");
112 
113  if (vertices < 2)
114  GUM_ERROR(OperationNotAllowed,
115  "LRSWrapper< GUM_SCALAR >::setUpV : vertices "
116  "must be at least 2 to build a polytope");
117 
118  tearDown();
119 
120  __input = std::vector< std::vector< GUM_SCALAR > >(
121  vertices, std::vector< GUM_SCALAR >(card + 1, 1));
122 
123  __output = std::vector< std::vector< GUM_SCALAR > >();
124 
126 
127  __card = (unsigned int)card;
128  __vertices = (unsigned int)vertices;
129  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
void tearDown()
Reset the wrapper as if it was built.
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the caller graph for this function:

◆ tearDown()

template<typename GUM_SCALAR >
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.

132  {
133  __input.clear();
134  __output.clear();
135  __vertex.clear();
136  __insertedModals.clear();
137 
138  __insertedVertices.clear();
139  __vertices = 0;
140 
141  __volume = 0;
142 
144  __card = 0;
145 
146  __getVolume = false;
147  __hull = false;
148  __polytope = false;
149  }
unsigned int __card
Cardinality of the variable.
Definition: LrsWrapper.h:121
matrix __output
Output matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:118
std::vector< GUM_SCALAR > __vertex
In case we have lower = upper for all modalities, a point probability, there is no need to use lrs...
Definition: LrsWrapper.h:137
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
std::unordered_set< int > __insertedModals
To keep track of which constraints over modalities have been inserted.
Definition: LrsWrapper.h:125
unsigned int __vertices
The number of vertices of the polytope.
Definition: LrsWrapper.h:128
matrix __input
Input matrix - either a V-representation or an H-representation.
Definition: LrsWrapper.h:114
GUM_SCALAR __volume
The volume of the polytope, if computed, 0 otherwise.
Definition: LrsWrapper.h:156
std::vector< std::vector< GUM_SCALAR > > __insertedVertices
To keep track of inserted vertices and total.
Definition: LrsWrapper.h:133

◆ V2H()

template<typename GUM_SCALAR >
void gum::credal::LRSWrapper< GUM_SCALAR >::V2H ( )

V-representation to H-representation.

Warning
Not complete yet.

Computes the H-representation of a polytope from it's V-representation.

Definition at line 359 of file LrsWrapper_tpl.h.

References GUM_ERROR.

359  {
360  if (!__state == __states::V2Hready)
361  GUM_ERROR(OperationNotAllowed,
362  "LRSWrapper< GUM_SCALAR >::V2H : fillV has "
363  "not been called with all vertices, current "
364  "state is still : "
366  }
__states __state
The current state of the LrsWrapper.
Definition: LrsWrapper.h:153
const char * __setUpStateNames[5]
To print an enum field name instead of it&#39;s value.
Definition: LrsWrapper.h:160
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55

Member Data Documentation

◆ __card

template<typename GUM_SCALAR>
unsigned int gum::credal::LRSWrapper< GUM_SCALAR >::__card
private

Cardinality of the variable.

Definition at line 121 of file LrsWrapper.h.

◆ __dat

template<typename GUM_SCALAR>
lrs_dat* gum::credal::LRSWrapper< GUM_SCALAR >::__dat
private

Structure for holding static problem data of lrs.

Definition at line 185 of file LrsWrapper.h.

◆ __dic

template<typename GUM_SCALAR>
lrs_dic* gum::credal::LRSWrapper< GUM_SCALAR >::__dic
private

Structure for holding current dictionary and indices of lrs.

Definition at line 182 of file LrsWrapper.h.

◆ __getVolume

template<typename GUM_SCALAR>
bool gum::credal::LRSWrapper< GUM_SCALAR >::__getVolume
private

Definition at line 200 of file LrsWrapper.h.

◆ __hull

template<typename GUM_SCALAR>
bool gum::credal::LRSWrapper< GUM_SCALAR >::__hull
private

Definition at line 202 of file LrsWrapper.h.

◆ __input

template<typename GUM_SCALAR>
matrix gum::credal::LRSWrapper< GUM_SCALAR >::__input
private

Input matrix - either a V-representation or an H-representation.

Definition at line 114 of file LrsWrapper.h.

◆ __insertedModals

template<typename GUM_SCALAR>
std::unordered_set< int > gum::credal::LRSWrapper< GUM_SCALAR >::__insertedModals
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.

◆ __insertedVertices

template<typename GUM_SCALAR>
std::vector< std::vector< GUM_SCALAR > > gum::credal::LRSWrapper< GUM_SCALAR >::__insertedVertices
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.

◆ __Lin

template<typename GUM_SCALAR>
lrs_mp_matrix gum::credal::LRSWrapper< GUM_SCALAR >::__Lin
private

Holds lrs input linearities if any are found.

Definition at line 193 of file LrsWrapper.h.

◆ __lrsOutput

template<typename GUM_SCALAR>
lrs_mp_vector gum::credal::LRSWrapper< GUM_SCALAR >::__lrsOutput
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.

◆ __oldCout

template<typename GUM_SCALAR>
int gum::credal::LRSWrapper< GUM_SCALAR >::__oldCout
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.

◆ __output

template<typename GUM_SCALAR>
matrix gum::credal::LRSWrapper< GUM_SCALAR >::__output
private

Output matrix - either a V-representation or an H-representation.

Definition at line 118 of file LrsWrapper.h.

◆ __polytope

template<typename GUM_SCALAR>
bool gum::credal::LRSWrapper< GUM_SCALAR >::__polytope
private

Definition at line 204 of file LrsWrapper.h.

◆ __setUpStateNames

template<typename GUM_SCALAR>
const char* gum::credal::LRSWrapper< GUM_SCALAR >::__setUpStateNames[5]
private
Initial value:
= {
enumStringify(__states::nHup),
enumStringify(__states::nVup),
enumStringify(__states::nH2Vready),
enumStringify(__states::nV2Hready),
}

To print an enum field name instead of it's value.

Used with GUM_ERROR.

Definition at line 160 of file LrsWrapper.h.

◆ __state

template<typename GUM_SCALAR>
__states gum::credal::LRSWrapper< GUM_SCALAR >::__state
private

The current state of the LrsWrapper.

Definition at line 153 of file LrsWrapper.h.

◆ __vertex

template<typename GUM_SCALAR>
std::vector< GUM_SCALAR > gum::credal::LRSWrapper< GUM_SCALAR >::__vertex
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.

◆ __vertices

template<typename GUM_SCALAR>
unsigned int gum::credal::LRSWrapper< GUM_SCALAR >::__vertices
private

The number of vertices of the polytope.

Definition at line 128 of file LrsWrapper.h.

◆ __volume

template<typename GUM_SCALAR>
GUM_SCALAR gum::credal::LRSWrapper< GUM_SCALAR >::__volume
private

The volume of the polytope, if computed, 0 otherwise.

Definition at line 156 of file LrsWrapper.h.


The documentation for this class was generated from the following files: