30
CSP Yaron Kassner Winter 2013

CSP

  • Upload
    dore

  • View
    49

  • Download
    0

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

Page 1: CSP

CSP

Yaron KassnerWinter 2013

Page 2: CSP

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.

Page 3: CSP

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.

Page 4: CSP

AC-3 complexity

Page 5: CSP

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

Page 6: CSP

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

Page 7: CSP

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

Page 8: CSP

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

Page 9: CSP

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

Page 10: CSP

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

Page 11: CSP

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

Page 12: CSP

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

Page 13: CSP

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

Page 14: CSP

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

Page 15: CSP

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

Page 16: CSP

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

Page 17: CSP

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

Page 18: CSP

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

Page 19: CSP

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

Page 20: CSP

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

Page 21: CSP

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

Page 22: CSP

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

Page 23: CSP

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

Page 24: CSP

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

Page 25: CSP

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

Page 26: CSP

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

Page 27: CSP

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

Page 28: CSP

867+ 867 _____ 17U4

O

R

C1

W

U

C2

T

F

1

1

87

4

63 5

1C3 1

1 1 1Example: Cryptarithmetic Problem

Page 29: CSP

867+ 867 _____ 1734

O

R

C1

W

U

C2

T

F

1

1

87

4

63

1C3 1

1 1 1Example: Cryptarithmetic Problem

Page 30: CSP

Example: Zebra puzzle

• http://www.youtube.com/watch?v=_dcsqBY04OY

• Some kind of MAC.