Blame view

Debug/src/kernels/cl_propagators.c 19.6 KB
0c8ce2b0   Pedro Roque   missing files
1
2
3
4
/*
 * cl_propagators.c
 *
 *  Created on: 09/09/2019
4d26a735   Pedro Roque   Increased recogni...
5
 *      Author: Pedro
0c8ce2b0   Pedro Roque   missing files
6
7
 */

0c8ce2b0   Pedro Roque   missing files
8
9
10
11
12
13
14
15
16
#ifndef __OPENCL_VERSION__
#include <stdbool.h>
#include <sys/types.h>

#include "cl_propagators.h"
#include "cl_aux_functions.h"
#include "../utils/cl_syntax.h"

#include "../constraints/all_different.h"
4d26a735   Pedro Roque   Increased recogni...
17
18
19
20
21
22
#include "../constraints/array_bool_and.h"
#include "../constraints/array_bool_element.h"
#include "../constraints/array_bool_or.h"
#include "../constraints/array_bool_xor.h"
#include "../constraints/array_int_element.h"
#include "../constraints/array_var_int_element.h"
0c8ce2b0   Pedro Roque   missing files
23
24
25
#include "../constraints/at_least.h"
#include "../constraints/at_most.h"
#include "../constraints/at_most_one.h"
0c8ce2b0   Pedro Roque   missing files
26
27
#include "../constraints/bool_and.h"
#include "../constraints/bool_clause.h"
4d26a735   Pedro Roque   Increased recogni...
28
29
30
31
32
33
#include "../constraints/bool_eq.h"
#include "../constraints/bool_le.h"
#include "../constraints/bool_lin_eq.h"
#include "../constraints/bool_lin_le.h"
#include "../constraints/bool_lt.h"
#include "../constraints/bool_not.h"
0c8ce2b0   Pedro Roque   missing files
34
#include "../constraints/bool_or.h"
4d26a735   Pedro Roque   Increased recogni...
35
36
#include "../constraints/bool_xor.h"
#include "../constraints/bool2int.h"
0c8ce2b0   Pedro Roque   missing files
37
#include "../constraints/element.h"
4d26a735   Pedro Roque   Increased recogni...
38
#include "../constraints/int_eq.h"
0c8ce2b0   Pedro Roque   missing files
39
40
#include "../constraints/exactly.h"
#include "../constraints/exactly_var.h"
4d26a735   Pedro Roque   Increased recogni...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "../constraints/int_div.h"
#include "../constraints/int_eq_c.h"
#include "../constraints/int_le.h"
#include "../constraints/int_lin_eq.h"
#include "../constraints/int_lin_le.h"
#include "../constraints/int_lin_ne.h"
#include "../constraints/int_lin_var.h"
#include "../constraints/int_lt.h"
#include "../constraints/int_max.h"
#include "../constraints/int_min.h"
#include "../constraints/int_mod.h"
#include "../constraints/int_ne.h"
#include "../constraints/int_plus.h"
#include "../constraints/int_times.h"
0c8ce2b0   Pedro Roque   missing files
55
#include "../constraints/maximize.h"
0c8ce2b0   Pedro Roque   missing files
56
57
58
59
60
61
62
63
#include "../constraints/minimize.h"
#include "../constraints/minus_eq.h"
#include "../constraints/minus_ne.h"
#include "../constraints/sum.h"
#include "../constraints/sum_prod.h"
#include "../constraints/sum_var.h"
#include "../constraints/var_eq_minus.h"
#include "../constraints/var_eq_minus_abs.h"
0c8ce2b0   Pedro Roque   missing files
64
65
66

#else
#include "../constraints/all_different.c"
4d26a735   Pedro Roque   Increased recogni...
67
68
69
70
71
72
#include "../constraints/array_bool_and.c"
#include "../constraints/array_bool_element.c"
#include "../constraints/array_bool_or.c"
#include "../constraints/array_bool_xor.c"
#include "../constraints/array_int_element.c"
#include "../constraints/array_var_int_element.c"
0c8ce2b0   Pedro Roque   missing files
73
74
75
#include "../constraints/at_least.c"
#include "../constraints/at_most.c"
#include "../constraints/at_most_one.c"
0c8ce2b0   Pedro Roque   missing files
76
77
#include "../constraints/bool_and.c"
#include "../constraints/bool_clause.c"
4d26a735   Pedro Roque   Increased recogni...
78
79
80
81
82
83
#include "../constraints/bool_eq.c"
#include "../constraints/bool_le.c"
#include "../constraints/bool_lin_eq.c"
#include "../constraints/bool_lin_le.c"
#include "../constraints/bool_lt.c"
#include "../constraints/bool_not.c"
0c8ce2b0   Pedro Roque   missing files
84
#include "../constraints/bool_or.c"
4d26a735   Pedro Roque   Increased recogni...
85
86
#include "../constraints/bool_xor.c"
#include "../constraints/bool2int.c"
0c8ce2b0   Pedro Roque   missing files
87
#include "../constraints/element.c"
4d26a735   Pedro Roque   Increased recogni...
88
#include "../constraints/int_eq.c"
0c8ce2b0   Pedro Roque   missing files
89
90
#include "../constraints/exactly.c"
#include "../constraints/exactly_var.c"
4d26a735   Pedro Roque   Increased recogni...
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "../constraints/int_div.c"
#include "../constraints/int_eq_c.c"
#include "../constraints/int_le.c"
#include "../constraints/int_lin_eq.c"
#include "../constraints/int_lin_le.c"
#include "../constraints/int_lin_ne.c"
#include "../constraints/int_lin_var.c"
#include "../constraints/int_lt.c"
#include "../constraints/int_max.c"
#include "../constraints/int_min.c"
#include "../constraints/int_mod.c"
#include "../constraints/int_ne.c"
#include "../constraints/int_plus.c"
#include "../constraints/int_times.c"
0c8ce2b0   Pedro Roque   missing files
105
#include "../constraints/maximize.c"
0c8ce2b0   Pedro Roque   missing files
106
107
108
109
110
111
112
113
#include "../constraints/minimize.c"
#include "../constraints/minus_eq.c"
#include "../constraints/minus_ne.c"
#include "../constraints/sum.c"
#include "../constraints/sum_prod.c"
#include "../constraints/sum_var.c"
#include "../constraints/var_eq_minus.c"
#include "../constraints/var_eq_minus_abs.c"
0c8ce2b0   Pedro Roque   missing files
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#endif

#include "../config.h"
#include "../domains.h"
#include "cl_constraints.h"
#include "cl_variables.h"
#include "cl_ttl.h"

#if CL_D_TYPE == CL_BITMAP
#include "cl_bitmaps.h"
#elif CL_D_TYPE == CL_INTERVAL
#include  "cl_intervals.h"
#endif

/*
 * Propagate the domain of the variable with the ID prop_v_id through all the other variables on each constraint that constrain prop_v_id
0c8ce2b0   Pedro Roque   missing files
130
131
132
133
134
 * vs - CSP variables
 * cs - CSP constraints
 * cs_per_v_idx - vector with all the constraints ID that constrain each variable, per variable ID order
 * vs_per_c_idx - vector with all constrained variables ID per constraint, per constraint ID order
 * c_consts - vector with all the constant values of a CSP
4d26a735   Pedro Roque   Increased recogni...
135
 * val_to_opt_g - value to optimize
0c8ce2b0   Pedro Roque   missing files
136
137
138
139
140
141
 * nodes_fail - counter for all the failed nodes
 * nodes_expl - counter for all the explored nodes
 * pruning - counter for all the propagations that prunned values
 * props_ok - counter for all the succeeded propagations
 * vs_prop_ - all CSP variables with current step values
 * prop_v_id - variable ID to propagate
4d26a735   Pedro Roque   Increased recogni...
142
143
144
145
 * vs_id_to_prop_ - list of variables marked for propagation
 * props_count - count each time any propagator was called
 * prop_ok - true if all the constraints were respected
 * terms_mem - generic memory used by some propagators to store auxiliary values
0c8ce2b0   Pedro Roque   missing files
146
147
 */
CUDA_FUNC void propagate(
4d26a735   Pedro Roque   Increased recogni...
148
149
150
CL_VS_MEM VARS *vs, CL_CS_MEM cl_constr *cs, CL_INTS_MEM int *cs_per_v_idx, CL_INTS_MEM int *vs_per_c_idx,
#if CS_AT_LEAST == 1 || CS_AT_MOST == 1 || CS_AT_MOST_ONE == 1 || CS_EXACTLY == 1 || CS_INT_LIN_EQ == 1 || CS_INT_LIN_LE == 1 || CS_INT_LIN_NE == 1 || CS_INT_LIN_VAR == 1 || CS_ARRAY_INT_ELEMENT == 1 || CS_BOOL_LIN_EQ == 1 || CS_BOOL_LIN_LE == 1
		CL_INTS_MEM int *c_consts,
0c8ce2b0   Pedro Roque   missing files
151
152
#endif
#if (CS_MAXIMIZE == 1 || CS_MINIMIZE == 1) && CL_WORK == CL_OPT
4d26a735   Pedro Roque   Increased recogni...
153
		__global unsigned int *val_to_opt_g,
0c8ce2b0   Pedro Roque   missing files
154
155
#endif
#if CL_STATS == 1
4d26a735   Pedro Roque   Increased recogni...
156
		__global unsigned long *nodes_fail, __global unsigned long *nodes_expl, __global unsigned long *pruning, __global unsigned long *props_ok,
0c8ce2b0   Pedro Roque   missing files
157
#endif
4d26a735   Pedro Roque   Increased recogni...
158
		CL_MEMORY VARS_PROP *vs_prop_, unsigned int prop_v_id, CL_MEMORY unsigned short *vs_id_to_prop_ TTL_CTR
0c8ce2b0   Pedro Roque   missing files
159
#if CL_N_DEVS > 1
4d26a735   Pedro Roque   Increased recogni...
160
		, unsigned long *props_count
0c8ce2b0   Pedro Roque   missing files
161
#endif
4d26a735   Pedro Roque   Increased recogni...
162
		CS_IGNORE_FUNC, bool *prop_ok, __global int *terms_mem) {
0c8ce2b0   Pedro Roque   missing files
163

4d26a735   Pedro Roque   Increased recogni...
164
	CL_CS_MEM cl_constr *current_cs;	// current constraint
0c8ce2b0   Pedro Roque   missing files
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
	int i;

	*prop_ok = 1;

#if CL_CHECK_ERRORS
	int l;
	for (l = 0; l < CL_N_VS; l++) {

		bool empty;
#if CL_N_WORDS == 1
		empty = (vs_prop_[l].prop_d == 0);
#else
		int m;
		empty = 1;
		for (m = 0; m < CL_N_WORDS; m++) {
			CHECK_TTL(ttl_ctr, 115)
			if (vs_prop_[l].prop_d[m] != 0) {
				empty = 0;
				m = CL_N_WORDS;
			}
		}
#endif
		if ((*prop_ok == 1 && (empty || vs_prop_[l].n_vals == 0 || vs_prop_[l].n_vals > vs_prop_[l].max + 1)) || vs_prop_[l].min > vs_prop_[l].max || vs_prop_[l].max > CL_D_MAX) {
			printf((__constant char *)"\n###error 71\n");
		}
	}
#endif

	// for statistics
#if CL_STATS == 1
	bool propagated;
	int last_prev_vs_to_prop;
#endif

#if CL_CHECK_ERRORS
	if (prop_v_id > CL_N_VS) {
		printf((__constant char *)"\n###error 48\n");
	}
#endif

	// iterates the constraints that constrain the variable to propagate
	for (i = 0; i < vs[prop_v_id].n_cs; i++) {
		CHECK_TTL(ttl_ctr, 28)
4d26a735   Pedro Roque   Increased recogni...
208
209
210
		current_cs = &cs[cs_per_v_idx[convert_uint (vs[prop_v_id].c_idx) + convert_uint (i)]];
		unsigned int kind = convert_uint (current_cs->kind);
		CL_INTS_MEM int *vs_per_c_idx_ = &vs_per_c_idx[current_cs->v_idx];
0c8ce2b0   Pedro Roque   missing files
211
212

#if CL_CHECK_ERRORS
4d26a735   Pedro Roque   Increased recogni...
213
214
215
216
217
218
219
220
221
		if (cs_per_v_idx[vs[prop_v_id].c_idx + convert_uint(i)] > CL_N_CS) {
			printf((__constant char *)"\n###error 49\n");
		}
		if (kind > 47) {
			printf((__constant char *)"\n###error 50\n");
		}
		if (current_cs->v_idx > CL_N_VS_CS) {
			printf((__constant char *)"\n###error 52\n");
		}
0c8ce2b0   Pedro Roque   missing files
222
223
#endif

4d26a735   Pedro Roque   Increased recogni...
224
225
#if CS_AT_LEAST == 1 || CS_AT_MOST == 1 || CS_AT_MOST_ONE == 1 || CS_EXACTLY == 1 || CS_INT_LIN_EQ == 1 || CS_INT_LIN_LE == 1 || CS_INT_LIN_NE == 1 || CS_INT_LIN_VAR == 1 || CS_ARRAY_INT_ELEMENT == 1 || CS_BOOL_LIN_EQ == 1 || CS_BOOL_LIN_LE == 1
		CL_INTS_MEM int *c_consts_ = &c_consts[current_cs->const_idx];
0c8ce2b0   Pedro Roque   missing files
226
227

#if CL_CHECK_ERRORS
4d26a735   Pedro Roque   Increased recogni...
228
229
230
		if (current_cs->v_idx > CL_N_CS_VS) {
			printf((__constant char *)"\n###error 53\n");
		}
0c8ce2b0   Pedro Roque   missing files
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#endif
#endif

#if CL_N_DEVS > 1
		(*props_count)++;
#endif

#if CL_STATS == 1
		last_prev_vs_to_prop = vs_id_to_prop_[1];
		propagated = false;
#endif

#if CL_CS_IGNORE
		if (cs_ignore[current_cs->c_id] == 0) {
#endif
			switch (kind) {

#if CS_ALL_DIFFERENT == 1
			case ALL_DIFFERENT:
				all_different_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL TTL_CTR_V);
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#if CS_ARRAY_BOOL_AND == 1
			case ARRAY_BOOL_AND:
				array_bool_and_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_ARRAY_BOOL_ELEMENT == 1
			case ARRAY_BOOL_ELEMENT:
				array_bool_element_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_ARRAY_BOOL_OR == 1
			case ARRAY_BOOL_OR:
				array_bool_or_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_ARRAY_BOOL_XOR == 1
			case ARRAY_BOOL_XOR:
				array_bool_xor_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_ARRAY_INT_ELEMENT == 1
			case ARRAY_INT_ELEMENT:
				array_int_element_propagate(vs_per_c_idx_, c_consts_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_ARRAY_VAR_INT_ELEMENT == 1
			case ARRAY_VAR_INT_ELEMENT:
				array_var_int_element_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

0c8ce2b0   Pedro Roque   missing files
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#if CS_AT_LEAST == 1
			case AT_LEAST:
				at_least_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_AT_MOST == 1
			case AT_MOST:
				at_most_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_AT_MOST_ONE == 1
			case AT_MOST_ONE:
				at_most_one_propagate(vs_per_c_idx_, c_consts_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL TTL_CTR_V);
				break;
#endif

0c8ce2b0   Pedro Roque   missing files
310
311
312
313
314
315
316
317
318
319
320
321
#if CS_BOOL_AND == 1
			case BOOL_AND:
				bool_and_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL_CLAUSE == 1
			case BOOL_CLAUSE:
				bool_clause_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#if CS_BOOL_EQ == 1
			case BOOL_EQ:
				bool_eq_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL_LE == 1
			case BOOL_LE:
				bool_le_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL_LIN_EQ == 1
			case BOOL_LIN_EQ:
				bool_lin_eq_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL_LIN_LE == 1
			case BOOL_LIN_LE:
				bool_lin_le_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL_LT == 1
			case BOOL_LT:
				bool_lt_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL_NOT == 1
			case BOOL_NOT:
				bool_not_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

0c8ce2b0   Pedro Roque   missing files
360
361
362
363
364
365
#if CS_BOOL_OR == 1
			case BOOL_OR:
				bool_or_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
366
367
368
369
370
371
372
373
374
375
376
377
#if CS_BOOL_XOR == 1
			case BOOL_XOR:
				bool_xor_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_BOOL2INT == 1
			case BOOL2INT:
				bool2int_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

0c8ce2b0   Pedro Roque   missing files
378
379
380
381
382
383
#if CS_ELEMENT == 1
			case ELEMENT:
				element_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
384
385
386
#if CS_EXACTLY == 1
			case EXACTLY:
				exactly_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
387
388
389
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
390
391
392
#if CS_EXACTLY_VAR == 1
			case EXACTLY_VAR:
				exactly_var_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
393
394
395
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
396
397
398
#if CS_INT_DIV == 1
			case INT_DIV:
				int_div_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
399
400
401
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
402
403
404
#if CS_INT_EQ == 1
			case INT_EQ:
				int_eq_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
405
406
407
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
408
409
410
#if CS_INT_EQ_C == 1
			case INT_EQ_C:
				int_eq_c_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
411
412
413
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
414
415
416
#if CS_INT_LE == 1
			case INT_LE:
				int_le_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
417
418
419
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
420
421
422
423
#if CS_INT_LIN_EQ == 1
			case INT_LIN_EQ:
				int_lin_eq_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
424
425
426
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
427
428
429
430
#if CS_INT_LIN_LE == 1
			case INT_LIN_LE:
				int_lin_le_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
431
432
433
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
434
435
436
437
#if CS_INT_LIN_NE == 1
			case INT_LIN_NE:
				int_lin_ne_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
438
439
440
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
441
442
443
444
#if CS_INT_LIN_VAR == 1
			case INT_LIN_VAR:
				int_lin_var_propagate(vs_per_c_idx_, c_consts_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL
				CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
445
446
447
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
448
449
450
#if CS_INT_LT == 1
			case INT_LT:
				int_lt_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
451
452
453
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
454
455
456
#if CS_INT_MAX_ == 1
			case INT_MAX_:
				int_max_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
457
458
459
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
460
461
462
#if CS_INT_MIN_ == 1
			case INT_MIN_:
				int_min_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
463
464
465
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
466
467
468
469
470
471
472
473
474
#if CS_INT_MOD == 1
			case INT_MOD:
				int_mod_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_INT_NE == 1
			case INT_NE:
				int_ne_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
475
476
477
				break;
#endif

4d26a735   Pedro Roque   Increased recogni...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
#if CS_INT_PLUS == 1
			case INT_PLUS:
				int_plus_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_INT_TIMES == 1
			case INT_TIMES:
				int_times_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_MAXIMIZE == 1 && CL_WORK == CL_OPT
			case MAXIMIZE:
				maximize_propagate(vs_prop_, current_cs, vs_id_to_prop_, val_to_opt_g, prop_ok PROPAGATED_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
493
494
495
496
497
498
499
500
501
502
503
				break;
#endif

#if CS_MINIMIZE == 1 && CL_WORK == CL_OPT
			case MINIMIZE:
				minimize_propagate(vs_prop_, current_cs, vs_id_to_prop_, val_to_opt_g, prop_ok PROPAGATED_CALL TTL_CTR_V);
				break;
#endif

#if CS_MINUS_EQ == 1
			case MINUS_EQ:
4d26a735   Pedro Roque   Increased recogni...
504
				minus_eq_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
505
506
507
508
509
				break;
#endif

#if CS_MINUS_NE == 1
			case MINUS_NE:
4d26a735   Pedro Roque   Increased recogni...
510
				minus_ne_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
				break;
#endif

#if CS_SUM == 1
			case SUM:
				sum_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_SUM_PROD == 1
			case SUM_PROD:
				sum_prod_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_SUM_VAR == 1
			case SUM_VAR:
				sum_var_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok, terms_mem PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
				break;
#endif

#if CS_VAR_EQ_MINUS == 1
			case VAR_EQ_MINUS:
4d26a735   Pedro Roque   Increased recogni...
534
				var_eq_minus_propagate(vs_per_c_idx_, vs_prop_, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL CS_IGNORE_CALL TTL_CTR_V);
0c8ce2b0   Pedro Roque   missing files
535
536
537
538
539
540
541
542
				break;
#endif

#if CS_VAR_EQ_MINUS_ABS == 1
			case VAR_EQ_MINUS_ABS:
				var_eq_minus_abs_propagate(vs_per_c_idx_, vs_prop_, prop_v_id, current_cs, vs_id_to_prop_, prop_ok PROPAGATED_CALL TTL_CTR_V);
				break;
#endif
0c8ce2b0   Pedro Roque   missing files
543
544
545
546
			default:
				*prop_ok = 0;

#if CL_CHECK_ERRORS
4d26a735   Pedro Roque   Increased recogni...
547
				printf((__constant char *)"\n###error 65 contraint type %u not in switch...\n", kind);
0c8ce2b0   Pedro Roque   missing files
548
549
550
551
552
553
554
555
556
557
558
559
560
561
#endif
				break;
			}

#if CL_STATS == 1
			if (propagated) {
				if (*prop_ok == 0) {
					(*nodes_fail)++;
					(*nodes_expl)++;

				} else {
					(*props_ok)++;

					if (last_prev_vs_to_prop != vs_id_to_prop_[1]) {
4d26a735   Pedro Roque   Increased recogni...
562
						(*pruning) += convert_ulong (abs(vs_id_to_prop_[1] - last_prev_vs_to_prop));
0c8ce2b0   Pedro Roque   missing files
563
564
565
566
					}
				}
			}
#endif
0c8ce2b0   Pedro Roque   missing files
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
			if (*prop_ok == 0) {
				i = vs[prop_v_id].n_cs;
			}

			// check if there is any variable marked for being propagated, but not listed in the list of variables to propagate
#if CL_CHECK_ERRORS
			int k;
			for (l = 0; l < CL_N_VS; l++) {

				bool empty;
#if CL_N_WORDS == 1
				empty = (vs_prop_[l].prop_d == 0);
#else
				int m;
				empty = 1;
				for (m = 0; m < CL_N_WORDS; m++) {
					CHECK_TTL(ttl_ctr, 115)
4d26a735   Pedro Roque   Increased recogni...
584
585
586
587
							if (vs_prop_[l].prop_d[m] != 0) {
								empty = 0;
								m = CL_N_WORDS;
							}
0c8ce2b0   Pedro Roque   missing files
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
				}
#endif
				if ((*prop_ok == 1 && (empty || vs_prop_[l].n_vals == 0 || vs_prop_[l].n_vals > vs_prop_[l].max + 1)) || vs_prop_[l].min > vs_prop_[l].max || vs_prop_[l].max > CL_D_MAX) {
					printf((__constant char *)"\n###error 70\n");
					printf((__constant char *)"constraint=%d, prop_ok=%d, empty=%d, vs_prop_[l].n_vals=%u, vs_prop_[l].min=%u, vs_prop_[l].max=%u\n",
							kind, *prop_ok, empty, vs_prop_[l].n_vals, vs_prop_[l].min, vs_prop_[l].max);

					*prop_ok = 0;
					i = vs[prop_v_id].n_cs;
				}

				if (vs_prop_[l].to_prop == 1) {

					if (vs_id_to_prop_[0] <= vs_id_to_prop_[1]) {
						for (k = vs_id_to_prop_[0]; k < vs_id_to_prop_[1]; k++) {
							CHECK_TTL(ttl_ctr, 154)

4d26a735   Pedro Roque   Increased recogni...
605
606
607
									if (vs_id_to_prop_[k] == l) {
										break;
									}
0c8ce2b0   Pedro Roque   missing files
608
609
610
611
612
613
614
615
616
						}

						if (k == vs_id_to_prop_[1]) {
							printf((__constant char *)"\n###error 66\n");
						}
					} else {
						for (k = vs_id_to_prop_[0]; k < vs_id_to_prop_[CL_N_VS + 2]; k++) {
							CHECK_TTL(ttl_ctr, 155)

4d26a735   Pedro Roque   Increased recogni...
617
618
619
									if (k < CL_D_MAX + 2 && vs_id_to_prop_[k] == l) {
										break;
									}
0c8ce2b0   Pedro Roque   missing files
620
621
622
623
624
625
626
						}

						if (k == vs_id_to_prop_[CL_N_VS + 2]) {

							for (k = 2; k < vs_id_to_prop_[1]; k++) {
								CHECK_TTL(ttl_ctr, 156)

4d26a735   Pedro Roque   Increased recogni...
627
628
629
										if (vs_id_to_prop_[k] == l) {
											break;
										}
0c8ce2b0   Pedro Roque   missing files
630
631
632
633
634
635
636
637
638
639
640
641
							}
						}
					}
				}
			}
#endif

#if CL_CS_IGNORE
		}
#endif
	}
}