PIPS
sc_debug.c
Go to the documentation of this file.
1 /*
2 
3  $Id: sc_debug.c 1671 2019-06-26 19:14:11Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of Linear/C3 Library.
8 
9  Linear/C3 Library is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #ifdef HAVE_CONFIG_H
26  #include "config.h"
27 #endif
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include "linear_assert.h"
32 
33 #include "boolean.h"
34 #include "arithmetique.h"
35 #include "vecteur.h"
36 #include "contrainte.h"
37 #include "sc.h"
38 
39 #include "sc-private.h"
40 
41 #ifdef FILTERING
42 #include "signal.h"
43 #endif
44 
45 /************************************************************* DEBUG */
46 #define SC_DEBUG_LEVEL "SC_DEBUG_LEVEL"
47 #define SC_SWITCH_HEURISTIC_FLAG "SC_SWITCH_HEURISTIC_FLAG"
48 
49 /************************************************************* CONTROL */
50 //Note: CONTROL and FILTER are different.
51 
52 //OVERFLOW_CONTROL is implemented.
53 //SIZE_CONTROL is to be implemented
54 //TIMEOUT_CONTROL is not completed yet.
55 
56 #ifdef FILTERING
57 
58 #define FLAG_CONTROL_DIMENSION_CONVEX_HULL "CONTROL_DIMENSION_CONVEX_HULL"
59 #define FLAG_CONTROL_NUMBER_CONSTRAINTS_CONVEX_HULL "CONTROL_NUMBER_CONSTRAINTS_CONVEX_HULL"
60 #define FLAG_CONTROL_DIMENSION_PROJECTION "CONTROL_DIMENSION_PROJECTION"
61 #define FLAG_CONTROL_NUMBER_CONSTRAINTS_PROJECTION "CONTROL_NUMBER_CONSTRAINTS_PROJECTION"
62 
63 
64 /************************************************************* FILTERING TIMEOUT*/
65 #define FLAG_FILTERING_TIMEOUT_JANUS "FILTERING_TIMEOUT_JANUS"
66 #define FLAG_FILTERING_TIMEOUT_LINEAR_SIMPLEX "FILTERING_TIMEOUT_LINEAR_SIMPLEX"
67 #define FLAG_FILTERING_TIMEOUT_FM "FILTERING_TIMEOUT_FM"
68 #define FLAG_FILTERING_TIMEOUT_CONVEX_HULL "FILTERING_TIMEOUT_CONVEX_HULL"
69 #define FLAG_FILTERING_TIMEOUT_PROJECTION "FILTERING_TIMEOUT_PROJECTION"
70 
71 /************************************************************* FILTERING SIZE*/
72 #define FLAG_FILTERING_DIMENSION_FEASIBILITY "FILTERING_DIMENSION_FEASIBILITY"
73 #define FLAG_FILTERING_NUMBER_CONSTRAINTS_FEASIBILITY "FILTERING_NUMBER_CONSTRAINTS_FEASIBILITY"
74 #define FLAG_FILTERING_DENSITY_FEASIBILITY "FILTERING_DENSITY_FEASIBILITY"
75 #define FLAG_FILTERING_MAGNITUDE_FEASIBILITY "FILTERING_MAGNITUDE_FEASIBILITY"
76 
77 #define FLAG_FILTERING_DIMENSION_PROJECTION "FILTERING_DIMENSION_PROJECTION"
78 #define FLAG_FILTERING_NUMBER_CONSTRAINTS_PROJECTION "FILTERING_NUMBER_CONSTRAINTS_PROJECTION"
79 #define FLAG_FILTERING_DENSITY_PROJECTION "FILTERING_DENSITY_PROJECTION"
80 #define FLAG_FILTERING_MAGNITUDE_PROJECTION "FILTERING_MAGNITUDE_PROJECTION"
81 
82 #define FLAG_FILTERING_DIMENSION_CONVEX_HULL "FILTERING_DIMENSION_CONVEX_HULL"
83 #define FLAG_FILTERING_NUMBER_CONSTRAINTS_CONVEX_HULL "FILTERING_NUMBER_CONSTRAINTS_CONVEX_HULL"
84 #define FLAG_FILTERING_DENSITY_CONVEX_HULL "FILTERING_DENSITY_CONVEX_HULL"
85 #define FLAG_FILTERING_MAGNITUDE_CONVEX_HULL "FILTERING_MAGNITUDE_CONVEX_HULL"
86 
87 #endif
88 
91 
92 #ifdef FILTERING
93 
94 int filtering_timeout_J = 0;
95 int filtering_timeout_S = 0;
96 int filtering_timeout_FM = 0;
97 int filtering_timeout_CH = 0;
98 int filtering_timeout_projection = 0;
99 
100 int filtering_dimension_feasibility = 0;
101 int filtering_number_constraints_feasibility = 0;
102 int filtering_density_feasibility = 0;
103 long int filtering_magnitude_feasibility = 0;// need to cast to Value
104 
105 int filtering_dimension_projection = 0;
106 int filtering_number_constraints_projection = 0;
107 int filtering_density_projection = 0;
108 long int filtering_magnitude_projection = 0;// need to cast to Value
109 
110 int filtering_dimension_convex_hull = 0;
111 int filtering_number_constraints_convex_hull = 0;
112 int filtering_density_convex_hull = 0;
113 long int filtering_magnitude_convex_hull = 0;// need to cast to Value
114 
115 #endif
116 
117 /* SET FUNCTIONS*/
118 /* Let's change variables directly here, except sc_debug_level?*/
119 /* or use functions returning values, within private variables? DN*/
120 
122 {
123  sc_debug_level = l ;
124 }
125 
127 {
129 }
130 
131 
132 #ifdef FILTERING
133 
134 /*TIMEOUT*/
135 static void set_filtering_timeout_J(int l)
136 {
137  filtering_timeout_J = l;
138 }
139 static void set_filtering_timeout_S(int l)
140 {
141  filtering_timeout_S = l ;
142 }
143 static void set_filtering_timeout_FM(int l)
144 {
145  filtering_timeout_FM = l ;
146 }
147 static void set_filtering_timeout_convex_hull(int l)
148 {
149  filtering_timeout_CH = l ;
150 }
151 static void set_filtering_timeout_projection(int l)
152 {
153  filtering_timeout_projection = l ;
154 }
155 
156 /*SIZE - dimension, number of constraints, density and magnitude*/
157 
158 static void set_filtering_dimension_feasibility(int l)
159 {
160  filtering_dimension_feasibility = l ;
161 }
162 static void set_filtering_number_constraints_feasibility(int l)
163 {
164  filtering_number_constraints_feasibility = l ;
165 }
166 static void set_filtering_density_feasibility(int l)
167 {
168  filtering_density_feasibility = l ;
169 }
170 static void set_filtering_magnitude_feasibility(long int l)
171 {
172  filtering_magnitude_feasibility = l ;
173 }
174 
175 static void set_filtering_dimension_projection(int l)
176 {
177  filtering_dimension_projection = l ;
178 }
179 static void set_filtering_number_constraints_projection(int l)
180 {
181  filtering_number_constraints_projection = l ;
182 }
183 static void set_filtering_density_projection(int l)
184 {
185  filtering_density_projection = l ;
186 }
187 static void set_filtering_magnitude_projection(long int l)
188 {
189  filtering_magnitude_projection = l ;
190 }
191 
192 static void set_filtering_dimension_convex_hull(int l)
193 {
194  filtering_dimension_convex_hull = l ;
195 }
196 static void set_filtering_number_constraints_convex_hull(int l)
197 {
198  filtering_number_constraints_convex_hull = l ;
199 }
200 static void set_filtering_density_convex_hull(int l)
201 {
202  filtering_density_convex_hull = l ;
203 }
204 static void set_filtering_magnitude_convex_hull(long int l)
205 {
206  filtering_magnitude_convex_hull = l ;
207 }
208 #endif
209 
210 /***************************************************** VARIABLE NAME STACK */
211 typedef char * (*var_name_t)(Variable);
212 
213 static var_name_t * var_name_stack = NULL;
214 static int var_name_stack_index = 0; /* next available chunck */
215 static int var_name_stack_size = 0;
216 
217 void sc_variable_name_push(char * (*fun)(Variable))
218 {
220  {
224  }
226 }
227 
228 static void sc_variable_name_init(void)
229 {
231 
233  var_name_stack_size = 10;
237 }
238 
240 {
243 }
244 
246 {
248  return (*(var_name_stack[var_name_stack_index-1]))(v);
249 }
250 
251 /********************************************************** INITIALIZATION */
252 
253 void initialize_sc(char *(*var_to_string)(Variable))
254 {
255  char * tmp;
256 
257  /* sc debug */
258  tmp = getenv(SC_DEBUG_LEVEL);
259  if (tmp) set_sc_debug_level(atoi(tmp));
260 
261  /* sc switch heuristic */
262  tmp = getenv(SC_SWITCH_HEURISTIC_FLAG);
263  if (tmp) set_sc_switch_heuristic_flag(atoi(tmp));
264 
265 #ifdef FILTERING
266 
267  /* timeout filtering*/
268  tmp = getenv(FLAG_FILTERING_TIMEOUT_JANUS);
269  if (tmp) set_filtering_timeout_J(atoi(tmp));
270 
271  tmp = getenv(FLAG_FILTERING_TIMEOUT_LINEAR_SIMPLEX);
272  if (tmp) set_filtering_timeout_S(atoi(tmp));
273 
274  tmp = getenv(FLAG_FILTERING_TIMEOUT_FM);
275  if (tmp) set_filtering_timeout_FM(atoi(tmp));
276 
277  tmp = getenv(FLAG_FILTERING_TIMEOUT_CONVEX_HULL);
278  if (tmp) set_filtering_timeout_convex_hull(atoi(tmp));
279 
280  tmp = getenv(FLAG_FILTERING_TIMEOUT_PROJECTION);
281  if (tmp) set_filtering_timeout_projection(atoi(tmp));
282 
283  /* size filtering*/
284  tmp = getenv(FLAG_FILTERING_DIMENSION_FEASIBILITY);
285  if (tmp) set_filtering_dimension_feasibility(atoi(tmp));
286 
287  tmp = getenv(FLAG_FILTERING_NUMBER_CONSTRAINTS_FEASIBILITY);
288  if (tmp) set_filtering_number_constraints_feasibility(atoi(tmp));
289 
290  tmp = getenv(FLAG_FILTERING_DENSITY_FEASIBILITY);
291  if (tmp) set_filtering_density_feasibility(atoi(tmp));
292 
293  tmp = getenv(FLAG_FILTERING_MAGNITUDE_FEASIBILITY);
294  if (tmp) set_filtering_magnitude_feasibility(atol(tmp));
295 
296  tmp = getenv(FLAG_FILTERING_DIMENSION_PROJECTION);
297  if (tmp) set_filtering_dimension_projection(atoi(tmp));
298 
299  tmp = getenv(FLAG_FILTERING_NUMBER_CONSTRAINTS_PROJECTION);
300  if (tmp) set_filtering_number_constraints_projection(atoi(tmp));
301 
302  tmp = getenv(FLAG_FILTERING_DENSITY_PROJECTION);
303  if (tmp) set_filtering_density_projection(atoi(tmp));
304 
305  tmp = getenv(FLAG_FILTERING_MAGNITUDE_PROJECTION);
306  if (tmp) set_filtering_magnitude_projection(atol(tmp));
307 
308  tmp = getenv(FLAG_FILTERING_DIMENSION_CONVEX_HULL);
309  if (tmp) set_filtering_dimension_convex_hull(atoi(tmp));
310 
311  tmp = getenv(FLAG_FILTERING_NUMBER_CONSTRAINTS_CONVEX_HULL);
312  if (tmp) set_filtering_number_constraints_convex_hull(atoi(tmp));
313 
314  tmp = getenv(FLAG_FILTERING_DENSITY_CONVEX_HULL);
315  if (tmp) set_filtering_density_convex_hull(atoi(tmp));
316 
317  tmp = getenv(FLAG_FILTERING_MAGNITUDE_CONVEX_HULL);
318  if (tmp) set_filtering_magnitude_convex_hull(atol(tmp));
319 
320 #endif
321 
322  /* variable name stuff */
324  sc_variable_name_push(var_to_string);
325 
326  ifscdebug(1)
327  fprintf(stderr, "[initialize_sc] Value: " LINEAR_VALUE_STRING "\n");
328 }
#define LINEAR_VALUE_STRING
default: LINEAR_VALUE_IS_INT
void * malloc(YYSIZE_T)
char * variable_default_name(Variable v)
char * variable_default_name(Variable v): returns the name of variable v
Definition: variable.c:81
#define assert(ex)
Definition: newgen_assert.h:41
char *(* var_name_t)(Variable)
Definition: sc_debug.c:211
static int var_name_stack_index
Definition: sc_debug.c:214
int sc_switch_heuristic_flag
Definition: sc_debug.c:90
#define SC_SWITCH_HEURISTIC_FLAG
Definition: sc_debug.c:47
static int var_name_stack_size
next available chunck
Definition: sc_debug.c:215
char * default_variable_to_string(Variable v)
Definition: sc_debug.c:245
void set_sc_debug_level(int l)
SET FUNCTIONS.
Definition: sc_debug.c:121
int sc_debug_level
Definition: sc_debug.c:89
void sc_variable_name_pop(void)
Definition: sc_debug.c:239
#define SC_DEBUG_LEVEL
Definition: sc_debug.c:46
static void set_sc_switch_heuristic_flag(int l)
Definition: sc_debug.c:126
void sc_variable_name_push(char *(*fun)(Variable))
Definition: sc_debug.c:217
static var_name_t * var_name_stack
Definition: sc_debug.c:213
static void sc_variable_name_init(void)
Definition: sc_debug.c:228
void initialize_sc(char *(*var_to_string)(Variable))
Definition: sc_debug.c:253
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
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