965dadaa
Salvador Abreu
initial commit fr...
|
1
2
3
4
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
58
59
60
61
62
63
64
|
/* X eq Y */
static int fd_eq_filter(fd_constraint this)
{
int i;
// only propagate if culprit's domain is a singleton
for (i = 0; i < 2; ++i)
{
fd_int revise = VAR(this, 1 - i);
if (_fd_var_intersect(revise, VAR(this, i)))
{
if (fd_domain_empty(revise))
return FD_NOSOLUTION;
_fd_revise_connected(this, revise);
}
}
return FD_OK;
}
int fd_eq_propagate2(fd_constraint this, fd_int culprit)
{
fd_int revise;
int changed = 0;
revise = VAR(this, culprit == VAR(this, 0) ? 1 : 0);
changed = _fd_var_intersect(revise, culprit);
if (!changed)
return FD_OK;
if (fd_domain_empty(revise))
return FD_NOSOLUTION;
_fd_revise_connected(this, revise);
return FD_OK;
}
int fd_eq_propagate(fd_constraint this, fd_int revise)
{
fd_int other;
int changed = 0;
other = VAR(this, revise == VAR(this, 0) ? 1 : 0);
changed = _fd_var_intersect(revise, other);
if (changed && fd_domain_empty(revise))
return FD_NOSOLUTION;
// XXX: enqueue further updates here?
if (changed)
_fd_revise_connected(this, revise);
return FD_OK;
}
fd_constraint fd_eq(fd_int x, fd_int y)
{
|
965dadaa
Salvador Abreu
initial commit fr...
|
72
73
74
75
76
77
78
79
80
|
#else /* CONSTRAINT_CLASS */
c->propagator2 = fd_eq_propagate2;
c->propagator = fd_eq_propagate;
#endif /* CONSTRAINT_CLASS */
_fd_var_add_constraint(x, c);
_fd_var_add_constraint(y, c);
_fd_add_constraint(c);
|