constraint propagation
DESCRIPTION
Constraint Propagation. Constraint Propagation …. … is the process of determining how the possible values of one variable affect the possible values of other variables. Forward Checking. - PowerPoint PPT PresentationTRANSCRIPT
Constraint PropagationConstraint Propagation
Constraint Propagation 2
Constraint Propagation …Constraint Propagation … … is the process of determining
how the possible values of one variable affect the possible values of other variables
Constraint Propagation 3
Forward CheckingForward Checking After a variable X is assigned a value v,
look at each unassigned variable Y that is connected to X by a constraint and deletes from Y’s domain any value that is inconsistent with v
Constraint Propagation 4
Map ColoringMap Coloring
WA NT Q NSW V SA TRGB RGB RGB RGB RGB RGB RGB
TWA
NT
SA
Q
NSWV
Constraint Propagation 5
Map ColoringMap Coloring
WA NT Q NSW V SA TRGB RGB RGB RGB RGB RGB RGBR GB RGB RGB RGB GB RGB
TWA
NT
SA
Q
NSWV
Constraint Propagation 6
WA NT Q NSW V SA TRGB RGB RGB RGB RGB RGB RGBR GB RGB RGB RGB GB RGBR B G RB RGB B RGB
Map ColoringMap Coloring
TWA
NT
SA
Q
NSWV
Constraint Propagation 7
Map ColoringMap Coloring
WA NT Q NSW V SA TRGB RGB RGB RGB RGB RGB RGBR GB RGB RGB RGB GB RGBR B G RB RGB B RGBR B G R B RGB
Impossible assignments that forward checking do not detect
TWA
NT
SA
Q
NSWV
Constraint Propagation 8
constraint propagationconstraint propagation
Constraint Propagation 9
Edge Labeling in Computer Edge Labeling in Computer VisionVision
Russell and Norvig: Chapter 24, pages 745-749
Constraint Propagation 10
Edge LabelingEdge Labeling
Constraint Propagation 11
Edge LabelingEdge Labeling
Constraint Propagation 12
Edge LabelingEdge Labeling+ –
Constraint Propagation 13
Edge LabelingEdge Labeling
+
++
+
+
+
+
+
++
--
Constraint Propagation 14
Junction Label SetsJunction Label Sets
+ + --
-- - + +
++ ++
+
--
--
-+
(Waltz, 1975; Mackworth, 1977)
Constraint Propagation 15
Edge Labeling as a CSPEdge Labeling as a CSPA variable is associated with each junctionThe domain of a variable is the label set of the corresponding junctionEach constraint imposes that the values given to two adjacent junctions give the same label to the joining edge
Constraint Propagation 16
Edge LabelingEdge Labeling
+ -
+-
+- -++
Constraint Propagation 17
Edge LabelingEdge Labeling +
++
+---
-- -
+
Constraint Propagation 18
Edge LabelingEdge Labeling
++
+
++
+
-- - + +
++
Constraint Propagation 19
Edge LabelingEdge Labeling
++
+
- -++
+ + --
Constraint Propagation 20
Removal of Arc Removal of Arc InconsistenciesInconsistencies
REMOVE-ARC-INCONSISTENCIES(J,K)removed falseX label set of JY label set of KFor every label y in Y do If there exists no label x in X such that the
constraint (x,y) is satisfied then Remove y from Y If Y is empty then contradiction true removed true
Label set of K YReturn removed
Constraint Propagation 21
CP Algorithm for Edge CP Algorithm for Edge LabelingLabeling
Associate with every junction its label set contradiction false Q stack of all junctions while Q is not empty and not contradiction do J UNSTACK(Q) For every junction K adjacent to J do
If REMOVE-ARC-INCONSISTENCIES(J,K) then STACK(K,Q)
(Waltz, 1975; Mackworth, 1977)
Constraint Propagation 22
General CP for Binary General CP for Binary ConstraintsConstraints
Algorithm AC3 contradiction false Q stack of all variables while Q is not empty and not contradiction do X UNSTACK(Q) For every variable Y adjacent to X do
If REMOVE-ARC-INCONSISTENCIES(X,Y) then
STACK(Y,Q)
Constraint Propagation 23
General CP for Binary General CP for Binary ConstraintsConstraints
REMOVE-ARC-INCONSISTENCY(X,Y) removed false For every value y in the domain of Y do
If there exists no value x in the domain of X such that the constraints on (x,y) is satisfied then
Remove y from the domain of Y If Y is empty then contradiction true removed true
Return removed
Algorithm AC3 contradiction false
Q stack of all variables while Q is not empty and not contradiction do
X UNSTACK(Q) For every variable Y adjacent to X do
If REMOVE-ARC-INCONSISTENCY(X,Y) then STACK(Y,Q)
Constraint Propagation 24
Complexity Analysis of Complexity Analysis of AC3AC3
n = number of variables d = number of values per variable s = maximum number of constraints on a pair of variables Each variables is inserted in Q up to d times REMOVE-ARC-INCONSISTENCY takes O(d2) time CP takes O(n s d3) time
Constraint Propagation 25
Is AC3 All What is Is AC3 All What is Needed?Needed?
NO!X Y
Z
X Y
X Z Y Z
{1, 2}
{1, 2}{1, 2}
Constraint Propagation 26
Solving a CSPSolving a CSP
Interweave constraint propagation, e.g.,• forward checking• AC3 and backtracking
+ Take advantage of the CSP structure
Constraint Propagation 27
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 28
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 29
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 30
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 31
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 32
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 33
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 34
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 35
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 36
4-Queens Problem4-Queens Problem
1
32
4
32 41X1
{1,2,3,4}
X3{1,2,3,4}
X4{1,2,3,4}
X2{1,2,3,4}
Constraint Propagation 37
Structure of CSP Structure of CSP If the constraint graph contains multiple components, then one independent CSP per component
TWA
NT
SA
Q
NSWV
Constraint Propagation 38
Structure of CSP Structure of CSP If the constraint graph contains multiple components, then one independent CSP per component If the constraint graph is a tree (no loop), then the CSP can be solved efficiently
Constraint Propagation 39
Constraint TreeConstraint TreeX
Y Z
U V
W (X, Y, Z, U, V, W)
Constraint Propagation 40
Constraint TreeConstraint Tree Order the variables from the root to the leaves (X1, X2, …, Xn) For j = n, n-1, …, 2 do REMOVE-ARC-INCONSISTENCY(Xj, Xi) where Xi is the parent of Xj Assign any legal value to X1 For j = 2, …, n do assign any value to Xj consistent with
the value assigned to Xi, where Xi is the parent of Xj
Constraint Propagation 41
Structure of CSP Structure of CSP If the constraint graph contains multiple components, then one independent CSP per component If the constraint graph is a tree, then the CSP can be solved efficiently Whenever a variable is assigned a value by the backtracking algorithm, propagate this value and remove the variable from the constraint graph
WA
NT
SA
Q
NSWV
Constraint Propagation 42
Structure of CSP Structure of CSP If the constraint graph contains multiple components, then one independent CSP per component If the constraint graph is a tree, then the CSP can be solved in linear time Whenever a variable is assigned a value by the backtracking algorithm, propagate this value and remove the variable from the constraint graph
WA
NTQ
NSWV
Constraint Propagation 43
Over-Constrained Over-Constrained ProblemsProblems
Weaken an over-constrained problem by: Enlarging the domain of a variable Loosening a constraint Removing a variable Removing a constraint
Constraint Propagation 44
Non-Binary ConstraintsNon-Binary ConstraintsSo far, all constraints have been binary (two variables) or unary (one variable)Constraints with more than 2 variables would be difficult to propagateTheoretically, one can reduce a constraint with k>2 variables to a set of binary constraints by introducing additional variables
Constraint Propagation 45
When to Use CSP When to Use CSP Techniques?Techniques?
When the problem can be expressed by a set of variables with constraints on their values When constraints are relatively simple (e.g., binary) When constraints propagate well (AC3 eliminates many values) When the solutions are “densely” distributed in the space of possible assignments
Constraint Propagation 46
SummarySummary
Forward checking Constraint propagation Edge labeling in Computer Vision Interweaving CP and backtracking Exploiting CSP structure Weakening over-constrained CSP
Game PlayingGame Playing
Constraint Propagation 48
Games as search Games as search problemsproblems
Chess, GoSimulation of war (war game)스타크래프트의 전투Claude Shannon, Alan Turing Chess program (1950 년대 )
Constraint Propagation 49
Contingency problemsContingency problemsThe opponent introduces uncertainty마이티에서는 co-work 이 필요고스톱에서는 co-work 방지가 필요Hard to solve in chess, 35100 possible nodes, 1040 different legal positionsTime limits how to make the best use of time to reach good decisionsPruning, heuristic evaluation function
Constraint Propagation 50
Perfect decisions in two Perfect decisions in two person gamesperson games
The initial state, A set of operators, A terminal test, A utility function (payoff function)Mini-max algorithm, Negmax algorithms
Constraint Propagation 51
Mini-max algorithmMini-max algorithm(AND-OR tree)(AND-OR tree)
1A
4A
10win
11win
12lose
13win
14lose
15lose
16draw
17draw
18win
19draw
20lose
21draw
3B
6A
7A
8A
9A
2B
5A
Constraint Propagation 52
상대방의 관점상대방의 관점
1A
draw
3B
draw
2B
win
10lose
11lose
12win
13lose
14win
15win
16draw
17draw
18lose
19draw
20win
21draw
4A
lose
6A
win
7A
draw
8A
lose
9A
draw
5A
lose
Constraint Propagation 53
NegmaxNegmax
Knuth and Moore (1975)
F(n) = f(n), if n has no successors F(n) = max{-F(n1), …, -F(nk)}, if n has successors n1, …, nk
Constraint Propagation 54
The Negmax formalismThe Negmax formalism1A
F=0
4A
F=+1
10F=-1
11F=-1
12F=+1
13F=-1
14F=+1
15F=+1
16F=0
17F=0
18F=-1
19F=0
20F=+1
21F=0
3B
F=0
6A
F=-1
7A
F=0
8A
F=+1
9A
F=0
2B
F=+1
5A
F=+1
Constraint Propagation 55
Imperfect DecisionsImperfect Decisions
utility function evaluationterminal test cutoff testEvaluation function ::: an estimate of the utility of the game from a given positionChess material value ( 장기도 유사 )Weighted linear function
w1f1+w2f2+….+wnfn
Constraint Propagation 56
Cutting off searchCutting off searchTo set a fixed depth limit, so that the cutoff test succeeds for all nodes at or below depth d iterative deepening until time runs out 위험이 있을 수 있다Quiescent posiiton ::: unlikely to exhibit wild swings in value in near futureQuiescent search :: Non-quiescent search extra search to find quiescent positionHorizon problem
Constraint Propagation 57
Alpha-beta pruning Alpha-beta pruning
Eliminate unnecessary evaluationsPruning
Constraint Propagation 58
Alpha-beta pruningAlpha-beta pruning1
MAX
3MIN2
MINF(2)=15
5MAX
1MAX
2MIN
3MIN
4MAX
F(4)=205
MAX
6MIN
F(6)=25
7MIN
4MAX
F(4)=10
Alpha cutoff Beta cutoff
Constraint Propagation 59
Negmax representationNegmax representation
1MAX
3MIN
4MAX
F(4)=10
5MAX
1MAX
2MIN
3MIN
4MAX
F(4)=20
5MAX
6MIN
F(6)=-25
7MIN
2MIN
F(2)=-15
Constraint Propagation 60
ExampleExample
1
1 2 2
1 2 2 3 X X 3 X X 2 2 2 X X X X X X 2 2 2 X X X X X X
1 2 2 3 X X 3 X X
Distribution of critical nodes
Constraint Propagation 61
Games with ChanceGames with Chance
Chance nodes expected value Backgammon, 윷놀이 Expectimax value
Constraint Propagation 62
A backgammon positionA backgammon position
C
…
… … …
… … …
………
2 -1 1 -1 1
…
…
…
…… … …
1/361,1
1/181,2
6,5 6,6
1/361,1
1/181,2 6,5 6,6
MAX
DICE
MIN
DICE
MAX
TREMINAL
Constraint Propagation 63
ComparisionComparision
A1 A2
2.1 1.3
.9 .1 .9 .1
2 2 3 3 1 1 4 4
2 3 1 4
A1 A2
21 40.9
.9 .1 .9 .1
20 20 30 30 1 1 400 400
20 30 1 400
MAX
DICE
MIN
Constraint Propagation 64
숙제숙제
5.6, 5.8, 5.11, 5.15, 5.16, 5.17