CSP Yaron Kassner Winter 2013. Reminder Arc Consistency: the domains of pairs of variables are...
-
Upload
anika-coleson -
Category
Documents
-
view
215 -
download
0
Transcript of CSP Yaron Kassner Winter 2013. Reminder Arc Consistency: the domains of pairs of variables are...
CSP
Yaron KassnerWinter 2013
Reminder
• Arc Consistency: the domains of pairs of variables are consistent.
• k-consistency: the domains of every k variables are consistent.
• AC3 – an algorithm that reduces the domains of variables by enforcing arc-consistency.
Reminder
• CSP problems can be solved using search.• Heuristics:
– assign the variable with the minimum number of remaining values
– Most constraining variable – choose the variable that constrains the most variables.
– choose the least-constraining-value: the value that is inconsistent with as few other values as possible.
• Forward checking – after assignment, reduce domain of neighboring variables.
• MAC – maintain arc-consistency: do a back-tracking search, and fix arc consistency after every assignment.
AC-3 complexity
Example: Cryptarithmetic Problem
TWO+ TWO _____ FOUR
O
R
C1
W
U
C2
T
F
0 1
0 1
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
C3 0 1
3C F
C3 C2 C1
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
0 1
0 1
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
1
C3 1
Characters are distinct
1 C2 C1
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
0 1
0 1
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
%10O O R O R
1 C2 C1Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
0 1
0 1
0 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 C2 C1
2 9T T C
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
0 1
0 1
5 6 7 8 9
2 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 C2 C1
2 %10T T C O
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
0 1
0 1
6 7 8 9
2 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 C2 C1
MRVLCV
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 8 9
2 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 C1
1 %10 ,T T O T O
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 8
3 5 7
0 2 4 6 8
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 C1
%10O O R
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 8
3 5 7
0 4 6
0 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 C1
1 9W W C
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 8
3 5 7
0 4 6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 C1
MRVLCV
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0
6 7 8
3 5 7
0 4 6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 0
10O O
Example: Cryptarithmetic Problem
TW3+ TW3 _____ 13UR
O
R
C1
W
U
C2
T
F
1
0
6 7 8
3
0 4 6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 0
3 3 R
Example: Cryptarithmetic Problem
TW3+ TW3 _____ 13U6
O
R
C1
W
U
C2
T
F
1
0
6 7 8
3
6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 0
1 10 3T T
Example: Cryptarithmetic Problem
6W3+ 6W3 _____ 13U6
O
R
C1
W
U
C2
T
F
1
0
6
3
6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 0
אחורה גלגול
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 8
3 5 7
0 4 6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 C1
MRV
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
6 7 8
3 5 7
0 4 6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 1
9O O
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
6 7 8
5 7
0 4 6
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 1
10O O R
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
6 7 8
5 7
0 4
5 6 7 8 9
0 2 3 4 5 6 7 8 9
1
C3 1
1 1 1
1 10W W U
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
6 7 8
5 7
0 4
6 7 8
3 5 7
1
C3 1
1 1 1
1 10T T O
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
7 8
5 7
0 4
6 7 8
3 5 7
1
C3 1
1 1 1
MRVLCV
Example: Cryptarithmetic Problem
8WO+ 8WO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
8
5 7
0 4
6 7 8
3 5 7
1
C3 1
1 1 1
Example: Cryptarithmetic Problem
8W7+ 8W7 _____ 17UR
O
R
C1
W
U
C2
T
F
1
1
8
7
0 4
6 7 8
3 5 7
1
C3 1
1 1 1
Example: Cryptarithmetic Problem
8W7+ 8W7 _____ 17U4
O
R
C1
W
U
C2
T
F
1
1
8
7
4
6 7 8
3 5 7
1
C3 1
1 1 1
Distinct character values
Example: Cryptarithmetic Problem
867+ 867 _____ 17U4
O
R
C1
W
U
C2
T
F
1
1
8
7
4
6
3 5
1
C3 1
1 1 1Example: Cryptarithmetic Problem
867+ 867 _____ 1734
O
R
C1
W
U
C2
T
F
1
1
8
7
4
6
3
1
C3 1
1 1 1Example: Cryptarithmetic Problem
Example: Zebra puzzle
• http://www.youtube.com/watch?v=_dcsqBY04OY
• Some kind of MAC.