59
1 Advances in Pattern Databases Ariel Felner, Ben-Gurion University Israel email: [email protected]

Advances in Pattern Databases

  • Upload
    leigh

  • View
    39

  • Download
    1

Embed Size (px)

DESCRIPTION

Advances in Pattern Databases. Ariel Felner, Ben-Gurion University Israel email: [email protected]. Overview. Heuristic search and pattern databases Disjoint pattern databases Compressed pattern databases - PowerPoint PPT Presentation

Citation preview

Page 1: Advances in Pattern Databases

1

Advances in Pattern Databases

Ariel Felner, Ben-Gurion University Israel email: [email protected]

Page 2: Advances in Pattern Databases

2

Overview

• Heuristic search and pattern databases• Disjoint pattern databases• Compressed pattern databases• Dual lookups in pattern databases• Current and future work

Page 3: Advances in Pattern Databases

3

optimal path search algorithms

• For small graphs: provided explicitly, algorithm such as Dijkstra’s shortest path, Bellman-Ford or Floyd-Warshal. Complexity O(n^2).

• For very large graphs , which are implicitly defined, the A* algorithm which is a best-first search algorithm.

Page 4: Advances in Pattern Databases

4

Best-first search schema• sorts all generated nodes in an

OPEN-LIST and chooses the node with the best cost value for expansion.

• generate(x): insert x into OPEN_LIST.

• expand(x): delete x from OPEN_LIST and generate its children.

• BFS depends on its cost (heuristic) function. Different functions cause BFS to expand different nodes..

20

30 25 35

40 35

2025 30 3530 35 35 40

Open-List

Page 5: Advances in Pattern Databases

5

Best-first search: Cost functions• g(x): Real distance from the initial state to x • h(x): The estimated remained distance from x to

the goal state. • Examples:Air distance Manhattan Dinstance Different cost combinations of g and h• f(x)=level(x) Breadth-First Search. • f(x)=g(x) Dijkstra’s algorithms. • f(x)=h’(x) Pure Heuristic Search (PHS). • f(x)=g(x)+h’(x) The A* algorithm (1968).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Page 6: Advances in Pattern Databases

6

A* (and IDA*)• A* is a best-first search algorithm that uses

f(n)=g(n)+h(n) as its cost function. • f(x) in A* is an estimation of the shortest path to

the goal via x.• A* is admissible, complete and optimally effective.

[Pearl 84]• Result: any other optimal search algorithm will

expand at least all the nodes expanded by A*

BreadthFirstSearch A*

Page 7: Advances in Pattern Databases

7

Domains

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

15 puzzle• 10^13 states• First solved by [Korf 85] with

IDA* and Manhattan distance• Takes 53 seconds

24 puzzle• 10^24 states• First solved by [Korf 96]• Takes 2 days

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Page 8: Advances in Pattern Databases

8

• Rubik’s cube• 10^19 states• First solved by [Korf 97]• Takes 2 days to solve

Domains

Page 9: Advances in Pattern Databases

9

(n,k) Top Spin Puzzle

• n tokens arranged in a ring• States: any possible permutation of the tokens• Operators: Any k consecutive tokens can be

reversed• The (17,4) version has 10^13 states• The (20,4) version has 10^18 states

Page 10: Advances in Pattern Databases

10

4-peg Towers of Hanoi (TOH4)

• There is a conjecture about the length of optimal path but it was not proven.

• Size 4^k

Page 11: Advances in Pattern Databases

11

How to improve search?• Enhanced algorithms: • Perimeter-search [Delinberg and Nilson 95]• RBFS [Korf 93]• Frontier-search [Korf and Zang 2003] • Breadth-first heuristic search [Zhou and Hansen 04]

They all try to better explore the search tree.

• Better heuristics: more parts of the search tree will be pruned.

Page 12: Advances in Pattern Databases

12

Better heuristics• In the 3rd Millennium we have very large

memories. We can build large tables.• For enhanced algorithms: large open-lists or

transposition tables. They store nodes explicitly.

• A more intelligent way is to store general knowledge. We can do this with heuristics

Page 13: Advances in Pattern Databases

13

Subproblems-Abstractions• Many problems can be abstracted into

subproblems that must be also solved. • A solution to the subproblem is a lower

bound on the entire problem.

• Example: Rubik’s cube [Korf 97]• Problem: 3x3x3 Rubik’s cube Subproblem: 2x2x2 Corner cubies.

Page 14: Advances in Pattern Databases

14

Pattern Databases heuristics• A pattern database [Culbreson & Schaeffer 96] is a

lookup table that stores solutions to all configurations of the subproblem / abstraction / pattern.

• This table is used as a heuristic during the search.• Example: Rubik’s cube. • Has 10^19 States.• The corner cubies subproblem has 88 Million states • A table with 88 Million entries fits in memory [Korf 97].

Patternspace

Search space

Mapping/Projection

Page 15: Advances in Pattern Databases

15

Non-additive pattern databases• Fringe pattern database

[Culberson & Schaeffer 1996].

• Has only 259 Million states.

• Improvement of a factor of 100 over Manhattan Distance

B x x 3 x x x 7 x x x 11 12 13 14 15

13 x B x x 11 7 x 14 x 12 15 3 x x x

Page 16: Advances in Pattern Databases

16

Example - 15 puzzle

2 3 6 7

2 3 6 7

• How many moves do we need to move tiles 2,3,6,7 from locations 8,12,13,14 to their goal locations

• The solution to this is located in

PDB[8][12][13][14]=18

Page 17: Advances in Pattern Databases

17

Disjoint Additive PDBs (DADB)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

• Values of disjoint databases can be added and are still admissible [Korf & Felner: AIJ-02,

Felner, Korf & Hanan: JAIR-04]• Additivity can be applied if the cost of a

subproblem is composed from costs of objects from corresponding pattern only

7-8

•If you have many PDBS, take their maximum

Page 18: Advances in Pattern Databases

18

DADB:Tile puzzles

PuzzleHeuristicValueNodes TimeMemory15Breadth-FS10^1328 days3-tera-bytes15Manhattan36.942401,189,63053.4240155-5-541.5623,090,4050.5413,145156-6-342.924617,5550.16333,554157-845.63236,7100.034576,575246-6-6-6360,892,479,6712 days242,000

5-5-5 6-6-3 7-8 6-6-6-6[Korf, AAAI 2005]

Page 19: Advances in Pattern Databases

19

Heuristics for the TOH

• Infinite peg heuristic (INP): Each disk moves to its own temporary peg.

• Additive pattern databases [Felner, Korf & Hanan, JAIR-04]

Page 20: Advances in Pattern Databases

20

Additive PDBS for TOH4• Partition the disks into disjoint sets • Store the cost of the complete

pattern space of each set in a pattern database.

• Add values from these PDBs for the heuristic value.

• The n-disk problem contains 4^n states

• The largest database that we stored was of 14 disks which needed 4^14=256MB.

6

10

Page 21: Advances in Pattern Databases

21

TOH4: results

16 disksHeuristicsolutionh(s)Avg hNodesseconds

Infinite peg memory fullStatic 13-316110275.78134,653,23248Static 14-216111489.1036,479,15114Dynamic 14-216111495.5212,872,73221

17 disksDynamic 14-318311697.05238,561,5902,501

•The difference between static and dynamic is covered in [Felner, Korf & Hanan: JAIR-04]

Page 22: Advances in Pattern Databases

22

Best Usage of Memory• Given 1 giga byte of memory, how do we

best use it with pattern databases?• [Holte, Newton, Felner, Meshulam and

Furcy, ICAPS-2004] showed that it is better to use many small databases and take their maximum instead of one large database.

• We will present a different (orthogonal) method [Felner, Mushlam & Holte: AAAI-04].

Page 23: Advances in Pattern Databases

23

Compressing pattern database Felner et al AAAI-04[[

• Traditionally, each configuration of the pattern had a unique entry in the PDB.

• Our main claim Nearby entries in PDBs are highly correlated !!• We propose to compress nearby entries by

storing their minimum in one entry.• We show that most of the knowledge is preserved• Consequences: Memory is saved, larger patterns

can be used speedup in search is obtained.

Page 24: Advances in Pattern Databases

24

Cliques in the pattern space• The values in a PDB for

a clique are d or d+1• In permutation puzzles

cliques exist when only one object moves to another location.

G d

dd+1

• Usually they have nearby entries in the PDB• A[4][4][4][4][4]

A clique in TOH4

Page 25: Advances in Pattern Databases

25

Compressing cliques• Assume a clique of size K with values d or d+1• Store only one entry (instead of K) for the

clique with the minimum d. Lose at most 1. • A[4][4][4][4][4] A[4][4][4][4][1] • Instead of 4^p we need only 4^(p-1) entries. • This can be generalized to a set of nodes with

diameter D. (for cliques D=1)• A[4][4][4][4][4] A[4][4][4][1][1]• In general: compressing by k disks reduces

memory requirements from 4^p to 4^(p-k)

Page 26: Advances in Pattern Databases

26

TOH4 results: 16 disks (14+2)

PDBH(s)Avg HDNodesTimeMem MB

14/0 + 211687.03036,479,15114.3425614/1 + 211586.48137,964,22714.696414/2 + 2 11385.67340,055,43615.411614/3 + 211184.44544,996,74316.94414/4 + 210782.73945,808,32817.36114/5 + 2 10380.841361,132,72623.780.256

• Memory was reduced by a factor of 1000!!! at a cost of only a factor of 2 in the search effort.

Page 27: Advances in Pattern Databases

27

TOH4: larger versionssizePDBTypeAvg HNodesTimeMem

1714/0 + 3static81.5>393,887,923>4212561714/0 + 3dynamic87.0238,561,5902,5012561715/1 + 2static103.7155,737,832832561716/2 + 1 static123.817,293,60372561816/2 + 2static123.8380,117,836463256

• For the 17 disks problem a speed up of 3 orders of magnitude is obtained!!!

• The 18 disks problem can be solved in 5 minutes!!

Page 28: Advances in Pattern Databases

28

Tile Puzzles

• Storing PDBs for the tile puzzle• (Simple mapping) A multi dimensional array A[16][16][16][16][16] size=1.04Mb• (Packed mapping) One dimensional array

A[16*15*14*13*12 ] size = 0.52Mb.• Time versus memory tradeoff !!

A B C D

A B C D

A B D C

Goal StateClique

Page 29: Advances in Pattern Databases

29

15 puzzle results• A clique in the tile puzzle is of size 2. • We compressed the last index by two A[16][16][16][16][8]

PDBTypecompressNodesTimeMemAvg H

1 7-8packedNo136,2880.081576,57544.75

1 +7-8packedNo36,7100.034576,57545.631 7-7-1packedNo464,9770.23257,65743.641 7-7-1simpleNo464,9770.058536,87043.641 7-7-1simpleYes565,8810.069268,43543.022 7-7-1simpleYes147,3360.021536,87043.98

2 +7-7-1simpleYes66,6920.016536,87044.92

Page 30: Advances in Pattern Databases

30

• Dual lookups in pattern databases [Felner et al, IJCAI-04]

Page 31: Advances in Pattern Databases

31

Symmetries in PDBs• Symmetric lookups were already

performed by the first PDB paper of [Culberson & Schaeffer 96]

• examples – Tile puzzles: reflect the tiles about the main diagonal.– Rubik’s cube: rotate the cube

• We can take the maximum among the different lookups

• These are all geometrical symmetries• We suggest a new type of symmetry!!

8

8

7

7

Page 32: Advances in Pattern Databases

32

Regular and dual representation• Regular representation of a problem:• Variables – objects (tiles, cubies etc,)• Values – locations• Dual representation:• Variables – locations• Values – objects

Page 33: Advances in Pattern Databases

33

Regular vs. Dual lookups in PDBs

2 3 6 7

• Regular question: Where are tiles {2,3,6,7} and how

many moves are needed to gather them to their goal locations?

• Dual question: Who are the tiles in locations

{2,3,6,7} and how many moves are needed to distribute them to

their goal locations?

Page 34: Advances in Pattern Databases

34

Regular and dual lookups

• Regular lookup: PDB[8,12,13,14]• Dual lookup: PDB[9,5,12,15]

Page 35: Advances in Pattern Databases

35

Regular and dual in TopSpin

• Regular lookup for C : PDB[1,2,3,7,6]• Dual lookup for C: PDB[1,2,3,8,9]

Page 36: Advances in Pattern Databases

36

Dual lookups

• Dual lookups are possible when there is a symmetry between locations and objects:– Each object is in only one location

and each location occupies only one object.

• Good examples: TopSpin, Rubik’s cube• Bad example: Towers of Hanoi• Problematic example: Tile Puzzles

Page 37: Advances in Pattern Databases

37

Inconsistency of Dual lookups

Example: Top-Spin

c)b,c(=1

Consistency of heuristics: |h(a)-h(b)| <= c(a,b)

Regular Dual

b00c12

• Both lookups for B PDB[1,2,3,4,5]=0• Regular lookup for C

PDB[1,2,3,7,6]=1• Dual lookup for C

PDB[1,2,3,8,9]=2

Page 38: Advances in Pattern Databases

38

Traditional Pathmax• children inherit f-value from their parents if it

makes them larger

g=1h=4f=5

g=2h=2f=4

g=2h=3f=5

Inconsistency

Pathmax

Page 39: Advances in Pattern Databases

39

Bidirectional pathmax (BPMX)

• Bidirectional pathmax: h-values are propagated in both directions decreasing by 1 in each edge.– If the IDA* threshold is 2 then with BPMX

the right child will not even be generated!!

h-values

2

5 1

4

5 3

h-values

BPMX

Page 40: Advances in Pattern Databases

40

Results: (17,4) TopSpin puzzleregulardualBPMXnodestime

10----40,019,42967.7601no7,618,80515.7201yes1,397,6142.9344yes82,6060.94

1717yes27,5751.34

• Nodes improvement (17r+17d) : 1451• Time improvement (4r+4d) : 72• We also solved the (20,4) TopSpin version.

Page 41: Advances in Pattern Databases

41

Results: Rubik’s cube

regulardualBPMXnodestime10----90,930,66228.1801no19,653,3867.3801yes8,315,1163.2444yes615,5630.51

2424yes362,9270.90• Nodes improvement (24r+24d) : 250• Time improvement (4r+4d) : 55

• Data on 1000 states with 14 random moves• PDB of 7-edges cubies

Page 42: Advances in Pattern Databases

42

Results: Rubik’s cube

• With duals we improved Korf’s results on random instances by a factor of 1.5 using exactly the same PDBs.

Page 43: Advances in Pattern Databases

43

Results: tile puzzles

HeuristicBPMXValuenodestimeManhattan----36.94401,189,63053.424R----44.75136,2890.081R+R*----45.6336,7100.034R+R*+D+D*yes46.1218,6010.022

• With duals, the time for the 24 puzzle drops from 2 days to 1 day.

Page 44: Advances in Pattern Databases

44

Discussion• Results for the TopSpin and Rubik’s cube

are better than those of the tile puzzles

• Dual PDB lookups and BPMX cutoffs are more effective if each operators changes larger part of the states.

• This is because the identity of the objects being queried in consecutive states are dramatically changed

Page 45: Advances in Pattern Databases

45

Summary

• Dual PDB lookups• BPMX cutoffs for inconsistent heuristics• State of the art solvers.

Page 46: Advances in Pattern Databases

46

Future work• More compression • Duality in search spaces• Which and how many symmetries to use• Other sources of inconsistencies• Better ways for propagating inconsistencies

Page 47: Advances in Pattern Databases

47

Ongoing and future work compressing PDBs

• An item for the PDB of tiles (a,b,c,d) is in the form: <La, Lb, Lc, Ld>=d

• Store the PDBs in a Trie• A PDB of 5 tiles will have a level in the trie

for each tile. The values will be in the leaves of the trie.

• This data-structure will enable flexibility and will save memory as subtrees of the trie can be pruned

Page 48: Advances in Pattern Databases

48

Trie pruninig

2 2 22

2

Simple (lossless) pruning:

Fold leaves with exactly the same values. No data will be lost.

Page 49: Advances in Pattern Databases

49

Trie pruninigIntelligent (lossy)pruning: Fold leaves/subtrees with are correlated to each

other (many option for this!!)Some data will be lost.Admissibility is still kept.

2 2 24

2

Page 50: Advances in Pattern Databases

50

Trie: Initial Results

PDBMDH(s)NodesTimeNodes/secMemSimple36.9441.563,090,4050.65,150,6763,145,728Packed36.94 41.563,090,4053.126988,6131,572,480Trie36.9441.563,090,4052.593 1,191,826765,778

A 5-5-5 partitioning stored in a trie with simple folding

Page 51: Advances in Pattern Databases

51

Neural Networks (NN)• We can feed a PDB into a neural network

engine. Especially, Addition above MD• For each tile we focus on its dx and dy

from its goal position. (i.e. MD)• Linear conflict :• dx1= dx2 = 0 • dy1 > dy2+1• A NN can learn these rules

2 1

dy1 =2

dy2=0

Page 52: Advances in Pattern Databases

52

Neural network• We train the NN by feeding the entire

(or part of the) pattern space.• For example for a pattern of 5 tiles we

have 10 features, 2 for each tile. • During the search, given the locations of

the tiles we look them up in the NN.

Page 53: Advances in Pattern Databases

53

Neural network exampledx4

dy4

dx5

dy5

dx6

dy6

4

Layout for the pattern of the tiles 4, 5 and 6

Page 54: Advances in Pattern Databases

54

Neural Network: problems• We face the problem of overestimating

and will have to bias the results towards underestimating.

• We keep the overestimating values in a separate hash table

• Results are encouraging!!

PDBH(s)NodesTimeMemRegular31.00243,2900.491,572,480Neural Network29.67 454,26269.75 33,611d+472w

Page 55: Advances in Pattern Databases

55

Ongoing and Future Work on Duality

• Definition 1:• Let O be a sequence of operators such

that s O G• We apply O to G and get s^d G O s^d

Page 56: Advances in Pattern Databases

56

Duality continued• Definition 2: For a state S we flip the

roles of variables and objects

Page 57: Advances in Pattern Databases

57

DualityThe two definitions are equivalent!!

Therefore: Copt(S,G) == Copt(S^d,G)

Page 58: Advances in Pattern Databases

58

Duality• We can use heuristics from S^d for S• We can search from both ways.• Dual A* (DA*): An algorithm that searches

and jumps if the heuristic is better. Results in progress.

Page 59: Advances in Pattern Databases

59

Workshop

You are all welcome to the workshop on:”Heuristic Search, Memory-based

Heuristics and Their application” To be held in AAAI-06

See: www.ise.bgu.ac.il/faculty/felner