1 / 25

Backward Checking Search BT, BM, BJ, CBJ

Backward Checking Search BT, BM, BJ, CBJ. An example problem. 1. 2. 3. 4. 5. Colour each of the 5 nodes, such that if they are adjacent, they take different colours. Representation. 1. 2. 3. 4. 5. variables v1, v2, v3, v4, and v5 domains d1, d2, d3, d4, and d5

oren
Download Presentation

Backward Checking Search BT, BM, BJ, CBJ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Backward Checking Search BT, BM, BJ, CBJ

  2. An example problem 1 2 3 4 5 Colour each of the 5 nodes, such that if they are adjacent, they take different colours

  3. Representation 1 2 3 4 5 • variables v1, v2, v3, v4, and v5 • domains d1, d2, d3, d4, and d5 • domains are the three colours {R,B,G} • constraints • v1  v2 • v1  v3 • v2  v3 • v2  v5 • v3  v5 • v4  v5 Assign a value to each variable, from its domain, such that the constraints are satisfied CSP = (V,D,C)

  4. Chronological Backtracking (BT) 1 2 3 4 5 • (0) label(variable:vi) • (1) let consistent := false • (2) assign vi a value x from its domain di • (3) consistent := true • (4) while consistent, check against past variables vh • if inconsistent(vh,vi) then consistent := false • (5) if not consistent • remove x from di • if di is not empty go to (2) • (6) return consistent • (0) unlabel(variable:vi) • (1) restore domain di (set to original value) • (2) let h be i-1 • (3) remove the value of vh from domain dh • (3) if dh is empty • then return false • else return true • (0) BT(integer:i) • (1) if i > N then return(true) • (2) if i = 1 and d_1 is empty then return(false) • (3) if label(v[i]) • then bt(i+1) • else unlabel(v[i]) • bt(i-1)

  5. Three Different Views of Search a trace a tree past, current, future

  6. A Trace of BT (assume domain ordered {R,B,G}) 1 2 3 4 1 1 2 2 5 5 3 3 5 4 4 • V[1] := R • V[2] := R • check(v[1],v[2]) fails • V[2] := B • check(v[1],v[2]) good • V[3] := R • check(v[1],v[3]) fails • V[3] := B • check(v[1],v[3]) good • check(v[2],v[3]) fails • V[3] := G • check(v[1],v[3]) good • check(v[2],v[3]) good • V[4] := R • V[5] := R • check(v[2],v[5]) good • check(v[3],v[5]) good • check(v[4],v[5]) fails • V[5] := B • check(v[2],v[5]) fails • V[5] := G • check(v[2],v[5]) good • check(v[3],v[5]) fails • backtrack! • V[4] := B • V[5] := R • check(v[2],v[5]) good • check(v[3],v[5]) good • check(v[4],v[5]) good • solution found 16 checks and 12 nodes

  7. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 v1 v2 v3 v4 v5 4 5

  8. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 v1 v2 v3 v4 v5 4 5

  9. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 v1 v2 v3 v4 v5 4 5

  10. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 v1 v2 v3 v4 v5 4 5

  11. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 v1 v2 v3 v4 v5 4 5

  12. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 v1 v2 v3 v4 v5 4 5

  13. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  14. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  15. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  16. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  17. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  18. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  19. A Tree Trace of BT (assume domain ordered {R,B,G}) 1 2 3 5 4 v1 v2 v3 v4 v5

  20. 1 v1 2 v2 v3 3 v4 4 v5 5 Another view past variables check back current variable future variables

  21. 1 2 3 4 5 Can you solve this? Try bt1 and/or bt2 with constraints C2 - load(“bt2”) - bt(V,D,C2) this is csp2

  22. 1 2 3 9 4 7 8 5 6 Thrashing? (csp3)

  23. 1 2 3 9 4 7 8 5 6 Thrashing? (csp3) V1 = R v2 = B v3 = G v4 = R v5 = B v6 = R v7 = B v8 = R v9 = conflict The cause of the conflict with v9 is v4, but what will bt do? Find out how it goes with bt3 and csp4

  24. Where’s the code? See clairExamples/bt*.cl and clairExample/csp*.cl

  25. questions • Why measure checks and nodes? • What is a node anyway? • Who cares about checks? • Why instantiate variables in lex order? • Would a different order make a difference? • How many nodes could there be? • How many checks could there be? • Are all csp’s binary? • How can we represent constraints? • Is it reasonable to separate V from D? • Why not have variables with domains • What is a constraint graph? • How can (V,D,C) be a graph?

More Related