CSP3
-
Upload
mihai-ilie -
Category
Documents
-
view
289 -
download
0
Transcript of CSP3
-
8/22/2019 CSP3
1/17
Recap Consistency Arc Consistency
CSPs: Arc Consistency
CPSC 322 CSPs 3
Textbook 4.5
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 1
http://find/http://goback/ -
8/22/2019 CSP3
2/17
Recap Consistency Arc Consistency
Lecture Overview
1 Recap
2 Consistency
3 Arc Consistency
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 2
http://find/ -
8/22/2019 CSP3
3/17
Recap Consistency Arc Consistency
Constraint Satisfaction Problems: Definition
Definition
A constraint satisfaction problem consists of:
a set of variables
a domain for each variablea set of constraints
DefinitionA model of a CSP is an assignment of values to variables thatsatisfies all of the constraints.
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 3
http://find/http://goback/ -
8/22/2019 CSP3
4/17
Recap Consistency Arc Consistency
CSPs as Search Problems
We map CSPs 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 variablestart node: the empty assignment (no variables assignedvalues)
goal node: a node which assigns a value to each variable, and
satisfies all of the constraintsNote: the path to a goal node is not important
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 4
http://find/ -
8/22/2019 CSP3
5/17
Recap Consistency Arc Consistency
Lecture Overview
1 Recap
2 Consistency
3 Arc Consistency
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 5
R C i A C i
http://find/ -
8/22/2019 CSP3
6/17
Recap Consistency Arc Consistency
Consistency Algorithms
Idea: prune the domains as much as possible before selectingvalues from them.
DefinitionA variable is domain consistent if no value of the domain of thenode is ruled impossible by any of the constraints.
Example: dom(B) = {1, 2, 3, 4} isnt domain consistent if wehave the constraint B = 3.
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 6
R C i t A C i t
http://find/ -
8/22/2019 CSP3
7/17
Recap Consistency Arc Consistency
Constraint Networks
Domain consistency only talked about constraints involving a
single variablewhat can we say about constraints involving multiple variables?
Definition
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 andconstraint nodes whenever a given variable is involved in a given
constraint.
When all of the constraints are binary, constraint nodes arenot necessary: we can drop constraint nodes and use edges toindicate that a constraint holds between a pair of variables.
why cant we do the same with general k-ary constraints?
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 7
Recap Consistency Arc Consistency
http://find/http://goback/ -
8/22/2019 CSP3
8/17
Recap Consistency Arc Consistency
Example Constraint Network
A A
-
8/22/2019 CSP3
9/17
Recap Consistency Arc Consistency
Lecture Overview
1 Recap
2 Consistency
3 Arc Consistency
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 9
Recap Consistency Arc Consistency
http://find/ -
8/22/2019 CSP3
10/17
Recap Consistency Arc Consistency
Arc Consistency
DefinitionAn arc
X, r(X, Y)
is arc consistent if for each value of X in
dom(X) there is some value Y in dom(Y) such that r(X, Y) issatisfied.
In symbols, X dom(X), Y dom(Y) such that r(X, Y)is satisfied.
A network is arc consistent if all its arcs are arc consistent.
If an arc
X, Y
is not arc consistent, all values of X in
dom(X) for which there is no corresponding value in dom(Y)may be deleted from dom(X) to make the arc
X, Y
consistent.
This removal can never rule out any models (do you see why?)
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 10
Recap Consistency Arc Consistency
http://find/ -
8/22/2019 CSP3
11/17
Recap Consistency Arc Consistency
Arc Consistency Outcomes
Three possible outcomes (when all arcs are arc consistent):
One domain is empty no solution
Each domain has a single value unique solutionSome domains have more than one value may or may notbe a solution
in this case, arc consistency isnt enough to solve the problem:
we need to perform search
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 11
Recap Consistency Arc Consistency
http://find/ -
8/22/2019 CSP3
12/17
Recap Consistency Arc Consistency
Arc Consistency Algorithm
Consider the arcs in turn making each arc consistent.
An arc
X, r(X, Y)
needs to be revisited if the domain of Yis reduced.
Regardless of the order in which arcs are considered, we will
terminate with the same result: an arc consistent network.Worst-case complexity of this procedure:
let the max size of a variable domain be dlet the number of constraints be ecomplexity is O(ed3)
Some special cases are faster
e.g., if the constraint graph is a tree, arc consistency is O(ed)
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 12
Recap Consistency Arc Consistency
http://find/ -
8/22/2019 CSP3
13/17
p y y
Arc Consistency Algorithm (binary constraints case)
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 13
Recap Consistency Arc Consistency
http://find/http://goback/ -
8/22/2019 CSP3
14/17
Adding edges back to TDA (binary constraints case)
When we change the domain of a variable X in the course ofmaking an arc X, r arc consistent, we add every arc Z, rwhere r involves X and:
r = r
Z= X
Thus we dont add back the same arc:
This makes senseits definitely arc consistent.
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 14
Recap Consistency Arc Consistency
http://find/http://goback/ -
8/22/2019 CSP3
15/17
Adding edges back to TDA (binary constraints case)
When we change the domain of a variable X in the course ofmaking an arc X, r arc consistent, we add every arc Z, rwhere r involves X and:
r = r
Z= X
We dont add back other arcs that involve the same variableX
Weve just reduced the domain of X
If an arc X, r was arc consistent before, it will still be arcconsistent
in the for all well just check fewer values
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 14
Recap Consistency Arc Consistency
http://find/ -
8/22/2019 CSP3
16/17
Adding edges back to TDA (binary constraints case)
When we change the domain of a variable X in the course ofmaking an arc X, r arc consistent, we add every arc Z, rwhere r involves X and:
r = r
Z= X
We dont add back other arcs that involve the same constraintand a different variable:
Imagine that such an arcinvolving variable Yhad been arcconsistent before, but was no longer arc consistent after Xsdomain was reduced.
This means that some value in Ys domain could satisfy r onlywhen X took one of the dropped valuesBut we dropped these values precisely because there were novalues of Y that allowed r to be satisfied when X takes thesevaluescontradiction!
CSPs: Arc Consistency CPSC 322 CSPs 3, Slide 14
Recap Consistency Arc Consistency
http://goforward/http://find/http://goback/ -
8/22/2019 CSP3
17/17
Arc Consistency Example
A A