70
Computer Science CPSC 502 Lecture 3 Constraint Satisfaction Problems (Ch. 4 )

Computer Science CPSC 502 Lecture 3 Constraint Satisfaction Problems (Ch. 4 )

Embed Size (px)

Citation preview

Computer Science CPSC 502

Lecture 3

Constraint Satisfaction Problems

(Ch. 4 )

2

Lecture Overview

• Finish Search• Constraint Satisfaction Problems

• Variables/Features • Constraints• CSPs• Generate-and-Test• Search • Arc Consistency

Course OverviewEnvironment

Problem Type

Query

Planning

Deterministic Stochastic

Constraint Satisfaction Search

Arc Consistency

Search

Search

Logics

STRIPS

Vars + Constraints

Value Iteration

Variable

Elimination

Belief Nets

Decision Nets

Markov Processes

Static

Sequential

Representation

ReasoningTechnique

Variable

Elimination

First Part of the Course

Standard Search vs. CSP

• First studied general state space search in isolation• Standard search problem: search in a state space

• State is a “black box” - any arbitrary data structure that supports three problem-specific routines: • goal test: goal(state)• finding successor nodes: neighbors(state)• if applicable, heuristic evaluation function: h(state)

• We’ll see more specialized versions of search for various problems

4

• Constraint Satisfaction Problems (CPS):• State• Successor function• Goal test• Solution• Heuristic function

• Query : • State• Successor function• Goal test• Solution• Heuristic function

• Planning• State• Successor function• Goal test• Solution• Heuristic function

Search in Specific R&R Systems

Course OverviewEnvironment

Problem Type

Query

Planning

Deterministic Stochastic

Constraint Satisfaction Search

Arc Consistency

Search

Search

Logics

STRIPS

Vars + Constraints

Value Iteration

Variable

Elimination

Belief Nets

Decision Nets

Markov Processes

Static

Sequential

Representation

ReasoningTechnique

Variable

Elimination

We’ll start from CPS

Slide 7

CSPs: Crossword Puzzles - Proverb

Source: Michael Littman

Slide 8

CSPs: Radio link frequency assignment

Source: INRIA

Assigning frequencies to a set of radio links defined between pairs of sites in order to avoid interferences.

Constraints on frequency depend on position of the links and on physical environment .

Sample Constraint network

Constraint Satisfaction Problems (CSP)

• In a CSP

– state is defined by a set of variables Vi with values from

domain Di

– goal test is a set of constraints specifying

1. allowable combinations of values for subsets of variables (hard

constraints)

2. preferences over values of variables (soft constraints)

Dimensions of Representational Complexity(from lecture 2)

• Reasoning tasks (Constraint Satisfaction / Logic&Probabilistic Inference / Planning)

• Deterministic versus stochastic domainsSome other important dimensions of complexity:• Explicit state or features or relations• Flat or hierarchical representation• Knowledge given versus knowledge learned from experience• Goals versus complex preferences• Single-agent vs. multi-agent

• Explicit state or features or relations

Variables/Features and Possible Worlds• Variable: a synonym for feature

• We denote variables using capital letters• Each variable V has a domain dom(V) of possible values

• Variables can be of several main kinds:• Boolean: |dom(V)| = 2• Finite: the domain contains a finite number of values• Infinite but discrete: the domain is countably infinite• Continuous: e.g., real numbers between 0 and 1

• Possible world: complete assignment of values to each variable• This is equivalent to a state as we have defined it so far• Soon, however, we will give a broader definition of state, so it is best to

start distinguishing the two concepts.

Example (lecture 2)

Mars Explorer Example

Weather

Temperature

Longitude

Latitude

One possible world (state)

Number of possible (mutually exclusive) worlds (states)

{S, C}

[-40, 40]

[0, 359]

[0, 179]

Example (lecture 2)

Mars Explorer Example

Weather

Temperature

Longitude

Latitude

One possible world (state)

Number of possible (mutually exclusive) worlds (states)

{S, -30, 320, 210}

2 x 81 x 360 x 180

{S, C}

[-40, 40]

[0, 359]

[0, 179]

Product of cardinality of each domain

… always exponential in the number of variables

How many possible worlds?• Crossword Puzzle 1:

• variables are words that have to be filled in• domains are English words of correct length• possible worlds: all ways of assigning words

• Number of English words? Let’s say 150,000• Of the right length? Assume for simplicity: 15,000 for each

length

• Number of words to be filled in? 63• How many possible worlds? (assume any combination is ok)

15,00063

14

How many possible worlds?• Crossword 2:

• variables are cells (individual squares)• domains are letters of the alphabet• possible worlds: all ways of assigning

letters to cells

• Number of empty cells? 15*15 – 32 = 193

• Number of letters in the alphabet? 26• How many possible worlds? (assume any combination is ok)

• 26193

• In general: (domain size) #variables

Examples: variables, domains, possible worlds

• Scheduling Problem:• variables are different tasks that need to be scheduled

(e.g., course in a university; job in a machine shop)• domains are the different combinations of times and

locations for each task (e.g., time/room for course; time/machine for job)

• possible worlds: time/location assignments for each task

Constraint Satisfaction Problems (CSP)

• Allow for usage of useful general-purpose algorithms

with more power than standard search algorithms

• They exploit the multi-dimensional nature of the problem and the structure provided by the goal

set of constraints, *not* black box.

Constraints• Constraints are restrictions on the values that one or

more variables can take• Unary constraint: restriction involving a single variable• k-ary constraint: restriction involving k different variables

• it turns out that k-ary constraints can always be represented as binary constraints, so we'll mainly only talk about this case

• Constraints can be specified by 1. listing all combinations of valid domain values for the

variables participating in the constraint

2. giving a function that returns true when given values for each variable which satisfy the constraint

Example: Map-Coloring

Variables WA, NT, Q, NSW, V, SA, T

Domains Di = {red,green,blue}

Constraints: adjacent regions must have different colorse.g.,

Or WA NT

NT SA

NT QU

…………..

Example: Map-Coloring

Variables WA, NT, Q, NSW, V, SA, T

Domains Di = {red,green,blue}

Constraints: adjacent regions must have different colorse.g., WA ≠ NT, NT ≠ SA, NT ≠ QU, …..,

Or WA NT

Red Green

Red Bue

Green Red

Green Blue

Blue Red

Blue Green

NT SA

Red Green

Red Bue

Green Red

Green Blue

Blue Red

Blue Green

NT QU

Red Green

Red Bue

Green Red

Green Blue

Blue Red

Blue Green

…………..

Examples• Crossword Puzzle 1:

• variables are words that have to be filled in• domains are valid English words• constraints: words have the same letters at points

where they intersect

h1[0] = v1[0]

h1[1] = v2[0]

…..

~225 constraints

h1

v1

• Eight Queen problem: place 8 queens on a chessboard so that no queen can attack the others

• Constraints: No queens can be in the same row, column or diagonal

Example: Eight Queen problem

Example 2: 8 queens• Variables: V1 ,.. Vn.

Vi = Row occupied by the ith queen in the ith column

• Domains: D Vi = {1,2,3,4,5,6,7,8}

• Constraints: : Two queens cannot be on the same row or on the same diagonal

• We can specify the constraints by enumerating explicitly, for each pair of columns, what positions are allowed. Ex:

Constr(V1 , V2) = {(1,3), (1,4),..(1,8)(2,4)(2,5)…(8,6)}

Constraints• Constraints are restrictions on the values that one or more

variables can take• Unary constraint: restriction involving a single variable• k-ary constraint: restriction involving k different variables

We will mostly deal with binary constraints• Constraints can be specified by

1. listing all combinations of valid domain values for the variables participating in the constraint

2. giving a function that returns true when given values for each variable which satisfy the constraint

• A possible world satisfies a set of constraints • if the values for the variables involved in each constraint are consistent

with that constraint

1. Elements of the list of valid domain values

2. Function returns true for those values

Models and Possible Worlds

Definition: A model of a CSP is an assignment of values to all of its variables

(i.e. a possible world) that satisfies all of its constraints.

V = {V1,V2}– dom(V1) = {1,2,3}

– dom(V2) = {1,2}

• C = {C1,C2,C3}– C1: V2 2– C2: V1 + V2 < 5

– C3: V1 > V2

Possible worlds for this CSP: {V1=1, V2=1}

{V1=1, V2=2} {V1=2, V2=1}

{V1=2, V2=2}

{V1=3, V2=1}

{V1=3, V2=2}

{V1=2, V2=1} (a model)

{V1=3, V2=1} (a model)

end

Example: Map-Coloring

WA = red, NT = green, Q = red, NSW = green, V = red,SA = blue, T = green

Definition: A model of a CSP is an assignment of values to all of its variables (i.e., a possible

world) that satisfies all of its constraints.

Finite Constraint Satisfaction Problem: Definition

Definition: A finite constraint satisfaction problem (FCSP) is a CSP with a finite set of variables and a finite domain for each variable.

We will only study finite CSPs here but many of the techniques carry over to countably infinite and continuous domains. We use CSP here to refer to FCSP.

Constraint Satisfaction Problems: Variants

• We may want to solve the following problems with a CSP:• determine whether or not a model exists• find a model• find all of the models• count the number of models• find the best model, given some measure of model quality

this is now an optimization problem

• determine whether some property of the variables holds in all models

Solving Constraint Satisfaction Problems

• Even the simplest problem of determining whether or not a model exists in a general CSP with finite domains is NP-hard• There is no known algorithm with worst case polynomial runtime.• We can't hope to find an algorithm that is polynomial for all CSPs.

• However, we can try to:• find efficient (polynomial) consistency algorithms that reduce the size of

the search space• identify special cases for which algorithms are efficient • work on approximation algorithms that can find good solutions quickly,

even though they may offer no theoretical guarantees• find algorithms that are fast on typical (not worst case) cases

30

Lecture Overview

• Finish Search• Constraint Satisfaction Problems

• Variables/Features • Constraints• CSPs• Generate-and-Test• Search • Arc Consistency

• Systematically check all possible worlds

- Possible worlds: cross product of domains

dom(V1) dom(V2) ... dom(Vn)

• Generate and Test:- Generate possible worlds one at a time- Test constraints for each one.

Example: 3 variables A,B,C

Generate and Test (GT) Algorithms

For a in dom(A)For b in dom(B)

For c in dom(C) if {A=a, B=b, C=c} satisfies all

constraints return {A=a, B=b, C=c}

fail

• If there are k variables, each with domain size d, and there are c constraints, the complexity of Generate & Test is

- There are dk possible worlds- For each one need to check c constraints

Generate and Test (GT) Algorithms

32

Need to find a better way, that exploits the “insights” that we have on the goal expressed in terms of constraints • Why does GT fail to do this?

CSP as a Search Problem: one formulation

• States: partial assignment of values to variables• Start state: empty assignment• Successor function: states with the next variable assigned

• E.g., follow a total order of the variables V1, …, Vn

• A state assigns values to the first k variables:{V1 = v1,…,Vk = vk }

Neighbors of node {V1 = v1,…,Vk = vk }: nodes {V1 = v1,…,Vk = vk, Vk+1 = x} for each x dom(Vk+1)

• Goal state: complete assignments of values to variables that satisfy all constraints• That is, models

• Solution: assignment (the path doesn't matter)

V1 = v1

V2 = v1

V1 = v1

V2 = v2

V1 = v1

V2 = vk

CSP as a Search Problem: one formulation

V1 = v1

V2 = v1

V3 = v2

V1 = v1

V2 = v1

V3 = v1

{}

V1 = v1 V1 = vk

Slide 35

CSPs as Search Problems• Which search strategy will work well for a CSP

formulated this way?• If there are n variables every solution is at depth…….• Is there a role for a heuristic function?

• the tree is always finite and has no cycles, so which one is better BFS or IDS or DFS?

Is there any way to prune the DFS Search tree?

• Explore search space via DFS but evaluate each constraint as soon as all its variables are bound.

• Any partial assignment that doesn’t satisfy the constraint can be pruned.

• Example: - 3 variables A, B, C each with domain {1,2,3,4}- {A = 1, B = 1} is inconsistent with constraint A B

regardless of the value of the other variables

Fail! Prune!

CSP as Search problem

V1 = v1

V2 = v1

V1 = v1

V2 = v2

V1 = v1

V2 = vk

CSP as Graph Searching

V1 = v1

V2 = v1

V3 = v2

V1 = v1

V2 = v1

V3 = v1

{}

V1 = v1 V1 = vk

Problem?

Check unary constraints on V1

If not satisfied = PRUNE

Check constraints on V1

and V2 If not satisfied = PRUNE

V1 = v1

V2 = v1

V1 = v1

V2 = v2

V1 = v1

V2 = vk

CSP as Graph Searching

V1 = v1

V2 = v1

V3 = v2

V1 = v1

V2 = v1

V3 = v1

{}

V1 = v1 V1 = vk

Problem?Performance heavily depends on the order in which variables are considered

Check unary constraints on V1

If not satisfied = PRUNE

Check constraints on V1

and V2 If not satisfied = PRUNE

Slide 39

Solving CSPs by DFS: Example

• Variables: A,B,C• Domains: {1, 2, 3, 4}• Constraints: A < B, B < C

Good ordering, lots of pruning happens right away

Slide 40

Solving CSPs by DFS: Example Efficiency• Variables: A,B,C• Domains: {1, 2, 3, 4}• Constraints: A < B, B < C

Much worse ordering, keeps more branches around

A=1

A=2 A=3

A=4

C=1 C=2 C=3 C=4

C=1 C=2 C=3 C=4 C=1 C=2 C=3 C=4

C=1 C=2 C=3 C=4

• Backtracking relies on one or more heuristics to select which variables to consider next.- E.g, variable involved in the largest number of constraints (“Degree

heuristics”)

• But we will look at an alternative approach that can do much better

Selecting variables in a smart way

Standard Search vs. Specific R&R systems• Constraint Satisfaction (Problems):

• State: assignments of values to a subset of the variables• Successor function: assign values to a “free” variable• Goal test: all variables assigned a value and all constraints satisfied?• Solution: possible world that satisfies the constraints• Heuristic function: none (all solutions at the same distance from start)

• Planning : • State• Successor function• Goal test• Solution• Heuristic function

• Inference• State• Successor function• Goal test• Solution• Heuristic function

43

Lecture Overview

• Finish Search• Constraint Satisfaction Problems

• Variables/Features • Constraints• CSPs• Generate-and-Test• Search • Arc Consistency

Can we do better than Search?

Key idea

• prune the domains as much as possible before searching for a solution.

• Example: dom(V2) = {1, 2, 3, 4}.

• Variable V2 is not domain consistent with the constraint

- It is domain consistent once we remove from its domain.

• Trivial for unary constraints. Trickier for k-ary ones.

Def.: A variable is domain consistent if no value of its domain is ruled impossible by any unary constraints.

V2 2

• Example: - Two variables X and Y- One constraint: X<Y

X YX< Y

46

Def. A constraint network is defined by a graph, with- one node for every variable (drawn as circle)- one node for every constraint (drawn as rectangle)- undirected edges running between variable nodes

and constraint nodes whenever a given variable is involved in a given constraint.

Constraint network: definition

Example Constraint NetworkDef. A constraint network is defined by a graph, with

- one node for every variable (drawn as circle)

- one node for every constraint (drawn as rectangle)- undirected edges running between variable nodes and constraint nodes

whenever a given variable is involved in a given constraint.

{2,3} {3}A B

A< B

A>C

{1,2}

C

Example Constraint Network

Example: • Variables: A,B,C• Domains: {1, 2, 3, 4}• 3 Constraints: A < B, B < C, B = 3

Def. A constraint network is defined by a graph, with- one node for every variable (drawn as circle)- one node for every constraint (drawn as rectangle)- undirected edges running between variable nodes and

constraint nodes whenever a given variable is involved in a given constraint.

5 edges/arcs in the constraint network: ⟨A,A<B , B,A<B ⟩ ⟨ ⟩⟨B,B<C , C,B<C⟩ ⟨ ⟩⟨B, B=3⟩

Arc Consistency

Definition:An arc <x, r(x,y)> is arc consistent if for each value x in dom(X) there is some value y in dom(Y) such that r(x,y) is satisfied.A network is arc consistent if all its arcs are arc consistent.

2,3 2,4

A B

A< B

2,3 3,4A B

A< B

49

T T

T F

Arc Consistency

Definition:An arc <x, r(x,y)> is arc consistent if for each value x in dom(X) there is some value y in dom(Y) such that r(x,y) is satisfied.A network is arc consistent if all its arcs are arc consistent.

2,3 2,4

A B

A< B

2,3 3,4A B

A< B

Not arc consistent: No value in domain of B that satisfies A<B ifB = 2

Both arcs are consistent: Each value in B(A) have ok values for A(B)- e.g. for B=3, A = 2

50

How can we enforce Arc Consistency?

• If an arc <X, r(X,Y)> is not arc consistent- Delete all values x in dom(X) for which there is no corresponding value

in dom(Y)- This deletion makes the arc <X, r(X,Y)> arc consistent.- This removal can never rule out any models/solutions

• Why?

Try this simple example in

(easy to create from scratch in AI space)

2,3,4 1,2,3X Y

X< Y

52

Arc Consistency Algorithm: high level strategy

• Consider the arcs in turn, making each arc consistent

• Reconsider arcs that could be made inconsistent again by this pruning of the domains

• Eventually reach a ‘fixed point’: all arcs consistent• Run ‘simple problem 1’ in AIspace for an example:

53

• When we reduce the domain of a variable X to make an arc X,c arc consistent, which arcs do we need to reconsider?

• You do not need to reconsider other arcs- If arc Y,c was arc consistent before, it will still be arc consistent

- If an arc X,c' was arc consistent before, it will still be arc consistent

- Nothing changes for arcs of constraints not involving X

Which arcs need to be reconsidered?

54

every arc Z,c' where c’ c involves Z and X:Z1 c1

Z2 c2

Z3 c3

Yc

THESE

X

Ac4

• Consider the arcs in turn, making each arc consistent

• Reconsider arcs that could be made inconsistent again by this pruning

• DO trace on ‘simple problem 1’ and on ‘scheduling problem 1’, trying to predict

- which arcs are not consistent and - which arcs need to be reconsidered after each removal

in

55

Which arcs need to be reconsidered?

Arc consistency algorithm (for binary constraints)

56

Procedure GAC(V,dom,C)           Inputs                     V: a set of variables                     dom: a function such that dom(X) is the domain of variable X                     C: set of constraints to be satisfied           Output                     arc-consistent domains for each variable           Local                     DX is a set of values for each variable X                    TDA is a set of arcs

1:           for each variable X do2:                     DX ←dom(X) 3:           TDA ←{ X,c | X ∈ V, c ∈ C  and X ∈ scope(c)} ⟨ ⟩         4:           while (TDA {}) 5:                     select X,c ∈TDA⟨ ⟩6:                     TDA ←TDA  \ { X,c }⟨ ⟩7:                     NDX ←{x| x ∈ DX and y ∈ DY s.t. (x, y) satisfies c}8:                     if (NDX DX) then 9:                               TDA ←TDA ∪ { Z,c' | X ∈ scope(c'), c' ⟨ ⟩ c, Z ∈ scope(c') \ {X} } 10:                             DX ←NDX                     11:           return {DX| X  is a variable}

Scope of constraint c is the set of variables involved in that constraint

NDX: values x for X for which there a value for y supporting x

X’s domain changed: arcs (Z,c’) for variables Z sharing a constraint c’ with X could become inconsistent

TDA: ToDoArcs,blue arcsin AIspace

Slide 57

Arc Consistency Algorithm: Complexity• Let’s determine Worst-case complexity of this procedure

(compare with DFS )• let the max size of a variable domain be d• let the number of variables be n• The max number of binary constraints is ~n(n-1)/2 or O(n2).

• How many times the same arc can be inserted in the ToDoArc list? O(d)

• How many steps are involved in checking the consistency of an arc? O(d2)

Arc Consistency Algorithm: Interpreting Outcomes• Three possible outcomes

(when all arcs are arc consistent):1. Each domain has a single value, e.g.

We have a (unique) solution.

2. At least one domain is empty, e.g.

No solution! (All values are ruled out for this variable.)

3. Some domains have more than one value, e.g.

There may be one solution, many solutions, or none.

Need to solve this new CSP (usually simpler) problem: same constraints, domains have been reduced

Can we have an arc consistent network with non-empty domains

that has no solution?

YES

• Example: vars A, B, C with domain {1, 2} and constraints A ≠ B, B ≠ C, A ≠ C

• Or see AIspace CSP applet Simple Problem 2

Domain splitting (or case analysis)

• Arc consistency ends: Some domains have more than one value may or may not have a solutionA. Apply Depth-First Search with Pruning or

B. Split the problem in a number of disjoint cases:

CSP with dom(X) = {x1, x2, x3, x4} becomes

CSP1 with dom(X) = {x1, x2} and CSP2 with dom(X) = {x3, x4}

• Solution to CSP is the union of solutions to CSPi60

Domain splitting

• Each smaller CSP is easier to solve• Arc consistency might already solve it

• For each subCSP, which arcs have to be on the ToDoArcs list when we get the subCSP by splitting the domain of X?

A1 c1

A2 c2

A3 c3

YcX

Ac4

Domain splitting

• Each smaller CSP is easier to solve• Arc consistency might already solve it

• For each subCSP, which arcs have to be on the ToDoArcs list when we get the subCSP by splitting the domain of X?

A1 c1

A2 c2

A3 c3

Yc

THESE

X

Ac4

THIS

If domains with multiple values Split on one

Searching by domain splitting

63

CSP, apply AC

CSP1, apply AC CSP2, apply AC

If domains with multiple values …Split on one

If domains with multiple values…..Split on one

• 3 variables: A, B, C• Domains: all {1,2,3,4}• A=B, B=C, AC

• Let’s tracearc consistency + domain splittingfor this network for “Simple Problem 2” in AIspace

Domain Splitting in Action:

64

Arc consistency + domain splitting: example

({1,2,3,4}, {1,2,3,4}, {1,2,3,4})

({1,3}, {1,2,3,4}, {1,2,3,4})

({1,3}, {1,3}, {1,3})

({2,4}, {1,2,3,4}, {1,2,3,4})

({1,3}, {1}, {1,3})

AC

({}, {}, {})

({1,3}, {3}, {1,3})

({}, {}, {})

AC

AC

({2,4}, {2,4}, {2,4})

({2,4}, {2}, {2,4})

AC

({}, {}, {})

({2,4}, {4}, {2,4})

({}, {}, {})

AC

AC

A ϵ {1,3} A ϵ {2,4}

B ϵ {1} B ϵ {3} B ϵ {2} B ϵ {4}

3 variables: A, B, CDomains: all {1,2,3,4}A=B, B=C, AC

No solution No solution No solution No solution

({1,2,3,4}, {1,2,3,4}, {1,2,3,4})

AC (arc consistency)

Arc consistency + domain splitting: another example

({1,2,3,4}, {1,2,3,4}, {1,2,3,4})

({1,3}, {1,2,3,4}, {1,2,3,4})

({1,3}, {1,3}, {1,3})

({2,4}, {1,2,3,4}, {1,2,3,4})

({1,3}, {1}, {1,3})

AC

({1}, {1}, {1})

({1,3}, {3}, {1,3})

({3}, {3}, {3})

AC

AC

({2,4}, {2,4}, {2,4})

({2,4}, {2}, {2,4})

AC

({2}, {2}, {2})

({2,4}, {4}, {2,4})

({4}, {4}, {4})

AC

AC

A ϵ {1,3} A ϵ {2,4}

B ϵ {1} B ϵ {3} B ϵ {2} B ϵ {4}

3 variables: A, B, C

Domains: all {1,2,3,4}

A=B, B=C, A=C

Solution Solution Solution Solution

({1,2,3,4}, {1,2,3,4}, {1,2,3,4})

AC (arc consistency)

Another formulation of CSP as search

• Arc consistency with domain splitting

• States: vector (D(V1), …, D(Vn)) of remaining domains, with D(Vi) dom(Vi) for each Vi

• Start state: vector of original domains (dom(V1), …, dom(Vn))

• Successor function:• reduce one of the domains + run arc consistency

• Goal state: vector of unary domains that satisfies all constraints• That is, only one value left for each variable• The assignment of each variable to its single value is a model

• Solution: that assignment67

If domains with multiple values Split on one

Searching by domain splitting

68

How many CSPs do we need to keep around at a time? Assume solution at depth m and 2 children at each split

CSP, apply AC

CSP1, apply AC CSP2, apply AC

If domains with multiple values Split on one

If domains with multiple values…..Split on one

If domains with multiple values Split on one

Searching by domain splitting

69

How many CSPs do we need to keep around at a time? Assume solution at depth m and 2 children at each split

O(2m): It is DFS

CSP, apply AC

CSP1, apply AC CSP2, apply AC

If domains with multiple values Split on one

If domains with multiple values…..Split on one

Slide 70

Systematically solving CSPs: Summary

• Build Constraint Network• Apply Arc Consistency

• One domain is empty • Each domain has a single value • Some domains have more than one value

• Apply Depth-First Search with Pruning OR• Split the problem in a number of disjoint cases

• Apply Arc Consistency to each case, and repeat

Slide 71

Limitation of Systematic Approaches• Many CSPs are simply too big for systematic approaches• If you have 105 vars with dom(vari) = 104

• Systematic Search

Branching factor b =

Solution depth d =

Complexity =

• Constraint Network

Size

Complexity of AC

Do this as an exerciseS

Learning Goals for CSP• Define possible worlds in term of variables and their domains• Compute number of possible worlds on real examples • Specify constraints to represent real world problems differentiating between:

• Unary and k-ary constraints • List vs. function format

• Verify whether a possible world satisfies a set of constraints (i.e., whether it is a model, a solution)

• Implement the Generate-and-Test Algorithm. Explain its disadvantages.• Solve a CSP by search (specify neighbors, states, start state, goal state).

Compare strategies for CSP search. Implement pruning for DFS search in a CSP.

• Define/read/write/trace/debug the arc consistency algorithm. Compute its complexity and assess its possible outcomes

• Define/read/write/trace/debug domain splitting and its integration with arc consistency

72