Foundations of Constraint Processing - PowerPoint PPT Presentation

About This Presentation
Title:

Foundations of Constraint Processing

Description:

Return: new current variable. 20 September 2004. Backtracking. 13 ... CBJ: data structure. Maintains a conflict set: conf-set. conf-set[i] are first initialized to {0} ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 55
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 2004
  • www.cse.unl.edu/choueiry/F04-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
  • 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
  • Backchecking
  • Backtracking

5
Outline
  • Review of terminology of search
  • Hybrid backtracking algorithms
  • Vanilla BT
  • Improving back steps BJ, CBJ
  • Improving forward step BM, FC
  • 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-domaini, 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
    consistenttrue, return i1
  • 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
  • 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 (positively) 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
1
0
2
1
2
3
  • bj-label same as bt-label, but updates
    max-checki
  • bj-unlabel, same as bt-unlabel but
  • Backtracks to h maxchecki
  • Resets max-checkj ? 0 for j in h1,i

3
h-2
h-1
h-1
h
h
i
0
0
0
21
Example BJ
v0 0
-
v1
Max-check1 0
1
v2
2
1
Max-check2 1
v3
1
V41, fails for V2, mc1
V42, fails for V2, mc1
V42, succeeds
v4
2
1
3
4
Max-check4 3
V51, fails for V1, mc0
V52, fails for V2, mc1
V53, fails for V1
v5
V54, fails for V1
1
2
3
4
5
V55, fails for V1
Max-check5 1
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

Max-check5
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
  • 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,vh) has failed ? it will fail
    again
  • Or, (vik,vh) 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,kmbli,kj
  • 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

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

36
Hybrids of BM
  • mcl can be used to allow BJ with BJ
  • Mixing BJ BM yields BMJ, which avoids redundant
    consistency checking (types ab savings) and
    reduces the number of nodes visited during search
    (by jumping)
  • Mixing BJ CBJ yields BM-CBJ

37
Problem of BM and its hybrids warning
BMJ can perform worst than BM
vm
vm
vm
  • vi backjumps up to vg
  • When reconsidering vh, it will be checked
    against all f, vm?fltg ?
  • BMJ enjoys some of the advantages of BM
  • Phenomenon will worsen with CBJ
  • Problem fixed by Kondrak van Beek 95

vf
vg
vg
vg
vh
vh
vh
vi
vi
vi
Assume mblh m max-checkimax(mcli,x
)g
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
    backcjecking
  • 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 connect to j 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.
  • 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
  • Evaluation of (deterministic) BT search
    algorithms
  • CSP parameters
  • Comparison criteria
  • Theoretical evaluations
  • Empirical evaluations

49
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

50
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 constraints

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

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

53
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)

54
Example MAC vs. FC
  • Reference Sabin Freuder, ECAI94, Bessiere
    Regin, 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 FC MAC
High density 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