Non-Binary Constraint Satisfaction - PowerPoint PPT Presentation

About This Presentation
Title:

Non-Binary Constraint Satisfaction

Description:

Trick is to exploit semantics of constraints. Regin's all-different algorithm ... If we can exploit the constraint semantics to keep it cheap! ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 46
Provided by: TobyW4
Category:

less

Transcript and Presenter's Notes

Title: Non-Binary Constraint Satisfaction


1
Non-Binary Constraint Satisfaction
  • Toby Walsh
  • Cork Constraint Computation Center

2
Overview
  • Introduction to CSPs
  • Local Consistencies, search algorithms
  • Modelling (4 case studies)
  • Auxiliary variables, implied constraints
  • Redundant models and channelling constraints
  • Eliminating non-binary constraints
  • Encodings, decomposition
  • Theoretical properties
  • Tightness, relational consistencies

3
Resources
  • Course links
  • www.cs.york.ac.uk/tw/Links/csps/
  • Benchmark problems
  • www.csplib.org
  • Constraints solvers
  • LP based like ECLIPSE, Java based liked Jsolver,
    open source like Choco,

4
Constraint programming
  • Ongoing dream of declarative programming
  • State the constraints
  • Solver finds a solution
  • Paradigm of choice for many hard combinatorial
    problems
  • Scheduling, assignment, routing,

5
Constraints are everywhere!
  • No meetings before 10am
  • Network traffic lt 100 Gbytes/sec
  • PCB width lt 21cm
  • Salary gt 45k Euros

6
Constraint satisfaction
  • Constraint satisfaction problem (CSP) is a triple
    ltV,D,Cgt where
  • V is set of variables
  • Each X in V has set of values, D_X
  • Usually assume finite domain
  • true,false, red,blue,green, 0,10,
  • C is set of constraints
  • Goal find assignment of values to variables to
    satisfy all the constraints

7
Example CSP
  • Course timetabling
  • Variable for each course
  • X1, X2 ..
  • Domain are possible times for course
  • Wed9am, Fri10am, ..
  • Constraints
  • X1 \ Wed9am
  • Capacity constraints atmost(3,X1,X2..,Wed9am)
  • Lecturer constraints alldifferent(X1,X5,)

8
Constraint optimization
  • CSP objective function
  • E.g. objective is Profit Income - Costs
  • Find assignment of vals to vars that
  • Satisfies constraints
  • Maximizes (minimizes) objective
  • Often solved as sequence of satisfaction problems
  • Profit gt 0, Profit gt Ans1, Profit gt Ans2,

9
Constraint programming v. Constraint logic
programming
  • Constraints declaratively specify problem
  • Logic programming natural approach
  • Assert constraints, call labelling strategy
    (backtracking search predicate)
  • But can also define constraint satisfaction or
    optimization within an imperative of functional
    language
  • Popular toolkits in C, Java, CAML,

10
Constraints
  • Constraints are tuples ltS,Rgt where
  • S is the scope, X1,X2, Xm
  • list of variables to which constraint applies
  • R is relation specifying allowed values (goods)
  • Subset of D_X1 x D_X2 x x D_Xm
  • May be specified intensionally or extensionally

11
Constraints
  • Extensional specification
  • List of goods (or for tight constraints, nogoods)
  • Intensional specification
  • X1 / X2
  • 5X1 6X2 lt X3
  • alldifferent(X1,X2,X3,X4),

12
Constraint tightness
  • Informally, tight constraints admit few tuples
  • E.g. on 0/1 vars
  • X1 / X2 is loose as half tuples satisfy
  • X1X2X3X4X5 lt 1 is tight as only 5 out of 32
    tuples satisfy
  • More formal definition later

13
Binary v non-binary
  • Binary constraint
  • Scope covers 2 variables
  • E.g. not-equals constraint X1 / X2.
  • E.g. ordering constraint X1 lt X2
  • Non-binary constraint
  • Scope covers 3 or more variables
  • E.g. alldifferent(X1,X2,X3).
  • E.g. tour(X1,X2,X3,X4).
  • Non-binary constraints usually do not
    include unary constraints!

14
Constraint graph
  • Nodes variables
  • Edge between 2 nodes iff constraint between 2
    associated variables
  • Few constraints, sparse constraint graph
  • Lots of constraints, dense constraint graph

15
Some non-binary examples
  • Timetabling
  • Variables Lecture1, Lecture2,
  • Values time1, time2,
  • Constraint that lectures taught by same lecturer
    do not conflict
  • alldifferent(Lecture1,Lecture5,).

16
Some non-binary examples
  • Scheduling
  • Variables Job1. Job2,
  • Values machine1, machine2,
  • Constraint on number of jobs on each machine
  • atmost(2,Job1,Job2,,machine1),
  • atmost(1,Job1,Job2,,machine2).

17
Why use non-binary constraints?
  • Binary constraints are NP-complete
  • Any non-binary constraint can be represented
    using binary constraints
  • E.g. alldifferent(X1,X2,X3) is equivalent to X1
    / X2, X1 / X3, X2 / X3
  • In theory therefore theyre not needed
  • But in practice, they are!

18
Modelling with non-binary constraints
  • Benefits include
  • Compact, declarative specifications
  • (discussed next)
  • Efficient constraint propagation
  • (discussed second)

19
Modelling with non-binary constraints
  • Consider writing your own alldifferent
    constraint
  • alldifferent().
  • alldifferent(HeadTail)-
  • onediff(Head,Tail),
  • alldifferent(Tail).
  • onediff(El,).
  • onediff(El,HeadTail)-
  • El \ Head,
  • onediff(El,Tail).

20
Modelling with non-binary constraints
  • Its possible but its not very pleasant!
  • Nor is it very compact
  • alldifferent(X1,Xn) expands into n(n-1)/2
    binary not-equals constraints, Xi \ Xj
  • one non-binary constraint or O(n2) binary
    constraints?
  • And there exist very efficient algorithms
    for reasoning efficiently with many specialized
    non-binary constraints

21
Constraint solvers
  • Two main approaches
  • Systematic, tree search algorithms
  • Local search or repair based procedures
  • Other more exotic possibilities
  • Hybrid algorithms
  • Quantum algorithms

22
Systematic solvers
  • Tree search
  • Assign value to variable
  • Deduce values that must be removed from
    future/unassigned variables
  • Propagation to ensure some level of consistency
  • If future variable has no values, backtrack else
    repeat
  • Number of choices
  • Variable to assign next, value to assign
  • Some important refinements like nogood learning,
    non-chronological backtracking,

23
Local search
  • Repair based methods
  • Generate complete assignment
  • Change value to some variable in a violated
    constraint
  • Number of choices
  • Violated constraint, variable within it,
  • Unable to exploit powerful constraint propagation
    techniques

24
Constraint propagation
  • Arc-consistency (AC)
  • A binary constraint r(X1,X2) is AC iff
  • for every value for X1, there is a consistent
    value (often called support) for X2 and vice
    versa
  • A problem is AC iff every constraint is AC

25
Enforcing arc-consistency
  • Remove all values that are not AC
  • (i.e. have no support)
  • May remove support from other values
  • (often queue based algorithm)
  • Best AC algorithms (AC7, AC-2000) run in O(ed2)
  • Optimal if we know nothing else about the
    constraints

26
Enforcing arc-consistency
  • X2 \ X3 is AC
  • X1 \ X2 is not AC
  • X21 has no support so can this value can be
    pruned
  • X2 \ X3 is now not AC
  • No support for X32
  • This value can also be pruned
  • Problem is now AC

1
X1
\
1,2
2,3
\
X3
X2
27
Properties of AC
  • Unique maximal AC subproblem
  • Or problem is unsatisfiable
  • Enforcing AC can process constraints in any order
  • But order does affect (average-case) efficiency

28
Non-binary constraint propagation
  • Most popular is generalized arc-consistency (GAC)
  • A non-binary constraint is GAC iff for every
    value for a variable there are consistent values
    for all other variables in the constraint
  • We can again prune values that are not supported
  • GAC AC on binary constraints

29
GAC on alldifferent
  • alldifferent(X1,X2,X3)
  • Constraint is not GAC
  • X12 cannot be extended
  • X2 would have to be 3
  • No value left then for X3
  • X11 is GAC

X1
  • 1,2

2,3
2,3
X2
X3
30
Enforcing GAC
  • Enforcing GAC is expensive in general
  • GAC schema is O(dk)
  • On k-ary constraint on vars with domains of size
    d
  • Trick is to exploit semantics of constraints
  • Regins all-different algorithm
  • Achieves GAC in just O(k2 d2)
  • On k-ary all different constraint with domains of
    size d
  • Based on finding matching in value graph

31
Other types of constraint propagation
  • (i,j)-consistency due to Freuder, JACM 85
  • Non-empty domains
  • Any consistent instantiation for i variables can
    be extended to j others
  • Describes many different consistency techniques

32
(i,j)-consistency
  • Generalization of arc-consistency
  • AC (1,1)-consistency
  • Path-consistency (2,1)-consistency
  • Strong path-consistency AC PC
  • Path inverse consistency (1,2)-consistency

33
Enforcing (i,j)-consistency
  • problem is (1,1)-consistent (AC)
  • BUT is not (2,1)-consistent (PC)
  • X12, X23 cannot be extended to X3
  • Need to add constraints
  • not(X12 X23)
  • not(X12 X33)
  • Nor is it (1,2)-consistent (PIC)
  • X12 cannot be extended to X2 X3 (so needs to
    be deleted)

1,2
X1
\
\
2,3
2,3
\
X3
X2
34
Other types of constraint propagation
  • Singleton arc-consistency (SAC)
  • Problem resulting from instantiating any variable
    can be made AC
  • Restricted path-consistency (RPC)
  • AC if a value has just one support then any
    third variable has a consistent value

35
Other types of consistency
  • problem is (1,1)-consistent (AC)
  • BUT is not singleton AC (SAC)
  • Problem with X12 cannot be made AC (so value
    should be deleted)
  • Nor is it restricted PC (RPC)
  • X12 has only one support in X2 (the value 3) but
    X3 then has no consistent values
  • X12 can therefore be deleted

1,2
X1
\
\
2,3
2,3
\
X3
X2
36
Other types of constraint propagation
  • Neighbourhood inverse consistency (NIC)
  • For all vals for a var, there are consistent vals
    for all vars in the immediate neighbourhood
  • Bounds consistency (BC)
  • With ordered domains
  • Enforce AC just on max/min elements

37
Comparing local consistencies
  • Formal definition of tightness introduced by
    Debruyne Bessiere IJCAI-97
  • A-consistency is tighter than B-consistency iff
  • If a problem is A-consistent -gt it is
    B-consistent
  • We write A gt B

38
Properties
  • Partial ordering
  • reflexive A ? A
  • transitive A ? B B ? C implies A ? C
  • Defined relations
  • tighter A gt B iff A ? B not B ?
    A
  • incomparable A _at_ B iff neither A ? B

  • nor B ? A

39
Comparison of consistency techniques
  • Exercise for the reader, prove the following
    identities!
  • Strong PC gt SAC gt PIC gt RPC gt AC gt BC
  • NIC gt PIC
  • NIC _at_ SAC
  • NIC _at_ Strong PC
  • NB gaps can reduce search exponentially!

40
Which to choose?
  • For binary constraints, AC is often chosen
  • Space efficient
  • Just prune domains (cf PC)
  • Time efficient
  • For non-binary constraints GAC is often chosen
  • If we can exploit the constraint semantics to
    keep it cheap!

41
Why consider these other consistencies?
  • Promising experimental results
  • Useful pruning for their additional cost
  • Theoretical value
  • E.g. GAC on non-binary constraints may exceed SAC
    on equivalent binary model

42
Maintaining a local consistency property
  • Tree search
  • Assign value to variable
  • Enforce some level of local consistency
  • Remove values/add new constraints
  • If any future variable has no values, backtrack
    else repeat
  • Two popular algorithms
  • Maintaining arc-consistency (MAC)
  • Forward checking (very restricted form of AC
    maintained)

43
Forward checking
  • Binary constraints (FC)
  • Make constraints involving current variable and
    one future variable arc-consistent
  • No need to look at any other constraints!
  • Non-binary constraints
  • Several choices as to how to do forward checking

44
Forward checking with non-binary constraints
  • nFC0 makes AC only those k-ary constraints with
    k-1 variables set
  • nFC1 applies one pass of AC on constraints and
    projections involving current var and one future
    var
  • nFC2 applies one pass of GAC on constraints
    involving current var and at least one future var
  • nFC3 enforces GAC on this set
  • nFC4 applies one pass of GAC on constraints
    involving at least one past and one future var
  • nFC5 enforces GAC on this set

45
Summary
  • Constraint solving
  • Constraint propagation central part of many
    algorithms
  • Binary v non-binary constraints
  • Compact, more efficient representation
Write a Comment
User Comments (0)
About PowerShow.com