Lecture-3.2 Constraint Satisfaction Problem (CSP)
Lecture-3.2 Constraint Satisfaction Problem (CSP)
Lecture-3.2 Constraint Satisfaction Problem (CSP)
(CSP)
Goal: Steal TV set Goal: Earn some money Goal: Buy new TV set
Why BFS is not Adequate for Searching AND-OR Graph?
-A expanded to A
two arcs: one
leading to B &
(9)
one leading to
C&D B C D
f`: numbers (5) (3) (4)
-Every operation uniform
cost
-Each arc with a single Which expand next? Which expand next?
successor has a cost of 1 -C (3) lowest cost -B (5+1=06)
- Each AND arc with -C+D+2 (3+4+2=09) -lowest compared to C
multiple successors has
a cost of 1 for each of The choice of which node to expand next
its components must depend not only on the f` value of that node
But also on whether that node is part of the current
Best path from the initial node
AND-OR Graph
• Most promising single node:
G (f`=3)
• Arc: G-H (7+2=9) A
(5+10+2+1=18)
• Should not expand G next;
rather should examine either
E/F
Algorithm: Problem Reduction
1. Initialize the graph to the starting node
2. Loop until the starting node is labeled SOLVED or until
its cost goes above FUTILITY
(a) Traverse the graph, starting at the initial node &
following the current best path, & accumulate the set
of nodes that are on that path & have not yet been
expanded/labeled as solved
(b) Pick one of these unexpanded nodes & expand
it. if there are no successors, assign FUTILITY as the
value of this node. Otherwise, add its successors to
the graph & for each of them compute f` (use only h`
& ignore g). If f` of any node is 0, mark that node as
SOLVED
Algorithm: Problem Reduction
(c) Change the f` estimate of the newly expanded node to reflect the new
info provided by its successors
-propagate this change backward through the graph
-if any node contains a successor are whose descendants are all solved,
label the node itself as SOLVED
-at each node that is visited while going up the graph, decide which of its
successor arcs is the most promising & mark it as part of the current
best path
- This may cause the current best path to change
- This propagation of revised cost estimates back up the tree was not
necessary in the BFS algo because only unexpanded nodes were
examined
- But now expanded nodes must be reexamined so that the best current
path can be selected
- Thus it is important that their f` value estimates available
Problem Reduction Example
Before Step 1 Before Step 2 Before Step 3
A (5) A (6) A
(9) (9)
B C D B C D (10)
(3) (4) (5) (3) (4)
Before Step 4 E F
A (4) (4)
B C D B C D
E F G H E F
G H
Unsolvable Unsolvable
I J I J
•
» state is defined by variables Xi with values from
domain Di
Example: Map-Coloring
BASIC 6 0 8 5 2 CROSS 9 6 2 3 3
LOGIC 4 7 3 5 2 ROADS 6 2 5 1 3
------------ ----------------- ------------ -----------------
ORANGE 1 0 8 2 0 4 DANGER 1 5 8 7 4 6
More Cryptarithmetic Problem
TAKE 3 9 6 1 BASE 7 4 8 3
A 9 BALL 7 4 5 5
CAKE 2 9 6 1 ------------ -----------------
------------ ----------------- GAMES 1 4 9 3 8
KATE 6 9 3 1
EAT 8 1 9 FOOT ? ? ? ?
THAT 9 1 1 9 BALL ? ? ? ?
------------ ----------------- ------------ -----------------
APPLE 10 0 3 8 GAMES ? ? ? ? ?
16 possible
solutions