PIPS
sc_feasibility.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "linear_assert.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "sc-private.h"
+ Include dependency graph for sc_feasibility.c:

Go to the source code of this file.

Macros

#define SWITCH_HEURISTIC_FLAG   sc_switch_heuristic_flag
 
#define LINEAR_SIMPLEX_PROJECT_EQ_METHOD   11
 
#define LINEAR_SIMPLEX_NO_PROJECT_EQ_METHOD   12
 
#define FM_METHOD   13
 
#define JANUS_METHOD   14
 
#define ALL_METHOD   15
 
#define HEURISTIC1   1 /**Keep the old heuristic of FC */
 We can add other heuristic if we need in an easy way. More...
 
#define HEURISTIC2   2 /**Replace Simplex by Janus in heuristic 1 */
 
#define HEURISTIC3   3 /**Only for experiment. Test successtively 3 methods to see the coherence */
 
#define HEURISTIC4   4 /**The best?: (Linear Simplex vs Janus) try to use the method that succeeded recently. If failed than turn to another. Rely on the fact that the sc are similar. [optional?] : If the 2 methods fail, then call FM. This can solve many sc, in fact. */
 

Functions

char * default_variable_to_string (Variable)
 
bool sc_rational_feasibility_ofl_ctrl (Psysteme sc, int ofl_ctrl, bool ofl_res)
 
bool sc_integer_feasibility_ofl_ctrl (Psysteme sc, int ofl_ctrl, bool ofl_res)
 
void decision_data (Pcontrainte c, int volatile *pc, int volatile *pv, Value *magnitude, int weight)
 just a test to improve the Simplex/FM decision. More...
 
static Variable chose_variable_to_project_for_feasability (Psysteme s, Pbase b, bool ineq)
 chose the next variable in base b for projection in system s. More...
 
static bool sc_fm_project_variables (Psysteme volatile *ps1, bool integer_p, bool use_eq_only, int ofl_ctrl)
 project in s1 (which is modified) using equalities or both equalities and inequalities. More...
 
static bool internal_sc_feasibility (Psysteme sc, int heuristic, bool int_p, int ofl_ctrl)
 means LINEAR_SIMPLEX :-) More...
 
bool sc_feasibility_ofl_ctrl (Psysteme sc, bool integer_p, volatile int ofl_ctrl, volatile bool ofl_res)
 return true is the system is feasible More...
 
bool sc_fourier_motzkin_feasibility_ofl_ctrl (Psysteme s, bool integer_p, int ofl_ctrl)
 bool sc_fourier_motzkin_faisabilite_ofl(Psysteme s): test de faisabilite d'un systeme de contraintes lineaires, par projections successives du systeme selon les differentes variables du systeme More...
 
bool sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl (Psysteme sc, bool int_p, int ofl_ctrl)
 
bool sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl (Psysteme sc, bool project_eq_p, bool int_p, int ofl_ctrl)
 
bool sc_janus_feasibility_ofl_ctrl_timeout_ctrl (Psysteme sc, bool ofl_ctrl)
 
static Psysteme simplify_big_coeff (Psysteme sc)
 
bool efficient_sc_check_inequality_feasibility (Pvecteur v, Psysteme prec)
 

Variables

static int feasibility_sc_counter = 0
 
bool FM_timeout = false
 
bool J_timeout = false
 
bool S_timeout = false
 
static int method_used = 0
 

Macro Definition Documentation

◆ ALL_METHOD

#define ALL_METHOD   15

Definition at line 352 of file sc_feasibility.c.

◆ FM_METHOD

#define FM_METHOD   13

Definition at line 350 of file sc_feasibility.c.

◆ HEURISTIC1

#define HEURISTIC1   1 /**Keep the old heuristic of FC */

We can add other heuristic if we need in an easy way.

Note: FM is not good for big sc, but good enough for small sc. Simplex build a tableau, so it's not good for small sc

Definition at line 359 of file sc_feasibility.c.

◆ HEURISTIC2

#define HEURISTIC2   2 /**Replace Simplex by Janus in heuristic 1 */

Definition at line 360 of file sc_feasibility.c.

◆ HEURISTIC3

#define HEURISTIC3   3 /**Only for experiment. Test successtively 3 methods to see the coherence */

Definition at line 361 of file sc_feasibility.c.

◆ HEURISTIC4

#define HEURISTIC4   4 /**The best?: (Linear Simplex vs Janus) try to use the method that succeeded recently. If failed than turn to another. Rely on the fact that the sc are similar. [optional?] : If the 2 methods fail, then call FM. This can solve many sc, in fact. */

Definition at line 362 of file sc_feasibility.c.

◆ JANUS_METHOD

#define JANUS_METHOD   14

Definition at line 351 of file sc_feasibility.c.

◆ LINEAR_SIMPLEX_NO_PROJECT_EQ_METHOD

#define LINEAR_SIMPLEX_NO_PROJECT_EQ_METHOD   12

Definition at line 349 of file sc_feasibility.c.

◆ LINEAR_SIMPLEX_PROJECT_EQ_METHOD

#define LINEAR_SIMPLEX_PROJECT_EQ_METHOD   11

Definition at line 348 of file sc_feasibility.c.

◆ SWITCH_HEURISTIC_FLAG

#define SWITCH_HEURISTIC_FLAG   sc_switch_heuristic_flag

Definition at line 87 of file sc_feasibility.c.

Function Documentation

◆ chose_variable_to_project_for_feasability()

static Variable chose_variable_to_project_for_feasability ( Psysteme  s,
Pbase  b,
bool  ineq 
)
static

chose the next variable in base b for projection in system s.

tries to avoid Fourier potential explosions when combining inequalities.

  • if there are equalities, chose the var with the min |coeff| (not null)
  • if there are only inequalities, chose the var that will generate the minimum number of constraints with pairwise combinations.
  • if ineq is true, consider variables even if no equalities.

(c) FC 21 July 1995

find the lowest coeff

shouldn't find empty equalities ??

assert(minvar!=TCST);

only inequalities, reduce the explosion

initialize t

t[x][0 (resp. 1)] = number of negative (resp. positive) coeff

t[x][0] = number of combinations, i.e. new created constraints.

Definition at line 188 of file sc_feasibility.c.

189 {
190  Pcontrainte c = sc_egalites(s);
191  Pvecteur v;
192  Variable var = NULL;
193  Value val;
194  int size = vect_size(b);
195 
196  ifscdebug(8)
197  {
198  fprintf(stderr, "[chose_variable_to_project_for_feasability] b/s:\n");
201  }
202 
203  if (size==1) return var_of(b);
204  assert(size>1);
205 
206  if (c)
207  {
208  /* find the lowest coeff
209  */
210  Variable minvar = TCST;
211  Value minval = VALUE_ZERO;
212 
213  for (; c; c=c->succ)
214  {
215  for (v = contrainte_vecteur(c); v; v=v->succ)
216  {
217  var = var_of(v);
218 
219  if (var!=TCST)
220  {
221  val = value_abs(val_of(v));
222  if ((value_notzero_p(minval) && value_lt(val,minval))
223  || value_zero_p(minval))
224  minval = val, minvar = var;
225 
226  if (value_one_p(minval)) return minvar;
227  }
228  }
229  }
230 
231  /* shouldn't find empty equalities ?? */
232  /* assert(minvar!=TCST); */
233  var = minvar;
234  }
235 
236  if (!var && ineq)
237  {
238  /* only inequalities, reduce the explosion
239  */
240  int i;
241  two_int_infop t = (two_int_infop) malloc(2*size*sizeof(int));
242  Pbase tmp;
243  int min_new;
244 
245  c = sc_inegalites(s);
246 
247  /* initialize t
248  */
249  for (i=0; i<size; i++) t[i][0]=0, t[i][1]=0;
250 
251  /* t[x][0 (resp. 1)] = number of negative (resp. positive) coeff
252  */
253  for (; c; c=c->succ)
254  {
255  for (v = contrainte_vecteur(c); v; v=v->succ)
256  {
257  var = var_of(v);
258  if (var!=TCST)
259  {
260  ifscdebug(9)
261  fprintf(stderr, "%s\n", default_variable_to_string(var));
262 
263  for (i=0, tmp=b; tmp && var_of(tmp)!=var;
264  i++, tmp=tmp->succ) (void) NULL;
265  assert(tmp);
266 
267  t[i][value_posz_p(val_of(v))]++;
268  }
269  }
270  }
271 
272  /* t[x][0] = number of combinations, i.e. new created constraints.
273  */
274  for (i=0; i<size; i++) t[i][0] *= t[i][1];
275 
276  for (tmp=b->succ, var=var_of(b), min_new=t[0][0], i=1;
277  min_new && i<size;
278  i++, tmp=tmp->succ) {
279  if (t[i][0]<min_new)
280  min_new = t[i][0], var=var_of(tmp);
281  }
282 
283  free(t);
284  }
285 
286  ifscdebug(8)
288  "suggesting %s\n", default_variable_to_string(var));
289 
290  return var;
291 }
#define VALUE_ZERO
#define value_notzero_p(val)
#define value_one_p(val)
#define value_zero_p(val)
int Value
#define value_abs(val)
#define value_lt(v1, v2)
#define value_posz_p(val)
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
void * malloc(YYSIZE_T)
void free(void *)
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
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define assert(ex)
Definition: newgen_assert.h:41
char * default_variable_to_string(Variable)
Definition: sc_debug.c:245
static Variable chose_variable_to_project_for_feasability(Psysteme s, Pbase b, bool ineq)
chose the next variable in base b for projection in system s.
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
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
return(s1)
struct Scontrainte * succ
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#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)

References assert, contrainte_vecteur, default_variable_to_string(), fprintf(), free(), malloc(), sc_fprint(), Scontrainte::succ, Svecteur::succ, TCST, val_of, value_abs, value_lt, value_notzero_p, value_one_p, value_posz_p, VALUE_ZERO, value_zero_p, var_of, vect_fprint(), and vect_size().

Referenced by sc_fm_project_variables().

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

◆ decision_data()

void decision_data ( Pcontrainte  c,
int volatile *  pc,
int volatile *  pv,
Value magnitude,
int  weight 
)

just a test to improve the Simplex/FM decision.

c is a list of constraints, equalities or inequalities pc is the number of constraints in the list pv is the number of non-zero coefficients in the system magnitude is the biggest coefficent in the system pc, pv and magnitude MUST be initialized. They are multiplied by weight.

Modif: Become public, used by filters

Definition at line 156 of file sc_feasibility.c.

162 {
163  Pvecteur v;
164  for(; c!=NULL; c=c->succ) {
165  v=c->vecteur;
166  if (v!=NULL) {
167  (*pc)+=weight;
168  for(; v!=NULL; v=v->succ)
169  if (var_of(v)!=TCST) {
170  (*pv) += weight;
171  if (value_gt(value_abs(val_of(v)),(*magnitude)))
172  value_assign(*magnitude,value_abs(val_of(v)));
173  }
174  }
175  }
176 }
#define value_gt(v1, v2)
#define value_assign(ref, val)
assigments
Pvecteur vecteur

References Scontrainte::succ, Svecteur::succ, TCST, val_of, value_abs, value_assign, value_gt, var_of, and Scontrainte::vecteur.

Referenced by internal_sc_feasibility().

+ Here is the caller graph for this function:

◆ default_variable_to_string()

char* default_variable_to_string ( Variable  v)

Definition at line 245 of file sc_debug.c.

246 {
248  return (*(var_name_stack[var_name_stack_index-1]))(v);
249 }
static int var_name_stack_index
Definition: sc_debug.c:214
static var_name_t * var_name_stack
Definition: sc_debug.c:213

References assert, var_name_stack, and var_name_stack_index.

Referenced by chose_variable_to_project_for_feasability(), hyperplane(), new_system_with_only_live_variable(), sc_default_dump(), sc_default_dump_to_files(), sc_fm_project_variables(), and sc_fourier_motzkin_feasibility_ofl_ctrl().

+ Here is the caller graph for this function:

◆ efficient_sc_check_inequality_feasibility()

bool efficient_sc_check_inequality_feasibility ( Pvecteur  v,
Psysteme  prec 
)

Definition at line 1033 of file sc_feasibility.c.

1034 {
1035  bool retour = true;
1036  // try fast check
1037  int fast_check = sc_check_inequality_redundancy(contrainte_make(v), prec);
1038 
1039  // ok, feasible because ineq is redundant wrt prec
1040  // or ok, system {prec + ineq} is infeasible
1041  if (fast_check == 1 || fast_check == 2)
1042  return fast_check == 1;
1043  // ELSE no result, try slow version. default is feasible.
1044  assert(fast_check == 0);
1045 
1046  // NN: 25/09/2001, try to avoid overflows by using a smaller system:
1047  // only constraints transitively connected to a constraint referencing
1048  // a variable of interest in v are taken from prec.
1049  // sc_restricted_to_variables_transitive_closure(sc,vars)
1050 
1051  Psysteme s_dup = sc_dup(prec);
1052  Pbase vars = make_base_from_vect(v);
1054 
1055  // nofoverflows is used to save the number of overflows before the call
1056  // to sc_integer_feasibility_ofl_ctrl
1057 
1058  int nofoverflows = linear_number_of_exception_thrown;
1059 
1060  Psysteme s = sc_dup(s_res);
1061  // add the inegality to the system
1062  sc_constraint_add(s, contrainte_make(v), false);
1063  retour = sc_integer_feasibility_ofl_ctrl(s, OFL_CTRL,true);
1064  sc_rm(s);
1065 
1066  // if retour = true : the system is feasible or there are overflows
1067  // (our goal is to verify if retour is false or not)
1068  // if there are overflows (the value of nofoverflows will be changed),
1069  // we simplify the system and recalcul the feasibility
1070 
1071  if (retour && nofoverflows < linear_number_of_exception_thrown)
1072  {
1073  // there has been an overflow, let us try something else...
1074  Psysteme new_s = sc_dup(prec);
1075  new_s = simplify_big_coeff(new_s);
1076  sc_constraint_add(new_s, contrainte_make(v), false);
1077  retour = sc_integer_feasibility_ofl_ctrl(new_s, OFL_CTRL,true);
1078  sc_rm(new_s);
1079  }
1080  return retour;
1081 }
int linear_number_of_exception_thrown
Pbase make_base_from_vect(Pvecteur pv)
Definition: base.c:109
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
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
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
int sc_check_inequality_redundancy(Pcontrainte ineq, Psysteme ps)
int sc_check_inequality_redundancy(Pcontrainte ineq, Psysteme ps) Check if an inequality ineq,...
bool sc_integer_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
static Psysteme simplify_big_coeff(Psysteme sc)
Psysteme sc_constraint_add(Psysteme sc, Pcontrainte c, bool equality)
Definition: sc_insert_eq.c:115
Psysteme sc_restricted_to_variables_transitive_closure(Psysteme sc, Pbase variables)
for an improved dependence test (Beatrice Creusillet)
Definition: sc_misc.c:64
#define OFL_CTRL
I do thing that overflows are managed in a very poor manner.

References assert, contrainte_make(), linear_number_of_exception_thrown, make_base_from_vect(), OFL_CTRL, sc_check_inequality_redundancy(), sc_constraint_add(), sc_dup(), sc_integer_feasibility_ofl_ctrl(), sc_restricted_to_variables_transitive_closure(), sc_rm(), and simplify_big_coeff().

Referenced by expression_equal_in_context_p().

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

◆ internal_sc_feasibility()

static bool internal_sc_feasibility ( Psysteme  sc,
int  heuristic,
bool  int_p,
int  ofl_ctrl 
)
static

means LINEAR_SIMPLEX :-)

Automatic variables read in a CATCH block need to be declared volatile as specified by the documentation

We can put the size filters here! filtering timeout is integrated in the methods themself size filtering: dimension,number_constraints, density, magnitude

HEURISTIC1 if nb_ineg >= 10 and nb_eg < 6 then use LSimplex (replace n eg by 2n ineg) if nb_ineg >= 10 and nb_eg >= 6 then project eg and use LSimplex if nb_ineg < 10 then use FM

ifscdebug(5) {fprintf(stderr,"nb_exceptions af %d\n",linear_number_of_exception_thrown);}

INEAR_SIMPLEX

ok = sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl(sc,int_p,ofl_ctrl);

anus

M

f TRY

se heuristic1

f switch heuristic

fprintf(stderr, "in=%d eq=%d method=%d magnitude=", n_cont_in, n_cont_eq, method);print_Value(magnitude);

ien faire

f switch method

Definition at line 366 of file sc_feasibility.c.

368 {
369  bool ok = true;
370  int method, n_ref_eq = 0, n_ref_in = 0;
371  /* Automatic variables read in a CATCH block need to be declared volatile as
372  * specified by the documentation*/
373  int volatile n_cont_in = 0;
374  int volatile n_cont_eq = 0;
375  Value magnitude;
376 
378 
379  /* We can put the size filters here! filtering timeout is integrated in the methods themself
380  * size filtering: dimension,number_constraints, density, magnitude */
381 
382 #ifdef FILTERING
383  /*Begin size filters*/
384 
385  if (true) {
386  int dimens; int nb_cont_eq = 0; int nb_ref_eq = 0; int nb_cont_in = 0; int nb_ref_in = 0;
387 
388  dimens = sc->dimension; value_assign(magnitude,VALUE_ZERO);
389  decision_data(sc_egalites(sc), &nb_cont_eq, &nb_ref_eq, &magnitude, 1);
390  decision_data(sc_inegalites(sc), &nb_cont_in, &nb_ref_in, &magnitude, 1);
391 
392  if ((FILTERING_DIMENSION_FEASIBILITY)&&(dimens>=FILTERING_DIMENSION_FEASIBILITY)) {
393  char *directory_name = "feasibility_dimension_filtering_SC_OUT";
395  }
396  if ((FILTERING_NUMBER_CONSTRAINTS_FEASIBILITY)&&((nb_cont_eq + nb_cont_in) >= FILTERING_NUMBER_CONSTRAINTS_FEASIBILITY)) {
397  char *directory_name = "feasibility_number_constraints_filtering_SC_OUT";
399  }
400  if ((FILTERING_DENSITY_FEASIBILITY)&&((nb_ref_eq + nb_ref_in) >= FILTERING_DENSITY_FEASIBILITY)) {
401  char *directory_name = "feasibility_density_filtering_SC_OUT";
403  }
404  if ((value_notzero_p(FILTERING_MAGNITUDE_FEASIBILITY))&&(value_gt(magnitude,FILTERING_MAGNITUDE_FEASIBILITY))) {
405  char *directory_name = "feasibility_magnitude_filtering_SC_OUT";
407  }
408  }
409 
410  /*End size filters*/
411 #endif
412  if (int_p) sc_gcd_normalize(sc);
413  switch(heuristic) {
414  case (HEURISTIC1):
415  {
416  method=0, n_cont_eq = 0, n_ref_eq = 0, n_cont_in = 0, n_ref_in = 0;
417  value_assign(magnitude,VALUE_ZERO);
418  decision_data(sc_egalites(sc), &n_cont_eq, &n_ref_eq, &magnitude, 1);
419  decision_data(sc_inegalites(sc), &n_cont_in, &n_ref_in, &magnitude, 1);
420  /* HEURISTIC1
421  * if nb_ineg >= 10 and nb_eg < 6 then use LSimplex (replace n eg by 2n ineg)
422  * if nb_ineg >= 10 and nb_eg >= 6 then project eg and use LSimplex
423  * if nb_ineg < 10 then use FM */
424 
425  if (n_cont_in >= 10) {
426  if (n_cont_eq >= 6) {method=LINEAR_SIMPLEX_PROJECT_EQ_METHOD;}
428  } else {
429  method = FM_METHOD;
430  }
431  break;
432  }
433  case (HEURISTIC2):
434  {
435  method=0, n_cont_eq = 0, n_ref_eq = 0, n_cont_in = 0, n_ref_in = 0;
436  value_assign(magnitude,VALUE_ZERO);
437  decision_data(sc_egalites(sc), &n_cont_eq, &n_ref_eq, &magnitude, 1);
438  decision_data(sc_inegalites(sc), &n_cont_in, &n_ref_in, &magnitude, 1);
439 
440  if (n_cont_in >= 10) {
441  method = JANUS_METHOD;
442  } else { method = FM_METHOD;}
443  break;
444  }
445  case (HEURISTIC3):
446  {
447  method=0, n_cont_eq = 0, n_ref_eq = 0, n_cont_in = 0, n_ref_in = 0;
448  value_assign(magnitude,VALUE_ZERO);
449  decision_data(sc_egalites(sc), &n_cont_eq, &n_ref_eq, &magnitude, 1);
450  decision_data(sc_inegalites(sc), &n_cont_in, &n_ref_in, &magnitude, 1);
451 
452  method = ALL_METHOD;
453  break;
454  }
455  case (HEURISTIC4):
456  {
457  method=0, n_cont_eq = 0, n_ref_eq = 0, n_cont_in = 0, n_ref_in = 0;
458  value_assign(magnitude,VALUE_ZERO);
459  decision_data(sc_egalites(sc), &n_cont_eq, &n_ref_eq, &magnitude, 1);
460  decision_data(sc_inegalites(sc), &n_cont_in, &n_ref_in, &magnitude, 1);
461 
463 
464  /* ifscdebug(5) {fprintf(stderr,"nb_exceptions af %d\n",linear_number_of_exception_thrown);}*/
465 
466  if (n_cont_in >= 10) {
467  if (method_used==JANUS_METHOD) {
468  method_used = 0;/*LINEAR_SIMPLEX*/
469  ifscdebug(5) {fprintf(stderr,"J failes so change to LS ...");}
470  if (n_cont_eq>=6) {
471  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,true,int_p,ofl_ctrl);
472  }else{
473  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,false,int_p,ofl_ctrl);
474  }
475  ifscdebug(5) {fprintf(stderr," ...Passed\n");}
477  } else {
479  ifscdebug(5) {fprintf(stderr,"LS failed so change to J ...");}
481  ifscdebug(5) {fprintf(stderr," ...Passed\n");}
483  }
484  /* ok = sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl(sc,int_p,ofl_ctrl);*/
485  } else {
486  ifscdebug(5) {fprintf(stderr,"\nFM fail with small sc => bug??? ...");}
487  if (method_used == JANUS_METHOD) {
489  /*Janus*/
490  }else {
491  if (n_cont_eq>=6) {
492  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,true,int_p,ofl_ctrl);
493  }else{
494  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,false,int_p,ofl_ctrl);
495  }
496  }
497  ifscdebug(5) {fprintf(stderr," ...Passed\n");}
499  }
500  }
501  TRY {
502  if (n_cont_in >= 10) {
503  if (method_used == JANUS_METHOD) {
505  }else {
506  if (n_cont_eq>=6) {
507  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,true,int_p,ofl_ctrl);
508  }else{
509  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,false,int_p,ofl_ctrl);
510  }
511  }
512  }
513  // sc_fourier_motzkin does not (yet?) support GMP
514  else if (linear_use_gmp()) {
515  if (n_cont_eq >= 6) {
516  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc, true, int_p, ofl_ctrl);
517  }
518  else {
519  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc, false, int_p, ofl_ctrl);
520  }
521  } else {
522  /*FM*/
524  }
526  }/*of TRY*/
527 
528  break;
529  }
530 
531  default: /*use heuristic1*/
532  {
533  method=0, n_cont_eq = 0, n_ref_eq = 0, n_cont_in = 0, n_ref_in = 0;
534  value_assign(magnitude,VALUE_ZERO);
535  decision_data(sc_egalites(sc), &n_cont_eq, &n_ref_eq, &magnitude, 1);
536  decision_data(sc_inegalites(sc), &n_cont_in, &n_ref_in, &magnitude, 1);
537 
538  if (n_cont_in >= 10) {
539  if (n_cont_eq >= 6) {method=LINEAR_SIMPLEX_PROJECT_EQ_METHOD;}
541  } else {
542  method = FM_METHOD;
543  }
544  break;
545  }
546 
547  }/*of switch heuristic*/
548 
549  /* fprintf(stderr, "in=%d eq=%d method=%d magnitude=", n_cont_in, n_cont_eq, method);print_Value(magnitude);*/
550 
551  switch(method){
552 
554  {
555  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,true,int_p,ofl_ctrl);
556  break;
557  }
559  {
560  ok = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,false,int_p,ofl_ctrl);
561  break;
562  }
563  case (FM_METHOD):
564  {
566  break;
567  }
568  case (JANUS_METHOD):
569  {
571  break;
572  }
573  case (ALL_METHOD):
574  {
575 
576  bool okS = true,okJ = true,okFM = true;
578  ifscdebug(5) {
579  fprintf(stderr,"Janus or Simplex failed. Let's go with FM\n");
580  }
582  ok = okFM;
583  }
584  TRY {
585  if (n_cont_eq >= 10) {
586  okS = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,true,int_p,ofl_ctrl);
587  } else {
588  okS = sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(sc,false,int_p,ofl_ctrl);
589  }
591 
593 
594  ifscdebug(5) {
595  if (okS != okFM) {
596  fprintf(stderr,"\n[internal_sc_feasibility]: okS %d != okFM %d\n",okS,okFM);
597  sc_default_dump(sc);
598  }
599  if (okJ != okFM) {
600  fprintf(stderr,"\n[internal_sc_feasibility]: okJ %d != okFM %d\n",okJ,okFM);
601  sc_default_dump(sc);
602  }
603  assert(okS == okFM);
604  assert(okJ == okFM);
605  }
606  ok = okFM;
608  }
609  break;
610  }
611  default:
612  {
613  /*rien faire*/
614  break;
615  }
616 
617  }/*of switch method*/
618 
619  return ok;
620 }
#define CATCH(what)
@ overflow_error
#define UNCATCH(what)
#define TRY
bool linear_use_gmp(void)
whether linear is to use gmp
Definition: errors.c:454
#define JANUS_METHOD
void decision_data(Pcontrainte c, int volatile *pc, int volatile *pv, Value *magnitude, int weight)
just a test to improve the Simplex/FM decision.
static int feasibility_sc_counter
#define FM_METHOD
#define HEURISTIC4
#define HEURISTIC2
#define LINEAR_SIMPLEX_NO_PROJECT_EQ_METHOD
bool sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl(Psysteme sc, bool int_p, int ofl_ctrl)
static int method_used
bool sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(Psysteme sc, bool project_eq_p, bool int_p, int ofl_ctrl)
#define ALL_METHOD
#define LINEAR_SIMPLEX_PROJECT_EQ_METHOD
#define HEURISTIC3
bool sc_janus_feasibility_ofl_ctrl_timeout_ctrl(Psysteme sc, bool ofl_ctrl)
#define HEURISTIC1
We can add other heuristic if we need in an easy way.
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):
Definition: sc_io.c:288
void sc_default_dump(Psysteme sc)
void sc_default_dump(Psysteme sc): dump to stderr
Definition: sc_io.c:170
void sc_gcd_normalize(Psysteme ps)
sc_gcd_normalize(ps)
static bool ok
int dimension
Definition: sc-local.h:74

References ALL_METHOD, assert, CATCH, decision_data(), Ssysteme::dimension, feasibility_sc_counter, FM_METHOD, fprintf(), HEURISTIC1, HEURISTIC2, HEURISTIC3, HEURISTIC4, JANUS_METHOD, linear_number_of_exception_thrown, LINEAR_SIMPLEX_NO_PROJECT_EQ_METHOD, LINEAR_SIMPLEX_PROJECT_EQ_METHOD, linear_use_gmp(), method_used, ok, overflow_error, sc_default_dump(), sc_default_dump_to_files(), sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl(), sc_gcd_normalize(), sc_janus_feasibility_ofl_ctrl_timeout_ctrl(), sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl(), TRY, UNCATCH, value_assign, value_gt, value_notzero_p, and VALUE_ZERO.

Referenced by sc_feasibility_ofl_ctrl().

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

◆ sc_feasibility_ofl_ctrl()

bool sc_feasibility_ofl_ctrl ( Psysteme  sc,
bool  integer_p,
volatile int  ofl_ctrl,
volatile bool  ofl_res 
)

return true is the system is feasible

In case an exception, due to an overflow or to an error such as zero divide or a GCD with 0, occurs, return ofl_res. So, an error may lead to a feasible or a non feasible system.

Automatic variables read in a CATCH block need to be declared volatile as specified by the documentation

this should be treated somewhere else -> faster

his should be treated somewhere else -> faster

What we need to do here: choose a method or a heuristic predifined by a variable of environment and catch an overflow exception if it happens DN240203

By default, heuristic flag is 0

Definition at line 630 of file sc_feasibility.c.

635 {
636  bool ok = false;
637  volatile bool catch_performed = false;
638  /* Automatic variables read in a CATCH block need to be declared volatile as
639  * specified by the documentation*/
640  int volatile heuristic = 0;
641 
642  ifscdebug(5) {
643  if (sc->dimension < 0) {
644  sc_default_dump(sc);
645  sc_fix(sc);
646  assert(false);
647  }
648  }
649 
650  if (sc_rn_p(sc)) {
651  ifscdebug(5) {
652  fprintf(stderr,"\n sc_rn is given to sc_feasibility_ofl_ctrl : return true");
653  }/* this should be treated somewhere else -> faster */
654  return true;
655  }
656  if (sc_empty_p(sc)) {
657  ifscdebug(5) {
658  fprintf(stderr,"\n sc_empty is given to sc_feasibility_ofl_ctrl : return false");
659  }/*this should be treated somewhere else -> faster*/
660  return false;
661  }
662 
663  if (ofl_ctrl == OFL_CTRL)
664  {
665  ofl_ctrl = FWD_OFL_CTRL;
666  catch_performed = true;
668  ok = ofl_res;
669  catch_performed = false;
670  /*
671  * PLEASE do not remove this warning.
672  *
673  * FC 30/01/95
674  */
676  fprintf(stderr, "\n[sc_feasibility_ofl_ctrl] "
677  "arithmetic error (%d) -> %s\n",
678  heuristic, ofl_res ? "true" : "false");
679  return ok;
680  }
681  }
682 
683  /* What we need to do here:
684  * choose a method or a heuristic predifined by a variable of environment
685  * and catch an overflow exception if it happens DN240203 */
686 
687  heuristic = SWITCH_HEURISTIC_FLAG;/* By default, heuristic flag is 0 */
688  ok = internal_sc_feasibility(sc, heuristic, integer_p, ofl_ctrl);
689  if (catch_performed)
691  return ok;
692 }
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
void sc_fix(Psysteme s)
fix system s for coherency of the base and number of things.
Definition: sc_alloc.c:141
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
static bool internal_sc_feasibility(Psysteme sc, int heuristic, bool int_p, int ofl_ctrl)
means LINEAR_SIMPLEX :-)
#define SWITCH_HEURISTIC_FLAG
#define FWD_OFL_CTRL

References assert, CATCH, Ssysteme::dimension, fprintf(), FWD_OFL_CTRL, internal_sc_feasibility(), linear_number_of_exception_thrown, OFL_CTRL, ok, overflow_error, sc_default_dump(), sc_empty_p(), sc_fix(), sc_rn_p(), SWITCH_HEURISTIC_FLAG, and UNCATCH.

Referenced by sc_integer_feasibility_ofl_ctrl(), sc_rational_feasibility_ofl_ctrl(), and test_system().

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

◆ sc_fm_project_variables()

static bool sc_fm_project_variables ( Psysteme volatile *  ps1,
bool  integer_p,
bool  use_eq_only,
int  ofl_ctrl 
)
static

project in s1 (which is modified) using equalities or both equalities and inequalities.

if use_eq_only

Definition at line 296 of file sc_feasibility.c.

298 {
299  Pbase b = base_copy(sc_base(*ps1));
300  Variable var;
301  bool faisable = true;
302 
303  while (b && faisable)
304  {
305  var = chose_variable_to_project_for_feasability(*ps1, b, !use_eq_only);
306 
307  /* if use_eq_only */
308  if (!var) break;
309 
310  vect_erase_var(&b, var);
311 
312  ifscdebug(8) {
313  // Guess the variable is printable as a string if you debug...
314  fprintf(stderr,
315  "[sc_fm_project_variables] system before %s projection:\n",
316  (char *) var);
317  sc_fprint(stderr, *ps1, default_variable_to_string);
318  }
319 
320  sc_projection_along_variable_ofl_ctrl(ps1, var, ofl_ctrl);
321 
322  ifscdebug(8)
323  {
324  fprintf(stderr,
325  "[sc_fm_project_variables] system after projection:\n");
326  sc_fprint(stderr, *ps1, default_variable_to_string);
327  }
328 
329  if (sc_empty_p(*ps1))
330  {
331  faisable = false;
332  break;
333  }
334 
335  if (integer_p) {
336  *ps1 = sc_normalize(*ps1);
337  if (SC_EMPTY_P(*ps1))
338  {
339  faisable = false;
340  break;
341  }
342  }
343  }
344  base_rm(b);
345  return faisable;
346 }
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
#define base_rm(b)
Pbase base_copy(Pbase b)
Direct duplication.
Definition: alloc.c:300
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....
Definition: unaires.c:106

References base_copy(), base_rm, chose_variable_to_project_for_feasability(), default_variable_to_string(), fprintf(), sc_empty_p(), sc_fprint(), sc_normalize(), and vect_erase_var().

Referenced by sc_fourier_motzkin_feasibility_ofl_ctrl(), and sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl().

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

◆ sc_fourier_motzkin_feasibility_ofl_ctrl()

bool sc_fourier_motzkin_feasibility_ofl_ctrl ( Psysteme  s,
bool  integer_p,
int  ofl_ctrl 
)

bool sc_fourier_motzkin_faisabilite_ofl(Psysteme s): test de faisabilite d'un systeme de contraintes lineaires, par projections successives du systeme selon les differentes variables du systeme

resultat retourne par la fonction :

bool : true si le systeme est faisable false sinon

Les parametres de la fonction :

Psysteme s : systeme lineaire

Le controle de l'overflow est effectue et traite par le retour du contexte correspondant au dernier CATCH(overflow_error) effectue.

Back to the version modifying the sc. Calls of this function should store the sc first or pls call sc_fourier_motzkin_ofl_ctrl_timeout_ctrl DN210203

maybe timeout_error or overflow_error

ethrow whatever the exception is

default is feasible

a small basis if possible... (FC).

hould remove the copy of the sc.

sc_kill_db_eg a de'sallouer s a` la detection de sa non-faisabilite

Definition at line 714 of file sc_feasibility.c.

718 {
719  bool faisable = true;
720 
722  /* maybe timeout_error or overflow_error*/
723  if (ofl_ctrl == FWD_OFL_CTRL) {
724  RETHROW(); /*rethrow whatever the exception is*/
725  } else {
726  fprintf(stderr,"\n[sc_fourier_motzkin_feasibility_ofl_ctrl] without OFL_CTRL => RETURN true\n");
727  return true;/* default is feasible*/
728  }
729  }
730 
731  if (s == NULL) return true;
732 
733  ifscdebug(8)
734  {
735  fprintf(stderr, "[sc_fourier_motzkin_feasibility_ofl_ctrl] system:\n");
737  }
738  if (integer_p) sc_gcd_normalize(s);
740  if (s != NULL && !sc_empty_p(s))
741  {
742  /* a small basis if possible... (FC).
743  */
744  base_rm(sc_base(s));
745  sc_creer_base(s);
746 
747  faisable = sc_fm_project_variables(&s, integer_p, false, ofl_ctrl);
748 
749  sc_rm(s); /*should remove the copy of the sc.*/
750  s = NULL;
751 
752  }
753  else
754  /* sc_kill_db_eg a de'sallouer s a` la detection de
755  sa non-faisabilite */
756  faisable = false;
757 
759 
760  return faisable;
761 }
@ any_exception_error
catch all
#define RETHROW()
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
Psysteme sc_safe_elim_db_constraints(Psysteme ps)
The returned value must be used because they argument is freed when the system is not feasible.
static bool sc_fm_project_variables(Psysteme volatile *ps1, bool integer_p, bool use_eq_only, int ofl_ctrl)
project in s1 (which is modified) using equalities or both equalities and inequalities.

References any_exception_error, base_rm, CATCH, default_variable_to_string(), fprintf(), FWD_OFL_CTRL, RETHROW, sc_creer_base(), sc_empty_p(), sc_fm_project_variables(), sc_fprint(), sc_gcd_normalize(), sc_rm(), sc_safe_elim_db_constraints(), and UNCATCH.

Referenced by sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl().

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

◆ sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl()

bool sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl ( Psysteme  sc,
bool  int_p,
int  ofl_ctrl 
)

Automatic variables read in a CATCH block need to be declared volatile as specified by the documentation

there r 2 exceptions here!

if (w) sc_rm(w); sc_fourier_motzkin_feasibility_ctrl_ofl has freed the memory. base

Definition at line 764 of file sc_feasibility.c.

768 {
769  /* Automatic variables read in a CATCH block need to be declared volatile as
770  * specified by the documentation*/
771  Psysteme volatile w = NULL;
772  bool ok = true;
773 
774  if (sc->dimension == 0) return true;
775 
777 
778  ifscdebug(5) {
779  fprintf(stderr,"sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl fails");
780  }
781 
782 #ifdef FILTERING
783  if (FILTERING_TIMEOUT_FM) alarm(0);
784  if (EXCEPTION_PRINT_FM) {
785  char *directory_name = "feasibility_FM_fail_SC_OUT";
787  }
788 #endif
789 
790  if (w) sc_rm(w);
791 
792  if (ofl_ctrl==FWD_OFL_CTRL) {
793  linear_number_of_exception_thrown -=2;/* there r 2 exceptions here! */
795  } else {
796  fprintf(stderr,"\n[sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl] without OFL_CTRL => RETURN true\n");
797  return true;
798  }
799  }
800  TRY {
801 
802  w = sc_copy(sc);
803 
804 #ifdef FILTERING
805  if (FILTERING_TIMEOUT_FM) {
806  signal(SIGALRM, filtering_catch_alarm_FM);
807  alarm(FILTERING_TIMEOUT_FM);
808  FM_timeout = false;
809  }
810 #endif
811 
812  if (w) {
813  ok= sc_fourier_motzkin_feasibility_ofl_ctrl(w,int_p,ofl_ctrl);
814  }
815  else ok = true;
816 
817 #ifdef FILTERING
818  if (FILTERING_TIMEOUT_FM) {
819  alarm(0);
820  if (FM_timeout) {
821  char *directory_name = "feasibility_FM_timeout_filtering_SC_OUT";
823  }
824  }
825 #endif
826 
827  }
828 
829  /* if (w) sc_rm(w); sc_fourier_motzkin_feasibility_ctrl_ofl has freed the memory. base */
830 
832 
833  return ok;
834 }
#define THROW(what)
Psysteme sc_copy(Psysteme ps)
Psysteme sc_copy(Psysteme ps): duplication d'un systeme (allocation et copie complete des champs sans...
Definition: sc_alloc.c:230
bool sc_fourier_motzkin_feasibility_ofl_ctrl(Psysteme s, bool integer_p, int ofl_ctrl)
bool sc_fourier_motzkin_faisabilite_ofl(Psysteme s): test de faisabilite d'un systeme de contraintes ...
bool FM_timeout

References any_exception_error, CATCH, Ssysteme::dimension, feasibility_sc_counter, FM_timeout, fprintf(), FWD_OFL_CTRL, linear_number_of_exception_thrown, ok, overflow_error, sc_copy(), sc_default_dump_to_files(), sc_fourier_motzkin_feasibility_ofl_ctrl(), sc_rm(), THROW, TRY, and UNCATCH.

Referenced by internal_sc_feasibility().

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

◆ sc_integer_feasibility_ofl_ctrl()

bool sc_integer_feasibility_ofl_ctrl ( Psysteme  sc,
int  ofl_ctrl,
bool  ofl_res 
)

Definition at line 111 of file sc_feasibility.c.

115 {
116  return sc_feasibility_ofl_ctrl(sc, true, ofl_ctrl, ofl_res);
117 }
bool sc_feasibility_ofl_ctrl(Psysteme sc, bool integer_p, volatile int ofl_ctrl, volatile bool ofl_res)
return true is the system is feasible

References sc_feasibility_ofl_ctrl().

Referenced by convex_cells_intersection_p(), dependence_cone_positive(), efficient_sc_check_inequality_feasibility(), interlaced_basic_workchunk_regions_p(), region_intersection(), sc_triang_elim_redund(), and sc_triang_elim_redund_n_first().

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

◆ sc_janus_feasibility_ofl_ctrl_timeout_ctrl()

bool sc_janus_feasibility_ofl_ctrl_timeout_ctrl ( Psysteme  sc,
bool  ofl_ctrl 
)

Automatic variables read in a CATCH block need to be declared volatile as specified by the documentation

N: We should be sure that the sc is not null in the sc_feasibility_ofl_ctrl, but for direct calls of Janus ...

sc_empty_p is filtered, (sc_fix is called), so there's no other reason for janus to fail ... maybe a sc_not_easy_to_see_empty

TODO aware of vectors of one element: 0 <= 1. treating it here is better than in Janus

here r 2 exceptions here!

c_janus_feasibility returns type int, not boolean

result found

result not found

default is feasible

Definition at line 911 of file sc_feasibility.c.

914 {
915  /* Automatic variables read in a CATCH block need to be declared volatile as
916  * specified by the documentation*/
917  Psysteme volatile w = NULL;
918  int ok=0;
919 
920  /*DN: We should be sure that the sc is not null in the sc_feasibility_ofl_ctrl, but for direct calls of Janus ...*/
921  if (sc) {
922  if (sc->dimension == 0) return true;
923  }
924  else return true;
925 
926  /* sc_empty_p is filtered, (sc_fix is called), so there's no other reason for janus to fail ...
927  * maybe a sc_not_easy_to_see_empty */
928  /* TODO aware of vectors of one element: 0 <= 1.
929  * treating it here is better than in Janus */
930 
932 
933  ifscdebug(5) {
934  fprintf(stderr,"\n[sc_janus_feasibility_ofl_ctrl_timeout_ctrl] fails");
935  }
936 
937 #ifdef FILTERING
938  if (FILTERING_TIMEOUT_JANUS) alarm(0);
939 
940  if (EXCEPTION_PRINT_JANUS) {
941  char *directory_name = "feasibility_janus_fail_SC_OUT";
943  }
944 #endif
945 
946  if (w) sc_rm(w);
947  linear_number_of_exception_thrown -=1;/*there r 2 exceptions here!*/
949  }
950  TRY {
951  if (sc) {w = sc_copy(sc);}
952  else return true;
953  if (w) {sc_fix(w);}
954 
955  if (w) {
956 
957 #ifdef FILTERING
958  if (FILTERING_TIMEOUT_JANUS) {
959  signal(SIGALRM, filtering_catch_alarm_J);
960  alarm(FILTERING_TIMEOUT_JANUS);
961  J_timeout = false;
962  }
963 #endif
964 
965  ok = sc_janus_feasibility(w); /*sc_janus_feasibility returns type int, not boolean*/
966 
967 #ifdef FILTERING
968  if (FILTERING_TIMEOUT_JANUS) {
969  alarm(0);
970  if (J_timeout){
971  char *directory_name = "feasibility_janus_timeout_filtering_SC_OUT";
973  }
974  }
975 #endif
976 
977  } else return true;
978 
979  }
980 
982 
983  if (ok<3) {
984  /* result found*/
985  if (w) sc_rm(w);
986  if (ok > 0) return true;
987  else return false;
988  } else {
989  /* result not found*/
990  ifscdebug(5) {
991  if (ok ==7) fprintf(stderr,"TRIED JANUS BUT OVERFLOW !!\n");
992  if (ok ==6) fprintf(stderr,"TRIED JANUS BUT BUG OF PROGRAMMATION IN JANUS !!\n");
993  if (ok ==5) fprintf(stderr,"TRIED JANUS BUT WRONG PARAMETER !!\n");
994  if (ok ==4) fprintf(stderr,"TRIED JANUS BUT ARRAY OUT OF BOUNDARY !!\n");
995  if (ok ==3) fprintf(stderr,"TRIED JANUS BUT NUMBER OF PIVOTAGE TOO BIG, MIGHT BOUCLE !!\n");
996  if (ok ==8) fprintf(stderr,"TRIED JANUS BUT pivot anormally small !!\n");
997  if (ok ==9) fprintf(stderr,"Janus is not ready for this system of constraints !!\n");
998  }
999  if (w) sc_rm(w);
1000  if (ofl_ctrl == FWD_OFL_CTRL) {
1002  } else {
1003  fprintf(stderr,"\n[sc_janus_feasibility_ofl_ctrl_timeout_ctrl] without OFL_CTRL => RETURN true\n");
1004  return true;/* default is feasible*/
1005  }
1006  }
1007  return(ok);
1008 }
bool sc_janus_feasibility(Psysteme sc)
Compute feasibility, using custom Janus function if set, fallback function otherwise.
bool J_timeout

References any_exception_error, CATCH, Ssysteme::dimension, feasibility_sc_counter, fprintf(), FWD_OFL_CTRL, J_timeout, linear_number_of_exception_thrown, ok, overflow_error, sc_copy(), sc_default_dump_to_files(), sc_fix(), sc_janus_feasibility(), sc_rm(), THROW, TRY, and UNCATCH.

Referenced by internal_sc_feasibility().

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

◆ sc_rational_feasibility_ofl_ctrl()

◆ sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl()

bool sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl ( Psysteme  sc,
bool  project_eq_p,
bool  int_p,
int  ofl_ctrl 
)

Automatic variables read in a CATCH block need to be declared volatile as specified by the documentation

here r 2 exceptions here!

default is feasible

Definition at line 837 of file sc_feasibility.c.

842 {
843  /* Automatic variables read in a CATCH block need to be declared volatile as
844  * specified by the documentation*/
845  Psysteme volatile w = NULL;
846  bool ok = true;
847 
848  if (sc->dimension == 0) return true;
849 
851 
852  ifscdebug(5) {
853  fprintf(stderr,"\n[sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl] fails");
854  }
855 
856 #ifdef FILTERING
857  if (FILTERING_TIMEOUT_LINEAR_SIMPLEX) alarm(0);
858 
859  if (EXCEPTION_PRINT_LINEAR_SIMPLEX) {
860  char *directory_name = "feasibility_linear_simplex_fail_SC_OUT";
862  }
863 #endif
864 
865  if (w) sc_rm(w);
866  if (ofl_ctrl == FWD_OFL_CTRL) {
867  linear_number_of_exception_thrown -=2;/*there r 2 exceptions here!*/
869  } else {
870  fprintf(stderr,"\n[sc_simplex_feasibility_ofl_ctrl_timeout_ctrl] without OFL_CTRL => RETURN true\n");
871  return true;/* default is feasible*/
872  }
873  }
874  TRY {
875 
876 #ifdef FILTERING
877  if (FILTERING_TIMEOUT_LINEAR_SIMPLEX) {
878  signal(SIGALRM, filtering_catch_alarm_S);
879  alarm(FILTERING_TIMEOUT_LINEAR_SIMPLEX);
880  S_timeout = false;
881  }
882 #endif
883 
884  if (project_eq_p) {
885  w = sc_copy(sc);
886  ok = sc_fm_project_variables(&w, int_p, true, ofl_ctrl);
887  ok = sc_simplex_feasibility_ofl_ctrl(w,ofl_ctrl);
888  }else {
889  ok = sc_simplex_feasibility_ofl_ctrl(sc,ofl_ctrl);
890  }
891 
892 #ifdef FILTERING
893  if (FILTERING_TIMEOUT_LINEAR_SIMPLEX) {
894  alarm(0);
895  if (S_timeout) {
896  char *directory_name = "feasibility_linear_simplex_timeout_filtering_SC_OUT";
898  }
899  }
900 #endif
901 
902  }
903 
904  if (w) sc_rm(w);
906 
907  return ok;
908 }
bool S_timeout
bool sc_simplex_feasibility_ofl_ctrl(Psysteme sys, int ofl_ctrl)
Main Function.

References any_exception_error, CATCH, Ssysteme::dimension, feasibility_sc_counter, fprintf(), FWD_OFL_CTRL, linear_number_of_exception_thrown, ok, overflow_error, S_timeout, sc_copy(), sc_default_dump_to_files(), sc_fm_project_variables(), sc_rm(), sc_simplex_feasibility_ofl_ctrl(), THROW, TRY, and UNCATCH.

Referenced by internal_sc_feasibility().

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

◆ simplify_big_coeff()

static Psysteme simplify_big_coeff ( Psysteme  sc)
static

Definition at line 1012 of file sc_feasibility.c.

1013 {
1014  int MAXCOEFFICIENT = 1000;
1015  Value val_max = int_to_value(MAXCOEFFICIENT);
1016  Pcontrainte ineg, ineg1;
1017  for (ineg = sc->inegalites; ineg != NULL; ineg = ineg1)
1018  {
1019  Pvecteur vec = ineg->vecteur,v;
1020  for (v = vec; v !=NULL && ineg->vecteur != VECTEUR_NUL; v = v->succ)
1021  {
1022  Value val = v->val;
1023  Variable var =v->var;
1024  if (value_gt(value_abs(val),val_max) && (var!=TCST))
1025  eq_set_vect_nul(ineg);
1026  }
1027  ineg1 = ineg->succ;
1028  }
1030  return sc;
1031 }
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
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 sc_rm_empty_constraints(Psysteme ps, bool process_equalities)
package sc: elimination de redondance simple
Definition: sc_elim_eq.c:56
Pcontrainte inegalites
Definition: sc-local.h:71
Value val
Definition: vecteur-local.h:91
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.

References eq_set_vect_nul(), Ssysteme::inegalites, int_to_value, sc_rm_empty_constraints(), Scontrainte::succ, TCST, Svecteur::val, value_abs, value_gt, Scontrainte::vecteur, and VECTEUR_NUL.

Referenced by efficient_sc_check_inequality_feasibility().

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

Variable Documentation

◆ feasibility_sc_counter

◆ FM_timeout

bool FM_timeout = false

◆ J_timeout

bool J_timeout = false

Definition at line 92 of file sc_feasibility.c.

Referenced by sc_janus_feasibility_ofl_ctrl_timeout_ctrl().

◆ method_used

int method_used = 0
static

Definition at line 364 of file sc_feasibility.c.

Referenced by internal_sc_feasibility().

◆ S_timeout

bool S_timeout = false

Definition at line 93 of file sc_feasibility.c.

Referenced by sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl().