PIPS
reduc.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "linear_assert.h"
#include <time.h>
#include <sys/time.h>
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "sommet.h"
#include "polyedre.h"
#include "union.h"
+ Include dependency graph for reduc.c:

Go to the source code of this file.

Macros

#define hspara_join(se1, se2)   (((se1) >= (se2))?hspara_jm[(se1)][(se2)]:hspara_jm[(se2)][(se1)])
 
#define hspara_meet(se1, se2)   (((se1) <= (se2))?hspara_jm[(se1)][(se2)]:hspara_jm[(se2)][(se1)])
 
#define hspara_to_string(se)   (char*) hspara_string[(int) (se)]
 

Functions

static char *hspara_string[10] __attribute__ ((unused))
 Package : C3/union Author : Arnauld LESERVOT (leservot(a)limeil.cea.fr) Date :
Modified : 04 04 95 Documents: UNION.tex : `‘Extension de C3 aux unions de polyedres’' Comments : More...
 
enum hspara_elem vect_parallel (Pvecteur in_v1, Pvecteur in_v2)
 enum hspara_elem vect_parallel(Pvecteur in_v1, Pvecteur in_v2) AL950711 input: 2 Pvecteur in_v1 and in_v2 output: hspara_elem (element of the parallel half space lattice) memory: Inspector (nothing is shared, nor modified, output allocated). More...
 
enum hspara_elem contrainte_parallel_in_liste (Pcontrainte in_co, Pcontrainte in_lc)
 enum enum hspara_elem contrainte_parallel_in_liste( in_co, in_lc ) AL950711 input: 1 constraint in_co and a list of constraints in_lc output: hspara_elem (element of the parallel half space lattice) memory: Inspector (nothing is shared, nor modified, output allocated). More...
 
Psysteme sc_supress_parallel_redund_constraints (Psysteme in_ps1, Psysteme in_ps2)
 Psysteme sc_supress_parallel_redund_constraints( in_ps1, in_ps2 ) input: 2 Psystemes in_ps1 and in_ps2 output: in_ps1 / in_ps2 (cut operation on polyhedrons) memory: Inspector (nothing is shared, nor modified, output allocated). More...
 
Psysteme sc_supress_same_constraints (Psysteme in_ps1, Psysteme in_ps2)
 Psysteme sc_supress_same_constraints( in_ps1, in_ps2 ) supress in in_ps2 constraints that are in in_ps1. More...
 
Psysteme sc_elim_redund_with_first_ofl_ctrl (Psysteme in_ps1, Psysteme in_ps2, int ofl_ctrl)
 Psysteme sc_elim_redund_with_first_ofl_ctrl( in_ps1, in_ps2, ofl_ctrl ) Returns constraints of in_ps2 which cut in_ps1. More...
 
Ppath pa_supress_same_constraints (Ppath in_pa)
 Ppath pa_supress_same_constraints( (Ppath) in_pa )
Supress from complements of in_pa same constraints than those in positif Psystem in_pa->psys. More...
 
Pdisjunct pa_path_to_disjunct_rule4_ofl_ctrl (Ppath in_pa, int ofl_ctrl)
 Pdisjunct pa_path_to_disjunct_rule4_ofl_ctrl( (Ppath) in_pa, int ofl_ctrl)
Returns the corresponding disjunction according rule 4. More...
 
Pdisjunct pa_path_to_few_disjunct_ofl_ctrl (Ppath in_pa, int ofl_ctrl)
 line 1197 "reduc.w" More...
 
bool pa_inclusion_p_ofl_ctrl (Psysteme ps1, Psysteme ps2, int ofl_ctrl)
 bool pa_inclusion_p(Psysteme ps1, Psysteme ps2) BA, AL 31/05/94 returns true if ps1 represents a subset of ps2, false otherwise Inspector (no sharing on memory). More...
 
bool pa_system_equal_p_ofl_ctrl (Psysteme ps1, Psysteme ps2, int ofl_ctrl)
 bool pa_system_equal_p(Psysteme ps1, Psysteme ps2) BA More...
 
Pdisjunct pa_system_difference_ofl_ctrl (Psysteme ps1, Psysteme ps2, int ofl_ctrl)
 Pdisjunct pa_system_difference_ofl_ctrl(ps1, ps2) input : two Psystemes output : a disjunction representing ps1 - ps2 modifies : nothing comment : algorihtm : chemin = ps1 inter complement of (ps2) ret_dj = dj_simple_inegs_to_eg( pa_path_to_few_disjunct(chemin) ) More...
 
bool pa_convex_hull_equals_union_p_ofl_ctrl (Psysteme conv_hull, Psysteme ps1, Psysteme ps2, int ofl_ctrl, volatile bool ofl_res)
 bool pa_convex_hull_equals_union_p(conv_hull, ps1, ps2) input : two Psystems and their convex hull AL,BC 23/03/95 output : true if ps1 U ps2 = convex_hull, false otherwise modifies : nothing comment : complexity = nb_constraints(ps1) * nb_constraints(ps2) if ofl_ctrl = OFL_CTRL, conservatively returns ofl_ctrl when an overflow error occurs More...
 

Variables

static enum hspara_elem hspara_jm [10][10]
 

Macro Definition Documentation

◆ hspara_join

#define hspara_join (   se1,
  se2 
)    (((se1) >= (se2))?hspara_jm[(se1)][(se2)]:hspara_jm[(se2)][(se1)])

Definition at line 85 of file reduc.c.

◆ hspara_meet

#define hspara_meet (   se1,
  se2 
)    (((se1) <= (se2))?hspara_jm[(se1)][(se2)]:hspara_jm[(se2)][(se1)])

Definition at line 86 of file reduc.c.

◆ hspara_to_string

#define hspara_to_string (   se)    (char*) hspara_string[(int) (se)]

Definition at line 87 of file reduc.c.

Function Documentation

◆ __attribute__()

static char* hspara_string [10] __attribute__ ( (unused)  )
static

Package : C3/union Author : Arnauld LESERVOT (leservot(a)limeil.cea.fr) Date :
Modified : 04 04 95 Documents: UNION.tex : `‘Extension de C3 aux unions de polyedres’' Comments :

           WARNING

THOSE FUNCTIONS ARE AUTOMATICALLY DERIVED

    FROM THE WEB SOURCES !

Ansi includes
Linear includes

Definition at line 4277 of file bootstrap.c.

4279 {
4280  type t = type_undefined;
4282 
4284  t = make_type(is_type_functional, ft);
4285 
4286  functional_parameters(ft) =
4288  return t;
4289 }
functional make_functional(list a1, type a2)
Definition: ri.c:1109
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
static list make_parameter_list(int n, parameter(*mkprm)(void))
Definition: bootstrap.c:329
parameter MakeVoidParameter()
Definition: bootstrap.c:4199
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
type MakeOverloadedResult(void)
this function creates a default fortran operator result, i.e.
Definition: type.c:261
#define functional_parameters(x)
Definition: ri.h:1442
#define type_undefined
Definition: ri.h:2883
@ is_type_functional
Definition: ri.h:2901
#define functional_undefined
Definition: ri.h:1418

References functional_parameters, functional_undefined, is_type_functional, make_functional(), make_parameter_list(), make_type(), MakeOverloadedResult(), MakeVoidParameter(), NIL, and type_undefined.

+ Here is the call graph for this function:

◆ contrainte_parallel_in_liste()

enum hspara_elem contrainte_parallel_in_liste ( Pcontrainte  in_co,
Pcontrainte  in_lc 
)

enum enum hspara_elem contrainte_parallel_in_liste( in_co, in_lc ) AL950711 input: 1 constraint in_co and a list of constraints in_lc output: hspara_elem (element of the parallel half space lattice) memory: Inspector (nothing is shared, nor modified, output allocated).

complexity: length(in_lc) * comp(vect_parallel()) comment: in_co represents a1 X+b1 <= 0 and in_lc aj X + bj <=0. Returns in_co/in_lc = join_j( vect_parallel( in_co, in_lc_j ) ) between keep, empty and full.

debuging

debuging

Parameters
in_con_co
in_lcn_lc

Definition at line 49 of file reduc.c.

206 {
207  Pcontrainte c;
208  Pvecteur vpos;
209  enum hspara_elem ret_sle = keep;
210 
212  if (CONTRAINTE_NULLE_P(in_co)) return keep;
213 
214  /* debuging */
215  C3_DEBUG("contrainte_parallel_in_list", {
216  fprintf(stderr, "Input in_co:");
217  inegalite_fprint( stderr, in_co, union_variable_name );
218  fprintf(stderr, "Input in_lc:\n");
219  inegalites_fprint( stderr, in_lc, union_variable_name );
220  });
221 
222  vpos = in_co->vecteur;
223 
224  for (c = in_lc; !CONTRAINTE_UNDEFINED_P(c) && (ret_sle != full); c=c->succ) {
225  Pvecteur cv = c->vecteur;
226  enum hspara_elem hs = vect_parallel(vpos, cv);
227 
228  C3_DEBUG("contrainte_parallel_in_list", {
229  fprintf(stderr, "ret_sle: %s , hs: %s\n",
230  hspara_to_string(ret_sle),
231  hspara_to_string( hs ) );
232  });
233 
234  ret_sle = hspara_join( ret_sle, hs);
235  }
236 
237 
238  /* debuging */
239  C3_DEBUG("contrainte_parallel_in_list",
240  { fprintf(stderr, "Output hspara: %s\n", hspara_to_string(ret_sle)); });
241 
242  return ret_sle;
243 }
#define CONTRAINTE_UNDEFINED_P(c)
#define CONTRAINTE_NULLE_P(c)
contrainte nulle (non contrainte 0 == 0 ou 0 <= 0)
void inegalites_fprint(FILE *, Pcontrainte, char *(*)(Variable))
void inegalite_fprint(FILE *, Pcontrainte, char *(*)(Variable))
#define assert(ex)
Definition: newgen_assert.h:41
#define hspara_to_string(se)
Definition: reduc.c:87
#define hspara_join(se1, se2)
Definition: reduc.c:85
enum hspara_elem vect_parallel(Pvecteur in_v1, Pvecteur in_v2)
enum hspara_elem vect_parallel(Pvecteur in_v1, Pvecteur in_v2) AL950711 input: 2 Pvecteur in_v1 and i...
Definition: reduc.c:104
char *(* union_variable_name)(Variable)
Package : C3/union Author : Arnauld LESERVOT (leservot(a)limeil.cea.fr) Date : Modified : 04 04 95 ...
Definition: sc_list.c:51
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pvecteur vecteur
struct Scontrainte * succ
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define C3_DEBUG(fun, code)
Definition: union-local.h:150
hspara_elem
Implementation of the finite parallel half space lattice hspara.
Definition: union-local.h:49
@ full
Definition: union-local.h:65
@ keep
bj > b1 -> h1/hj = h1
Definition: union-local.h:61

Referenced by sc_supress_parallel_redund_constraints().

+ Here is the caller graph for this function:

◆ pa_convex_hull_equals_union_p_ofl_ctrl()

bool pa_convex_hull_equals_union_p_ofl_ctrl ( Psysteme  conv_hull,
Psysteme  ps1,
Psysteme  ps2,
int  ofl_ctrl,
volatile bool  ofl_res 
)

bool pa_convex_hull_equals_union_p(conv_hull, ps1, ps2) input : two Psystems and their convex hull AL,BC 23/03/95 output : true if ps1 U ps2 = convex_hull, false otherwise modifies : nothing comment : complexity = nb_constraints(ps1) * nb_constraints(ps2) if ofl_ctrl = OFL_CTRL, conservatively returns ofl_ctrl when an overflow error occurs

Parameters
conv_hullonv_hull
ps1s1
ps2s2
ofl_ctrlfl_ctrl
ofl_resfl_res

Definition at line 937 of file reduc.c.

942 {
943  volatile Ppath chemin;
944  bool result;
945  int local_ofl_ctrl = (ofl_ctrl == OFL_CTRL)?FWD_OFL_CTRL:ofl_ctrl;
946 
947  chemin = pa_make(conv_hull,sl_append_system(sl_append_system(NULL,ps1),ps2));
948 
949  if (ofl_ctrl==OFL_CTRL) {
951  result = ofl_res;
952  }
953  TRY {
954  result = !(pa_feasibility_ofl_ctrl(chemin, local_ofl_ctrl));
956  }
957  }
958  else
959  result = !(pa_feasibility_ofl_ctrl(chemin, local_ofl_ctrl));
960 
961  chemin = pa_free1(chemin);
962  return(result);
963 }
#define CATCH(what)
@ overflow_error
#define UNCATCH(what)
#define TRY
Ppath pa_make(Psysteme in_ps, Pcomplist in_pcomp)
Package : C3/union Author : Arnauld LESERVOT (leservot(a)limeil.cea.fr) Date : Modified : 04 04 95 ...
Definition: path.c:53
bool pa_feasibility_ofl_ctrl(Ppath in_pa, int ofl_ctrl)
bool pa_feasibility_ofl_ctrl( (Ppath) in_pa, int ofl_ctrl) Returns true if the input path is possib...
Definition: path.c:309
Ppath pa_free1(Ppath in_pa)
Ppath pa_free1(Ppath pa) BA, AL 30/05/94 1 depth free.
Definition: path.c:102
Psyslist sl_append_system(Psyslist in_sl, Psysteme in_ps)
Psyslist sl_append_system( (Psyslist) in_sl, (Psysteme) in_ps ) Input : A disjunct in_sl to wich in_p...
Definition: sc_list.c:240
#define FWD_OFL_CTRL
#define OFL_CTRL
I do thing that overflows are managed in a very poor manner.

References CATCH, FWD_OFL_CTRL, OFL_CTRL, overflow_error, pa_feasibility_ofl_ctrl(), pa_free1(), pa_make(), sl_append_system(), TRY, and UNCATCH.

+ Here is the call graph for this function:

◆ pa_inclusion_p_ofl_ctrl()

bool pa_inclusion_p_ofl_ctrl ( Psysteme  ps1,
Psysteme  ps2,
int  ofl_ctrl 
)

bool pa_inclusion_p(Psysteme ps1, Psysteme ps2) BA, AL 31/05/94 returns true if ps1 represents a subset of ps2, false otherwise Inspector (no sharing on memory).

Parameters
ps1s1
ps2s2
ofl_ctrlfl_ctrl

Definition at line 868 of file reduc.c.

871 {
872  bool result;
873  Ppath chemin = pa_make(ps1, sl_append_system(NULL, ps2));
874 
876  result = false;
877  }
878  TRY {
879  result = ! (pa_feasibility_ofl_ctrl(chemin, ofl_ctrl));
881  }
882  chemin = pa_free1(chemin);
883  return(result);
884 }

References CATCH, overflow_error, pa_feasibility_ofl_ctrl(), pa_free1(), pa_make(), sl_append_system(), TRY, and UNCATCH.

Referenced by pa_system_equal_p_ofl_ctrl().

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

◆ pa_path_to_disjunct_rule4_ofl_ctrl()

Pdisjunct pa_path_to_disjunct_rule4_ofl_ctrl ( Ppath  in_pa,
int  ofl_ctrl 
)

Pdisjunct pa_path_to_disjunct_rule4_ofl_ctrl( (Ppath) in_pa, int ofl_ctrl)
Returns the corresponding disjunction according rule 4.

AL 05/16/95 No sharing.

Returns according to different cases

we've modified P0 systeme

Parameters
in_pan_pa
ofl_ctrlfl_ctrl

Definition at line 570 of file reduc.c.

573 {
574  Pcomplist comp, lcomp = NULL;
575  Pdisjunct ret_dj ;
576  Psysteme systeme ;
577  Ppath pa ;
578  int pa_clength1, pa_clength2;
579 
580  if (in_pa == PA_UNDEFINED) return DJ_UNDEFINED;
581  if (pa_empty_p(in_pa)) return dj_empty();
582 
583  C3_DEBUG( "pa_path_to_disjunct_rule4_ofl_ctrl", {
584  fprintf(stderr, "\n\n Input path:\n\n");
585  pa_fprint(stderr, in_pa, union_variable_name );
586  });
587 
588 
590  C3_RETURN(IS_DJ, pa_path_to_disjunct_ofl_ctrl( in_pa, ofl_ctrl));
591 
592  systeme = in_pa->psys;
593  if (in_pa->pcomp == NULL)
594  C3_RETURN(IS_DJ, sl_append_system(NULL,sc_dup(systeme)));
595 
596  for( comp = in_pa->pcomp; comp != NULL; comp = comp->succ ) {
597  Psysteme ps;
598  if (comp->psys == SC_UNDEFINED)
599  { sl_free(lcomp); C3_RETURN( IS_DJ, DJ_UNDEFINED ); }
600 
601  ps = sc_dup(comp->psys);
602 
603  ps = sc_elim_redund_with_first_ofl_ctrl( systeme, ps, ofl_ctrl );
604 
605  if (sc_empty_p( ps )) { ps = sc_free(ps); continue; }
606  if (sc_full_p ( ps ))
607  { ps = sc_free(ps); C3_RETURN( IS_DJ, dj_empty() ); }
608 
609  lcomp = sl_append_system( lcomp, ps );
610  }
611 
612  pa = pa_make(sc_dup(in_pa->psys), lcomp);
613  pa_clength1 = sl_length( pa->pcomp );
614  pa = pa_reduce_simple_complement( pa );
615  pa_clength2 = sl_length( pa->pcomp );
616  systeme = pa->psys;
617 
618 
619  /* Returns according to different cases */
620  if (pa_empty_p(pa))
621  { ret_dj = dj_empty(); }
622  else if (pa_clength2 == 0)
623  { ret_dj = dj_append_system(NULL,sc_dup(systeme)); }
624  else if (pa_clength1 != pa_clength2) /* we've modified P0 systeme */
625  { ret_dj = pa_path_to_disjunct_rule4_ofl_ctrl( pa, ofl_ctrl); }
626  else { ret_dj = pa_path_to_disjunct_ofl_ctrl( pa, ofl_ctrl); }
627 
628  pa = pa_free( pa );
629 
630  C3_RETURN( IS_DJ, ret_dj );
631 }
Pdisjunct dj_append_system(Pdisjunct in_dj, Psysteme in_ps)
Pdisjunct dj_append_system( (Pdisjunct) in_dj, (Psysteme) in_ps ) Input : A disjunct in_dj to wich in...
Definition: disjunct.c:403
Pdisjunct dj_empty()
Pdisjunct dj_empty() AL 18/11/93 Returns a disjunction with sc_empty() element.
Definition: disjunct.c:111
int pa_max_constraints_nb(Ppath in_pa)
int pa_max_constraints_nb( (Ppath) in_pa ) Give the maximum constraints nb among systems of in_pa.
Definition: path.c:155
Ppath pa_free(Ppath in_pa)
Ppath pa_free(Ppath pa) BA, AL 30/05/94.
Definition: path.c:76
Pdisjunct pa_path_to_disjunct_ofl_ctrl(Ppath in_pa, int ofl_ctrl)
Pdisjunct pa_path_to_disjunct_ofl_ctrl ( (Ppath) in_pa, (int) ofl_ctrl) Produces a Pdisjunct corres...
Definition: path.c:374
bool pa_empty_p(Ppath in_pa)
pa_empty_p( (Ppath) in_pa ) AL 18/11/93 Returns True if in_pa = (1*TCST = 0) ^ (NIL)
Definition: path.c:141
Ppath pa_reduce_simple_complement(Ppath in_pa)
Ppath pa_reduce_simple_complement( (Ppath) in_pa ) AL 16/11/93 Scan all the complement.
Definition: path.c:222
Pdisjunct pa_path_to_disjunct_rule4_ofl_ctrl(Ppath in_pa, int ofl_ctrl)
Pdisjunct pa_path_to_disjunct_rule4_ofl_ctrl( (Ppath) in_pa, int ofl_ctrl) Returns the correspondin...
Definition: reduc.c:570
Psysteme sc_elim_redund_with_first_ofl_ctrl(Psysteme in_ps1, Psysteme in_ps2, int ofl_ctrl)
Psysteme sc_elim_redund_with_first_ofl_ctrl( in_ps1, in_ps2, ofl_ctrl ) Returns constraints of in_ps2...
Definition: reduc.c:412
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
Psysteme sc_free(Psysteme in_ps)
Psysteme sc_free( in_ps ) AL 30/05/94 Free of in_ps.
Definition: sc_list.c:112
Psyslist sl_free(Psyslist psl)
Psyslist sl_free(Psyslist psl) BA, AL 30/05/94 w - 1 depth free.
Definition: sc_list.c:327
bool sc_full_p(Psysteme in_ps)
Psysteme sc_full_p( in_ps ) similar to sc_new.
Definition: sc_list.c:61
bool sl_length(Psyslist in_sl)
int sl_length( (Psyslist) in_sl ) AL 26/04/95 Returns length of in_sl.
Definition: sc_list.c:193
Pcomplist pcomp
Definition: union-local.h:20
Psysteme psys
Definition: union-local.h:19
Warning! Do not modify this file that is automatically generated!
Definition: union-local.h:3
Psysteme psys
Definition: union-local.h:4
struct Ssyslist * succ
Definition: union-local.h:5
#define pa_fprint(fi, pa, fu)
Definition: union-local.h:109
#define PA_UNDEFINED
Definition: union-local.h:23
#define IS_DJ
Definition: union-local.h:135
#define C3_RETURN(type, val)
Definition: union-local.h:151
#define PATH_MAX_CONSTRAINTS
Misceleanous (debuging...)
Definition: union-local.h:131
#define DJ_UNDEFINED
Definition: union-local.h:12

References C3_DEBUG, C3_RETURN, dj_append_system(), dj_empty(), DJ_UNDEFINED, fprintf(), IS_DJ, pa_empty_p(), pa_fprint, pa_free(), pa_make(), pa_max_constraints_nb(), pa_path_to_disjunct_ofl_ctrl(), pa_reduce_simple_complement(), PA_UNDEFINED, PATH_MAX_CONSTRAINTS, Spath::pcomp, Ssyslist::psys, Spath::psys, sc_dup(), sc_elim_redund_with_first_ofl_ctrl(), sc_empty_p(), sc_free(), sc_full_p(), sl_append_system(), sl_free(), sl_length(), Ssyslist::succ, and union_variable_name.

Referenced by pa_path_to_few_disjunct_ofl_ctrl().

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

◆ pa_path_to_few_disjunct_ofl_ctrl()

Pdisjunct pa_path_to_few_disjunct_ofl_ctrl ( Ppath  in_pa,
int  ofl_ctrl 
)

line 1197 "reduc.w"

Pdisjunct pa_path_to_few_disjunct_ofl_ctrl( (Ppath) in_pa, (int) ofl_ctrl )
Produces a Pdisjunct corresponding to the path Ppath and reduces the number of disjunctions. See "Extension de C3 aux Unions de Polyedres" Version 2, for a complete explanation about this function. in_pa is modified. AL 23/03/95

line 1208 "reduc.w"

If it's an empty path or if it has no complements : return

We are looking for a common hyperplan

removes cons_pv and vect_dup(vect_1)

take care of rule 2

take care of rule 2

Manage memory, free: cons_oppose, common_ps, common_ps_oppose, cons_pv, vect_1, pa1, pa2

Manage memory

Parameters
in_pan_pa
ofl_ctrlfl_ctrl

Definition at line 648 of file reduc.c.

651 {
652 
653 #line 980 "reduc.w"
654  Psysteme systeme; Pdisjunct ret_dj = DJ_UNDEFINED;
655 #line 1001 "reduc.w"
656  Ppath pa; Pcomplist lcomp;
657 #line 1040 "reduc.w"
658 
659  Pcontrainte common_cons = NULL, cons, cons_oppose = NULL;
660  Pvecteur vect_1, cons_pv = NULL;
661  Pcomplist comp;
662 
663 #line 1111 "reduc.w"
664 
665  Pcontrainte common_cons_oppose;
666  Psysteme common_ps, common_ps_oppose;
667  Ppath pa1, pa2;
668  bool pa1_empty = false, pa2_empty = false;
669  bool pa1_filled = false, pa2_filled = false;
670 
671 #line 1144 "reduc.w"
672  Pdisjunct dj1 = dj_empty(), dj2 = dj_empty();
673 #line 1214 "reduc.w"
674 
675 
676 
677 #line 981 "reduc.w"
678 
679  C3_DEBUG( "pa_path_to_few_disjunct_ofl_ctrl", {
680  fprintf(stderr, "\n\n Input path:\n\n");
681  pa_fprint(stderr, in_pa, union_variable_name );
682  });
683 
684  if (PA_UNDEFINED_P( in_pa )) C3_RETURN(IS_DJ, DJ_UNDEFINED);
685  if (pa_full_p ( in_pa )) C3_RETURN(IS_DJ, dj_full());
686  if (pa_empty_p ( in_pa )) C3_RETURN(IS_DJ, dj_empty());
687 
688  /* If it's an empty path or if it has no complements : return */
689  systeme = in_pa->psys ;
690  if (!sc_faisabilite_ofl( systeme )) C3_RETURN(IS_DJ,dj_empty());
691  if (in_pa->pcomp == NULL) C3_RETURN(IS_DJ,(Pdisjunct) sl_append_system(NULL,sc_dup(systeme)));
692 
693 #line 1216 "reduc.w"
694 
695 
696 #line 1002 "reduc.w"
697 
698  pa = pa_make(sc_dup(systeme), sl_dup(in_pa->pcomp));
699  pa = pa_reduce_simple_complement( pa );
700 
701  if (pa_empty_p(pa)) {pa = pa_free(pa); C3_RETURN(IS_DJ,dj_empty());}
702 
703  pa = pa_transform_eg_in_ineg ( pa );
704  lcomp = pa->pcomp ;
705  systeme = pa->psys ;
706 
707  C3_DEBUG( "pa_path_to_few_disjunct_ofl_ctrl", {
708  fprintf(stderr, "pa:\n");
709  pa_fprint_tab(stderr, pa, union_variable_name, 1 );
710  });
711 
712  if ( pa->pcomp == NULL ) {
713  pa = pa_free1(pa);
714  ret_dj = (Pdisjunct) sl_append_system(NULL, systeme);
715 
716  C3_DEBUG( "pa_path_to_few_disjunct_ofl_ctrl", {
717  fprintf(stderr, "No complement, returning:\n");
718  dj_fprint_tab(stderr, ret_dj, union_variable_name, 1 );
719  });
720 
721  return ret_dj;
722  }
723 
724 #line 1217 "reduc.w"
725 
726 
727 #line 1045 "reduc.w"
728 
729  /* We are looking for a common hyperplan */
730  vect_1 = vect_new(TCST, VALUE_ONE); common_cons = NULL;
731 
732  for(cons = (lcomp->psys)->inegalites;
733  (cons != NULL)&&(lcomp->succ != NULL);cons = cons->succ){
734  bool is_common = true;
735  cons_pv = vect_dup( cons->vecteur ); vect_chg_sgn( cons_pv );
736  cons_oppose = contrainte_make(vect_add( cons_pv, vect_1 ));
737 
738  for(comp = lcomp->succ;(comp != NULL) && is_common; comp = comp->succ){
739  Pcontrainte ineg = (comp->psys)->inegalites;
740  bool is_common1, is_common2;
741 
742  is_common1 = contrainte_in_liste( cons, ineg );
743  is_common2 = contrainte_in_liste( cons_oppose, ineg );
744  is_common = is_common1 || is_common2;
745  }
746  if (!is_common) {
747  /* removes cons_pv and vect_dup(vect_1) */
748  cons_oppose = contrainte_free(cons_oppose);
749  vect_rm( cons_pv ); cons_pv = (Pvecteur) NULL;
750  continue;
751  }
752  common_cons = cons;
753  vect_chg_sgn( cons_pv );
754  break;
755  }
756 
757  C3_DEBUG( "pa_path_to_few_disjunct_ofl_ctrl", {
758  fprintf(stderr, "cons_pv: ");
759  if (common_cons == NULL) fprintf(stderr, "NULL\n");
760  else vect_fprint(stderr, cons_pv, union_variable_name);
761  });
762 
763 #line 1218 "reduc.w"
764 
765 
766 #line 1086 "reduc.w"
767 
768  if( common_cons != NULL ) {
769 
770 #line 1118 "reduc.w"
771 
772  common_ps = sc_make( CONTRAINTE_UNDEFINED, contrainte_make(cons_pv) );
773  cons_pv = vect_dup( common_cons->vecteur ); vect_chg_sgn( cons_pv );
774  common_cons_oppose = contrainte_make(vect_add(cons_pv,vect_1));
775  common_ps_oppose = sc_make( CONTRAINTE_UNDEFINED, common_cons_oppose );
776  pa1 = pa_new(); pa2= pa_new();
777 
778  for(comp = lcomp; comp != NULL; comp = comp->succ){
779  Psysteme local_ps;
780  Pcontrainte co = comp->psys->inegalites;
781 
782  if (!pa1_empty && contrainte_in_liste(common_cons, co)) {
783  local_ps = sc_supress_same_constraints( common_ps, comp->psys );
784  if (local_ps == SC_EMPTY) { pa1 = pa_empty(); pa1_empty = true; continue;}
785  pa1->pcomp = sl_append_system( pa1->pcomp, local_ps ); pa1_filled = true;
786  }
787  else if(!pa2_empty && contrainte_in_liste(common_cons_oppose, co)) {
788  local_ps = sc_supress_same_constraints( common_ps_oppose, comp->psys );
789  if (local_ps == SC_EMPTY) {pa2 = pa_empty(); pa2_empty = true; continue;}
790  pa2->pcomp = sl_append_system( pa2->pcomp, local_ps ); pa2_filled = true;
791  }
792  }
793 
794 #line 1088 "reduc.w"
795 
796 
797 #line 1145 "reduc.w"
798 
799  if (pa1_filled) {
800  /* take care of rule 2 */
801  if (pa_full_p( pa2 )) pa1->psys = sc_dup( systeme );
802  else pa1->psys = sc_safe_append( sc_dup(common_ps), systeme );
803 
804  C3_DEBUG("pa_path_to_few_disjunct", {
805  fprintf(stderr, "pa1:\n");
806  pa_fprint_tab( stderr, pa1, union_variable_name, 1 );
807  });
808 
809  if (pa_full_p(pa2)||sc_faisabilite_ofl(pa1->psys))
810  {dj_free(dj1);dj1 = pa_path_to_few_disjunct_ofl_ctrl(pa1, ofl_ctrl);}
811 
812  }
813 
814  if (pa2_filled) {
815  /* take care of rule 2 */
816  if (pa_full_p( pa1 )) pa2->psys = sc_dup( systeme );
817  else pa2->psys = sc_safe_append( sc_dup(common_ps_oppose), systeme );
818 
819  C3_DEBUG("pa_path_to_few_disjunct", {
820  fprintf(stderr, "pa2:\n");
821  pa_fprint_tab( stderr, pa2, union_variable_name, 1 );
822  });
823  if (pa_full_p(pa1)||sc_faisabilite_ofl(pa2->psys))
824  {dj_free(dj2);dj2 = pa_path_to_few_disjunct_ofl_ctrl(pa2, ofl_ctrl);}
825 
826 
827  }
828 
829  ret_dj = dj_union( dj1, dj2 );
830 
831  /* Manage memory, free:
832  * cons_oppose, common_ps, common_ps_oppose,
833  * cons_pv, vect_1, pa1, pa2
834  */
835  cons_oppose = contrainte_free( cons_oppose );
836  common_ps = sc_free( common_ps );
837  common_ps_oppose = sc_free( common_ps_oppose );
838  vect_rm(cons_pv); cons_pv = NULL;
839  pa1 = pa_free(pa1); pa2 = pa_free(pa2);
840 
841 #line 1089 "reduc.w"
842 
843  }
844  else {
845 
846 #line 1191 "reduc.w"
847  ret_dj = pa_path_to_disjunct_rule4_ofl_ctrl( pa, ofl_ctrl );
848 
849 #line 1092 "reduc.w"
850 
851  }
852 
853  /* Manage memory */
854  pa = pa_free(pa); vect_rm(vect_1); vect_1 = NULL;
855 
856  C3_RETURN(IS_DJ, ret_dj);
857 
858 #line 1219 "reduc.w"
859 
860 }
#define VALUE_ONE
#define CONTRAINTE_UNDEFINED
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
Pcontrainte contrainte_free(Pcontrainte c)
Pcontrainte contrainte_free(Pcontrainte c): liberation de l'espace memoire alloue a la contrainte c a...
Definition: alloc.c:184
bool contrainte_in_liste(Pcontrainte, Pcontrainte)
listes.c
Definition: listes.c:52
Pdisjunct dj_free(Pdisjunct in_dj)
Pdisjunct dj_free( (Pdisjunct) in_dj ) AL 31/05/94 w - 1 depth free of input disjunction.
Definition: disjunct.c:69
Pdisjunct dj_union(Pdisjunct in_dj1, Pdisjunct in_dj2)
Pdisjunct dj_union( (Pdisjunct) in_dj1, (Pdisjunct) in_dj2 ) Give the union of the two disjunctions.
Definition: disjunct.c:211
Pdisjunct dj_full()
Pdisjunct dj_full() AL 18/11/93 Return full space disjunction = dj_new()
Definition: disjunct.c:92
void dj_fprint_tab(FILE *in_fi, Pdisjunct in_dj, char *(*in_fu)(), int in_tab)
void dj_fprint_tab(FILE*, Pdisjunct, function, int) prints a Pdisjunct
Definition: disjunct.c:492
struct cons cons
The structure used to build lists in NewGen.
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
Ppath pa_empty()
Ppath pa_empty() AL 18/11/93 Returns empty path : pa_empty = sc_empty(NULL) ^ (NIL)
Definition: path.c:135
void pa_fprint_tab(FILE *in_fi, Ppath in_pa, char *(*in_fu)(), int in_tab)
void pa_fprint_tab(FILE*, Pdisjunct, function, tab) prints a Ppath
Definition: path.c:412
Ppath pa_transform_eg_in_ineg(Ppath in_pa)
Ppath pa_transform_eg_in_ineg( in_pa ) Transforms all equalities of all systems composing in_pa in in...
Definition: path.c:284
bool pa_full_p(Ppath in_pa)
pa_full_p( (Ppath) in_pa ) AL 18/11/93 Returns True if in_pa = (NIL) ^ (NIL)
Definition: path.c:123
Psysteme sc_supress_same_constraints(Psysteme in_ps1, Psysteme in_ps2)
Psysteme sc_supress_same_constraints( in_ps1, in_ps2 ) supress in in_ps2 constraints that are in in_p...
Definition: reduc.c:329
Pdisjunct pa_path_to_few_disjunct_ofl_ctrl(Ppath in_pa, int ofl_ctrl)
line 1197 "reduc.w"
Definition: reduc.c:648
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg)
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equ...
Definition: sc.c:78
Psysteme sc_safe_append(Psysteme s1, Psysteme s2)
Psysteme sc_safe_append(Psysteme s1, Psysteme s2) input : output : calcul de l'intersection des polye...
Psyslist sl_dup(Psyslist in_sl)
Psyslist sl_dup( (Psyslist) in_sl ) AL 15/11/93 w - 1 duplication : everything is duplicated,...
Definition: sc_list.c:296
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Pcontrainte inegalites
Definition: sc-local.h:71
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define PA_UNDEFINED_P(pa)
Definition: union-local.h:110
Ssyslist * Pdisjunct
Definition: union-local.h:10
#define pa_new()
Definition: union-local.h:111
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
struct Svecteur * Pvecteur
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53

References C3_DEBUG, C3_RETURN, contrainte_free(), contrainte_in_liste(), contrainte_make(), CONTRAINTE_UNDEFINED, dj_empty(), dj_fprint_tab(), dj_free(), dj_full(), DJ_UNDEFINED, dj_union(), fprintf(), Ssysteme::inegalites, IS_DJ, pa_empty(), pa_empty_p(), pa_fprint, pa_fprint_tab(), pa_free(), pa_free1(), pa_full_p(), pa_make(), pa_new, pa_path_to_disjunct_rule4_ofl_ctrl(), pa_reduce_simple_complement(), pa_transform_eg_in_ineg(), PA_UNDEFINED_P, Spath::pcomp, Ssyslist::psys, Spath::psys, sc_dup(), sc_free(), sc_make(), sc_safe_append(), sc_supress_same_constraints(), sl_append_system(), sl_dup(), Ssyslist::succ, TCST, union_variable_name, VALUE_ONE, vect_add(), vect_chg_sgn(), vect_dup(), vect_fprint(), vect_new(), vect_rm(), and Scontrainte::vecteur.

Referenced by dj_intersect_djcomp_ofl_ctrl(), pa_feasibility_ofl_ctrl(), and pa_system_difference_ofl_ctrl().

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

◆ pa_supress_same_constraints()

Ppath pa_supress_same_constraints ( Ppath  in_pa)

Ppath pa_supress_same_constraints( (Ppath) in_pa )
Supress from complements of in_pa same constraints than those in positif Psystem in_pa->psys.

Returned path have no more equalities. AL050795 No sharing, no modification of inputs.

Special cases

debuging

General case

Psysteme ps = sc_supress_same_constraints( positif, comp->psys );

Parameters
in_pan_pa

Definition at line 528 of file reduc.c.

530 {
531  Ppath ret_pa = PA_UNDEFINED;
532  Pcomplist comp;
533  Psysteme positif;
534  Psyslist psl = NULL;
535 
536  /* Special cases */
537  if ( PA_UNDEFINED_P( in_pa )) return PA_UNDEFINED;
538  if ( pa_empty_p ( in_pa )) return pa_empty();
539  if ( pa_full_p ( in_pa )) return pa_full ();
540 
541  /* debuging */
542  C3_DEBUG( "pa_supress_same_constraints", {
543  fprintf(stderr, "Input path:\n");
544  pa_fprint_tab(stderr, in_pa, union_variable_name, 1);
545  });
546 
547  /* General case */
548  positif = in_pa->psys;
549  if (!sc_faisabilite_ofl(positif)) return pa_empty();
550 
551  for( comp = in_pa->pcomp; comp != NULL; comp = comp->succ) {
552  /* Psysteme ps = sc_supress_same_constraints( positif, comp->psys ); */
554  if (ps == NULL)
555  {psl = sl_free(psl); ret_pa = pa_empty(); C3_RETURN(IS_PA, ret_pa);}
556  else psl = sl_append_system( psl, ps );
557  }
558 
559  positif = sc_dup(positif); sc_transform_eg_in_ineg( positif );
560  ret_pa = pa_make( positif, (Pcomplist) psl );
561  C3_RETURN(IS_PA, ret_pa);
562 }
Ppath pa_full()
Ppath pa_full() AL 18/11/93 Returns full space path : pa_full = pa_new()
Definition: path.c:117
Psysteme sc_supress_parallel_redund_constraints(Psysteme in_ps1, Psysteme in_ps2)
Psysteme sc_supress_parallel_redund_constraints( in_ps1, in_ps2 ) input: 2 Psystemes in_ps1 and in_ps...
Definition: reduc.c:255
void sc_transform_eg_in_ineg(Psysteme sc)
Package sc.
#define IS_PA
Definition: union-local.h:136

References C3_DEBUG, C3_RETURN, fprintf(), IS_PA, pa_empty(), pa_empty_p(), pa_fprint_tab(), pa_full(), pa_full_p(), pa_make(), PA_UNDEFINED, PA_UNDEFINED_P, Ssyslist::psys, sc_dup(), sc_supress_parallel_redund_constraints(), sc_transform_eg_in_ineg(), sl_append_system(), sl_free(), Ssyslist::succ, and union_variable_name.

Referenced by pa_feasibility_ofl_ctrl().

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

◆ pa_system_difference_ofl_ctrl()

Pdisjunct pa_system_difference_ofl_ctrl ( Psysteme  ps1,
Psysteme  ps2,
int  ofl_ctrl 
)

Pdisjunct pa_system_difference_ofl_ctrl(ps1, ps2) input : two Psystemes output : a disjunction representing ps1 - ps2 modifies : nothing comment : algorihtm : chemin = ps1 inter complement of (ps2) ret_dj = dj_simple_inegs_to_eg( pa_path_to_few_disjunct(chemin) )

Parameters
ps1s1
ps2s2
ofl_ctrlfl_ctrl

Definition at line 908 of file reduc.c.

911 {
912  Ppath chemin;
913  Pdisjunct dj, ret_dj;
914 
915  if ((ps1 == SC_UNDEFINED)||(ps2 == SC_UNDEFINED)) return DJ_UNDEFINED;
916  if (sc_empty_p(ps2)) return sl_append_system(NULL,sc_dup(ps1));
917  if (sc_empty_p(ps1)) return dj_empty();
918 
919  chemin = pa_make(ps1, sl_append_system(NULL,ps2));
920  dj = pa_path_to_few_disjunct_ofl_ctrl(chemin, ofl_ctrl);
921  chemin = pa_free1( chemin );
922  ret_dj = dj_simple_inegs_to_eg( dj );
923  dj = dj_free( dj );
924  return ret_dj;
925 }
Pdisjunct dj_simple_inegs_to_eg(Pdisjunct in_dj)
Pdisjunct dj_simple_inegs_to_eg( in_dj ) transforms two opposite inequalities in a simple equality in...
Definition: disjunct.c:339

References dj_empty(), dj_free(), dj_simple_inegs_to_eg(), DJ_UNDEFINED, pa_free1(), pa_make(), pa_path_to_few_disjunct_ofl_ctrl(), sc_dup(), sc_empty_p(), and sl_append_system().

+ Here is the call graph for this function:

◆ pa_system_equal_p_ofl_ctrl()

bool pa_system_equal_p_ofl_ctrl ( Psysteme  ps1,
Psysteme  ps2,
int  ofl_ctrl 
)

bool pa_system_equal_p(Psysteme ps1, Psysteme ps2) BA

Parameters
ps1s1
ps2s2
ofl_ctrlfl_ctrl

Definition at line 890 of file reduc.c.

893 {
894  return ( pa_inclusion_p_ofl_ctrl(ps1,ps2, ofl_ctrl) &&
895  pa_inclusion_p_ofl_ctrl(ps2,ps1, ofl_ctrl) );
896 }
bool pa_inclusion_p_ofl_ctrl(Psysteme ps1, Psysteme ps2, int ofl_ctrl)
bool pa_inclusion_p(Psysteme ps1, Psysteme ps2) BA, AL 31/05/94 returns true if ps1 represents a subs...
Definition: reduc.c:868

References pa_inclusion_p_ofl_ctrl().

+ Here is the call graph for this function:

◆ sc_elim_redund_with_first_ofl_ctrl()

Psysteme sc_elim_redund_with_first_ofl_ctrl ( Psysteme  in_ps1,
Psysteme  in_ps2,
int  ofl_ctrl 
)

Psysteme sc_elim_redund_with_first_ofl_ctrl( in_ps1, in_ps2, ofl_ctrl ) Returns constraints of in_ps2 which cut in_ps1.

AL 06 04 95 It is assumed that in_ps1 and in_ps2 are feasible ! in_ps1 is not modified, in_ps2 is modified.

Return on special cases

debuging

build in_ps1.and.in_ps2 with sharing on in_ps2 This also works if in_ps1 is full space

debuging

update information on ps1

debuging

Normalize 2 inputs systems

returns if there is no intersection

We run over in_ps2 constraints (shared by ps1) and detect redundance

eliminate the constraint from in_ps2, and thus from ps1

Parameters
in_ps1n_ps1
in_ps2n_ps2
ofl_ctrlfl_ctrl

Definition at line 412 of file reduc.c.

415 {
416  Psysteme ps1;
417  Pcontrainte prev_eq = NULL, eq, tail = NULL;
418  Pbase pb;
419 
420  /* Return on special cases */
421  if ( sc_full_p(in_ps1) ) return in_ps2;
422  if ( in_ps1->nb_ineq == 0 ) return in_ps2;
423 
424  /* debuging */
425  C3_DEBUG("sc_elim_redund_with_first", {
426  fprintf(stderr, "\nInput systems, in_ps1, then in_ps2:\n");
427  sc_fprint( stderr, in_ps1, union_variable_name );
428  sc_fprint( stderr, in_ps2, union_variable_name );
429  });
430 
431 
432  /* build in_ps1.and.in_ps2 with sharing on in_ps2
433  * This also works if in_ps1 is full space */
434  if ( in_ps2->nb_eq != 0 ) sc_transform_eg_in_ineg( in_ps2 );
435  ps1 = sc_dup( in_ps1 );
436  for (eq = ps1->inegalites; eq != NULL; tail = eq, eq = eq->succ) {}
437  tail->succ = in_ps2->inegalites;
438 
439  /* debuging */
440  C3_DEBUG("sc_elim_redund_with_first", {
441  fprintf(stderr, "ps1 old: nb_eq= %d, nb_ineq= %d, dimension= %d, base= \n",
442  ps1->nb_eq, ps1->nb_ineq, ps1->dimension);
443  vect_fprint(stderr, ps1->base, union_variable_name);
444  fprintf(stderr, "in_ps2: nb_eq= %d, nb_ineq= %d, dimension= %d, base= \n",
445  in_ps2->nb_eq, in_ps2->nb_ineq, in_ps2->dimension);
446  vect_fprint(stderr, in_ps2->base, union_variable_name);
447  });
448 
449  /* update information on ps1 */
450  ps1->nb_eq = ps1->nb_eq + in_ps2->nb_eq;
451  ps1->nb_ineq = ps1->nb_ineq + in_ps2->nb_ineq;
452  pb = ps1->base;
453  ps1->base = base_union( ps1->base, in_ps2->base );
454  ps1->dimension = vect_size ( ps1->base );
455  vect_rm( pb );
456 
457  /* debuging */
458  C3_DEBUG("sc_elim_redund_with_first", {
459  fprintf(stderr, "ps1: nb_eq= %d, nb_ineq= %d, dimension= %d, base= \n",
460  ps1->nb_eq, ps1->nb_ineq, ps1->dimension);
461  vect_fprint(stderr, ps1->base, union_variable_name);
462  });
463 
464  /* Normalize 2 inputs systems */
465  for (eq = ps1->inegalites; eq != NULL; eq=eq->succ)
466  {
468  }
469  /* returns if there is no intersection */
470  if (!sc_rational_feasibility_ofl_ctrl(ps1, ofl_ctrl, true)) {
471  tail->succ = NULL; ps1 = sc_free(ps1);
472  in_ps2 = sc_free(in_ps2); in_ps2 = sc_empty(NULL);
473  C3_RETURN( IS_SC, in_ps2 );
474  }
475 
476 
477  /* We run over in_ps2 constraints (shared by ps1)
478  * and detect redundance */
479  assert(sc_weak_consistent_p(in_ps2));
481  for (eq = tail->succ, prev_eq = tail; eq != NULL; eq = eq->succ)
482  {
485  C3_DEBUG("sc_elim_redund_with_first", {
486  fprintf(stderr, "\nps1:\n");
487  fprintf(stderr, "nb_eq= %d, nb_ineq= %d, dimension= %d\n",
488  ps1->nb_eq, ps1->nb_ineq, ps1->dimension);
489  sc_fprint( stderr, ps1, union_variable_name );
490  });
491 
492  if (sc_rational_feasibility_ofl_ctrl(ps1, ofl_ctrl, true))
493  {
495  prev_eq = prev_eq->succ;
496  }
497  else{
498  /* eliminate the constraint from in_ps2, and thus from ps1 */
500  if (in_ps2->inegalites == eq)
501  in_ps2->inegalites = eq->succ;
502  prev_eq->succ = eq->succ;
504  eq = contrainte_free(eq);
505  eq = prev_eq;
506  in_ps2->nb_ineq--;
507  ps1->nb_ineq--;
509  assert(sc_weak_consistent_p(in_ps2));
510  }
511  }
512 
513 
514  if ( in_ps2->inegalites == NULL )
515  { in_ps2 = sc_free(in_ps2); in_ps2 = sc_full(); }
516 
517  tail->succ = NULL; ps1 = sc_free( ps1 );
518  C3_RETURN( IS_SC, in_ps2 );
519 }
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
void eq_set_vect_nul(Pcontrainte)
void_eq_set_vect_nul(Pcontrainte c): transformation d'une contrainte en une contrainte triviale 0 == ...
Definition: unaires.c:84
void contrainte_reverse(Pcontrainte)
void contrainte_reverse(Pcontrainte eq): changement de signe d'une contrainte, i.e.
Definition: unaires.c:67
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
bool sc_weak_consistent_p(Psysteme sc)
check that sc is well defined, that the numbers of equalities and inequalities are consistent with th...
Definition: sc.c:362
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
bool sc_rational_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
Psysteme sc_full()
Psysteme sc_full() similar to sc_new.
Definition: sc_list.c:58
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
int nb_ineq
Definition: sc-local.h:73
int nb_eq
Definition: sc-local.h:72
#define IS_SC
Definition: union-local.h:133
void vect_normalize(Pvecteur v)
void vect_normalize(Pvecteur v): division de tous les coefficients de v par leur pgcd; "normalisation...
Definition: unaires.c:59

References assert, Ssysteme::base, base_union(), C3_DEBUG, C3_RETURN, contrainte_free(), contrainte_reverse(), CONTRAINTE_UNDEFINED, Ssysteme::dimension, eq, eq_set_vect_nul(), fprintf(), Ssysteme::inegalites, IS_SC, Ssysteme::nb_eq, Ssysteme::nb_ineq, sc_dup(), sc_empty(), sc_fprint(), sc_free(), sc_full(), sc_full_p(), sc_rational_feasibility_ofl_ctrl(), sc_transform_eg_in_ineg(), sc_weak_consistent_p(), Scontrainte::succ, union_variable_name, vect_fprint(), vect_normalize(), vect_rm(), vect_size(), and Scontrainte::vecteur.

Referenced by pa_path_to_disjunct_rule4_ofl_ctrl().

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

◆ sc_supress_parallel_redund_constraints()

Psysteme sc_supress_parallel_redund_constraints ( Psysteme  in_ps1,
Psysteme  in_ps2 
)

Psysteme sc_supress_parallel_redund_constraints( in_ps1, in_ps2 ) input: 2 Psystemes in_ps1 and in_ps2 output: in_ps1 / in_ps2 (cut operation on polyhedrons) memory: Inspector (nothing is shared, nor modified, output allocated).

comment: Supress in dup(in_ps2) parallel constraints that are redundant relatively to in_ps1. Returned Psysteme have only inequalities.

debuging

Transforms equalities in inequalities if necessary

Compare with inequalities

update base and normalize

Manage memory and return

Parameters
in_ps1n_ps1
in_ps2n_ps2

Definition at line 255 of file reduc.c.

257 {
258  Psysteme ps1, ps2, ret_ps = NULL;
259  Pcontrainte ineq1, ineqs2;
260  bool stop = false, dup1 = false, dup2 = false;
261 
262  if ( in_ps1 == SC_RN ) return sc_dup(in_ps2);
263 
264  /* debuging */
265  C3_DEBUG("sc_supress_parallel_constraints", {
266  fprintf(stderr, "Input systems, in_ps1, then in_ps2:\n");
267  sc_fprint( stderr, in_ps1, union_variable_name );
268  sc_fprint( stderr, in_ps2, union_variable_name );
269  });
270 
271 
272  /* Transforms equalities in inequalities if necessary */
273  if (in_ps1->nb_eq != 0)
274  { ps1 = sc_dup( in_ps1 ); sc_transform_eg_in_ineg( ps1 ); dup1 = true; }
275  else ps1 = in_ps1;
276 
277  if (in_ps2->nb_eq != 0)
278  { ps2 = sc_dup( in_ps2 ); sc_transform_eg_in_ineg( ps2 ); dup2 = true; }
279  else ps2 = in_ps2;
280 
281 
282  /* Compare with inequalities */
283  ineqs2 = ps2->inegalites;
284 
285  for (ineq1 = ps1->inegalites; ineq1 != NULL && !stop; ineq1 = ineq1->succ) {
286  enum hspara_elem sk = contrainte_parallel_in_liste( ineq1, ineqs2 );
287  switch (sk)
288  {
289  case keep:
290  if (ret_ps != NULL){ sc_add_inegalite( ret_ps, contrainte_dup(ineq1) ); }
291  else ret_ps = sc_make( NULL, contrainte_dup(ineq1) );
292  break;
293  case empty:
294  ret_ps = sc_free(ret_ps);
295  ret_ps = sc_empty(NULL);
296  stop = true;
297  break;
298  case full: continue; break;
299  default:
300  {
301  fprintf(stderr, "%s supress_kind == %d should not appear !",
302  "[sc_supress_parallel_redund_constraints]", (int) sk );
303  abort();
304  }
305  }
306 
307  }
308 
309  /* update base and normalize */
310  if ((ret_ps != NULL) && !sc_empty_p(ret_ps)) {
311  vect_rm(ret_ps->base);
312  ret_ps->base = NULL; sc_creer_base( ret_ps );
313  ret_ps = sc_normalize( ret_ps );
314  }
315 
316  /* Manage memory and return */
317  ps1 = (dup1)? sc_free(ps1) : ps1;
318  ps2 = (dup2)? sc_free(ps2) : ps2;
319  C3_RETURN( IS_SC, ret_ps );
320 }
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
#define abort()
Definition: misc-local.h:53
enum hspara_elem contrainte_parallel_in_liste(Pcontrainte in_co, Pcontrainte in_lc)
enum enum hspara_elem contrainte_parallel_in_liste( in_co, in_lc ) AL950711 input: 1 constraint in_co...
Definition: reduc.c:204
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
@ empty
b1 < bj -> h1/hj = empty
Definition: union-local.h:64

References abort, Ssysteme::base, C3_DEBUG, C3_RETURN, contrainte_dup(), contrainte_parallel_in_liste(), empty, fprintf(), full, Ssysteme::inegalites, IS_SC, keep, sc_add_inegalite(), sc_creer_base(), sc_dup(), sc_empty(), sc_empty_p(), sc_fprint(), sc_free(), sc_make(), sc_normalize(), sc_transform_eg_in_ineg(), Scontrainte::succ, union_variable_name, and vect_rm().

Referenced by pa_supress_same_constraints().

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

◆ sc_supress_same_constraints()

Psysteme sc_supress_same_constraints ( Psysteme  in_ps1,
Psysteme  in_ps2 
)

Psysteme sc_supress_same_constraints( in_ps1, in_ps2 ) supress in in_ps2 constraints that are in in_ps1.

Nothing is shared, nor modified. Returned Psysteme have only inequalities. This function should be superseded by sc_supress_parallel_redund_contraints

Compare with equalities a == 0 <=> a <= 0 and -a <= 0

add co to returned inegs

add eq to returned inegs

add co and eq to returned inegs

Compare with inequalities

Parameters
in_ps1n_ps1
in_ps2n_ps2

Definition at line 329 of file reduc.c.

331 {
332  Psysteme ret_ps = NULL;
333  Pcontrainte eq, ineq;
334 
335  if ( in_ps1 == SC_RN ) return sc_dup(in_ps2);
336 
337  C3_DEBUG("sc_supress_same_constraints", {
338  fprintf(stderr, "\nInput systems, in_ps1, then in_ps2:\n");
339  sc_fprint( stderr, in_ps1, union_variable_name );
340  sc_fprint( stderr, in_ps2, union_variable_name );
341  });
342 
343  /* Compare with equalities a == 0 <=> a <= 0 and -a <= 0 */
344  for (eq = in_ps2->egalites; eq != NULL; eq = eq->succ) {
345  Pcontrainte co, eq2;
346  Pvecteur pv;
347  bool eq_in_ineq, co_in_ineq;
348 
349  if (contrainte_in_liste(eq, in_ps1->egalites)) continue;
350 
351  pv = vect_dup(eq->vecteur);
352  vect_chg_sgn ( pv );
353  co = contrainte_make( pv );
354  if (contrainte_in_liste(co, in_ps1->egalites ))
355  { co = contrainte_free( co ); continue; }
356 
357 
359  co_in_ineq = contrainte_in_liste(co, in_ps1->inegalites);
360 
361  if (eq_in_ineq && co_in_ineq) {
362  co = contrainte_free( co );
363  }
364  else if (eq_in_ineq) { /* add co to returned inegs */
365  if (ret_ps != NULL){ sc_add_inegalite( ret_ps, co ); }
366  else ret_ps = sc_make( NULL, co );
367  }
368  else if (co_in_ineq) { /* add eq to returned inegs */
369  eq2 = contrainte_dup(eq);
370  if (ret_ps != NULL){ sc_add_inegalite( ret_ps, eq2 ); }
371  else ret_ps = sc_make( NULL, eq2 );
372  co = contrainte_free( co );
373  }
374  else { /* add co and eq to returned inegs */
375  eq2 = contrainte_dup(eq);
376  if (ret_ps != NULL){ sc_add_inegalite( ret_ps, eq2 ); }
377  else ret_ps = sc_make( NULL, eq2 );
378  sc_add_inegalite( ret_ps, co );
379  }
380  }
381 
382  /* Compare with inequalities */
383  for (ineq = in_ps2->inegalites; ineq != NULL; ineq = ineq->succ) {
384  Pcontrainte io;
385  if (contrainte_in_liste(ineq, in_ps1->inegalites)) continue;
386  if (contrainte_in_liste(ineq, in_ps1->egalites)) continue;
387  io = contrainte_dup( ineq ); contrainte_chg_sgn( io );
388  if (contrainte_in_liste(io, in_ps1->egalites)) {
389  io = contrainte_free(io);
390  continue;
391  }
392 
393  if (ret_ps != NULL){ sc_add_inegalite( ret_ps, contrainte_dup(ineq) ); }
394  else ret_ps = sc_make( NULL, contrainte_dup(ineq) );
395  io = contrainte_free(io);
396  }
397 
398  if (ret_ps != NULL)
399  { vect_rm(ret_ps->base); ret_ps->base = NULL; sc_creer_base( ret_ps );}
400 
401  ret_ps = sc_normalize( ret_ps );
402  C3_RETURN( IS_SC, ret_ps );
403 }
void contrainte_chg_sgn(Pcontrainte)
void contrainte_chg_sgn(Pcontrainte eq): changement de signe d'une contrainte, i.e.
Definition: unaires.c:56
Psommet eq_in_ineq(Psommet *sys, int *nb_som, Pvecteur *lvbase)
Psommet eq_in_ineq(Psommet * sys, int * nb_som, Pvecteur * lvbase): Transformation des egalites du sy...
Definition: plvar-ecart.c:68
Pcontrainte egalites
Definition: sc-local.h:70

References Ssysteme::base, C3_DEBUG, C3_RETURN, contrainte_chg_sgn(), contrainte_dup(), contrainte_free(), contrainte_in_liste(), contrainte_make(), eq, eq_in_ineq(), fprintf(), IS_SC, sc_add_inegalite(), sc_creer_base(), sc_dup(), sc_fprint(), sc_make(), sc_normalize(), Scontrainte::succ, union_variable_name, vect_chg_sgn(), vect_dup(), vect_rm(), and Scontrainte::vecteur.

Referenced by pa_path_to_few_disjunct_ofl_ctrl().

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

◆ vect_parallel()

enum hspara_elem vect_parallel ( Pvecteur  in_v1,
Pvecteur  in_v2 
)

enum hspara_elem vect_parallel(Pvecteur in_v1, Pvecteur in_v2) AL950711 input: 2 Pvecteur in_v1 and in_v2 output: hspara_elem (element of the parallel half space lattice) memory: Inspector (nothing is shared, nor modified, output allocated).

reduc.c

complexity: length(in_v1) * length(in_v2) comment: in_v1 = a1 X + b1 represents a1 X+b1 <= 0 and in_v2 a2 X + b2 <=0. if (a1!=a2) || (a1!=-a2), returns unpara else if (a1==a2), return sign(b2-b1) in ss part of hspara else if (a1==-a2), return sign(-b2-b1) in op part of hspara.

gcd of each vector

length of each vector without TCST

value of TCST and their diff

debuging

get gcd of each vector and constant linked to TCST

Determine what kind of parallel hyperplane we are in

coefficient value was 0 and was not represented

compute return value

debuging

Parameters
in_v1n_v1
in_v2n_v2

Definition at line 49 of file reduc.c.

106 {
107  Pvecteur v1, v2;
108  enum hspara_elem ret_sle = unpara;
109  bool first = true;
110  bool same_sign = false;
111  Value gcd1, gcd2; /* gcd of each vector */
112  int l1, l2; /* length of each vector without TCST */
113  Value b1, b2, diff; /* value of TCST and their diff */
114 
115  if (!in_v1 || !in_v2) return unpara;
116 
117  /* debuging */
118  /*
119  C3_DEBUG("vect_parallel", {
120  fprintf(stderr, "Input vectors, in_v1, then in_v2:\n");
121  vect_fprint( stderr, in_v1, union_variable_name );
122  vect_fprint( stderr, in_v2, union_variable_name );
123  });
124  */
125 
126 
127  /* get gcd of each vector and constant linked to TCST */
128 
129  l1 = 0; b1 = 0; gcd1 = value_abs(val_of(in_v1));
130  for (v1 = in_v1; v1 != NULL; v1 = v1->succ) {
131  gcd1 = pgcd( gcd1, value_abs(val_of(v1)) );
132  if(var_of(v1)==TCST) b1 = val_of(v1);
133  else l1++;
134  }
135 
136  l2 = 0; b2 = 0; gcd2 = value_abs(val_of(in_v2));
137  for (v2 = in_v2; v2 != NULL; v2 = v2->succ) {
138  gcd2 = pgcd( gcd2, value_abs(val_of(v2)) );
139  if(var_of(v2)==TCST) b2 = val_of(v2);
140  else l2++;
141  }
142 
143  if (l1 != l2) return unpara ;
144 
145 
146  /* Determine what kind of parallel hyperplane we are in */
147  for (v2 = in_v2; v2 != NULL; v2 = v2->succ) {
148  Variable var2 = var_of(v2);
149  Value val2 = val_of(v2);
150  bool found = false;
151 
152  if (var2 == TCST) continue;
153 
154  for (v1 = in_v1; v1 != NULL; v1 = v1->succ) {
155  if (var_of(v1) == var2) {
156  Value i1 = value_mult(gcd2,val_of(v1));
157  Value i2 = value_mult(gcd1,val2);
158  bool ss = value_eq(i1,i2);
159  bool op = value_eq(i1,value_uminus(i2));
160 
161  if (!ss && !op) return unpara;
162  if (first) {first = false; same_sign = (ss)?ss:op ;}
163  if ((same_sign && op)||(!same_sign && ss)) return unpara;
164  found = true;
165  }
166  }
167 
168  /* coefficient value was 0 and was not represented */
169  if(!found) return unpara;
170  }
171 
172 
173  /* compute return value */
174  {
175  Value p1 = value_mult(gcd1,b2),
176  p2 = value_uminus(value_mult(gcd2,b1));
177  diff = (same_sign)? value_plus(p1,p2): value_minus(p2,p1);
178  }
179  if (value_zero_p(diff)) ret_sle = (same_sign) ? sszero : opzero ;
180  else if (value_pos_p(diff)) ret_sle = (same_sign) ? ssplus : opplus ;
181  else if (value_neg_p(diff)) ret_sle = (same_sign) ? ssminus : opminus ;
182  else ret_sle = unpara;
183 
184  /* debuging */
185  /*
186  C3_DEBUG("vect_parallel",
187  { fprintf(stderr, "Output hspara: %s\n", hspara_to_string(ret_sle)); });
188  */
189 
190  return ret_sle;
191 }
#define value_pos_p(val)
#define value_minus(v1, v2)
#define pgcd(a, b)
Pour la recherche de performance, selection d'une implementation particuliere des fonctions.
#define value_uminus(val)
unary operators on values
#define value_zero_p(val)
int Value
#define value_eq(v1, v2)
bool operators on values
#define value_plus(v1, v2)
binary operators on values
#define value_abs(val)
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
#define value_neg_p(val)
Value b2
Definition: sc_gram.c:105
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
struct Svecteur * succ
Definition: vecteur-local.h:92
@ ssplus
b1 == bj -> h1/hj = full
Definition: union-local.h:53
@ opzero
bj < b1 -> h1/hj = h1
Definition: union-local.h:59
@ opplus
b1 == bj -> h1/hj = h1
Definition: union-local.h:60
@ ssminus
bj > b1 -> h1/hj = full
Definition: union-local.h:57
@ unpara
compare {h1: a1 X + b1 <= 0} with {hj: aj X + bj <= 0}
Definition: union-local.h:50
@ sszero
unparallel -> h1/hj = h1
Definition: union-local.h:52
@ opminus
empty part
Definition: union-local.h:63
#define val_of(varval)
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
#define var_of(varval)

Variable Documentation

◆ hspara_jm

enum hspara_elem hspara_jm[10][10]
static
Initial value:
= {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 0, 0, 0, 0, 0, 0, 1 },
{ 2, 2, 2, 0, 0, 0, 0, 0, 0, 2 },
{ 3, 9, 9, 3, 0, 0, 3, 0, 3, 3 },
{ 4, 9, 9, 6, 4, 4, 4, 0, 4, 4 },
{ 5, 9, 9, 6, 5, 5, 5, 0, 5, 5 },
{ 6, 9, 9, 6, 6, 6, 6, 0, 6, 6 },
{ 7, 9, 9, 8, 8, 8, 8, 7, 7, 7 },
{ 8, 9, 9, 8, 8, 8, 8, 8, 8, 8 },
{ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }}

Definition at line 49 of file reduc.c.