21
CSP: Definition, Creation, and Algorithms Mr. Tianbing Lin [email protected] Dr. Goodwin Scott University of Windsor

CSP: Definition, Creation, and Algorithms

  • Upload
    rhett

  • View
    65

  • Download
    3

Embed Size (px)

DESCRIPTION

CSP: Definition, Creation, and Algorithms. Mr. Tianbing Lin [email protected] Dr. Goodwin Scott University of Windsor. Outline. Introduction of Constraint Satisfaction Problem Algorithms: Backtracking, Forward Checking, Back Jump, Dynamic Backtracking Evaluation: Random CSP, N-Queen - PowerPoint PPT Presentation

Citation preview

Page 1: CSP: Definition, Creation, and Algorithms

CSP: Definition, Creation, and Algorithms

Mr. Tianbing Lin [email protected]

Dr. Goodwin Scott University of Windsor

Page 2: CSP: Definition, Creation, and Algorithms

23/4/22 2

Outline

Introduction of Constraint Satisfaction Problem Algorithms: Backtracking, Forward Checking,

Back Jump, Dynamic Backtracking Evaluation: Random CSP, N-Queen Experimental Result Question?

Page 3: CSP: Definition, Creation, and Algorithms

23/4/22 3

Introduction of CSP

Given a set of variables X={x1, x2…xn} and a finite set Di of possible values (its domain) for every variable.

Given some constraints restricting the values

How to assign values for all the variables so that all the constraints are satisfied?

Page 4: CSP: Definition, Creation, and Algorithms

23/4/22 4

Introduction of CSP: N-Queen

Variables: Q1, Q2, Q3, Q4 Domain: {1, 2, 3, 4} Constraints:

Qi<>Qj: Not in the same row|Qi-Qj|<>|i-j|: Not in diagonal

Extentional Constraints:(Q1, Q2): {(1,3), (1,4), (2, 4), (3,1), (4, 1), (4, 2)}(Q1, Q3): …

Page 5: CSP: Definition, Creation, and Algorithms

23/4/22 5

Introduction of CSP: Graph Coloring

Paint the graph with different colors

3 Color?

Page 6: CSP: Definition, Creation, and Algorithms

23/4/22 6

Algorithms: Overview

Systematic Algorithms: Backtracking, Forward Checking…– Search the whole solution space systematically– In most cases, slow

Heuristical Algorithms: Hill-climbing, Simulated Annealing, Genetic Algorithm…– In some cases, fast– Might not get solution at all.

Page 7: CSP: Definition, Creation, and Algorithms

23/4/22 7

Algorithms: Backtracking

Page 8: CSP: Definition, Creation, and Algorithms

23/4/22 8

Algorithms: Forward Checking

Page 9: CSP: Definition, Creation, and Algorithms

23/4/22 9

Algorithms: Back Jumping

if we find all the values of Variable C are invalid because they are conflict with the value of Variable A, then we don't need to change the value of B to check C again. We can directly jump to another value of Variable A, skip other values of B (under A1 value).

N-Queen problem can not demonstrate this algorithm.

Page 10: CSP: Definition, Creation, and Algorithms

23/4/22 10

Algorithms: Dynamic Backtracking

When we back jump to A from C, we reset value of B.

Do we really have to reset B, if it’s not conflict with A or C?

We dynamically change the order of variables: Before, A->B->C. Now: B->A->C

Page 11: CSP: Definition, Creation, and Algorithms

23/4/22 11

Algorithms: Dynamic Backtracking

Example of Graph Coloring:

We’ve finished painting the 3 slides in the north and 2 slides in the south.

We don’t need to change the value of south slides.

Page 12: CSP: Definition, Creation, and Algorithms

23/4/22 12

Evaluation: N-Queen

N-Queen is a nature test scheme. Normally a PC can solve 30-Queen problem in

reasonable time using above algorithms.

Drawback: Every assignment create (almost) same number of “no-good” for other variables.

Page 13: CSP: Definition, Creation, and Algorithms

23/4/22 13

Evaluation: Random CSP

Randomized constraints can be created according number of variables, average number of constraints, average tightness.

Use average solving time to compare different algorithms.

Page 14: CSP: Definition, Creation, and Algorithms

23/4/22 14

Experimental ResultsOveral l Compari son for one sol uti on

0

10000

20000

30000

40000

50000

60000

700001 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76

Mill

isec

onds

BackTracki ng Forward Check Back J ump Dynami c Backtracki ng

Page 15: CSP: Definition, Creation, and Algorithms

23/4/22 15

Experimental Results: Sort by Variable Number

0

1000

2000

3000

4000

5000

6000

13 14 15 16

Back Tracki ng Forward Check Back J ump Dynami c Backt rack

Page 16: CSP: Definition, Creation, and Algorithms

23/4/22 16

Experimental Results: Sort by Tightness

Sort By Ti ghtness (Al l Sol ut i on)

0

10000

20000

30000

40000

50000

60000

70000

80000

90000

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

Mill

isec

onds

Back Tracki ng Forward Check Back J ump

Page 17: CSP: Definition, Creation, and Algorithms

23/4/22 17

Considering Tightness Constraint density can’t assure the tightness of the CSP . For example, we have CSP A and CSP B (domain size:

3, 3 variables):

Density of Constraint 1 and Density of Constraint 2 are 33.3%. Solution is empty, so the tightness is 0/27

Page 18: CSP: Definition, Creation, and Algorithms

23/4/22 18

Considering Tightness

Density of Constraint 1 and Density of Constraint 2 are 33.3%, Can have 9 solutions{(1, 1, 1) (1, 1, 2) (1, 1, 3) (2, 1, 1) (2, 1, 2) (2, 1, 3) (3, 1, 1) (3, 1, 2) (3, 1, 3)}, which means the tightness is 9/27=33%.

Page 19: CSP: Definition, Creation, and Algorithms

23/4/22 19

Considering Tightness

The smallest constraint density of all the constraints is the maximum value of tightness the CSP can have. The exact value of the tightness depends on the relation of the constraint tables.

Page 20: CSP: Definition, Creation, and Algorithms

23/4/22 20

Reference [1] Barták, R., “Constraint Programming: In Pursuit of the Holy Grail”, in

Proceedings of the Week of Doctoral Students (WDS99), Part IV, MatFyzPress, Prague, June 1999, pp. 555-564.

[2] Malek Mouhoub, class notes of Artificial Intelligence. [3] Prosser, P., Binary constraint satisfaction problems: Some are harder than

others, Proceedings ECAI-94 (11th European Conference on Artificial Intelligence)

[4] White, S, Enhancing Knowledge Acquisition with Constraint Technology, PhD Thesis, University of Aberdeen

[5] Pedro Meseguer, CSP: Constraint Programming [6] Joe Culberson and Toby Walsh , Tightness of Constraint Satisfaction

Problems [7] Peter van Beek and Rina Dechter, Constraint Tightness and Looseness

versus Local and Global Consistency

Page 21: CSP: Definition, Creation, and Algorithms

23/4/22 21

Thank you

Question?