23
OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION A Generic Framework for Local Search : Application to the Sudoku Problem ICCS 2006, Reading, UK Tony LAMBERT LINA, Université de Nantes, France LERIA,Université d’Angers, France Universidad Santa María, Valparaíso, Chile joint work with E. Monfroy and F. Saubion Wed, 31 May, 2006 1/41

Lambert Iccs2006 Slides

Embed Size (px)

DESCRIPTION

A Generic Framework for Local Search :Application to the Sudoku Problem

Citation preview

Page 1: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

A Generic Framework for Local Search :Application to the Sudoku Problem

ICCS 2006, Reading, UK

Tony LAMBERT

LINA, Université de Nantes, France

LERIA,Université d’Angers, France

Universidad Santa María, Valparaíso, Chile

joint work with E. Monfroy and F. Saubion

Wed, 31 May, 2006

1 / 41

Page 2: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Outline

• Local search for solving CSP• A framework for local search techniques• Generic Iteration Algorithm with reduction

functions• Some results for the sudoku problem• Conclusion

3 5 1

1 5 6 3 7

6 9 1 4

3 6 9 8

8

1 9 7

9 5

8 4 6 7

9 5

1 63 4 5 7 8 9

2

2

2

2

2

2 / 41

Page 3: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Constraint satisfaction Problem (CSP)

X

Y

Constraints

VariablesU

TZ

C1

C2

C5C4

C3

3 / 41

Page 4: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Local search (1)

Definition :• Explore a D1 × D2 × · · · × Dn search space• Move from neighbor to neighbor thanks to an evaluation

function• Intensification• Diversification

Properties :

• focus on some “promising” parts of the search space• does not answer to unsat. problems• no guaranteed• “fast” to find a “good” solution

4 / 41

Page 5: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Local search (2)• Search space : set of possible configurations• Tools : neighborhood and evaluation function

of sNeighborhood

Set ofpossibleconfigurations

5 / 41

Page 6: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Local search (3)• Search space : set of possible configurations• Tools : neighborhood and evaluation function

of sNeighborhood

Set ofpossibleconfigurations

6 / 41

Page 7: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Local search (4)• Search space : set of possible configurations• Tools : neighborhood and evaluation function

s 1

s 1

2s s n

2s s n s n+1

p = (

p’ = (

LS(p) = p’

,

, , ...,

, ..., )

, )

of sNeighborhood

Set ofpossibleconfigurations

ss

ss

s

s21

34

5

6

7 / 41

Page 8: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

A framework for local search techniques

• Idea :• Fine grain control• More strategies

• Technique :• Decomposing local search resolution into basic functions• Adapting chaotic iterations

8 / 41

Page 9: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Our Purpose :

• Use of an existing theoretical model for CSP solving• Definition of the solving process

9 / 41

Page 10: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Abstract Model K.R. Apt [CP99]

CSP

Applicationof functions

Constraint Reduction functions

Fixed point

Partial Ordering

Abstraction

10 / 41

Page 11: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

A Generic Algorithm

F = { set reduction functions}

X =

X = initial CSPG = FWhile G 6= ∅

choose g ∈ GG = G − {g}G = G ∪ update(G, g, X )X = g(X )

EndWhile

11 / 41

Page 12: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

The theoretical model for CSP solving

Partial ordering :

1p

2p

3p

4p

p

Function to pass from one LSstate to another

5

Terminates with a fixed point : local minimum, maximum number of iteration

State of LS

12 / 41

Page 13: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Ls Ordering

Characteristics of a LS path

• notion of solution• maximum length

Operational (computational) point of view : path = samplesA sample :

• Depends on a CSP• Corresponds to a local search state

13 / 41

Page 14: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Neighborhood and Move functions

Neighborhood :

• FullNeighbor : V ′ = {s ∈ D|s 6∈ V}• TabuNeighbor : V ′ = {s ∈ D| 6 ∃k , n − l ≤ k ≤ n, sk = s}• DescentNeighbor : p = (s1, . . . , sn) and V ′ = s ⊂ D s.t. 6∃s′ ∈ V s.t eval(s′) < eval(sn)

Move :

• BestMove : p′ = p ⊕ s′ and eval(s′) = mins′′∈V eval(s′′)

• ImproveMove : p = p′′ ⊕ sn and p′ = p ⊕ s s.t.eval(s′) < eval(sn)

• RandomMove : p′ = p ⊕ s′ and s′ ∈ V

14 / 41

Page 15: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Instantiate the GI algorithm

We can precise here the input set of function F .

Tabu search :• TabuNeighbor• BestNeighBor

Random walk :• FullNeighbor• BestNeighBor• RandomNeighbor

Random walk + Descent :• FullNeighbor• BestNeighBor• RandomNeighbor• DescentNeighbor• ImproveNeighBor

TabuSearch + Descent :• TabuNeighbor• DescentNeighbor• ImproveNeighBor• BestNeighBor

15 / 41

Page 16: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Sudoku problem

• n2 × n2 problem• n4 variables• AllDiff constraints 3 5 1

1 5 7

8

6 9 8

1

9 5

1 9 7

8 4

4

6 7

6 3

6

9 5

3

9

2

2

2

2

16 / 41

Page 17: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Sudoku problem

3 5 1

1 5 7

8

6 9 8

1

1

3

9

3 6

9 5

1 9 7

8 4

4

1

6 7

6 3

6

8 9 5

3

9

2

2

2

2

2

2

17 / 41

Page 18: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Sudoku problem

3 5 1

1 5 7

8

6 9 8

1

1

3

9

3 6

9

9

4 9

9 5

1 9 7

8 4

5

4

7 4

4

5

7 8 3

7 5

5

4

1

6 7

6 3

6

8 9 5

3

9

2

2

2

2

2

2

18 / 41

Page 19: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Sudoku problem

3 5 1

1 5 7

8

6 9 8

1

1

3

9

3 6

9

9

4 9

9 5

1 9 7

8 4

5

4

7 4

4

5

7 8 3

7 5

5

5

6 8

4 8

6 4

6 7

4

1

6 7

6 3

6

8 9 5

3

9

2

2

2

2

2

2

19 / 41

Page 20: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Sudoku problem

3 5 1

1 5 7

9 5

8

6 9 8

1

1

3

9

3 6

9

9

4 9

9 5

1 9 7

8 4

5

4

7 4

4

5

7 8 3

7 5

5

5

6 8

4 8

6 4

6 7

3

4

11

1

1

7

7

3 8

3 6 7

4

8 6 3

6

1

8

3

9

2

2

2

2

2

2

2

2

2

20 / 41

Page 21: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

TabuSearch RandomWalkn2 x n2 16x16 25x25 36x36 16x16 25x25 36x36

cpu time 3,14 115,08 3289,8 3,92 105,22 2495deviations 1,28 52,3 1347,4 1,47 49,3 1099

mvts 405 3240 22333 443 2318 13975Descent + TabuSearch Descent +RandomWalk

n2 x n2 16x16 25x25 36x36 16x16 25x25 36x36cpu time 2,34 111,81 2948 2,41 82,94 2455

deviations 1,42 55,04 1476 1,11 36,99 1092mvts Avg 534 3666 20878 544 2581 14908

21 / 41

Page 22: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

Conclusion and Future works

• A generic model local search methods• Design of strategies

• Dynamic strategies learning• Providing more tools in a generic environment• A generic implementation

22 / 41

Page 23: Lambert Iccs2006 Slides

OUTLINE LOCAL SEARCH FOR SOLVING CSP A FRAMEWORK FOR LS THE SUDOKU RESULTS CONCLUSION

A Generic Framework for Local Search :Application to the Sudoku Problem

ICCS 2006, Reading, UK

Tony LAMBERT

LINA, Université de Nantes, France

LERIA,Université d’Angers, France

Universidad Santa María, Valparaíso, Chile

joint work with E. Monfroy and F. Saubion

Wed, 31 May, 2006

23 / 41