Foundations of Constraint Processing - PowerPoint PPT Presentation

About This Presentation
Title:

Foundations of Constraint Processing

Description:

September 11, 2005. Backtracking. 1. Foundations of Constraint Processing, Fall 2005 ... is wrong, we suffer from thrashing (exploring barren' parts of solution space) ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 63
Provided by: chou1
Learn more at: http://cse.unl.edu
Category:

less

Transcript and Presenter's Notes

Title: Foundations of Constraint Processing


1
Intelligent Backtracking Algorithms
  • Foundations of Constraint Processing
  • CSCE421/821, Fall 2005
  • www.cse.unl.edu/choueiry/F05-421-821/
  • Berthe Y. Choueiry (Shu-we-ri)
  • Avery Hall, Room 123B
  • choueiry_at_cse.unl.edu
  • Tel 1(402)472-5444

2
Reading
  • Required reading
  • Hybrid Algorithms for the Constraint Satisfaction
    Problem Prosser, CI 93
  • Recommended reading
  • Chapters 5 and 6 of Dechters book
  • Tsang, Chapter 5
  • Notes available upon demand
  • Notes of Fahiem Bacchus Chapter 2, Section 2.4
  • Handout 4 and 5 of Pandu Nayak (Stanford)

3
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Looking ahead
  • Evaluation of (deterministic) BT search algorithms

4
Backtrack search (BT)
  • Variable/value ordering
  • Variable instantiation
  • (Current) path
  • Current variable
  • Past variables
  • Future variables
  • Shallow/deep levels /nodes
  • Search space / search tree
  • Back-checking
  • Backtracking

5
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Vanilla BT
  • Improving back steps BJ, CBJ
  • Improving forward step BM, FC
  • Looking ahead
  • Evaluation of (deterministic) BT search algorithms

6
Two main mechanisms in BT
  • Backtracking
  • To recover from dead-ends
  • To go back
  • Consistency checking
  • To expand consistent paths
  • To move forward

7
Backtracking
  • To recover from dead-ends
  • Chronological (BT)
  • Intelligent
  • Backjumping (BJ)
  • Conflict directed backjumping (CBJ)
  • With learning algorithms (Dechter Chapt 6.4)
  • Etc.

8
Consistency checking
  • To expand consistent paths
  • Back-checking against past variables
  • Backmarking (BM)
  • Look-ahead against future variables
  • Forward checking (FC) (partial look-ahead)
  • Directional Arc-Consistency (DAC) (partial
    look-ahead)
  • Maintaining Arc-Consistency (MAC) (full
    look-ahead)

9
Hybrid algorithms
  • Backtracking checking new hybrids

BT BJ CBJ
BM BMJ BM-CBJ
FC FC-BJ FC-CBJ
  • Evaluation
  • Empirical Prosser 93. 450 instances of Zebra
  • Theoretical Kondrak Van Beek 95

10
Notations (in Prossers paper)
  • Variables Vi, i in 1, n
  • Domain Di vi1, vi2, ,viMi
  • Constraint between Vi and Vj Ci,j
  • Constraint graph G
  • Arcs of G Arc(G)
  • Instantiation order (static or dynamic)
  • Language primitives list, push, pushnew, remove,
    set-difference, union, max-list

11
Main data structures
  • v a (1xn) array to store assignments
  • vi gives the value assigned to ith variable
  • v0 pseudo variable (root of tree),
    backtracking to v0 indicates insolvability
  • domaini a (1xn) array to store the original
    domains of variables
  • current-domaini a (1xn) array to store the
    current domains of variables
  • Upon backtracking, current-domaini of future
    variables must be refreshed
  • check(i,j) a function that checks whether the
    values assigned to vi and vj are consistent

12
Generic search bcssp
  • Procedure bcssp (n, status)
  • Begin
  • consistent ? true
  • status ? unknown
  • i ? 1
  • While status unknown
  • Do Begin
  • If consistent
  • Then i ? label (i, consistent)
  • Else i ? unlabel (i, consistent)
  • If i gt n
  • Then status ? solution
  • Else If i0 then status ? impossible
  • End
  • End
  • Forward move x-label
  • Backward move x-unlabel
  • Parameters current variable, Boolean
  • Return new current variable

13
Chronological backtracking (BT)
  • Uses bt-label and bt-unlabel
  • When vi is assigned a value from
    current-domaini, we perform back-checking
    against past variables (check(i,k))
  • If back-checking succeeds, bt-label returns i1
  • If back-checking fails, we remove the assigned
    value from current-domaini, assign the next
    value in current-domaini, etc.
  • If no other value exists, vi-1 is
    un-instantiated and we seek a new value for it
    (notation in general vh)
  • For all future variables j current-domainj
    domainj
  • For all past variables g current-domaing ?
    domaing

14
BT-label
  • Function bt-label(i,consistent) INTEGER
  • BEGIN
  • consistent ? false
  • For vi ? each element of current-domaini
    while not consistent
  • Do Begin
  • consistent ? true
  • For h ? 1 to (i-1) While consistent
  • Do consistent ? check(i,h)
  • If not consistent
  • Then current-domaini ? remove(vi,
    current-domaini)
  • End
  • If consistent then return(i1) ELSE return(i)
  • END
  • Terminates
  • consistenttrue, return i1
  • consistentfalse, current-domaininil, returns i

15
BT-unlabel
  • FUNCTION bt-unlabel(i,consistent)INTEGER
  • BEGIN
  • h ? i -1
  • current-domaini ?domaini
  • current-domainh ?remove(vh,current-domainh)
  • consistent ? current-domainh ? nil
  • return(h)
  • END
  • Is called when consistentfalse and
    current-domaininil
  • Selects vh to backtrack to
  • Uninstantiates all variables between vh and vi
  • Removes vh from current-domain h
  • Sets consistent to true if current-domainh ? 0
  • Returns h

16
Example BT (the dumbest example ever)
v0
-
1,2,3,4,5
V1
v1
1
1,2,3,4,5
v2
V2
1
1,2,3,4,5
V3
v3
1
CV3,V4(V31,V43)
1,2,3,4,5
etc
V4
v4
2
1
3
4
CV2,V5(V25,V51),(V25,V54)
1,2,3,4,5
V5
v5
1
2
3
4
5
17
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Vanilla BT
  • Improving back steps BJ, CBJ
  • Improving forward step BM, FC
  • Looking ahead
  • Evaluation of (deterministic) BT search algorithms

18
Danger of BT thrashing
  • BT assumes that the instantiation of vi was
    prevented by a bad choice at (i-1).
  • It tries to change the assignment of vi-1
  • When this assumption is wrong, we suffer from
    thrashing (exploring barren parts of solution
    space)
  • Backjumping (BT) tries to avoid that
  • Jumps to the reason of failure
  • Then proceeds as BT

19
Backjumping (BJ)
  • Tries to reduce thrashing by saving some
    backtracking effort
  • When vi is instantiated, BJ remembers vh, the
    deepest node of past variables that vi has
    checked against.
  • Uses max-checki, global, initialized to 0
  • At level i, when check(i,h) succeeds
  • max-checki ?max(max-checki, h)
  • If current-domainh is getting empty, simple
    chronological backtracking is performed from h
  • BJ jumps then steps!

1
0
2
1
2
3
3
h-2
h-1
h-1
h
h
i
0
0
Past variable
0
Current variable
20
BJ label/unlabel
  • bj-label same as bt-label, but updates
    max-checki
  • bj-unlabel, same as bt-unlabel but
  • Backtracks to h max-checki
  • Resets max-checkj ? 0 for j in h1,i
  • ? Important max-check is the deepest level we
    checked against, could have been success or could
    have been failure

21
Example BJ
v0 0
-
v1
Max-check1 0
1
v2
2
1
Max-check2 1
v3
1
V41, fails for V2, mc2
V42, fails for V2, mc2
V43, succeeds
v4
2
1
3
4
max-check4 3
V51, fails for V1, mc1
V52, fails for V2, mc2
V53, fails for V1
v5
V54, fails for V1
1
2
3
4
5
V55, fails for V1
max-check5 2
22
Conflict-directed backjumping (CBJ)
  • Backjumping
  • jumps from vi to vh,
  • but then, it steps back from vh to vh-1 ?
  • CBJ improves on BJ
  • Jumps from vi to vh
  • And jumps back again, across conflicts involving
    both vi and vh
  • To maintain completeness, we jump back to the
    level of deepest conflict

23
CBJ data structure
conf-set
0
1
2
  • Maintains a conflict set conf-set
  • conf-seti are first initialized to 0
  • At any point, conf-seti is a subset of past
    variables that are in conflict with i

g
0
conf-setg
h-1
0
conf-seth
h
0
conf-seti
i
0 0 0
24
CBJ conflict-set
  • When a check(i,h) fails
  • conf-seti ? conf-seti ?h
  • When current-domaini empty
  • Jumps to deepest past variable
  • h in conf-seti
  • Updates
  • conf-seth ? conf-seth ? (conf-seti \h)
  • Primitive form of learning (while searching)

25
Example CBJ
26
Backtracking summary
  • Chronological backtracking
  • Steps back to previous level
  • No extra data structures required
  • Backjumping
  • Jumps to deepest checked-against variable, then
    steps back
  • Uses array of integers max-checki
  • Conflict-directed backjumping
  • Jumps across deepest conflicting variables
  • Uses array of sets conf-seti

27
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Vanilla BT
  • Improving back steps BJ, CBJ
  • Improving forward step BM, FC
  • Looking ahead
  • Evaluation of (deterministic) BT search algorithms

28
Backmarking goal
  • Tries to reduce amount of consistency checking
  • Situation
  • vi about to be re-assigned k
  • vi ? k was checked against vh?g
  • vh has not been modified

vh g
vi
k
29
BM motivation
  • Two situations
  • Either (vik,vhg) has failed ? it will fail
    again
  • Or, (vik,vhg) was founded consistent ? it
    will remain consistent
  • In either case, back-checking effort against vh
    can be saved!

30
Data structures for BM 2 arrays
  • maximum checking level mcl (n x m)
  • Minimum backup level mbl (n x 1)

31
Maximum checking level
  • mcli,k stores the deepest variable that vi?k
    checked against
  • mcli,k is a finer version of max-checki

32
Minimum backup level
  • mbli gives the shallowest past variable whose
    value has changed since vi was the current
    variable
  • BM (and all its hybrid) do not allow dynamic
    variable ordering

33
When mcli,kmblij
  • BM is aware that
  • The deepest variable that (vi ?k) checked
    against is vj
  • Values of variables in the past of vj (hltj)
    have not changed
  • So
  • We do need to check (vi ?k) against the values
    of the variables between vj and vi
  • We do not need to check (vi ?k) against the
    values of the variables in the past of vj

vj
vi
k
mbli j
34
Type a savings
When mcli,k lt mbli, do not check vi ? k
because it will fail
35
Type b savings
  • When mcli,k ? mbli, do not check (i,hltj)
    because they will succeed

h
vj
vg
vi
k
mcli,k?mbli
mcli,kg mbli j
36
Hybrids of BM
  • mcl can be used to allow backjumping in BJ
  • Mixing BJ BM yields BMJ
  • avoids redundant consistency checking (types ab
    savings) and
  • reduces the number of nodes visited during search
    (by jumping)
  • Mixing BM CBJ yields BM-CBJ

37
Problem of BM and its hybrids warning
BMJ enjoys only some of the advantages of
BM Assume mblh m and max-checkimax(mcli
,x)g
  • Backjumping from vi
  • vi backjumps up to vg
  • Backmarking of vh
  • When reconsidering vh, vh will be checked
    against all f in m,g(
  • effort could be saved ?
  • Phenomenon will worsen with CBJ
  • Problem fixed by Kondrak van Beek 95

vm
vm
vf
vg
vh
vi
38
Forward checking (FC)
  • Looking ahead from current variable, consider
    all future variables and clear from their domains
    the values that are not consistent with current
    partial solution
  • FC makes more work at every instantiation, but
    will expand fewer nodes
  • When FC moves forward, the values in
    current-domain of future variables are all
    compatible with past assignment, thus saving
    backchecking
  • FC may wipe out the domain of a future variable
    (aka, domain annihilation) and thus discover
    conflicts early on. FC then backtracks
    chronologically
  • Goal of FC is to fail early (avoid expanding
    fruitless subtrees)

39
FC data structures
  • When vi is instantiated, current-domainj are
    filtered for all j connected to i and iltjltn
  • reductionj store sets of values remove from
    current-domainj by some variable before vj
  • reductionsj a, b, c, d, e, f, g, h
  • future-fci subset of the future variables that
    vi checks against (redundant)
  • future-fci k, j, n
  • past-fci past variables that checked against
    vj
  • All these sets are treated like stacks

40
Forward Checking functions
  • check-forward
  • undo-reductions
  • update-current-domain
  • fc-label
  • fc-unlabel

41
FC functions
  • check-forward(i,j) is called when instantiating
    vi
  • It performs REVISE(j,i)
  • Returns false if current-domainj is empty, true
    otherwise
  • Values removed from current-domainj are pushed,
    as a set, into reductionsj
  • These values will be popped back if we have to
    backtrack over vi (undo-reductions)

42
FC functions
  • update-current-domain
  • current-domaini ? domaini \ reductionsi
  • actually, we have to iterate over reductionsset
    of sets
  • fc-label
  • Attempts to instantiate current-variable
  • Then filters domains of all future variables
    (push into reductions)
  • Whenever current-domain of a future variable is
    wiped-out
  • vi is un-instantiated and
  • domain filtering is undone (pop reductions)

43
Hybrids of FC
  • FC suffers from thrashing it is based on BT
  • FC-BJ
  • max-check is integrated in fc-bj-label and
    fc-bj-unlabel
  • Enjoys advantages of FC and BJ but suffers
    malady of BJ (jump the step)
  • FC-CBJ
  • Best algorithm for far (assuming static variable
    ordering)
  • fc-cbj-label and fc-cbj-unlabel

44
Consistency checking summary
  • Chronological backtracking
  • Uses back-checking
  • No extra data structures
  • Backmarking
  • Uses mcl and mbl
  • Two types of consistency-checking savings
  • Forward-checking
  • Works more at every instantiation, but expands
    fewer subtrees
  • Uses reductionsi, future-fci, past-fci

45
Experiments
  • Empirical evaluations on Zebra
  • Representative of design/scheduling problems
  • 25 variables, 122 binary constraints
  • Permutation of variable ordering yields new
    search spaces
  • Variable ordering different bandwidth/induced
    width of graph
  • 450 problem instances were generated
  • Each algorithm was applied to each instance
  • Experiments were carried out under static
    variable ordering

46
Analysis of experiments
  • Algorithms compared with respect to
  • Number of consistency checks (average)
  • FC-CBJ lt FC-BJ lt BM-CBJ lt FC lt CBJ lt BMJ lt BM lt
    BJ lt BT
  • Number of nodes visited (average)
  • FC-CBJ lt FC-BJ lt FC lt BM-CBJ lt BMJ BJ lt BM BT
  • CPU time (average)
  • FC-CBJ lt FC-BJ lt FC lt BM-CBJ lt CBJ lt BMJ lt BJ lt
    BT lt BM
  • FC-CBJ apparently the champion

47
Additional developments
  • Other backtracking algorithms exist
  • Graph-based backjumping (GBJ), etc. Dechter
  • Pseudo-trees Freuder 85
  • Other look-ahead techniques exist
  • DAC, MAC, etc.
  • More empirical evaluations
  • over randomly generated problems
  • Theoretical evaluations
  • Based on approach of Kondrak Van Beek IJCAI95

48
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Looking ahead
  • Forward checking (FC)
  • Directional Arc Consistency (DAC)
  • Maintaining Arc Consistency (a.k.a. full
    arc-consistency)
  • Evaluation of (deterministic) BT search algorithms

49
Looking ahead
  • Rationale
  • As decisions are made (conditioning),
  • Revise the domain of future variables to
    propagate the effects of decisions
  • I.e., eliminate inconsistent choices in future
    sub-problem
  • Domain annihilation of a future variable avoids
    expansion of useless portions of the tree
  • Techniques
  • Partial forward-checking (FC), directional
    arc-consistency (DAC)
  • Full Maintaining arc-consistency (MAC)
  • Use Revise(Vf, Vc), Vf future variable, Vc
    current variable

50
Revising the domain of Vi
  • Revising the domain of Vi given a constraint C on
    Vi (i.e., Vi ? Scope(C))
  • General notation Revise(Vi,C)
  • In a binary CSP
  • Revise(Vi,C)
  • Revise(Vi,CVi,Vj)
  • Revise(Vi, Vj)

51
Revise(Vi, Vj)
  • Revise(Vi, Vj)
  • ? x ? DVi
  • ? y ? DVj
  • If ? y ? DVj with (x,y) ? C return()
  • ElseIf DVi ? DVi \ x
  • NOTE only DVi may be updated

52
Domain filtering in lookahead
  • Vc current variable
  • Vf future variable
  • Vf all future variables
  • Revise(Vf, Vc)
  • FC(Vc)
  • ? Vf ? Vf connected to Vc
  • Revise(Vf,Vc)
  • If DVf then return(failure)

53
Look-ahead techniques FC, DAC, MAC
  • FC
  • DAC
  • assumes a fixed variable ordering d
  • MAC
  • does more pruning at the cost of more consistency
    checks

FC(Vc)
FC(Vc) ? Vf ? Vf, FC(Vf) in the ordering d
FC(Vc) AC(Vf)
FC(Vc) Repeat until quiescence or failure
? Vf1,Vf2 ? Vf, Revise(Vf1,Vf2)
54
Terminology overload alert FC
  • FC is used to denote any of the following
  • a partial look-ahead schema
  • a specific chronological backtrack search
    algorithm that uses the partial look-ahead schema
  • Meaning is inferred from context
  • Not a healthy situation, but a reality
  • Advice state upfront the meaning of your terms
    and stick to them throughout your paper

55
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Looking ahead
  • Evaluation of (deterministic) BT search
    algorithms Dechter, 6.6.2
  • CSP parameters
  • Comparison criteria
  • Theoretical evaluations
  • Empirical evaluations

56
CSP parameters
  • Number of variables n
  • Domain size a, d
  • Constraint tightness
  • t forbidden tuples / all tuples
  • Proportion of constraints (a.k.a., constraint
    density, constraint probability)
  • p1 e / emax, e is nbr of constraints

57
Comparison criteria
  • Number of nodes visited (NV)
  • Every time you call label
  • Number of constraint check (CC)
  • Every time you call check(i,j)
  • CPU time
  • Be as honest and consistent as possible
  • Some specific criterion for assessing the quality
    of the improvement proposed
  • Presentation of values
  • Average or median of criterion
  • (qualified) run-time distribution
  • Solution-quality distribution

58
Theoretical evaluations
  • Comparing NV and/or CC
  • Common assumptions
  • for finding all solutions
  • static orderings

59
Empirical evaluation data sets
  • Use real-data sets (anecdotal evidence)
  • Use benchmarks (csp library)
  • Use randomly generated problems

60
Empirical evaluations random problems
  • Various models exist (use Model B)
  • Models A, B, C, E, F, etc.
  • Vary parameters ltn, a, t, pgt
  • Number of variables n
  • Domain size a, d
  • Constraint tightness t forbidden tuples /
    all tuples
  • Proportion of constraints (a.k.a., constraint
    density, constraint probability) p1 e / emax
  • Issues
  • Uniformity
  • Difficulty (phase transition)
  • Solvability of instances (for incomplete search
    techniques)

61
Model B
  1. Input n, a, t, p1
  2. Generate n nodes
  3. Generate a list of n2 tuples of all combinations
    of 2 nodes
  4. Choose e elements from above list as constraints
    to between the n nodes
  5. If the graph is not connected, throw away, go
    back to step 4, else proceed
  6. Generate a list of a2 tuples of all combinations
    of 2 values
  7. For each constraint, choose randomly a number of
    tuples from the list to guarantee tightness t for
    the constraint

62
Example MAC vs. FC
  • Reference Sabin Freuder, ECAI94, Bessière
    Régin, CP97, Sabin Freuder, CP97, Gent
    Prosser, APES-20-2000, Experiments by Lin XU,
    2001, Yang, MS thesis 2003
  • Results (sketchy)

Low tightness High tightness
Low density (sparse) FC MAC
High density (dense) FC FC
  • Note results depend on
  • Variable ordering (static vs. dynamic)
  • Problem difficulty (positive relative to
    crossover point)
Write a Comment
User Comments (0)
About PowerShow.com