44
Tutorial Constraint Satisfaction Problems

Tutorial Constraint Satisfaction Problems. CSP Exercise 1

  • View
    238

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Tutorial

Constraint Satisfaction Problems

Page 2: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

CSP

Exercise 1

Page 3: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

• Consider the following map. The task is to color the map using the three colors Red, Blue, and Green, such that no two adjacent regions take the same color.

Page 4: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

1. Formulate the problem as a CSP. Clearly state the variables, domains, and constraints.

2. Describe the topology of the constraint graph.

3. What is the size of the search space?

4. Color the map using:

1. Backtracking Search with MRV heuristic. 2. Backtracking Search with MCV heuristic. 3. Backtracking Search with LCV heuristic. 4. Backtracking Search with Forward Checking heuristic.

5. Note: Variables and values are ordered as follows:

• Variables: WA, NT, Q, NSW, V, SA, T • Values: Red, Blue, and Green

Page 5: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

1. Backtracking Search with MRV heuristic.

Page 6: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

2. Backtracking Search with MCV heuristic.

Page 7: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

3. Backtracking Search with LCV heuristic.

Page 8: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

4. Backtracking Search with Forward Checking.

Page 9: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

CSP

Exercise 2

Page 10: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Use all heuristics including arc-propagation to solve this problem.

CE

D

B

F

A

G

H

{blue, green, red} {blue, green, red}

{blue, green, red}

{blue, green, red}

{blue, green, red}

{blue, green, red}

{blue, green, red}

{blue, green, red}

3 colour me!

Page 11: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

3 colour me using Backtracking and Forward Checking …

CE

D

B

F

A

G

H

{blue, green, red} { , green, red}

{blue, , }

{ , green, }

{blue, , red}

{ , , red}

{blue, , }

{ , green, }

3 colour me!

Page 12: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

CSP

Exercise 3

Page 13: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

CSP – Examination Problem

• During an examination, an invigilator has to arrange six students in a way to make sure that the examination is properly conducted and no one cheats. 2 students have makeup in Artificial Intelligence, 1 student has makeup in Database, 2 students have makeup in Mathematics, and 1 student in Physics. As shown in figure below, there exist 6 desks arranged into two rows and three columns.

Page 14: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Examination Problem• The problem for the invigilator is to arrange students so that

students having the same makeup exam should not be neighbors (in the same column, in the same row or the same diagonal for example - neighbors of 5 are 1, 2, 3, 4 and 6, - and neighbors of 3 are 2 (same row), 5 (same diagonal) and 6 (same column)).

1. Propose a formulation of the problem in term of CSP by specifying variables, domains and constraints

2. Describe the topology of the constraint graph.

3. Using Forward Checking with Backpropagation, propose a solution to help the invigilator. Variables and values should be selected according to alphabetical or ascending order.

4. Using Backpropagation with MCV heuristic, propose a solution to help the invigilator. Variables and values are ordered according to alphabetical or ascending order.

Page 15: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Examination Problem - Solution

1. Using Forward Checking with Backpropagation, propose a solution to help the invigilator. Variables and values should be selected according to alphabetical or ascending order.

2. Using Backpropagation with MCV heuristic, propose a solution to help the invigilator. Variables and values are ordered according to alphabetical or ascending order.

AI DB AI

M P M

Page 16: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

CSP

Exercise 4

Backtracking + FC

Page 17: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Do it yourself …

• Solve 6-queens …

1

3

2

4

Q3Q2 Q4Q1 Q5

5

6

Q6

Page 18: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 19: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 20: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 21: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 22: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 6 has domain wipeoutBacktrack to next “choice”

Page 23: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 5 has domain wipeoutBacktrack to next “choice”

Page 24: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 25: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 26: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 6 has domain wipeoutBacktrack to next “choice”

Page 27: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 28: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 5 has domain wipeoutBacktrack to next “choice”

Page 29: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 30: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 31: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 32: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 6 has domain wipeoutBacktrack to next “choice”

Page 33: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 34: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 5 has domain wipeoutBacktrack to next “choice”

Page 35: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 5 has domain wipeoutBacktrack to next “choice”

Page 36: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 37: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 38: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 39: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 40: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6 Column 6 has domain wipeoutBacktrack to next “choice”

Page 41: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 42: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 43: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

Page 44: Tutorial Constraint Satisfaction Problems. CSP Exercise 1

Forward Checking

• Solve 6-queens …

1

3

2

4

32 41 5

5

6

6

First Solution!