Upload
dore
View
49
Download
0
Tags:
Embed Size (px)
DESCRIPTION
CSP. Yaron Kassner Winter 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. - PowerPoint PPT Presentation
Citation preview
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 90 1 2 3 4 5 6 7 8 90 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 90 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9C3 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 90 1 2 3 4 5 6 7 8 90 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 90 1 2 3 4 5 6 7 8 9
1C3 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 90 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 92 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 92 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 92 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 C2 C1MRV
LCVExample: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 8 92 3 4 5 6 7 8 9
0 2 4 6 8
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 83 5 7
0 2 4 6 8
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 83 5 7
0 4 6
0 2 3 4 5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 83 5 7
0 4 6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 1 C1
MRVLCV
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0
6 7 83 5 7
0 4 6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 1 0
10O O
Example: Cryptarithmetic Problem
TW3+ TW3 _____ 13UR
O
R
C1
W
U
C2
T
F
1
0
6 7 83
0 4 6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 83
6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 1 0
1 10 3T T
Example: Cryptarithmetic Problem
6W3+ 6W3 _____ 13U6
O
R
C1
W
U
C2
T
F
1
0
63
6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 1 0
אחורה גלגול
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
0 1
6 7 83 5 7
0 4 6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 1 C1
MRV
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
6 7 83 5 7
0 4 6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 1
1 1 1
9O O
Example: Cryptarithmetic Problem
TWO+ TWO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
6 7 85 7
0 4 6
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 85 7
0 4
5 6 7 8 90 2 3 4 5 6 7 8 9
1C3 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 85 7
0 4
6 7 83 5 7
1C3 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 85 7
0 4
6 7 83 5 7
1C3 1
1 1 1
MRVLCV
Example: Cryptarithmetic Problem
8WO+ 8WO _____ 1OUR
O
R
C1
W
U
C2
T
F
1
1
85 7
0 4
6 7 83 5 7
1C3 1
1 1 1Example: Cryptarithmetic Problem
8W7+ 8W7 _____ 17UR
O
R
C1
W
U
C2
T
F
1
1
87
0 4
6 7 83 5 7
1C3 1
1 1 1Example: Cryptarithmetic Problem
8W7+ 8W7 _____ 17U4
O
R
C1
W
U
C2
T
F
1
1
87
4
6 7 83 5 7
1C3 1
1 1 1
Distinct character values
Example: Cryptarithmetic Problem
867+ 867 _____ 17U4
O
R
C1
W
U
C2
T
F
1
1
87
4
63 5
1C3 1
1 1 1Example: Cryptarithmetic Problem
867+ 867 _____ 1734
O
R
C1
W
U
C2
T
F
1
1
87
4
63
1C3 1
1 1 1Example: Cryptarithmetic Problem
Example: Zebra puzzle
• http://www.youtube.com/watch?v=_dcsqBY04OY
• Some kind of MAC.