Ch 3
Ch 3
Heuristic Search
• Are a set of general purpose search
techniques.
• Can be described independently of any
problem domain.
• Their efficacy is highly dependent on the
applied problem domain since they are unable
to overcome combinatorial explosion.
• Two methods already discussed (DFS and
BFS).
2
Generate and Test
Algorithm: Generate and Test
1. Generate a possible solution. For some problems, this
means generating a particular point on problem space.
For others, it means generating a path from start state.
2. Test to see if it is actually a solution by comparing the
chosen point or end point of chosen path to the set of
acceptable states.
3. If solution has been found quit. Otherwise return to
step 1.
• Is a DFS procedure.
3
Example: Colored Blocks Problem
4
Hill climbing
• In pure generate and test procedure, the test
function responds only with yes or know.
• Hill climbing is a variant of generate and test
in which the feedback from the test procedure
decides the direction of search process.
• Test function is augmented with a heuristic
function to provide an estimate of how close a
given state is to the goal state.
5
Simple Hill Climbing
6
Colored Blocks Problem Revisited
• Heuristic function: Sum of the number of
different colors on each of four sides ( value 16 in
this case).
• Rule: Pick up a block and rotate it 90 degree in
any direction.
• Application of hill climbing: Generate a new state
by selecting a block and rotating it. If the
resulting state is better, keep it. If not return to
the previous state an try a different combination.
7
Best First Search
• DFS is good because it allows solution to be
found without all competing branches having
to be expanded.
• BFS is good because it does not get trapped in
dead end paths.
• BFS combines the effectiveness of both by
following a single path at a time but switching
paths when some competing path looks more
promising than the current one.
8
How does it work?
• At each step of the search process the most
promising node is selected by applying an
appropriate heuristic.
• The node is then expanded using appropriate set
of rules.
• If it is the solution then the search process stops.
• Otherwise all the new nodes are added to the set
of nodes generated so far.
• Again the most promising node is selected and
the process continues.
9
Example
10
• The heuristic function is an estimate of the cost
of getting to the solution from a given node.
• BFS is applied on a directed graph in which each
node represents a point in problem space. Each
node contains a description of the problem state,
an indication how promising it is, list of nodes
generated from it and the parent link.
• Such a graph is called an OR graph, since each
branch represents an alternate problem solving
path.
11
Two list of nodes are required....
12
Heuristic Function….
13
14
Constraint Satisfaction
• Goal is to discover some problem state that
satisfies a given set of constraints.
• Ex: Cryptarithmetic puzzles.
• Is a search procedure that operates in a space of
constraint sets.
• Initial state: problem description.
• Goal state: problem solved following constraints.
• Two step process.
15
• First, constraints are discovered and
propagated as far as possible throughout the
system.
• Second, if the solution is not yet found a guess
is made and added as a new constraint.
• Constraint propagation terminates for one of
the two reasons. First, a contradiction is
detected. Second, propagation has run out of
steam and no further changes can be made on
the basis of current knowledge.
16
17
18
19
20
Means End Analysis
• Previous algorithms used either forward or
backward reasoning.
• MEA uses a mixture of these two techniques.
• Major parts of the problem are solved first
and then these parts appended to get the
solution.
• Difference between current state and goal
state is to be detected.
21
• Operator to be applied to reduce this
difference.
• But this operator may not be applicable to the
current state.
• This kind of backward chaining in which
operators are selected and then sub goals are
set up to establish the preconditions of the
operators are called operator sub goaling.
• If the operator does not produce the goal
state we want then the same process is
applicable.
• Thus the process can be applied recursively.
22
23
24
• Ex: Moving a desk with two things on it.
• Push or Carry operators may be used.
• Preconditions not satisfied for carry(as object
is not small).
• Preconditions for push satisfied.
25
Ex: Moving a desk with two things on it.
26
27
28