eef94371
Vasco Pedro
Update to PaCCS v...
|
1
2
3
4
|
/* poly-eq(C, X, y) == min(y) <= sum(C . X) <= max(y) */
static int fd_poly_eq_filter(fd_constraint this)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
int ub, lb;
int min, max;
int terms = this->nconstants;
int *mins, *maxs;
int i;
#ifdef CONSTRAINT_TEMPS
int *base;
assert(!fd__constraint_data_valid(this));
if (!constraint_memory[this->index])
constraint_memory[this->index] = malloc((2 * terms + 4) * sizeof(int));
base = constraint_memory[this->index];
mins = base + 4;
maxs = mins + terms;
#else
mins = alloca(terms * sizeof(*mins));
maxs = alloca(terms * sizeof(*maxs));
#endif
lb = _fd_var_min(VAR(this, this->nvariables - 1)); // lower bound
ub = _fd_var_max(VAR(this, this->nvariables - 1)); // upper bound
// sum the minima and the maxima of the terms
min = max = 0;
for (i = 0; i < terms; ++i)
{
int vl, vh;
if (this->constants[i] > 0)
{
vl = mins[i] = _fd_var_min(VAR(this, i));
vh = maxs[i] = _fd_var_max(VAR(this, i));
}
else
{
vl = maxs[i] = _fd_var_max(VAR(this, i));
vh = mins[i] = _fd_var_min(VAR(this, i));
}
min += this->constants[i] * vl;
max += this->constants[i] * vh;
}
if (min > ub || max < lb)
return FD_NOSOLUTION;
if ((min > lb && _fd_var_del_lt(min, VAR(this, this->nvariables - 1))) |
(max < ub && _fd_var_del_gt(max, VAR(this, this->nvariables - 1))))
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
58
|
if (fd_domain_empty(VAR(this, this->nvariables - 1)))
|
965dadaa
Salvador Abreu
initial commit fr...
|
59
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
60
61
62
63
64
65
66
67
|
_fd_revise_connected(this, VAR(this, this->nvariables - 1));
}
if (min == max)
return FD_OK;
// XXX: poor man's propagation
|
965dadaa
Salvador Abreu
initial commit fr...
|
68
|
if (min == ub)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
69
|
for (i = 0; i < terms; ++i)
|
965dadaa
Salvador Abreu
initial commit fr...
|
70
71
72
|
{
int c = this->constants[i];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
73
74
75
76
77
78
79
|
if (c && mins[i] != maxs[i])
{
if (c > 0)
{
_fd_var_del_gt(mins[i], VAR(this, i));
// check needed for when variables occur twice and
|
965dadaa
Salvador Abreu
initial commit fr...
|
80
|
// with opposite signs
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
81
|
if (fd_domain_empty(VAR(this, i)))
|
965dadaa
Salvador Abreu
initial commit fr...
|
82
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
83
84
85
86
87
|
_fd_revise_connected(this, VAR(this, i));
}
else
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
88
|
_fd_var_del_lt(maxs[i], VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
89
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
90
|
if (fd_domain_empty(VAR(this, i)))
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
91
92
93
|
return FD_NOSOLUTION;
_fd_revise_connected(this, VAR(this, i));
|
965dadaa
Salvador Abreu
initial commit fr...
|
94
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
95
|
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
96
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
97
98
99
|
else if (max == lb)
for (i = 0; i < terms; ++i)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
100
|
int c = this->constants[i];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
101
102
103
104
|
if (c && mins[i] != maxs[i])
{
if (c > 0)
|
965dadaa
Salvador Abreu
initial commit fr...
|
105
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
106
|
_fd_var_del_lt(maxs[i], VAR(this, i));
|
965dadaa
Salvador Abreu
initial commit fr...
|
107
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
108
|
if (fd_domain_empty(VAR(this, i)))
|
965dadaa
Salvador Abreu
initial commit fr...
|
109
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
110
111
112
113
114
115
|
_fd_revise_connected(this, VAR(this, i));
}
else
{
_fd_var_del_gt(mins[i], VAR(this, i));
|
965dadaa
Salvador Abreu
initial commit fr...
|
116
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
117
118
119
120
121
122
|
if (fd_domain_empty(VAR(this, i)))
return FD_NOSOLUTION;
_fd_revise_connected(this, VAR(this, i));
}
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
123
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
124
|
else
|
965dadaa
Salvador Abreu
initial commit fr...
|
125
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
126
127
128
|
if (max > ub)
for (i = 0; i < terms; ++i)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
129
|
int c = this->constants[i];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
130
131
132
|
int xmin = mins[i];
int xmax = maxs[i];
|
965dadaa
Salvador Abreu
initial commit fr...
|
133
|
if (c > 0)
|
965dadaa
Salvador Abreu
initial commit fr...
|
134
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
135
136
137
|
if ((xmax - xmin) * c > ub - min)
{
// xmax = floor((ub - min) / c) + xmin
|
965dadaa
Salvador Abreu
initial commit fr...
|
138
|
xmax = (ub - min) / c + xmin;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
139
140
141
142
143
144
145
|
_fd_var_del_gt(xmax, VAR(this, i));
if (fd_domain_empty(VAR(this, i)))
return FD_NOSOLUTION;
_fd_revise_connected(this, VAR(this, i));
|
965dadaa
Salvador Abreu
initial commit fr...
|
146
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
147
148
149
150
151
152
|
}
else if (c < 0)
{
if ((xmin - xmax) * c > ub - min)
{
// xmin = ceil((ub - min) / c) + xmax
|
965dadaa
Salvador Abreu
initial commit fr...
|
153
|
xmin = (ub - min) / c + xmax;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
154
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
155
|
_fd_var_del_lt(xmin, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
156
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
157
|
if (fd_domain_empty(VAR(this, i)))
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
158
159
|
return FD_NOSOLUTION;
|
965dadaa
Salvador Abreu
initial commit fr...
|
160
|
_fd_revise_connected(this, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
161
|
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
162
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
163
164
165
166
167
168
|
}
if (min < lb)
for (i = 0; i < terms; ++i)
{
int c = this->constants[i];
|
965dadaa
Salvador Abreu
initial commit fr...
|
169
|
int xmin = mins[i];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
170
|
int xmax = maxs[i];
|
965dadaa
Salvador Abreu
initial commit fr...
|
171
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
172
|
if (c > 0)
|
965dadaa
Salvador Abreu
initial commit fr...
|
173
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
174
175
|
if ((xmax - xmin) * c > max - lb)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
176
177
|
// xmin = ceil((lb - max) / c) + xmax
xmin = (lb - max) / c + xmax;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
178
179
180
|
_fd_var_del_lt(xmin, VAR(this, i));
|
965dadaa
Salvador Abreu
initial commit fr...
|
181
182
|
if (fd_domain_empty(VAR(this, i))) // domains may have holes
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
183
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
184
|
_fd_revise_connected(this, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
185
186
|
}
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
187
|
else if (c < 0)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
188
|
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
189
|
if ((xmax - xmin) * c < lb - max)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
190
191
|
{
// xmax = floor((lb - max) / c) + xmin
|
965dadaa
Salvador Abreu
initial commit fr...
|
192
|
xmax = (lb - max) / c + xmin;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
193
194
195
196
|
_fd_var_del_gt(xmax, VAR(this, i));
if (fd_domain_empty(VAR(this, i))) // domains may have holes
|
965dadaa
Salvador Abreu
initial commit fr...
|
197
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
198
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
199
|
_fd_revise_connected(this, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
200
201
|
}
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
202
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
203
|
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
204
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
205
206
|
#ifdef CONSTRAINT_TEMPS
// save values
|
965dadaa
Salvador Abreu
initial commit fr...
|
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
*base = lb;
*(base + 1) = ub;
*(base + 2) = min;
*(base + 3) = max;
fd__constraint_remember(this);
#endif
return FD_OK;
}
static int fd_poly_eq_propagate2(fd_constraint this, fd_int culprit)
{
#ifdef CONSTRAINT_TEMPS
int ub, lb;
int min, max;
int terms = this->nconstants;
int *mins, *maxs;
int i;
int *base;
int x, c;
int nmin, nmin_x, nmax, nmax_x;
if (!fd__constraint_data_valid(this))
return fd_poly_eq_filter(this); // ignores culprit
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
233
|
// bounds filtering
|
965dadaa
Salvador Abreu
initial commit fr...
|
234
235
236
237
238
239
240
241
242
243
244
|
base = constraint_memory[this->index];
mins = base + 4;
maxs = mins + terms;
lb = *base;
ub = *(base + 1);
min = *(base + 2);
max = *(base + 3);
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
245
246
|
if (culprit == VAR(this, this->nvariables - 1))
|
965dadaa
Salvador Abreu
initial commit fr...
|
247
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
248
249
|
// the culprit is the sum variable
int nlb, nub;
|
965dadaa
Salvador Abreu
initial commit fr...
|
250
251
252
253
|
nlb = _fd_var_min(culprit);
nub = _fd_var_max(culprit);
|
965dadaa
Salvador Abreu
initial commit fr...
|
254
255
256
257
258
259
260
|
if (nlb == lb && nub == ub)
return FD_OK;
if (nlb != lb)
{
if (max < nlb)
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
261
262
263
264
265
266
267
268
|
if (max == nlb)
for (i = 0; i < terms; ++i)
{
if (this->constants[i] > 0)
{
if (_fd_var_del_lt(maxs[i], VAR(this, i)))
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
269
|
if (fd_domain_empty(VAR(this, i)))
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
270
271
|
return FD_NOSOLUTION;
|
965dadaa
Salvador Abreu
initial commit fr...
|
272
|
_fd_revise_connected(this, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
273
274
|
}
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
275
|
else if (this->constants[i] < 0)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
{
if (_fd_var_del_gt(mins[i], VAR(this, i)))
{
if (fd_domain_empty(VAR(this, i)))
return FD_NOSOLUTION;
_fd_revise_connected(this, VAR(this, i));
}
}
}
if (min < nlb)
for (i = 0; i < terms; ++i)
{
int c = this->constants[i];
int xmin = mins[i];
int xmax = maxs[i];
|
965dadaa
Salvador Abreu
initial commit fr...
|
293
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
294
295
|
if (c > 0)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
296
|
if ((xmax - xmin) * c > max - nlb)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
297
298
299
300
|
{
// xmin = ceil((nlb - max) / c) + xmax
xmin = (nlb - max) / c + xmax;
|
965dadaa
Salvador Abreu
initial commit fr...
|
301
|
_fd_var_del_lt(xmin, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
302
303
|
if (fd_domain_empty(VAR(this, i))) // domains may have holes
|
965dadaa
Salvador Abreu
initial commit fr...
|
304
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
305
306
307
|
_fd_revise_connected(this, VAR(this, i));
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
308
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
309
310
|
else if (c < 0)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
311
|
if ((xmax - xmin) * c < nlb - max)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
312
313
314
|
{
// xmax = floor((nlb - max) / c) + xmin
xmax = (nlb - max) / c + xmin;
|
965dadaa
Salvador Abreu
initial commit fr...
|
315
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
316
317
318
|
_fd_var_del_gt(xmax, VAR(this, i));
if (fd_domain_empty(VAR(this, i))) // domains may have holes
|
965dadaa
Salvador Abreu
initial commit fr...
|
319
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
320
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
321
|
_fd_revise_connected(this, VAR(this, i));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
322
323
324
325
326
327
328
329
|
}
}
}
*base = nlb;
}
if (nub != ub)
|
965dadaa
Salvador Abreu
initial commit fr...
|
330
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
331
|
if (min > nub)
|
965dadaa
Salvador Abreu
initial commit fr...
|
332
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
333
334
335
336
337
338
|
if (min == nub)
for (i = 0; i < terms; ++i)
{
if (this->constants[i] > 0)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
339
340
|
if (_fd_var_del_gt(mins[i], VAR(this, i)))
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
341
342
343
344
345
346
347
|
if (fd_domain_empty(VAR(this, i)))
return FD_NOSOLUTION;
_fd_revise_connected(this, VAR(this, i));
}
}
else if (this->constants[i] < 0)
|
965dadaa
Salvador Abreu
initial commit fr...
|
348
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
349
350
351
|
if (_fd_var_del_lt(maxs[i], VAR(this, i)))
{
if (fd_domain_empty(VAR(this, i)))
|
965dadaa
Salvador Abreu
initial commit fr...
|
352
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
353
354
355
356
357
358
|
_fd_revise_connected(this, VAR(this, i));
}
}
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
359
|
if (max > nub)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
360
|
for (i = 0; i < terms; ++i)
|
965dadaa
Salvador Abreu
initial commit fr...
|
361
362
|
{
int c = this->constants[i];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
363
|
int xmin = mins[i];
|
965dadaa
Salvador Abreu
initial commit fr...
|
364
|
int xmax = maxs[i];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
365
366
367
|
if (c > 0)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
368
|
if ((xmax - xmin) * c > nub - min)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
369
370
371
372
|
{
// xmax = floor((nub - min) / c) + xmin
xmax = (nub - min) / c + xmin;
|
965dadaa
Salvador Abreu
initial commit fr...
|
373
|
if (_fd_var_del_gt(xmax, VAR(this, i)))
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
374
375
376
|
{
if (fd_domain_empty(VAR(this, i)))
return FD_NOSOLUTION;
|
965dadaa
Salvador Abreu
initial commit fr...
|
377
378
379
380
|
_fd_revise_connected(this, VAR(this, i));
}
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
381
382
383
|
}
else if (c < 0)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
384
|
if ((xmin - xmax) * c > nub - min)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
385
386
387
|
{
// xmin = ceil((nub - min) / c) + xmax
xmin = (nub - min) / c + xmax;
|
965dadaa
Salvador Abreu
initial commit fr...
|
388
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
389
390
391
392
393
394
395
|
if (_fd_var_del_lt(xmin, VAR(this, i)))
{
if (fd_domain_empty(VAR(this, i)))
return FD_NOSOLUTION;
_fd_revise_connected(this, VAR(this, i));
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
396
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
397
|
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
398
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
399
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
400
|
*(base + 1) = nub;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
401
402
|
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
403
|
return FD_OK;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
404
405
406
407
408
|
}
// the culprit appears in one of the terms, find out which one(s)
for (x = 0; culprit != VAR(this, x); ++x)
;
|
965dadaa
Salvador Abreu
initial commit fr...
|
409
410
|
nmin_x = _fd_var_min(VAR(this, x));
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
411
|
nmax_x = _fd_var_max(VAR(this, x));
|
965dadaa
Salvador Abreu
initial commit fr...
|
412
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
413
|
if (nmin_x == mins[x] && nmax_x == maxs[x])
|
965dadaa
Salvador Abreu
initial commit fr...
|
414
|
return FD_OK;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
415
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
416
|
nmin = min;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
417
418
419
420
|
nmax = max;
do
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
421
|
c = this->constants[x];
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
422
423
424
|
if (c > 0)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
425
426
427
|
nmin = nmin + (nmin_x - mins[x]) * c;
nmax = nmax - (maxs[x] - nmax_x) * c;
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
428
|
else if (c < 0)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
429
430
431
|
{
nmin = nmin - (maxs[x] - nmax_x) * c;
nmax = nmax + (nmin_x - mins[x]) * c;
|
965dadaa
Salvador Abreu
initial commit fr...
|
432
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
433
434
435
436
|
if (nmin > ub || nmax < lb)
return FD_NOSOLUTION;
|
965dadaa
Salvador Abreu
initial commit fr...
|
437
|
mins[x] = nmin_x;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
438
|
maxs[x] = nmax_x;
|
965dadaa
Salvador Abreu
initial commit fr...
|
439
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
440
441
|
while (++x < terms && culprit != VAR(this, x))
;
|
965dadaa
Salvador Abreu
initial commit fr...
|
442
|
}
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
443
444
445
446
|
while (x < terms);
if ((nmin > lb && _fd_var_del_lt(nmin, VAR(this, this->nvariables - 1))) |
(nmax < ub && _fd_var_del_gt(nmax, VAR(this, this->nvariables - 1))))
|
965dadaa
Salvador Abreu
initial commit fr...
|
447
|
{
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
448
|
if (fd_domain_empty(VAR(this, this->nvariables - 1)))
|
965dadaa
Salvador Abreu
initial commit fr...
|
449
|
return FD_NOSOLUTION;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
450
451
452
|
_fd_revise_connected(this, VAR(this, this->nvariables - 1));
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
453
|
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
454
455
|
*(base + 2) = nmin;
*(base + 3) = nmax;
|
965dadaa
Salvador Abreu
initial commit fr...
|
456
457
|
return FD_OK;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
458
459
|
#else /* CONSTRAINT_TEMPS */
return fd_poly_eq_filter(this); // ignores culprit
|
965dadaa
Salvador Abreu
initial commit fr...
|
460
461
462
463
464
465
466
467
468
469
470
|
#endif /* CONSTRAINT_TEMPS */
}
fd_constraint fd_poly_eq(int cs[], fd_int xs[], int nterms, fd_int y)
{
fd_constraint c = _fd_constraint_new(nterms + 1, nterms);
int i;
if (c)
{
for (i = 0; i < nterms; ++i)
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
471
472
473
474
475
476
477
478
479
|
c->variables[i] = FD_INT2C_VAR(xs[i]);
c->variables[nterms] = FD_INT2C_VAR(y);
for (i = 0; i < nterms; ++i)
c->constants[i] = cs[i];
#ifdef CONSTRAINT_CLASS
c->kind = FD_CONSTR_POLY_EQ;
#else /* CONSTRAINT_CLASS */
c->propagator2 = fd_poly_eq_propagate2;
#endif /* CONSTRAINT_CLASS */
|
965dadaa
Salvador Abreu
initial commit fr...
|
480
481
482
483
484
485
486
487
|
for (i = 0; i < c->nvariables; ++i)
_fd_var_add_constraint(VAR(c, i), c);
_fd_add_constraint(c);
}
return c;
|
eef94371
Vasco Pedro
Update to PaCCS v...
|
488
|
}
|
965dadaa
Salvador Abreu
initial commit fr...
|
|
|
965dadaa
Salvador Abreu
initial commit fr...
|
|
|