aGrUM  0.15.0
LrsWrapper_tpl.h
Go to the documentation of this file.
1 
23 #include <string.h>
24 
25 #include <agrum/CN/LrsWrapper.h>
26 #include <agrum/agrum.h>
27 
28 namespace gum {
29  namespace credal {
30 
31  template < typename GUM_SCALAR >
33  __state = __states::none;
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  }
46 
47  template < typename GUM_SCALAR >
49  GUM_DESTRUCTOR(LRSWrapper);
50  }
51 
52  template < typename GUM_SCALAR >
53  auto LRSWrapper< GUM_SCALAR >::getInput() const -> const matrix& {
54  return __input;
55  }
56 
57  template < typename GUM_SCALAR >
59  return __output;
60  }
61 
62  template < typename GUM_SCALAR >
63  const unsigned int& LRSWrapper< GUM_SCALAR >::getVerticesNumber() const {
64  return __vertices;
65  }
66 
67  template < typename GUM_SCALAR >
68  const GUM_SCALAR& LRSWrapper< GUM_SCALAR >::getVolume() const {
69  if (__volume != 0)
70  return __volume;
71  else
73  "LRSWrapper< GUM_SCALAR >::getVolume () : "
74  "volume computation was not asked for this "
75  "credal set, call computeVolume() from a "
76  "V-representation.");
77  }
78 
79  template < typename GUM_SCALAR >
81  if (card < 2)
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 
101  __state = __states::Hup;
102 
103  __card = (unsigned int)card;
104  }
105 
106  template < typename GUM_SCALAR >
107  void LRSWrapper< GUM_SCALAR >::setUpV(const Size& card, const Size& vertices) {
108  if (card < 2)
110  "LRSWrapper< GUM_SCALAR >::setUpV : "
111  "cardinality must be at least 2");
112 
113  if (vertices < 2)
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 
125  __state = __states::Vup;
126 
127  __card = (unsigned int)card;
128  __vertices = (unsigned int)vertices;
129  }
130 
131  template < typename GUM_SCALAR >
133  __input.clear();
134  __output.clear();
135  __vertex.clear();
136  __insertedModals.clear();
137 
138  __insertedVertices.clear();
139  __vertices = 0;
140 
141  __volume = 0;
142 
143  __state = __states::none;
144  __card = 0;
145 
146  __getVolume = false;
147  __hull = false;
148  __polytope = false;
149  }
150 
151  template < typename GUM_SCALAR >
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 
166  if (__state == __states::H2Vready)
167  __state = __states::Hup;
168  else if (__state == __states::V2Hready) {
169  __state = __states::Vup;
170  GUM_ERROR(
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();
177  __state = __states::none;
178  __card = 0;
179  __vertex.clear();
180  }
181  }
182 
183  template < typename GUM_SCALAR >
184  void LRSWrapper< GUM_SCALAR >::fillH(const GUM_SCALAR& min,
185  const GUM_SCALAR& max,
186  const Size& modal) {
187  if (__state != __states::Hup)
188  GUM_ERROR(
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)
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 
210  if (__insertedModals.size() == __card) __state = __states::H2Vready;
211  }
212 
213  template < typename GUM_SCALAR >
215  const std::vector< std::vector< GUM_SCALAR > >& matrix) {
216  if (__state != __states::Hup)
217  GUM_ERROR(
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)
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 
235  __state = __states::H2Vready;
236  }
237 
238  template < typename GUM_SCALAR >
239  void LRSWrapper< GUM_SCALAR >::fillV(const std::vector< GUM_SCALAR >& vertex) {
240  if (__state != __states::Vup)
241  GUM_ERROR(
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)
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  }
281 
282  template < typename GUM_SCALAR >
284  if (__state != __states::H2Vready)
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]);*/
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++)
337  __getLRSWrapperOutput(__lrsOutput[i], __lrsOutput[0], Num, Den);
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  }
357 
358  template < typename GUM_SCALAR >
360  if (!__state == __states::V2Hready)
362  "LRSWrapper< GUM_SCALAR >::V2H : fillV has "
363  "not been called with all vertices, current "
364  "state is still : "
365  << __setUpStateNames[__state]);
366  }
367 
368  template < typename GUM_SCALAR >
370  if (!__state == __states::V2Hready)
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 : "
376  << __setUpStateNames[__state]);
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  }
421 
422  template < typename GUM_SCALAR >
424  if (__state != __states::V2Hready)
425  GUM_ERROR(
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)
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  }
500 
501  template < typename GUM_SCALAR >
503  lrs_mp Nin,
504  lrs_mp Din,
505  std::vector< int64_t >& Num,
506  std::vector< int64_t >& Den) const {
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  }
545 
546  /*
547  void pmp (char name[], lrs_mp a) {
548  int64_t i;
549  fprintf (lrs_ofp, "%s", name);
550  if (sign (a) == NEG)
551  fprintf (lrs_ofp, "-");
552  else
553  fprintf (lrs_ofp, " ");
554  fprintf (lrs_ofp, "%lu", a[length (a) - 1]);
555  for (i = length (a) - 2; i >= 1; i--)
556  fprintf (lrs_ofp, FORMAT, a[i]);
557  fprintf (lrs_ofp, " ");
558  }*/
559 
560  template < typename GUM_SCALAR >
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  }
594 
595  template < typename GUM_SCALAR >
597  if (__state != __states::H2Vready && __state != __states::V2Hready)
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();
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();
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();
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 
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  }
690 
691  template < typename GUM_SCALAR >
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  }
719 
720  template < typename GUM_SCALAR >
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  }
733 
734  template < typename GUM_SCALAR >
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  }
744 
745  } // namespace credal
746 } // namespace gum
~LRSWrapper()
Default Destructor.
void V2H()
V-representation to H-representation.
void fillMatrix(const std::vector< std::vector< GUM_SCALAR > > &matrix)
Fill the H-representation from the matrix given in argument.
void __coutOff() const
The function that redirects standard cout to /dev/null.
const GUM_SCALAR & getVolume() const
Get the volume of the polytope that has been computed.
const matrix & getInput() const
Get the intput matrix of the problem.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
#define BASE
Definition: LrsWrapper.h:74
void __initLrs()
Initialize lrs structs and first basis according to flags.
typename std::vector< std::vector< GUM_SCALAR > > matrix
Shortcut for dynamic matrix using vectors.
Definition: LrsWrapper.h:110
void __freeLrs()
Free lrs space.
void fillV(const std::vector< GUM_SCALAR > &vertex)
Creates the V-representation of a polytope by adding a vertex to the problem input __input...
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...
Class template acting as a wrapper for Lexicographic Reverse Search by David Avis.
Definition: LrsWrapper.h:107
void setUpH(const Size &card)
Sets up an H-representation.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void nextHInput()
Reset the wrapper for next computation for a H-representation with the same variable cardinality and ...
void tearDown()
Reset the wrapper as if it was built.
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
void __coutOn() const
The function that restores standard cout.
void setUpV(const Size &card, const Size &vertices)
Sets up a V-representation.
void H2V()
H-representation to V-representation.
void elimRedundVrep()
V-Redundancy elimination.
void __fill() const
Fill lrs_dictionnary and datas from __input using integer rationals.
const matrix & getOutput() const
Get the output matrix solution of the problem.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
LRSWrapper()
Default Constructor.
void computeVolume()
Computes a polytope ( pseudo ) volume from it&#39;s V-representation.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
const unsigned int & getVerticesNumber() const
Get the number of vertices of this polytope.