Artificial Intelligence 3451: UNIT: 02 Problem-Solving Through Search
Artificial Intelligence 3451: UNIT: 02 Problem-Solving Through Search
Artificial Intelligence 3451: UNIT: 02 Problem-Solving Through Search
UNIT: 02
Problem-Solving Through Search
Lecture: 05
3
Example: Map-Coloring
Domains Di = {red,green,blue}
4
Example: Map-Coloring
5
Constraint graph
Binary CSP: each constraint relates two variables
Constraint graph: nodes are variables, arcs are constraints
6
Dynamic Programming
Strategy
Dynamic Programming is a technique for solving
optimization problems. Generally, such problems
have many feasible solutions, each having some
associated cost. The dynamic programming method
determines the best solution, that is, the one which
has the maximum or minimum cost.
The algorithm works by splitting a problem into a sequence of optimization subproblems.
Thesubproblems
The dynamic programming
are solved,appears to combined
and then have sametoapproach as divide-and-conquer
obtain solution algorithm.
to the main problem.
There are, however, some subtle differences. Unlike the divide-and-conquer method, the
dynamic programming splits the problem into overlapping subproblems , which are solved in
bottom up fashion. The optimal solutions to subproblems are stored into a table, which is
used repeatedly to build the final or global optimal solution.
Dynamic Programming
Solution
In general, solution of problem is obtained by
using the dynamic programming algorithm in the
following manner:
1) A recursion is set up to express the running time of the main
problem in terms running times of overlapping subproblems
Initial conditions
Dynamic Programming solution is feasible when principle of optimality holds true for a
given problem.
The principle may not be applicable to all kinds of optimization problems. This condition
places a restriction on the wider applicability of dynamic programming algorithm.
Optimality Principle
Shortest Path
¾ The principle of optimality holds true for shortest paths in a
graph
Example: Consider the weighted graph shown in the diagram
It can be seen that the shortest distance the between the vertices A and D is 35
(i) The shortest path from A to D is A→B→C→D = 20+5+10=35
(ii) The shortest path from A to C is A→B→C=20+5=25
(iii) The shortest path from A to B is A→B=20.
It follows that each of the sub-paths from vertex A to vertex D is also the shortest
path between intermediate vertices. Thus, the principle of optimality holds true for
shortest distances in the sample graph.
50
A D
20 10
B C
5
50
A D
20 10
5
B C
3 9 0 7 2 6
3 0 2
3 9 0 7 2 6
3 0 2
3 9 0 7 2 6
More soon…
α-β Pruning
Principle
– If a move is determined worse than another move already
examined, then there is no need for further examination of the
node.
Alpha-Beta Pruning (αβ prune)
Rules of Thumb
α is the best ( highest) found so far along the path for Max
β is the best (lowest) found so far along the path for Min
Search below a MIN node may be alpha-pruned if the its β
of some MAX ancestor
Search below a MAX node may be beta-pruned if the its β
of some MIN ancestor.
Alpha-Beta Pruning Example
1. Searchbelow a MIN
node may be alpha-
pruned if the beta
value is <= to the
alpha value of some
MAX ancestor.
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
Alpha-Beta Pruning Example
1. Searchbelow a MIN 3
node may be alpha-
pruned if the beta
value is <= to the
alpha value of some
MAX ancestor.
3
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
3
Alpha-Beta Pruning Example
1. Searchbelow a MIN 3
node may be alpha-
pruned if the beta
value is <= to the
alpha value of some
MAX ancestor.
3
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
3 5
β
Alpha-Beta Pruning Example
1. Searchbelow a MIN 3
node may be alpha-
pruned if the beta
value is <= to the
alpha value of some
MAX ancestor.
3 0
2. Search below a
MAX node may be
beta-pruned if the α
alpha value is >= to
the beta value of
some MIN ancestor.
3 5 0
β
Alpha-Beta Pruning Example
1. Searchbelow a MIN 3
node may be alpha-
pruned if the beta
value is <= to the
alpha value of some
MAX ancestor.
3 0 2
2. Search below a
MAX node may be
α α
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
3 5 0 2
β
-β Search Algorithm
2. Search below a
MAX node may be
beta-pruned if the
alpha value is >= to
the beta value of
some MIN ancestor.
Example
1.Search below
a MIN node
may be
alpha-pruned
5 if the beta
5 3 value is <= to
the alpha
value of
some MAX
ancestor.
5 3
2. Search
5 6 3 7 below a
α MAX node
may be beta-
pruned if the
alpha value is
>= to the beta
5 6 3 value of
some MIN
5 0 6 1 3 2 4 7 ancestor.
β
Properties of α-β Prune
Pruning does not affect final result