PIPS
polyedre.h File Reference
#include "ray_dte.h"
#include "sg.h"
#include "polynome.h"
+ Include dependency graph for polyedre.h:

Go to the source code of this file.

Functions

Psysteme sc_enveloppe_chernikova_ofl_ctrl (Psysteme, Psysteme, int)
 Warning! Do not modify this file that is automatically generated! More...
 
Psysteme sc_enveloppe_chernikova (Psysteme, Psysteme)
 
Psysteme elementary_convex_union (Psysteme, Psysteme)
 implements FC basic idea of simple fast cases... More...
 
Psysteme sc_cute_convex_hull (Psysteme, Psysteme)
 returns s1 v s2. More...
 
Psysteme sc_rectangular_hull (Psysteme, Pbase)
 take the rectangular bounding box of the systeme sc, by projecting each constraint of the systeme against each of the basis in pb More...
 
Ptsg sc_to_sg_chernikova_fixprec (Psysteme)
 chernikova_fixprec.c More...
 
Psysteme sg_to_sc_chernikova_fixprec (Ptsg)
 
Psysteme sc_convex_hull_fixprec (Psysteme, Psysteme)
 
Ptsg sc_to_sg_chernikova (Psysteme)
 chernikova_mulprec.c More...
 
Psysteme sg_to_sc_chernikova (Ptsg)
 
Psysteme sc_convex_hull (Psysteme, Psysteme)
 

Function Documentation

◆ elementary_convex_union()

Psysteme elementary_convex_union ( Psysteme  s1,
Psysteme  s2 
)

implements FC basic idea of simple fast cases...

returns s1 v s2. s1 and s2 are not touched. The bases should be minimum for best efficiency! otherwise useless columns are allocated and computed. a common base is rebuilt in actual_convex_union. other fast cases may be added?

Parameters
s11
s22

Definition at line 171 of file sc_enveloppe.c.

172 {
173  bool
174  b1 = sc_empty_p(s1),
175  b2 = sc_empty_p(s2);
176 
177  if (b1 && b2)
178  return sc_empty(base_union(sc_base(s1), sc_base(s2)));
179 
180  if (b1) {
181  Psysteme s = sc_dup(s2);
182  Pbase b = base_union(sc_base(s1), sc_base(s2));
183  base_rm(sc_base(s));
184  sc_base(s) = b;
185  return s;
186  }
187 
188  if (b2) {
189  Psysteme s = sc_dup(s1);
190  Pbase b = base_union(sc_base(s1), sc_base(s2));
191  base_rm(sc_base(s));
192  sc_base(s) = b;
193  return s;
194  }
195 
196  if (sc_rn_p(s1) || sc_rn_p(s2) ||
197  !vect_common_variables_p(sc_base(s1), sc_base(s2)))
198  return sc_rn(base_union(sc_base(s1), sc_base(s2)));
199 
200  /*
201  if (sc_dimension(s1)==1 && sc_dimension(s2)==1 &&
202  sc_base(s1)->var == sc_base(s2)->var)
203  {
204  // fast computation...
205  }
206  */
207 
208  return actual_convex_union(s1, s2);
209 }
Pbase base_union(Pbase b1, Pbase b2)
Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all eleme...
Definition: base.c:428
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
Definition: sc_alloc.c:369
Psysteme sc_empty(Pbase b)
Psysteme sc_empty(Pbase b): build a Psysteme with one unfeasible constraint to define the empty subsp...
Definition: sc_alloc.c:319
Psysteme sc_rn(Pbase b)
Psysteme sc_rn(Pbase b): build a Psysteme without constraints to define R^n, where n is b's dimension...
Definition: sc_alloc.c:336
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Definition: sc_alloc.c:350
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
static Psysteme actual_convex_union(Psysteme s1, Psysteme s2)
call chernikova with compatible base.
Definition: sc_enveloppe.c:134
Value b2
Definition: sc_gram.c:105
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
s1
Definition: set.c:247
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define base_rm(b)
bool vect_common_variables_p(Pvecteur v1, Pvecteur v2)
bool vect_common_variables_p(Pvecteur v1, v2) BA 19/05/94 input : two vectors.
Definition: unaires.c:397

References actual_convex_union(), b1, b2, base_rm, base_union(), s1, sc_dup(), sc_empty(), sc_empty_p(), sc_rn(), sc_rn_p(), and vect_common_variables_p().

Referenced by sc_cute_convex_hull().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_convex_hull()

Psysteme sc_convex_hull ( Psysteme  sc1,
Psysteme  sc2 
)
Parameters
sc1c1
sc2c2

Definition at line 74 of file chernikova.c.

75 {
76  Psysteme sc;
77 
78  if (linear_use_gmp())
79 #ifdef HAVE_GMP_H
80  sc = sc_convex_hull_mulprec(sc1, sc2);
81 #else
82  abort();
83 #endif // HAVE_GMP_H
84  else
85  sc = sc_convex_hull_fixprec(sc1, sc2);
86 
87  return sc;
88 }
bool linear_use_gmp(void)
whether linear is to use gmp
Definition: errors.c:454
Psysteme sc_convex_hull_fixprec(Psysteme sc1, Psysteme sc2)
#define abort()
Definition: misc-local.h:53

References abort, linear_use_gmp(), and sc_convex_hull_fixprec().

Referenced by main(), and sc_enveloppe_chernikova_ofl_ctrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_convex_hull_fixprec()

Psysteme sc_convex_hull_fixprec ( Psysteme  sc1,
Psysteme  sc2 
)
Parameters
sc1c1
sc2c2

Definition at line 40 of file chernikova_fixprec.c.

40  {
41  return sc_union(sc1, sc2);
42 }
static Psysteme sc_union(Psysteme sc1, Psysteme sc2)
Definition: chernikova.h:1476

References sc_union().

Referenced by sc_convex_hull().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_cute_convex_hull()

Psysteme sc_cute_convex_hull ( Psysteme  is1,
Psysteme  is2 
)

returns s1 v s2.

initial systems are not changed.

v convex union u union n intersection T orthogonality

(1) CA:

P1 v P2 = (P n X1) v (P n X2) = let P = P' n P'' so that P' T X1 and P' T X2 and P' T P'' built by transitive closure, then P1 v P2 = (P' n (P'' n X1)) v (P' n (P'' n X2)) = P' n ((P'' n X1) v (P'' n X2))

Proof by considering generating systems: Def: A T B <=> var(A) n var(B) = 0 Prop: A n B if A T B Let A = (x,v,l), B = (y,w,m) A n B = { z | z = (x) \mu + (v) d + (l) e + (0) f (0) + (0) + (0) (I) and z = (0) \nu + (0) g + (0) h + (I) f' (y) + (w) + (m) (0) with \mu>0, \nu>0, \sum\mu=1, \sum\nu=1, d>0, g>0 } we can always find f and f' equals to the other part (by extension) so A n B = { z | z = (x 0) \mu + (v 0) d + (l 0) e (0 y) \nu (0 w) g (0 m) h with \mu \nu d g constraints... } It is a convex : ((xi) , (v 0), (l 0)) (yj)ij, (0 w), (0 m) we just need to prove that Cmn == Cg defined as (x 0) \mu == (xi) \gamma with >0 and \sum = 1 (0 y) \nu (yj)ij . Cg in a convex. . Cg \in Cmn since ((xi)(yj) ij) in Cmn with \mu = \delta i, \nu = \delta j . Cmn \in Cg by chosing \gamma_ij = \mu_i\nu_j, which >0 and \sum = 1 Prop: A T B and A T C => A T (B v C) and A T (B n C) Theo: A T B and A T C => (A n B) v (A n C) = A n (B v C) compute both generating systems with above props. they are equal.

(2) FI:

perform exact projections of common equalities. no proof at the time. It looks ok anyway.

(3) FC:

base(P) n base(Q) = 0 => P u Q = Rn and some other very basic simplifications... which are not really interesting if no decomposition is performed?

on overflows FI suggested.

1/ we want to compute : (A n B1) u (A n B2) 2/ we chose to approximate it as : (A n B1) v (A n B2) 3/ we try Corinne's factorization with transitive closure A' n ((A'' n B1) v (A'' n B2)) 4/ on overflow, we can try A n (B1 v B2) // NOT IMPLEMENTED YET 5/ if we have one more overflow, then A looks good as an approximation.

CA: extract common disjoint part.

FI: in sc_common_projection_convex_hull note that equalities are not that big a burden to chernikova?

fast sc_append

usually we use V (convex hull) as a U (set union) approximation. as we have : (A n B1) U (A n B2) \in A the common part of both systems is an approximation of the union! sc_rn is returned on overflows (and some other case). I don't think that the result is improved apart when actual overflow occurs. FC/CA.

dead. either rm or moved as sc.

better compatibility with previous version, as the convex union normalizes the system and removes redundancy, what is not done if part of the system is separated. Other calls may be considered here?

ok, it will look better.

misleading... not really projected. { x==y, y==3 } => { x==3, y==3 }

sc, su: fast union of disjoint.

regenerate the expected base.

Parameters
is1s1
is2s2

Definition at line 369 of file sc_enveloppe.c.

370 {
371  Psysteme s1, s2, sc, stc, su, scsaved;
372  int current_overflow_count;
373 
374  s1 = sc_dup(is1);
375  s2 = sc_dup(is2);
376 
377  /* CA: extract common disjoint part.
378  */
379  sc = extract_common_syst(s1, s2);
380  scsaved = sc_dup(sc);
381  stc = transitive_closure_from_two_bases(sc, s1->base, s2->base);
382 
383  /* FI: in sc_common_projection_convex_hull
384  note that equalities are not that big a burden to chernikova?
385  */
386  sc_extract_exact_common_equalities(stc, sc, s1, s2);
387 
388  /* fast sc_append */
389  s1 = sc_fusion(s1, sc_dup(stc));
390  sc_fix(s1);
391 
392  s2 = sc_fusion(s2, stc);
393  sc_fix(s2);
394 
395  stc = NULL;
396 
397  current_overflow_count = linear_number_of_exception_thrown;
398 
399  su = elementary_convex_union(s1, s2);
400 
401  /* usually we use V (convex hull) as a U (set union) approximation.
402  * as we have : (A n B1) U (A n B2) \in A
403  * the common part of both systems is an approximation of the union!
404  * sc_rn is returned on overflows (and some other case).
405  * I don't think that the result is improved apart
406  * when actual overflow occurs. FC/CA.
407  */
408  if (current_overflow_count!=linear_number_of_exception_thrown)
409  {
410  if (su) sc_rm(su), su = NULL;
411  if (sc) sc_rm(sc), sc = NULL;
412  sc = scsaved;
413  }
414  else
415  {
416  sc_rm(scsaved);
417  }
418 
419  scsaved = NULL; /* dead. either rm or moved as sc. */
420  sc_rm(s1);
421  sc_rm(s2);
422 
423  /* better compatibility with previous version, as the convex union
424  * normalizes the system and removes redundancy, what is not done
425  * if part of the system is separated. Other calls may be considered here?
426  */
427  sc_transform_ineg_in_eg(sc); /* ok, it will look better. */
428  /* misleading... not really projected. { x==y, y==3 } => { x==3, y==3 } */
429  sc_project_very_simple_equalities(sc);
430 
431  /* sc, su: fast union of disjoint. */
432  sc = sc_fusion(sc, su);
433 
434  /* regenerate the expected base. */
435  if (sc)
436  {
437  sc_fix(sc);
438  if (sc_base(sc)) base_rm(sc_base(sc));
439  }
440  else
441  {
442  sc = sc_rn(NULL);
443  }
444  sc_base(sc) = base_union(sc_base(is1), sc_base(is2));
445  sc_dimension(sc) = vect_size(sc_base(sc));
446 
447  return sc;
448 }
int linear_number_of_exception_thrown
static int is2(Pproblem XX, Pproblem VV, struct rproblem *RR)
=======================================================================
Definition: isolve.c:2158
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
void sc_fix(Psysteme s)
fix system s for coherency of the base and number of things.
Definition: sc_alloc.c:141
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
static Psysteme transitive_closure_from_two_bases(Psysteme s, Pbase b1, Pbase b2)
returns constraints from s which may depend on variables in b1 and b2.
Definition: sc_enveloppe.c:292
Psysteme elementary_convex_union(Psysteme s1, Psysteme s2)
implements FC basic idea of simple fast cases...
Definition: sc_enveloppe.c:171
Psysteme extract_common_syst(Psysteme s1, Psysteme s2)
returns the common subsystem if appropriate...
Psysteme sc_fusion(Psysteme s1, Psysteme s2)
package sc
void sc_transform_ineg_in_eg(Psysteme sc)
Transform the two constraints A.x <= b and -A.x <= -b of system sc into an equality A....
Pbase base
Definition: sc-local.h:75

References Ssysteme::base, base_rm, base_union(), elementary_convex_union(), extract_common_syst(), is2(), linear_number_of_exception_thrown, s1, sc_dup(), sc_fix(), sc_fusion(), sc_rm(), sc_rn(), sc_transform_ineg_in_eg(), transitive_closure_from_two_bases(), and vect_size().

Referenced by cute_convex_union(), do_array_expansion(), and statement_insertion_fix_access().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_enveloppe_chernikova()

Psysteme sc_enveloppe_chernikova ( Psysteme  s1,
Psysteme  s2 
)
Parameters
s11
s22

Definition at line 127 of file sc_enveloppe.c.

128 {
130 }
Psysteme sc_enveloppe_chernikova_ofl_ctrl(Psysteme s1, Psysteme s2, int ofl_ctrl)
package polyedre: enveloppe convexe de deux systemes lineaires
Definition: sc_enveloppe.c:68
#define OFL_CTRL
I do thing that overflows are managed in a very poor manner.

References OFL_CTRL, s1, and sc_enveloppe_chernikova_ofl_ctrl().

Referenced by actual_convex_union(), and dependence_cone_positive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_enveloppe_chernikova_ofl_ctrl()

Psysteme sc_enveloppe_chernikova_ofl_ctrl ( Psysteme  s1,
Psysteme  s2,
int  ofl_ctrl 
)

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/polyedre/polyedre-local.h instead, to add your own modifications. header file built by cproto polyedre-local.h package sur les polyedres poly

Malik Imadache, Corinne Ancourt, Neil Butler, Francois Irigoin

Modifications:

  • declaration de Ppoly et Spoly utilisant Psysteme au lieu de struct Ssysteme * (FI, 3/1/90) obsolete (not maintained) macro d'acces aux champs et sous-champs d'un polyedre, de son systeme generateur sg et de son systeme de contraintes sc cproto-generated files sc_enveloppe.c

Warning! Do not modify this file that is automatically generated!

Ce module est range dans le package polyedre bien qu'il soit utilisable en n'utilisant que des systemes lineaires (package sc) parce qu'il utilise lui-meme des routines sur les polyedres.

Francois Irigoin, Janvier 1990 Corinne Ancourt, Fabien Coelho from time to time (1999/2000) Psysteme sc_enveloppe_chernikova_ofl_ctrl(Psysteme s1, s2, int ofl_ctrl) input : output : modifies : s1 and s2 are NOT modified. comment : s1 and s2 must have a basis.

s = enveloppe(s1, s2); return s;

calcul d'une representation par systeme lineaire de l'enveloppe convexe des polyedres definis par les systemes lineaires s1 et s2

mem_spy_begin();

calcul de l'enveloppe convexe

printf("systeme final \n"); sc_dump(s);

mem_spy_end("sc_enveloppe_chernikova_ofl_ctrl");

Parameters
s11
s22
ofl_ctrlfl_ctrl

Definition at line 68 of file sc_enveloppe.c.

72 {
73  Psysteme s = SC_UNDEFINED;
74  volatile bool catch_performed = false;
75  /* mem_spy_begin(); */
76 
77  assert(!SC_UNDEFINED_P(s1) && !SC_UNDEFINED_P(s2));
78 
79  // yuk
80  if (ofl_ctrl == OFL_CTRL)
81  {
82  ofl_ctrl = FWD_OFL_CTRL;
83  catch_performed = true;
85  //CATCH(overflow_error) {
86  /*
87  * PLEASE do not remove this warning.
88  *
89  * BC 24/07/95
90  */
91  fprintf(stderr, "[sc_enveloppe_chernikova_ofl_ctrl] "
92  "arithmetic error occured\n" );
93  s = sc_rn(base_dup(sc_base(s1)));
94  return s;
95  }
96  }
97 
98  if (SC_RN_P(s2) || sc_rn_p(s2) || sc_dimension(s2)==0
99  || sc_empty_p(s1) || !sc_faisabilite_ofl(s1))
100  {
101  Psysteme sc2 = sc_dup(s2);
102  sc2 = sc_elim_redond(sc2);
103  s = SC_UNDEFINED_P(sc2)? sc_empty(base_dup(sc_base(s2))): sc2;
104  }
105  else
106  {
107  if (SC_RN_P(s1) ||sc_rn_p(s1) || sc_dimension(s1)==0
108  || sc_empty_p(s2) || !sc_faisabilite_ofl(s2))
109  {
110  Psysteme sc1 = sc_dup(s1);
111  sc1 = sc_elim_redond(sc1);
112  s = SC_UNDEFINED_P(sc1)? sc_empty(base_dup(sc_base(s1))): sc1;
113  }
114  else
115  {
116  /* calcul de l'enveloppe convexe */
117  s = sc_convex_hull(s1,s2);
118  /* printf("systeme final \n"); sc_dump(s); */
119  }
120  }
121  if (catch_performed)
123  /* mem_spy_end("sc_enveloppe_chernikova_ofl_ctrl"); */
124  return s;
125 }
#define CATCH(what)
@ overflow_error
@ timeout_error
#define UNCATCH(what)
Psysteme sc_convex_hull(Psysteme sc1, Psysteme sc2)
Definition: chernikova.c:74
#define assert(ex)
Definition: newgen_assert.h:41
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define FWD_OFL_CTRL
Pbase base_dup(Pbase b)
Pbase base_dup(Pbase b) Note: this function changes the value of the pointer.
Definition: alloc.c:268

References assert, base_dup(), CATCH, fprintf(), FWD_OFL_CTRL, OFL_CTRL, overflow_error, s1, sc_convex_hull(), sc_dup(), sc_empty(), sc_empty_p(), sc_rn(), sc_rn_p(), timeout_error, and UNCATCH.

Referenced by sc_enveloppe_chernikova().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_rectangular_hull()

Psysteme sc_rectangular_hull ( Psysteme  sc,
Pbase  pb 
)

take the rectangular bounding box of the systeme sc, by projecting each constraint of the systeme against each of the basis in pb

SG: this is basically a renaming of sc_projection_on_variables ...

Parameters
scc
pbb

Definition at line 456 of file sc_enveloppe.c.

456  {
457  volatile Psysteme rectangular = SC_UNDEFINED;
458  rectangular = sc_projection_on_variables(sc,pb,pb);
460  ;
461  // it does not matter if we fail ...
462  }
463  TRY {
464  sc_nredund(&rectangular);
466  }
467  return rectangular;
468 }
#define TRY

References CATCH, overflow_error, TRY, and UNCATCH.

Referenced by do_array_expansion(), do_solve_hardware_constraints_on_nb_proc(), and rectangularization_region().

+ Here is the caller graph for this function:

◆ sc_to_sg_chernikova()

Ptsg sc_to_sg_chernikova ( Psysteme  sc)

chernikova_mulprec.c

chernikova.c

Parameters
scc

Definition at line 42 of file chernikova.c.

43 {
44  Ptsg sg;
45 
46  if (linear_use_gmp())
47 #ifdef HAVE_GMP_H
48  sg = sc_to_sg_chernikova_mulprec(sc);
49 #else
50  abort();
51 #endif
52  else
54 
55  return sg;
56 }
Ptsg sc_to_sg_chernikova_fixprec(Psysteme sc)
chernikova_fixprec.c
Ptsg sg
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
Definition: sg-local.h:66

References abort, linear_use_gmp(), sc_to_sg_chernikova_fixprec(), and sg.

Referenced by dependence_cone_positive(), main(), and unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_to_sg_chernikova_fixprec()

Ptsg sc_to_sg_chernikova_fixprec ( Psysteme  sc)

chernikova_fixprec.c

Parameters
scc

Definition at line 32 of file chernikova_fixprec.c.

32  {
33  return sg_of_sc(sc);
34 }
static Ptsg sg_of_sc(Psysteme sc)
Definition: chernikova.h:1438

References sg_of_sc().

Referenced by sc_to_sg_chernikova().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sg_to_sc_chernikova()

Psysteme sg_to_sc_chernikova ( Ptsg  sg)
Parameters
sgg

Definition at line 58 of file chernikova.c.

59 {
60  Psysteme sc;
61 
62  if (linear_use_gmp())
63 #ifdef HAVE_GMP_H
64  sc = sg_to_sc_chernikova_mulprec(sg);
65 #else
66  abort();
67 #endif // HAVE_GMP_H
68  else
70 
71  return sc;
72 }
Psysteme sg_to_sc_chernikova_fixprec(Ptsg sg)

References abort, linear_use_gmp(), sg, and sg_to_sc_chernikova_fixprec().

Referenced by main(), prettyprint_dependence_graph(), and prettyprint_dependence_graph_view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sg_to_sc_chernikova_fixprec()

Psysteme sg_to_sc_chernikova_fixprec ( Ptsg  sg)
Parameters
sgg

Definition at line 36 of file chernikova_fixprec.c.

36  {
37  return sc_of_sg(sg);
38 }
static Psysteme sc_of_sg(Ptsg sg)
Definition: chernikova.h:1457

References sc_of_sg(), and sg.

Referenced by sg_to_sc_chernikova().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: