91 #define EXCEPTION_PRINT_PROJECTION true
97 #define FILTERING_DIMENSION_PROJECTION filtering_dimension_projection
98 #define FILTERING_NUMBER_CONSTRAINTS_PROJECTION filtering_number_constraints_projection
99 #define FILTERING_DENSITY_PROJECTION filtering_density_projection
100 #define FILTERING_MAGNITUDE_PROJECTION (Value) filtering_magnitude_projection
102 #define FILTERING_TIMEOUT_PROJECTION filtering_timeout_projection
104 static bool PROJECTION_timeout =
false;
107 catch_alarm_projection (
int sig)
110 PROJECTION_timeout =
true;
146 void sc_projection_along_variable_ofl_ctrl(psc, v, ofl_ctrl)
169 *psc = sc_variable_substitution_with_eq_ofl_ctrl
170 (*psc,
eq,v, ofl_ctrl);
179 sc_fourier_motzkin_variable_elimination_ofl_ctrl(*psc, v,
false,
181 if (fm_int_exact_p ==
false) {
204 void sc_and_base_projection_along_variable_ofl_ctrl(psc,v, ofl_ctrl)
209 sc_projection_along_variable_ofl_ctrl(psc,v,ofl_ctrl);
230 void sc_projection_along_variables_ofl_ctrl(psc, pv, ofl_ctrl)
240 sc_projection_along_variable_ofl_ctrl(psc,
vecteur_var(pv1),
242 if (!SC_UNDEFINED_P(*psc)) {
244 (void) sc_nredund(psc);
272 void sc_projection_along_variables_with_test_ofl_ctrl(psc, pv, is_proj_exact,
301 current_pv = current_pv->
succ;
307 sc = sc_variable_substitution_with_eq_ofl_ctrl
308 (sc,
eq, v, ofl_ctrl);
320 pve = current_pv = current_pv->
succ;
322 pvr->
succ = current_pv = current_pv->
succ;
344 current_pv = current_pv->
succ;
349 if (*is_proj_exact) *is_proj_exact =
false;
351 sc = sc_variable_substitution_with_eq_ofl_ctrl
352 (sc,
eq, v, ofl_ctrl);
360 pve = current_pv = current_pv->
succ;
362 pvr->
succ = current_pv = current_pv->
succ;
374 while (current_pv != NULL) {
377 if (! sc_fourier_motzkin_variable_elimination_ofl_ctrl(sc, v,
true,
390 current_pv = current_pv->
succ;
393 if (base_sc != NULL)
base_rm(base_sc);
400 for(current_pv = pv; current_pv != NULL; current_pv = current_pv->
succ) {
423 Psysteme sc_variable_substitution_with_eq_ofl_ctrl(sc,
eq, v, ofl_ctrl)
433 current_eq = sc->egalites;
434 while(current_eq != NULL)
440 sc->egalites = current_eq = current_eq->
succ;
444 pr->
succ = current_eq = current_eq->
succ;
468 sc->egalites = current_eq = current_eq->
succ;
470 pr->
succ = current_eq = current_eq->
succ;
478 current_eq = current_eq->
succ;
485 current_eq = sc->inegalites;
486 while(current_eq != NULL) {
507 sc->inegalites = current_eq = current_eq->
succ;
509 pr->
succ = current_eq = current_eq->
succ;
517 current_eq = current_eq->
succ;
541 Psysteme sc_simple_variable_substitution_with_eq_ofl_ctrl(sc, def, v, ofl_ctrl)
550 assert(!SC_UNDEFINED_P(sc));
594 bool sc_fourier_motzkin_variable_elimination_ofl_ctrl(sc,v, integer_test_p,
595 integer_test_res_p, ofl_ctrl)
599 bool *integer_test_res_p;
602 volatile Psysteme sc1 = SC_UNDEFINED;
608 if ((sc->inegalites) == NULL) {
615 fprintf(stderr,
"\n[sc_fourier_motzkin_variable_elimination_ofl_ctr] overflow or timeoutl!!!\n");}
625 fprintf(stderr,
"\n[fourier_motzkin_variable_elimination_ofl_ctrl]: ofl_ctrl <> FWD_OFL_CTRL \n");}
633 signal(SIGALRM, catch_alarm_projection);
634 alarm(FILTERING_TIMEOUT_PROJECTION);
636 if (integer_test_p) sc1 =
sc_copy(sc);
638 pos = neg = nul = NULL;
659 sc->inegalites = NULL;
662 for (pcp = pos; pcp != NULL; pcp = pcp->
succ) {
663 for (pcn = neg; pcn != NULL; pcn = pcn->
succ) {
667 if (integer_test_p) {
670 sc_integer_inequalities_combination_ofl_ctrl
671 (sc1, pcp, pcn, v, &int_comb_p, ofl_ctrl);
672 *integer_test_res_p = *integer_test_res_p && int_comb_p;
686 if (integer_test_p)
sc_rm(sc1);
707 sc->inegalites = nul;
709 if (integer_test_p)
sc_rm(sc1);
733 Psysteme sc_projection_on_variables(
759 sc_projection_along_variable_ofl_ctrl
764 if (SC_EMPTY_P(sc2)) {
775 if (SC_EMPTY_P(sc1)) {
803 Pcontrainte sc_integer_inequalities_combination_ofl_ctrl
804 (sc,posit,negat,v, integer_combination_p, ofl_ctrl)
808 bool *integer_combination_p;
834 *integer_combination_p =
true;
846 *integer_combination_p =
true;
848 *integer_combination_p =
false;
853 *integer_combination_p =
true;
870 sc_projection_along_variable_ofl_ctrl(&sc,v,
FWD_OFL_CTRL);
883 sc_projection_along_variable_ofl_ctrl(&sc,v,
FWD_OFL_CTRL);
901 sc_and_base_projection_along_variable_ofl_ctrl(&sc,v,
FWD_OFL_CTRL);
912 Psysteme sc_projection_ofl_along_variables(sc,pv)
916 sc_projection_along_variables_ofl_ctrl(&sc,pv,
FWD_OFL_CTRL);
922 Psysteme sc_projection_ofl_along_variables_with_test(sc, pv, is_proj_exact)
927 sc_projection_along_variables_with_test_ofl_ctrl(&sc, pv, is_proj_exact,
939 res = sc_variable_substitution_with_eq_ofl_ctrl(sc,
eq, v,
FWD_OFL_CTRL);
949 bool cond_suff_comb_integer_ofl_ctrl(sc,posit,negat, v, ofl_ctrl)
958 ineg = sc_integer_inequalities_combination_ofl_ctrl(sc, posit, negat, v,
976 sc1 = sc_projection_ofl_along_variables_with_test(sc1,pv,&exact);
992 bool sc_expensive_projection_p(sc,v)
996 bool expensive =
false;
1000 && sc->nb_ineq > 20 ) {
1002 int nb_pvar = 0, nb_nvar = 0;
1006 if (coeff >0) nb_pvar ++;
1007 else if (coeff<0) nb_nvar ++;
1009 if (nb_pvar*nb_nvar>200)
1021 #define SUBS(s,e,v) \
1022 sc_simple_variable_substitution_with_eq_ofl_ctrl(s,e,v,OFL_CTRL)
1025 void sc_extract_exact_common_equalities
1030 eq = sc_egalites(cl),
1033 peq =
eq==neq? peq:
eq,
1041 if (peq) peq->
succ = neq;
else sc_egalites(cl) = neq;
1042 sc_nbre_egalites(cl)--;
1045 eq->
succ = sc_egalites(common);
1046 sc_egalites(common) =
eq;
1047 sc_nbre_egalites(common)++;
1051 s2 = SUBS(s2,
eq, v);
1052 cl = SUBS(cl,
eq, v);
1066 void sc_project_very_simple_equalities(
Psysteme s)
1069 for (e = sc_egalites(s); e; e = e->
succ)
1072 if (v) SUBS(s, e, v);
1090 void sc_projection_along_variable_ofl_ctrl_timeout_ctrl(psc, v, ofl_ctrl)
1099 Pbase volatile base_saved;
1100 static int volatile projection_sc_counter = 0;
1112 ifscdebug(5) {projection_sc_counter ++;}
1120 PROJECTION_timeout =
false;
1125 int dimens, nb_cont_eq = 0, nb_ref_eq = 0, nb_cont_in = 0, nb_ref_in = 0;
1128 decision_data(sc_egalites(sc), &nb_cont_eq, &nb_ref_eq, &magnitude, 1);
1129 decision_data(sc_inegalites(sc), &nb_cont_in, &nb_ref_in, &magnitude, 1);
1131 if ((FILTERING_DIMENSION_PROJECTION>0)&&(dimens>=FILTERING_DIMENSION_PROJECTION)) {
1132 char *directory_name =
"projection_dimension_filtering_SC_OUT";
1135 if ((FILTERING_NUMBER_CONSTRAINTS_PROJECTION>0)&&((nb_cont_eq + nb_cont_in) >= FILTERING_NUMBER_CONSTRAINTS_PROJECTION)) {
1136 char *directory_name =
"projection_number_constraints_filtering_SC_OUT";
1139 if ((FILTERING_DENSITY_PROJECTION>0)&&((nb_ref_eq + nb_ref_in) >= FILTERING_DENSITY_PROJECTION)) {
1140 char *directory_name =
"projection_density_filtering_SC_OUT";
1143 if ((
value_notzero_p(FILTERING_MAGNITUDE_PROJECTION))&&(
value_gt(magnitude,FILTERING_MAGNITUDE_PROJECTION))) {
1144 char *directory_name =
"projection_magnitude_filtering_SC_OUT";
1153 if (EXCEPTION_PRINT_PROJECTION) {
1154 char *directory_name =
"projection_fail_SC_OUT";
1165 fprintf(stderr,
"\n[sc_projection_along_variable_ofl_ctrl_timeout_ctrl]: projection failed, return sc_empty(base_saved)\n");
1174 sc_projection_along_variable_ofl_ctrl(psc, v, ofl_ctrl);
1180 if (PROJECTION_timeout) {
1181 char * directory_name =
"projection_timeout_filtering_SC_OUT";
1195 return SC_UNDEFINED;
1198 bool is_proj_exact =
true;
1199 sc_projection_along_variables_with_test_ofl_ctrl(
1204 return SC_UNDEFINED;
#define value_minus(v1, v2)
#define value_notzero_p(val)
#define value_uminus(val)
unary operators on values
#define value_notone_p(val)
#define value_assign(ref, val)
assigments
#define value_plus(v1, v2)
binary operators on values
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
#define CONTRAINTE_UNDEFINED_P(c)
#define contrainte_succ(c)
#define CONTRAINTE_UNDEFINED
#define contrainte_rm(c)
the standard xxx_rm does not return a value
Pcontrainte contraintes_free(Pcontrainte pc)
Pcontrainte contraintes_free(Pcontrainte pc): desallocation de toutes les contraintes de la liste pc.
Pcontrainte contrainte_free(Pcontrainte c)
Pcontrainte contrainte_free(Pcontrainte c): liberation de l'espace memoire alloue a la contrainte c a...
Pcontrainte contrainte_copy(Pcontrainte c_in)
Have a look at contrainte_dup and contraintes_dup which reverse the order of the list This copy versi...
Pcontrainte contrainte_new(void)
package contrainte - allocations et desallocations
int contrainte_subst_ofl_ctrl(Variable v, Pcontrainte def, Pcontrainte c, bool eq_p, int ofl_ctrl)
int contrainte_subst_ofl_ctrl(Variable v, Pcontrainte def, Pcontrainte c Boolean eq_p,...
Pcontrainte inegalite_comb_ofl_ctrl(Pcontrainte posit, Pcontrainte negat, Variable v, int ofl_ctrl)
Pcontrainte inegalite_comb_ofl_ctrl(Pcontrainte posit, Pcontrainte negat, Variable v,...
Pcontrainte contrainte_var_min_coeff(Pcontrainte, Variable, Value *, bool)
Pcontrainte contrainte_var_min_coeff(Pcontrainte contraintes, Variable v, int *coeff) input : a list ...
bool egalite_normalize(Pcontrainte)
bool egalite_normalize(Pcontrainte eg): reduction d'une equation diophantienne par le pgcd de ses coe...
int nb_elems_list(Pcontrainte)
int nb_elems_list(Pcontrainte list): nombre de contraintes se trouvant dans une liste de contraintes
Variable contrainte_simple_equality(Pcontrainte)
returns whether a constraint is a simple equality: X == 12 the system is expected to be normalized?
bool contrainte_constante_p(Pcontrainte)
bool contrainte_constante_p(Pcontrainte c): test de contrainte triviale sans variables (ie du type 0<...
void contrainte_reverse(Pcontrainte)
void contrainte_reverse(Pcontrainte eq): changement de signe d'une contrainte, i.e.
bool contrainte_verifiee(Pcontrainte, bool)
bool contrainte_verifiee(Pcontrainte ineg, bool eq_p): test de faisabilite d'inegalite (eq_p == false...
void sc_base_remove_variable(Psysteme sc, Variable v)
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
Psysteme sc_empty(Pbase b)
Psysteme sc_empty(Pbase b): build a Psysteme with one unfeasible constraint to define the empty subsp...
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Psysteme sc_init_with_sc(Psysteme sc)
This function returns a new empty system which has been initialized with the same dimension and base ...
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.
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...
Psysteme sc_copy(Psysteme ps)
Psysteme sc_copy(Psysteme ps): duplication d'un systeme (allocation et copie complete des champs sans...
void build_sc_nredund_1pass(Psysteme volatile *ps)
Computation of a new system sc from the system ps, where each constraint of the system ps is added to...
void decision_data(Pcontrainte c, int volatile *pc, int volatile *pv, Value *magnitude, int weight)
just a test to improve the Simplex/FM decision.
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
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
Psysteme sc_intersection(Psysteme s1, Psysteme s2, Psysteme s3)
Psysteme sc_intersection(Psysteme s1, Psysteme s2, Psysteme s3): calcul d'un systeme de contraintes s...
void sc_default_dump_to_files(Psysteme sc, int sc_nb, char *directory_name)
void sc_default_dump_to_files(Psysteme sc, sc_nb,directory_name):
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
Psysteme sc_elim_var(Psysteme sc, Variable v)
package sur les systemes de contraintes sc
bool var_in_lcontrainte_p(Pcontrainte pc, Variable var)
Check if variable var appears in at least on of the constraints in constraint list pc with a non-zero...
struct Scontrainte * succ
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
#define OFL_CTRL
I do thing that overflows are managed in a very poor manner.
Pbase vect_copy(Pvecteur b)
direct duplication.
Pbase base_copy(Pbase b)
Direct duplication.
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Pvecteur vect_cl2_ofl_ctrl(Value x1, Pvecteur v1, Value x2, Pvecteur v2, int ofl_ctrl)
Pvecteur vect_cl2_ofl(Value x1, Pvecteur v1, Value x2, Pvecteur v2): allocation d'un vecteur v dont l...
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Variable vect_one_coeff_if_any(Pvecteur v)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...