Constraint Programming Search Techniques
Constraint Programming Search Techniques
– Searching : Part 1 –
Christophe Lecoutre
lecoutre@[Link]
January 2025
1
Outline
1 Backtracking Search
2
Search Space
3
Search Space
3
Search Space
3
Exponential Growth
Suppose that:
• the complexity is only O(2n )
• 109 complete instantiations can be processed any new second
n 2n Processing Time
10 around 103 around 1 nanosecond
20 around 106 around 1 millisecond
30 around 109 around 1 second
40 around 1012 around 16 minutes
50 around 1015 around 11 days
60 around 1018 around 32 years
70 around 1021 around 317 centuries
4
Search Tree
Most of the time, the search space can be perceived as a search tree.
5
Pruning the Search Tree
6
Pruning the Search Tree
Finding a solution may become realistic in a reduced search tree.
7
Constraint Inference Only?
8
Complete Exploration
Classical approach
• depth-first traversal
• backtracking mecanism
• interleaving of
• decisions
• propagations
Remark.
Other strategies exist:
• breadth-first traversal
• limited discrepancy search (LDS)
• large neighborhood search (LNS)
• ...
9
Complete Exploration
Classical approach
• depth-first traversal
• backtracking mecanism
• interleaving of
• decisions
• propagations
Remark.
Other strategies exist:
• breadth-first traversal
• limited discrepancy search (LDS)
• large neighborhood search (LNS)
• ...
9
Outline
1 Backtracking Search
10
Search Tree
root
δ1
δ8 δ17
decisions
δ2 δ10 δ18
δ7 δ9
⊥ ⊥
δ3 δ6 δ11
δ4 δ16 δ19
node v, parent of v ′
⊥ ⊥ ⊥
δ5 δ12 δ15
δ13
node v ′ , child of v
⊥ ⊥ ⊥
δ14
dead−ends δk
⊥
leaves solution
11
Nonbinary ϕ-search
Algorithm 1: nonbinary-ϕ-search(P: CN): Boolean
P ← ϕ(P)
if P = ⊥ then
return false
if ∀x ∈ vars(P), |dom(x)| = 1 then
return true
select a variable x of P such that |dom(x)| > 1
foreach value a ∈ dom(x) do
if nonbinary-ϕ-search(P|x=a ) then
return true
return false
Remark.
ϕ denotes the process (level) of filtering under the form of a consistency
to enforce (AC, BC, ...).
12
Nonbinary ϕ-search
Algorithm 2: nonbinary-ϕ-search(P: CN): Boolean
P ← ϕ(P)
if P = ⊥ then
return false
if ∀x ∈ vars(P), |dom(x)| = 1 then
return true
select a variable x of P such that |dom(x)| > 1
foreach value a ∈ dom(x) do
if nonbinary-ϕ-search(P|x=a ) then
return true
return false
Remark.
ϕ denotes the process (level) of filtering under the form of a consistency
to enforce (AC, BC, ...).
12
Illustration
For simplicity, we assume that the domains of all variables is
{1, 2, . . . , d}.
1 x=
x= d
2
...
=
x
1 y 1 z
y= = z= =
d d
2
2
... ...
=
=
y
z
1 z=
z= d
2
...
=
z
Remark.
Note that all taken decisions are positive, i.e., variable assignments.
13
Illustration
For simplicity, we assume that the domains of all variables is
{1, 2, . . . , d}.
1 x=
x= d
2
...
=
x
1 y 1 z
y= = z= =
d d
2
2
... ...
=
=
y
z
1 z=
z= d
2
...
=
z
Remark.
Note that all taken decisions are positive, i.e., variable assignments.
13
Binary ϕ-search
14
Binary ϕ-search
14
Binary ϕ-search
14
Illustration
1
=
...
xy
1
6=
=
1
y
z 6=
z 6=
1
1
z=
z=
1
1
...
z 6=
y 6=
2
2
...
z=
y=
2
2
... ...
Remark.
Note that first decisions are positive, i.e., variable assignments, and
second decisions are negative, i.e., value refutations.
15
Illustration
1
=
...
xy
1
6=
=
1
y
z 6=
z 6=
1
1
z=
z=
1
1
...
z 6=
y 6=
2
2
...
z=
y=
2
2
... ...
Remark.
Note that first decisions are positive, i.e., variable assignments, and
second decisions are negative, i.e., value refutations.
15
About Node Expansion
Remark.
Other forms of branching, different from:
• non-binary branching
• binary branching
introduced earlier can be considered, as for example,
• (binary) domain splitting
where two branches labelled with x < k and x ≥ k are generated.
16
About Node Expansion
Remark.
Other forms of branching, different from:
• non-binary branching
• binary branching
introduced earlier can be considered, as for example,
• (binary) domain splitting
where two branches labelled with x < k and x ≥ k are generated.
16
About Node Expansion
Remark.
Other forms of branching, different from:
• non-binary branching
• binary branching
introduced earlier can be considered, as for example,
• (binary) domain splitting
where two branches labelled with x < k and x ≥ k are generated.
16
Look-ahead and Look-back Schemes
Remark.
There exist look-back schemes that allo us to perform intelligent
backtracking:
• CBJ (Conflict-directed backjumping)
• DBT (Dynamic Backtracking)
17
Look-ahead and Look-back Schemes
Remark.
There exist look-back schemes that allo us to perform intelligent
backtracking:
• CBJ (Conflict-directed backjumping)
• DBT (Dynamic Backtracking)
17
BT
Definition
Let I be an instantiation and c be a constraint. c is covered by I iff
scp(c) ⊆ vars(I ).
Example.
Let I = {x = 1, y = 3, z = 2} be an instantiation. we have:
• the constraint x + z = y is covered and satisfied by I
• the constraint w = x is not covered by I
• the constraint x > y is covered but not satisfied by I
18
BT
Definition
Let I be an instantiation and c be a constraint. c is covered by I iff
scp(c) ⊆ vars(I ).
Example.
Let I = {x = 1, y = 3, z = 2} be an instantiation. we have:
• the constraint x + z = y is covered and satisfied by I
• the constraint w = x is not covered by I
• the constraint x > y is covered but not satisfied by I
18
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4
3
2
1
a b d
19
Illustration of BT
4 6 more steps
to nd
3 a solution
2
1
a b d
19
FC
FC (Forward Checking) is a nonbinary ϕ-search where at each node ϕ
enforces arc consistency only on constraints that are almost covered by
the current instantiation.
Definition
Let I be an instantiation and c be a constraint. c is almost covered by I
iff |scp(c) \ vars(I )| = 1.
Example.
Let I = {x = 1, y = 3, z = 2} be an instantiation. we have:
• the constraint x + z = y + w is almost covered by I
• the constraint w = t is neither covered nor almost covered by I
Remark.
FC enforces a partial form of Arc Consistency.
20
FC
FC (Forward Checking) is a nonbinary ϕ-search where at each node ϕ
enforces arc consistency only on constraints that are almost covered by
the current instantiation.
Definition
Let I be an instantiation and c be a constraint. c is almost covered by I
iff |scp(c) \ vars(I )| = 1.
Example.
Let I = {x = 1, y = 3, z = 2} be an instantiation. we have:
• the constraint x + z = y + w is almost covered by I
• the constraint w = t is neither covered nor almost covered by I
Remark.
FC enforces a partial form of Arc Consistency.
20
FC
FC (Forward Checking) is a nonbinary ϕ-search where at each node ϕ
enforces arc consistency only on constraints that are almost covered by
the current instantiation.
Definition
Let I be an instantiation and c be a constraint. c is almost covered by I
iff |scp(c) \ vars(I )| = 1.
Example.
Let I = {x = 1, y = 3, z = 2} be an instantiation. we have:
• the constraint x + z = y + w is almost covered by I
• the constraint w = t is neither covered nor almost covered by I
Remark.
FC enforces a partial form of Arc Consistency.
20
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
Illustration of FC
4
3
2
1
a b d
21
MAC
MAC is a binary search enforcing (maintaining) Arc Consistency at each
node of the search tree.
Remark.
We consider here that the level in the search tree corresponds to the
number of taken positive decisions (consequently ignoring negative
decisions in this regard).
22
MAC=Binary-AC-search
Algorithm 6: MAC(P: CN)
consistent ← AC (P, vars(P)) // AC initially enforced
if ¬consistent then
return
I ←∅ // I represents the current instantiation
finished ← false
while ¬finished do
select a value (x, a) of P such that x ∈
/ vars(I )
I .push(x, a)
dom(x).reduceTo(a, |I |) // x is assigned the value a at level |I |
consistent ← AC (P, {x}) // AC maintained after positive decisions
if consistent ∧ |I | = n then
print(I ) // A solution has been found and is printed
consistent ← false // Inserted to keep searching for solutions
while ¬consistent ∧ I ̸= ∅ do
(x, a) ← I .pop()
foreach variable y ∈ vars(P) \ vars(I ) do
dom(y ).restoreAt(|I |)
dom(x).remove(a, |I |) // a is removed from dom(x) at level |I |
if dom(x) = ∅ then
consistent ← false
else
consistent ← AC (P, {x}) // AC maintained after negative decisions
if ¬consistent then
finished ← true
23
Illustration of MAC
4
3
2
1
a b d
24
Illustration of MAC
4
3
2
1
a b d
24
Illustration of MAC
4
3
2
1
a b d
24
Illustration of MAC
4
3
2
1
a b d
24
Illustration of MAC
4
3
2
1
a b d
24
Illustration of MAC
4
3
2
1
a b d
24
Illustration of MAC
4
3
2
1
a b d
24
Experiment with ACE
where:
• -r_c=max means that the restart cutoff is the maximal value (so
there is no restart)
• -varh=Dom means that we use the variable ordering heuristic
min-dom
• -ppc=-1 means that we use a classical propagation scheme
• -s=all means that we look for all solutions
Comparing BT/FC/MAC :
• BT: add -p=BT
• FC: add -p=FC
• MAC: default value (this is equivalent to add -p=AC)
25
Experiment with ACE
where:
• -r_c=max means that the restart cutoff is the maximal value (so
there is no restart)
• -varh=Dom means that we use the variable ordering heuristic
min-dom
• -ppc=-1 means that we use a classical propagation scheme
• -s=all means that we look for all solutions
Comparing BT/FC/MAC :
• BT: add -p=BT
• FC: add -p=FC
• MAC: default value (this is equivalent to add -p=AC)
25
Backtracking Information
26
Backtracking Information
26
Intelligent Backtracking: CBJ
BT, FC and MAC basically performs chronological backtracking, whereas
CBJ performs intelligent backtracking.
x3 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
2 2
1 1
2 2
x1
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
2 2
1 1
2 2
x1
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
2 2
1 1
2 2
x1
1 1
2
x2 x1 x5 2
x4 x6
28
Illustration of CBJ
x3 x1 x5
1 1
x1
2 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Illustration of CBJ
x3 x5
1 1
2 ∅ 2
1 1
2 2
1 1
2
x2 x1 2
x4 x6
28
Outline
1 Backtracking Search
29
Search-guiding Heuristics
Important:
• The order in which variables are assigned by a backtracking search
algorithm has been recognized as a key issue for a long time.
• Using different search ordering heuristics to solve a CSP instance
can lead to drastically different results in terms of efficiency.
• Simply introducing some form of randomization to a given search
ordering heuristic may exhibit a large variability in performance.
30
Search-guiding Heuristics
Important:
• The order in which variables are assigned by a backtracking search
algorithm has been recognized as a key issue for a long time.
• Using different search ordering heuristics to solve a CSP instance
can lead to drastically different results in terms of efficiency.
• Simply introducing some form of randomization to a given search
ordering heuristic may exhibit a large variability in performance.
30
Search-guiding Heuristics
Important:
• The order in which variables are assigned by a backtracking search
algorithm has been recognized as a key issue for a long time.
• Using different search ordering heuristics to solve a CSP instance
can lead to drastically different results in terms of efficiency.
• Simply introducing some form of randomization to a given search
ordering heuristic may exhibit a large variability in performance.
30
Search-guiding Heuristics
Remark.
Depending on the context, the second rule may not be so important.
31
Search-guiding Heuristics
Remark.
Depending on the context, the second rule may not be so important.
31
Variable Ordering Heuristics
Example.
• min-dom, simply denoted by dom most of the time, is the heuristic
that selects the variable with the smallest current domain.
• max-deg, simply denoted by deg most of the time, is the heuristic
that selects the variable with the highest degree.
32
Variable Ordering Heuristics
Example.
• min-dom, simply denoted by dom most of the time, is the heuristic
that selects the variable with the smallest current domain.
• max-deg, simply denoted by deg most of the time, is the heuristic
that selects the variable with the highest degree.
32
Variable Ordering Heuristics
Example.
• min-dom, simply denoted by dom most of the time, is the heuristic
that selects the variable with the smallest current domain.
• max-deg, simply denoted by deg most of the time, is the heuristic
that selects the variable with the highest degree.
32
Categories of Variable Ordering Heuristics
Static variable ordering heuristics precomputes ordering before search.
• lexico
• deg and ddeg
33
Categories of Variable Ordering Heuristics
Static variable ordering heuristics precomputes ordering before search.
• lexico
• deg and ddeg
33
Categories of Variable Ordering Heuristics
Static variable ordering heuristics precomputes ordering before search.
• lexico
• deg and ddeg
33
Illustration
3
2
1
a b
34
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-min-dom on 3-queens
3
2
1
a b
35
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
FC-max-dom on 3-queens
3
2
1
a b
36
Value Ordering Heuristics
Classical heuristics:
• min-value, max-value
• random
• min-conflicts
Remark.
It is not easy to use min-conflicts when global constraints are present.
37
Value Ordering Heuristics
Classical heuristics:
• min-value, max-value
• random
• min-conflicts
Remark.
It is not easy to use min-conflicts when global constraints are present.
37
Outline
1 Backtracking Search
38
Adaptive Heuristics
Remark.
Actually, lc is a meta-reasoning, used in conjunction with a variable
ordering heuristic
39
Adaptive Heuristics
Remark.
Actually, lc is a meta-reasoning, used in conjunction with a variable
ordering heuristic
39
Adaptive Heuristics
Remark.
Actually, lc is a meta-reasoning, used in conjunction with a variable
ordering heuristic
39
Adaptive Heuristics
Remark.
Actually, lc is a meta-reasoning, used in conjunction with a variable
ordering heuristic
39
Adaptive Heuristics
Remark.
Actually, lc is a meta-reasoning, used in conjunction with a variable
ordering heuristic
39
Adaptive Heuristics
Remark.
Actually, lc is a meta-reasoning, used in conjunction with a variable
ordering heuristic
39
Constraint Weighting
40
Constraint Weighting
40
Implementation
41
Illustration with queensKnights-8-3-mul
V7
V6
V5
V4
V3
V2
V1
V0
V8
V10
V9
42
Illustration with queensKnights-8-3-mul
V7
V6
V5
V4
V3
V2
V1
V0
V8
V10
V9
42
Illustration with queensKnights-8-3-mul
V7
V6
V5
V4
V3
V2
V1
V0
V8
V10
V9
42
Illustration with queensKnights-8-3-mul
V7
V6
V5
V4
V3
V2
V1
V0
V8
V10
V9
42
Illustration with scen11-f6
V620 V626
V624 V625
V618 V639V621
V619 V638 V622 V627
V623
V616V617
V535 V293
V534
V287V292
V286
V17
V662 V663
V16
V632 V2
V79 V3
V614V615 V633 V94 V96 V99 V78
V98
V630 V4
V95 V97
V324 V0
V658
V650 V640V641
V325 V669 V631
V613 V656 V11 V651 V1
V612 V5
V513
V510 V646 V644
V645 V657 V10 V668 V667 V652
V203 V26 V461 V50 V666 V654
V659
V511 V24 V51 V665
V512 V25 V27
V670 V642 V329 V664
V655
V653
V210 V671
V48
V330 V643 V637 V660 V328
V202 V636 V661
V70
V71 V49 V327
V211
V72 V331 V303
V13 V326 V302
V73
V208 V647
V460 V648
V209 V18 V12
V63 V649
V204 V509 V502 V19 V21
V205 V149 V140V396
V397 V20
V206 V65V142V504V503 V299
V301
V207 V499 V505
V498
V507 V138 V139
V141 V23 V300
V298
V143 V22
V148 V32
V146 V30
V147 V420V421 V31
V64 V369
V506 V368
V134
V508
V62 V136 V566
V137
V135
V156
V157 V296
V297
V154 V33
V676
V677
V125 V124
V198
V560
V561
V144 V199
V678
V145V180 V279 V278 V496
V679 V497
V182 V181 V280V281
V183
V546 V547
V276V277
V270 V271
V272
V273
V345
V344
43
Illustration with scen11-f6
V620 V626
V624 V625
V618 V639V621
V619 V638 V622 V627
V623
V616V617
V535 V293
V534
V287V292
V286
V17
V662 V663
V16
V632 V2
V79 V3
V614V615 V633 V94 V96 V99 V78
V98
V630 V4
V95 V97
V324 V0
V658
V650 V640V641
V325 V669 V631
V613 V656 V11 V651 V1
V612 V5
V513
V510 V646 V644
V645 V657 V10 V668 V667 V652
V203 V26 V461 V50 V666 V654
V659
V511 V24 V51 V665
V512 V25 V27
V670 V642 V329 V664
V655
V653
V210 V671
V48
V330 V643 V637 V660 V328
V202 V636 V661
V70
V71 V49 V327
V211
V72 V331 V303
V13 V326 V302
V73
V208 V647
V460 V648
V209 V18 V12
V63 V649
V204 V509 V502 V19 V21
V205 V149 V140V396
V397 V20
V206 V65V142V504V503 V299
V301
V207 V499 V505
V498
V507 V138 V139
V141 V23 V300
V298
V143 V22
V148 V32
V146 V30
V147 V420V421 V31
V64 V369
V506 V368
V134
V508
V62 V136 V566
V137
V135
V156
V157 V296
V297
V154 V33
V676
V677
V125 V124
V198
V560
V561
V144 V199
V678
V145V180 V279 V278 V496
V679 V497
V182 V181 V280V281
V183
V546 V547
V276V277
V270 V271
V272
V273
V345
V344
43
Illustration with scen11-f6
V620 V626
V624 V625
V618 V639V621
V619 V638 V622 V627
V623
V616V617
V535 V293
V534
V287V292
V286
V17
V662 V663
V16
V632 V2
V79 V3
V614V615 V633 V94 V96 V99 V78
V98
V630 V4
V95 V97
V324 V0
V658
V650 V640V641
V325 V669 V631
V613 V656 V11 V651 V1
V612 V5
V513
V510 V646 V644
V645 V657 V10 V668 V667 V652
V203 V26 V461 V50 V666 V654
V659
V511 V24 V51 V665
V512 V25 V27
V670 V642 V329 V664
V655
V653
V210 V671
V48
V330 V643 V637 V660 V328
V202 V636 V661
V70
V71 V49 V327
V211
V72 V331 V303
V13 V326 V302
V73
V208 V647
V460 V648
V209 V18 V12
V63 V649
V204 V509 V502 V19 V21
V205 V149 V140V396
V397 V20
V206 V65V142V504V503 V299
V301
V207 V499 V505
V498
V507 V138 V139
V141 V23 V300
V298
V143 V22
V148 V32
V146 V30
V147 V420V421 V31
V64 V369
V506 V368
V134
V508
V62 V136 V566
V137
V135
V156
V157 V296
V297
V154 V33
V676
V677
V125 V124
V198
V560
V561
V144 V199
V678
V145V180 V279 V278 V496
V679 V497
V182 V181 V280V281
V183
V546 V547
V276V277
V270 V271
V272
V273
V345
V344
43
Illustration with scen11-f6
V620 V626
V624 V625
V618 V639V621
V619 V638 V622 V627
V623
V616V617
V535 V293
V534
V287V292
V286
V17
V662 V663
V16
V632 V2
V79 V3
V614V615 V633 V94 V96 V99 V78
V98
V630 V4
V95 V97
V324 V0
V658
V650 V640V641
V325 V669 V631
V613 V656 V11 V651 V1
V612 V5
V513
V510 V646 V644
V645 V657 V10 V668 V667 V652
V203 V26 V461 V50 V666 V654
V659
V511 V24 V51 V665
V512 V25 V27
V670 V642 V329 V664
V655
V653
V210 V671
V48
V330 V643 V637 V660 V328
V202 V636 V661
V70
V71 V49 V327
V211
V72 V331 V303
V13 V326 V302
V73
V208 V647
V460 V648
V209 V18 V12
V63 V649
V204 V509 V502 V19 V21
V205 V149 V140V396
V397 V20
V206 V65V142V504V503 V299
V301
V207 V499 V505
V498
V507 V138 V139
V141 V23 V300
V298
V143 V22
V148 V32
V146 V30
V147 V420V421 V31
V64 V369
V506 V368
V134
V508
V62 V136 V566
V137
V135
V156
V157 V296
V297
V154 V33
V676
V677
V125 V124
V198
V560
V561
V144 V199
V678
V145V180 V279 V278 V496
V679 V497
V182 V181 V280V281
V183
V546 V547
V276V277
V270 V271
V272
V273
V345
V344
43
Experimental Results
1000
100
dom/wdeg
10
1
1 10 100 1000
dom/ddeg
44
Different ways of weighting constraints
45
wdeg/dom
Algorithm 8: propagate((X , C): CN): Boolean
Q←C
while Q ̸= ∅ do
pick and delete c from Q
X ← filter(c) // X , variables with reduced domains
if ∃x ∈ X | dom(x) = ∅ then
incrementWeight(c)
return false // detected inconsistency
foreach c ′ ∈ C | c ′ ̸= c ∧ X ∩ scp(c ′ ) ̸= ∅ do
Q ← Q ∪ {c ′ }
return true
46
frba/dom (1/2)
47
frba/dom (2/2)
fr (x) + a(x)
|dom(x)|
48
pick/dom
pick[x]
|dom(x)|
49
Three Different Ways of Processing Conflicts
•
v =a
M
Queue
•
w =b w ̸= b x y w z y ... w
•
⊥ E ) cx1 cy1 cw1 cz1 cy1 cw1
x =a =
a
P |x cx2 cy2 cw2 cy2 cw2 L
⊥ ϕ(
cy3 cy3
50
Last-conflict based Reasoning
51
Last-conflict based Reasoning
52
Implementation
53
Illustration
xj
aj
6=
=
aj
xj
LC1
xi
x i−
1
−
ai
1
6=
=
a i−
1
−
xi
1
xi
ai
xi
6=
=
ai
xi
⊥
⊥
xi
⊥
testing-set = {xi }
54
Example
x2 x1 0 0 x4
1
2 1 1
2 2
1
2
x0 0 0
1 1 1
2
x3 x6 2 2 x5
Figure: The compatibility graph of a constraint network involving a clique of
constraints of difference and a clique of entailed constraints.
55
x4 = 1 x3 = 0 x2 = 0 x1 = 0
x4
Example
x3
x2
6=
1 6=
6=
0
0
x4 = 1 x3 = 1
x1 6=
0
x4 x3
6= 6=
1 1
x4 = 1 x3 = 0 x2 = 1
x
3
x4 x2
6=
6= 6=
0
1 1
x4 = 1 x3 = 1
x4 x3
6= 6=
1 1
x4 = 0 x3 = 0 x2 = 0 x1 = 1
x
3
x4
x2
6=
6=
0
6=
0
0
x4 = 0 x3 = 1
x1 6=
x4 x3
6= 6=
1
0 1
x4 = 0 x3 = 0 x2 = 1
x
3
x4 x2
6= 6=
6=
0 1
0
x4 = 0 x3 = 1
x4 x3
6= 6=
0 1
x4 = 0 x3 = 0 x2 = 0 x1 = 2
x
3
x4 x1
x2
6=
6= 6=
0
0 2
6=
0
x4 = 0 x3 = 1
x4 x3
6= 6=
0 1
x4 = 0 x3 = 0 x2 = 1
x
3
x4 x2
Figure: Search tree built by MAC (68 explored nodes).
6= 6=
6=
0 1
0
x4 = 0 x3 = 1
x4 x3
6= 6=
0 1
56
Example
x1 6=
0
x4 = 1 x3 = 0 x2 = 0 x1 = 0
x2 x
6=
1
0
0 4
6=
x1 = 1 x4 = 0
0
0
1
0
1
x3
x4
x1
x1
x4 = 1
x1 = 1
6=
6=
6=
6=
0
1
x4
x4
x4 = 1
priority = x1
6=
6=
1
priority = x4
Figure: Search tree built by MAC-LC1 (21 explored nodes).
57
Generalization
xk
ak
6=
=
ak
xk
LC2
xi
xj
1
−
−
aj
xj
1
6=
=
a j−
1
−
xj
1
xk
xj
aj
xi
6=
aj
xj
LC1 xj
xi
⊥
x i−
1
−
xj
ai
1
6=
=
a i−
1
⊥
−
xi
1
xi
ai
xi
6=
=
ai
xi
⊥
⊥
xi
⊥
testing-set = {xi } testing-set = {xi , xj }
58