Constraints - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Constraints

Description:

Constraints, describing the relationship between the variables. Constraint ... Find a satisfactory outfit. Rock Star Dressing Problem. Variables: shirt, tie pants ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 36
Provided by: NIC53
Category:

less

Transcript and Presenter's Notes

Title: Constraints


1
Constraints
  • COMP4418 Lecture 2

2
Constraint Models
  • In constraint programming, we express the problem
    using
  • Variables, representing unknowns and parameters
  • Constraints, describing the relationship between
    the variables

3
Constraint
  • A constraint consists of
  • a list of n variables
  • a relation with n columns

4
Constraint
  • A constraint consists of
  • a list of n variables
  • a relation with n columns
  • Relation can be defined
  • implicitly
  • X Y 5

5
Constraint
  • A constraint consists of
  • a list of n variables
  • a relation with n columns
  • Relation can be defined (X, Y)
  • implicitly or explicitly
  • X Y 5

6
Constraint Models
  • A constraint model is
  • a conjunctive set of constraints

7
Constraint Models
  • A constraint model is
  • a conjunctive set of constraints
  • a program that generates conjunctions of
    constraints

8
Constraint Models
  • A constraint model is
  • a conjunctive set of constraints
  • a program that generates conjunctions of
    constraints
  • (not even limited to conjunctions)

9
Solving Constraint Models
  • Finding a solution
  • Algorithmically
  • Uniform class of constraints
  • Constraint solving
  • Search propagation
  • General purpose, less efficient
  • Constraint satisfaction
  • Both

10
Constraint Solving
  • Given a signature ?
  • naming relevant function and predicate symbols
    and their arities
  • A constraint domain consists of
  • a language
  • describes what formulas are constraints
  • a structure
  • defines the set of values
  • defines the meaning of function and predicate
    symbols as functions and relations

11
Constraint Solving
  • Linear arithmetic constraints over the real
    numbers
  • ? , -, , lt, ?, 0, 1, 2, , -1, -2,
  • Terms are constructed by , -, and numerals
  • Primitive constraints
  • term term, term lt term, term ? term
  • Constraints are conjunctions of primitive
    constraints

12
Constraint Solving
  • Linear arithmetic constraints over the real
    numbers
  • The structure consists of
  • The set of values R
  • Mapping
  • numerals to the corresponding number
  • to addition
  • - to subtraction
  • , lt, ? to equality, less-than, less-than-or-equal

13
Constraint Solving
  • Linear equations over the real/rational numbers
  • Gauss, Gauss-Jordan algorithms
  • Equations over Herbrand terms
  • Unification algorithm
  • Linear equations and inequalities over the
    real/rational numbers
  • Simplex algorithm, interior point algorithms
  • Polynomial equations and inequalities over the
    real numbers
  • Collins method

14
Constraint Solving
  • Transcendental equations and inequalities over
    the real numbers
  • undecidable
  • Linear equations and inequalities over the
    integers
  • NP-complete
  • Polynomial equations and inequalities over the
    integers
  • undecidable

15
Constraint Solving
  • Constraints that are easy to solve
  • Bounds on real/rational numbers
  • Bounds on integers
  • Bounds on sets
  • Bounds on multisets/bags
  • Membership of finite sets

16
Constraint Satisfaction Problems
  • CSPs are used to formalize a class of conjunctive
    constraint problems
  • A CSP is a tuple ltV, D, Cgt where
  • V is a set of variables
  • D maps each variable to its domain the set of
    its possible values, usually finite
  • C is a set of constraints

17
Rock Star Dressing Problem
  • A rock star has
  • red, green, orange and blue shirts
  • pink and yellow ties
  • black, khaki, purple and blue pants
  • Fashion sense
  • A yellow tie only goes with red, green or blue
    shirts
  • A pink tie only goes with blue shirts
  • etc
  • Find a satisfactory outfit

18
Rock Star Dressing Problem
  • Variables shirt, tie pants
  • Domains
  • D(shirt) red, green, orange, blue
  • D(tie) pink, yellow
  • D(pants) black, khaki, purple, blue
  • There are three constraints, specifying the
    colours of pairs of items of clothing that are
    compatible

19
Rock Star Dressing Problem
  • Constraints
  • C1 C2
    C3
  • C1(P,S), C2(S,T), C3(T,P)

20
Binary CSPs
  • A binary CSP is one where all relations involve 2
    variables (or fewer)
  • Binary CSPs can be represented as graphs

21
Rock Star Dressing Problem
blue black purple khaki
red green orange blue
C1
C2
C3
yellow pink
22
Rock Star Dressing Problem
blue black purple khaki
red green orange blue
C
C
C
yellow pink
Equivalent formulation using only one relation
23
Binary CSPs
  • Binary CSPs are universal
  • Every CSP can be encoded as a binary CSP
  • Variables range over tuples in constraints of
    original CSP
  • Constraints permit only tuples that are
    compatible in original CSP

24
CSP Satisfiability
  • The satisfiability problems for CSPs is
    NP-complete
  • In NP because a solution is a PTIME checkable
    certificate
  • NP-hard by reduction from 3SAT
  • 8 primitive constraints, corresponding to 8
    3-clauses
  • All domains are 0, 1

25
CSP Satisfiability
Rpnn
  • X ? ?Y ? ?Z
  • Bool var 0/1 var
  • clause constraint
  • SAT problem CSP

26
Binary CSPs
  • Binary CSPs are universal
  • Every CSP can be encoded as a binary CSP
  • Variables range over tuples in constraints of
    original CSP
  • Constraints permit only tuples that are
    compatible in original CSP

27
Binary CSPs
  • A binary CSP is arc-consistent if
  • for every variable x in V,
  • and every constraint c(x, y) involving x,
  • for every value d in D(x)
  • there is a value d' in D(y)
  • such that c(d, d') is true ?
  • (equivalently, the tuple (d, d') is in c)
  • d is called a support for d

28
Binary CSPs
  • If a CSP is arc-consistent, then
  • all the information about possible variable
    values (i.e. domains)
  • that can be extracted from the constraints
    (looked at one-at-a-time)
  • is represented in the domains
  • Sometimes called domain consistency
  • By making a CSP arc-consistent, we simplify the
    problem, without losing solutions

29
Binary CSPs
  • We can make a CSP arc consistent by deleting all
    domain values that do not have a support
  • these are values that cannot participate in a
    solution
  • By making a CSP arc-consistent, we simplify the
    problem, without losing solutions
  • For table constraints, arc-consistency can be
    enforced in O(nD2)
  • n constraints
  • maximum domain size D

30
Rock Star Dressing Problem
blue black purple khaki
red green orange blue
C1
C2
C3
yellow pink
31
Rock Star Dressing Problem
blue black purple khaki
red green orange blue
C1
C2
C3
yellow pink
32
Rock Star Dressing Problem
blue black purple khaki
red green orange blue
C1
C2
C3
yellow pink
33
Generalized Arc Consistency
  • A CSP is generalized arc-consistent if
  • for every variable x in V,
  • and every constraint c(x, y1, , yn),
  • for every value d in D(x)
  • there are values d1dn in D(y1), , D(yn)
  • such that c(d, d1dn) is true ?
  • (equivalently, the tuple (d, d1dn) is in c)
  • Complexity O(nDk) for constraints of arity k

34
(No Transcript)
35
Rock Star Dressing Problem
blue black purple khaki
red green orange blue
C1
C2
C3
yellow pink
Write a Comment
User Comments (0)
About PowerShow.com