CSPs: Search and Arc Consistency - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

CSPs: Search and Arc Consistency

Description:

CSPs: Search and Arc Consistency. Computer Science cpsc322, Lecture 12 (Textbook Chpt 4.3-4.5) ... How can we enforce Arc Consistency? ... – PowerPoint PPT presentation

Number of Views:209
Avg rating:3.0/5.0
Slides: 26
Provided by: con81
Category:
Tags: arc | consistency | csps | search

less

Transcript and Presenter's Notes

Title: CSPs: Search and Arc Consistency


1
CSPs Search and Arc Consistency Computer Science
cpsc322, Lecture 12 (Textbook Chpt
4.3-4.5) February, 1, 2008
2
Lecture Overview
  • Recap Search vs. CSPs
  • Generate-and-Test
  • Search
  • Consistency
  • Arc Consistency

3
Recap Search vs. CSPs
  • While search strategies (BFS, MBA, etc.)
  • do not make any assumptions on how states are
    represented
  • require three problem specific routines
  • In CSPs
  • the representation of states conforms to a
    standard pattern
  • goal function can be specified in a generic way
  • Same for heuristics

4
Recap Search vs. CSPs
  • Key advantage of CSP

Standard Representation for States and Goals
Formal structures that can be used to simplify
the solution process (exponential reduction in
complexity)
5
Example Map-Coloring
  • Variables WA, NT, Q, NSW, V, SA, T
  • Domains Di red,green,blue
  • Constraints adjacent regions must have different
    colors
  • e.g., WA ? NT, or
  • (WA,NT) ? (red,green),(red,blue),(green,red),
    (green,blue),(blue,red),(blue,green)

6
Example Map-Coloring
  • Models / Solutions are complete and consistent
    assignments, e.g., WA red, NT green, Q red,
    NSW green, V red,SA blue, T green

7
Lecture Overview
  • Recap
  • Generate-and-Test
  • Search
  • Consistency
  • Arc Consistency

8
Generate-and-Test Algorithm
  • The assignment space of a CSP is the space of
    possible worlds
  • Algorithm
  • Generate possible worlds one at a time from the
    assignment space
  • Test them to see if they violate any constraints
  • This procedure is able to solve any CSP
  • However, the running time is proportional to the
    size of the state space
  • always exponential in the number of variables
  • far too long for many CSPs

9
Lecture Overview
  • Recap
  • Generate-and-Test
  • Search
  • Consistency
  • Arc Consistency

10
CSPs as search problems
  • CSPs can be mapped into search problems
  • nodes assignments of values to a subset of the
    variables
  • neighbours of a node nodes in which values are
    assigned to one additional variable
  • start node the empty assignment (no variables
    assigned values)
  • goal node a node which assigns a value to each
    variable, and satisfies all of the constraints

Note the path to a goal node is not important
11
CSPs as Search Problems
  • What search strategy will work well for a CSP?
  • there's no role for a heuristic function (every
    solution is at depth n if there are n variables
    (WHY?))
  • the tree is always finite and has no cycles, so
    DFS is better than BFS
  • DFS is one way of implementing generate-and-test

12
CSPs as Search Problems
How can we prune the DFS Search tree?
  • once we reach a node that violates one or more
    constraints, we know that a solution cannot exist
    below that point
  • thus we should prune/backtrack rather than
    continuing to search
  • this can yield us exponential savings over
    generate-and-test, though it's still exponential

13
Solving CSPs by DFS Example
  • Problem
  • Variables A,B,C
  • Domains 1, 2, 3, 4
  • Constraints A lt B, B lt C

14
Solving CSPs by DFS Example Efficiency
  • Problem
  • Variables A,B,C
  • Domains 1, 2, 3, 4
  • Constraints A lt B, B lt C

Note the algorithm's efficiency depends on the
order in which variables are expanded
Degree Heuristics
Minimum Remaining Heuristics
A1
A4
A2
A3
C1
C2
C3
C4
C1
C2
C3
C4
C1
C2
C3
C4
C1
C2
C3
C4
15
Summary CSPs as Search Problems
  • Any CSP can be solved by DFS
  • General purpose successor function
  • General purpose heuristics
  • General purpose pruning strategy (based on goal
    definition, i.e., the constraints)

16
Lecture Overview
  • Recap
  • Generate-and-Test Recap
  • Search
  • Consistency
  • Arc Consistency

17
Can we do better than DFS with general heuristics?
  • Key ideas
  • prune the domains as much as possible before
    searching for a solution.

Simple when using constraints involving single
variables (technically enforcing domain
consistency)
Definition A variable is domain consistent if no
value of its domain is ruled impossible by any
unary constraints.
  • Example DB 1, 2, 3, 4 . domain consistent
    if we have the constraint B ? 3.

18
How do we deal with constraints involving
multiple variables?
  • Definition (constraint network)
  • A constraint network is defined by a graph, with
  • one node for every variable
  • one node for every constraint
  • and undirected edges running between variable
    nodes and constraint nodes whenever a given
    variable is involved in a given constraint.

19
Example Constraint Network
  • Recall
  • Variables A,B,C
  • Domains 1, 2, 3, 4
  • Constraints A lt B, B lt C

20
Example Constraint Network for Map-Coloring
  • Variables WA, NT, Q, NSW, V, SA, T
  • Domains Di red,green,blue
  • Constraints adjacent regions must have different
    colors

21
Lecture Overview
  • Recap
  • Generate-and-Test Recap
  • Search
  • Consistency
  • Arc Consistency

22
Arc Consistency
Definition (arc consistency) An arc
is arc consistent if for each value in
there is some value in such
that is satisfied.
23
How can we enforce Arc Consistency?
  • A network is arc consistent if all its arcs are
    arc consistent.
  • If an arc is not arc consistent, all
    values in for which there is no
    corresponding value in may be deleted
    from to make the arc
    consistent.
  • This removal can never rule out any models (do
    you see why?)



Y
X
Xlt Y
1,2,3
2,3,4
  • A network is arc consistent if all its arcs are
    arc consistent.

24
Feedback ? or ?
  • Lectures
  • Slides
  • Assignments
  • AIspace
  • Textbook
  • Course Topics
  • TAs

25
Next class
  • How to make a constraint network arc consistent?
    Arc Consistency Algorithm
Write a Comment
User Comments (0)
About PowerShow.com