0% found this document useful (0 votes)
64 views

Introduction To Artificial Intelligence State Space Search: Gregory Adam

This document provides an introduction to state space search techniques used in artificial intelligence. It discusses blind state space searches like breadth-first search, depth-first search, and uniform cost search which explore the state space without using heuristics. It also discusses heuristic state space searches like ordered searching and A* search which use heuristics to guide the search. The document explains state space representations and algorithms for different search techniques.

Uploaded by

Genady Ferox
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Introduction To Artificial Intelligence State Space Search: Gregory Adam

This document provides an introduction to state space search techniques used in artificial intelligence. It discusses blind state space searches like breadth-first search, depth-first search, and uniform cost search which explore the state space without using heuristics. It also discusses heuristic state space searches like ordered searching and A* search which use heuristics to guide the search. The document explains state space representations and algorithms for different search techniques.

Uploaded by

Genady Ferox
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Introduction to Artificial Intelligence

State Space Search


Gregory Adam
Contents
• Intro
• Theory
– State Space Search
• Blind State Space Search ( 3 algorithms)
• Heuristic State Space Search ( 2 algorithms)
• Example

Most of the material used ( except the examples) comes from


“The Handbook of Artificial Intelligence – Volume I”
(Avron Barr & Edward A Feigenbaum)

Introduction to Artificial Intelligence 2


What
• Part of Computer Science concerned with
designing intelligent computer systems
• Systems exibiting the characteristics we
associate with intelligence in human
behaviour

Introduction to Artificial Intelligence 3


Areas
• The areas are not distinct – most are interrelated
• Problem Solving
– Puzzles
– Play games, eg chess
– Symbolic integration of mathematical formulas
– Some programs can improve their performance with experience
• Logical reasoning
– Prove assertions (theorems) by manipulating a database of facts
• Language
– Understanding of natural language
– Translation
– Eg Spelling checker
• Programming
– Write computer programs based on a description

Introduction to Artificial Intelligence 4


Areas – cont’d
• Learning
– Learning from examples
• Expertise (aka Expert Systems)
– User interacts with an Expert System via a dialogue
– Expert feeds knowledge
• Robotics and vision
– Manipulate robot devices (mostly in industrial applications to perform
repetitive tasks)
– Recognize objects and shadows in visual scenes
• Systems and languages
– Time-sharing, list processing, and interactive debugging were
developed in the AI research

Introduction to Artificial Intelligence 5


Search
• Components of search systems
– Database : describes the current task domain and the goal
– Set of operators: transform one state to another
– Eg in the 8 puzzle: UP, DOWN, LEFT, RIGHT
– Control strategy : decides what to do next
• Definition
– Find a finite sequence of operators transforming the initial state to a
goal state
• Reasoning
– Forward : Transform original state to a goal state
– Backward: Transform a goal state to the original state

Introduction to Artificial Intelligence 6


Search
• State Space and Problem Reduction
– State space
• An operator produces exactly one new state
– Problem reduction
• An operator produces a set of subproblems, each of which have to be solved
• Eg
– Tower of Hanoi
– Integrate (f(x) + g(x)) dx
» Integrate f(x) dx
» Integrate g(x) dx
» Add the results

Introduction to Artificial Intelligence 7


Search - problem representation
• State Space: State space graph

Introduction to Artificial Intelligence 8


Search - problem representation
• AND/OR Graph
– Horizontally connected edges (here marked in red)
represent AND nodes
– For AND nodes, each of the nodes have to be
solved
– Eg
• problem reduction
• Games (eg chess)

Introduction to Artificial Intelligence 9


Search – Blind Search
• The Blind search algorithms following
• Breadth First Search
• Depth First Search
• Uniform Cost Search
– Assume the State Space graph is a Directed Tree
• The Heuristic search algorithms following
• Ordered Search
• A* An optimal search for an optimal solution
– Assume the State Space graph is a General Graph

Introduction to Artificial Intelligence 10


Search
• General graph consists of
– Nodes or points
– Arcs or edges connecting two nodes

Introduction to Artificial Intelligence 11


Search
• Arcs can be
– Undirected

or

– Directed

Introduction to Artificial Intelligence 12


Search
• Undirected graph
– Contains only undirected arcs
• Directed graph or digraph
– Contains only directed arcs
• Mixed graph
– Contains both directed and undirected arcs

Introduction to Artificial Intelligence 13


Search
• In a directed graph (containing only directed arcs)
• The indegree of a node
– Is the number of arcs terminating in that node
• The outdegree of a node
– Is the number of arcs starting in that node

Introduction to Artificial Intelligence 14


Search
• A Directed tree
– Is an acyclic digraph
• Which has one node called the root
– The root node has indegree zero, and
• All other nodes have indegree one

Introduction to Artificial Intelligence 15


Search – Blind State Space Search
Breadth-First Search
• Expands nodes in their proximity from the
root (or start) node
• Expands all nodes of depth n before
expanding nodes of depth n+1
• Guaranteed to find the shortest possible
solution

Introduction to Artificial Intelligence 16


Search – Blind State Space Search
Breadth-First Search

Introduction to Artificial Intelligence 17


Search – Blind State Space Search
Breadth-First Search - Algorithm
1. Put the start node on a list, called OPEN, of unexpanded
nodes
2. If OPEN is empty, no solution exists
3. Remove the first node, n, from OPEN and put it in a list,
called CLOSED, of expanded nodes
4. Expand node n. If it has no successors, go to (2)
5. Place all successors of n at the end of the OPEN list
6. If any of the successors of n is a goal node, a solution has
been found. Otherwise go to (2)

Introduction to Artificial Intelligence 18


Search – Blind State Space Search
Breadth-First Search - Algorithm
Newly expanded nodes are added to the end of
the list

Introduction to Artificial Intelligence 19


Search – Blind State Space Search
Depth-First Search
• Expands most recent (deepest) nodes first
– Here abcdea first

Introduction to Artificial Intelligence 20


Search – Blind State Space Search
Depth-First Search - Algorithm
1. Put the start node on a list, called OPEN, of unexpanded
nodes
2. If OPEN is empty, no solution exists
3. Remove the first node, n, from OPEN and put it in a list,
called CLOSED, of expanded nodes
4. Expand node n. If it has no successors, go to (2)
5. If the depth of node n is greater than the maximum depth,
go to (2)
6. Place all successors of n at the beginning of OPEN list
7. If any of the successors of n is a goal node, a solution has
been found. Otherwise go to (2)

Introduction to Artificial Intelligence 21


Search – Blind State Space Search
Depth-First Search
• Newly expanded nodes are added at the
beginning of the list

Introduction to Artificial Intelligence 22


Search – Blind State Space Search
Uniform Cost Search
• The Breadth-First search can be generalized
slightly to solve to problem of finding the
cheapest path from a start node to a goal
state
• A non-negative cost is associated with each
arc joining two nodes
• The cost of a solution is then the sum of all
the costs along the path

Introduction to Artificial Intelligence 23


Search – Blind State Space Search
Uniform Cost Search

Introduction to Artificial Intelligence 24


Search – Blind State Space Search
Uniform Cost Search - Algorithm
1. Put the start node on a list, called OPEN, of unexpanded nodes
2. If OPEN is empty, no solution exists
3. Select from OPEN a node i such that TotalCost(i) is minimum. If several
nodes qualify choose i to be a goal node if there is one, otherwise
choose among them arbitrarily.
4. Remove node i from OPEN and place it on a list CLOSED of expanded
nodes
5. If node i is a goal node, a solution has been found
6. Expand node i, if it has no successors go to (2)
7. For each successor node j of I
– Compute TotalCost(j) = TotalCost(i) + Cost(j)
– Add node j to the OPEN list
8. Go to (2)

Introduction to Artificial Intelligence 25


Search – Blind State Space Search
Uniform Cost Search
• If we associate the cost of node i to node j
with
– -1
• the Uniform Cost Search becomes a Depth-First Search
• Since TotalCost of the node = - Depth of the node
–1
• the Uniform Cost Search becomes a Breadth-First
Search
• Since TotalCost of the node = Depth of the node

Introduction to Artificial Intelligence 26


Search – Blind State Space Search
Bidirectional Search
• The algorithms so far use forward reasoning, ie moving from
the start node towards a goal node

• In some cases we could use backward reasoning, ie moving


from the goal state to the start state

Introduction to Artificial Intelligence 27


Search – Blind State Space Search
Bidirectional Search
• Forward and backward reasoning can be
combined into a technique called bidirectional
search
• The idea is to replace a single search graph –
which is likely to grow exponentially – by two
smaller graphs
– One starting from the initial state and searching forward
– One starting from the goal state and searching backward
The search terminates when the two graphs intersect

Introduction to Artificial Intelligence 28


Search – Blind State Space Search
Bidirectional Search
• A bidirectional version of the Uniform Cost
Search, guaranteed to find the shortest
solution path, is due to Pohl (1969, 1971)
• Empirical data for randomly generated graphs
expanded only ¼ as many nodes as
unidirectional search

Introduction to Artificial Intelligence 29


Search – Limiting the search
• The amount of time and space is critical to find a solution
– Heuristics
– Relaxing the requirement
• Any (fast) solution, but not necessarily the best

Introduction to Artificial Intelligence 30


Search - Heuristics
• In blind search the number of nodes can be
extremely large
– The order of expanding the nodes is arbitrary
– Blind search does not use any properties of the problem
being solved
– Result is the combinatorial explosion
• Information about a particular problem can help to
reduce the search
– The question then is: how to search the given space
efficiently

Introduction to Artificial Intelligence 31


Search - Heuristics
• Heuristic information
– Additional information beyond that which is built into the
state and operator definitions
• Heuristic search
– A search method using that heuristic information
– Whether or not the method is foolproof
• Most of the programs were written for a single
domain – heuristics were closely intertwined in the
program and not accessible for study and adaptation
to new problems
Introduction to Artificial Intelligence 32
Search - Heuristics
• Heuristic search
– Strategy to limit (drastically) the search for solutions in
large problem spaces
• Ways of using heuristic information
– Which node(s) to expand first instead of expanding is a
strictly depth-first or breadth-first manner
– When expanding a node, decide which successors to
generate instead of blindly generate all successors at one
time
– Which nodes not to expand at all (pruning)

Introduction to Artificial Intelligence 33


Search – Heuristics
Ordered or Best-Fit Search
• Addresses only the first point
– Which node to expand first
– Expands fully
– The idea is to expand the node that seems most promising
– The promise of a node can be defined in several ways
• Estimate its distance to the goal node
• Estimate the length of the entire path
– In all cases the measure of promise of a node is
estimated by calling an evaluation function

Introduction to Artificial Intelligence 34


Search – Heuristics
Ordered or Best-Fit Search
• The basic algorithm is given by Nilsson (1971)
• The evaluation function f* is defined so that
the more promising a node is, the smaller is
the value of f*
– Estimates its distance to the goal node

• The node selected for expansion is the one at


which f* is minimum
• The search space is assumed to be a general
graph
Introduction to Artificial Intelligence 35
Ordered or Best-Fit Search - Algorithm
1. Put the start node s on a list called OPEN of unexpanded nodes.
Calculate f*(s) and associate its value with node s
2. If OPEN is empty, exit with failure; no solution exists
3. Select from OPEN a node i such that f*(i) is minimum. If several nodes
qualify choose i to be a goal node if there is one, otherwise choose
among them arbitrarily.
4. Remove node i from OPEN and place it on a list CLOSED of expanded
nodes
5. If i is a goal node, exit with success; a solution has been found

(continued on next slide)

Introduction to Artificial Intelligence 36


Ordered or Best-Fit Search - Algorithm
6. Expand node i
7. For each successor node j of i
a. Calculate f*(j)
b. If j is neither in list OPEN or list CLOSED, add it to OPEN. Attach a
pointer back from j to its predecessor i
c. If j was already on OPEN or CLOSED, compare the f* value just
calculated with the previously calculated value
d. If the new value is lower
i. Substitute it for the old value
ii. Point j back to i instead of to its previously found predecessor
iii. If j was on the CLOSED list, move it back to OPEN
8. Go to (2)

Introduction to Artificial Intelligence 37


A* Optimal search for an optimal solution

• Ordered search looked only at the promise of the node, not


necessarily at the minimum cost or path
• We can change f* slightly to find a minimum cost solution
• f*(n) = g*(n) + h*(n)
– g*(n) estimates the minimum cost of the start node to n
– h*(n) estimates the minimum cost of n to the goal
• h*
– is the carrier of heuristic information
– Should never overestimate the cost
• h*(n) <= h(n)

Introduction to Artificial Intelligence 38


Example – Breadth-First Search
• Given a number of amounts, try to find a
combination of amounts that matches
another amount
• Example
– We have 10, 20, 30, 40, ….., 100
– Find all combinations that produce eg 120
• We use Breadth-First search, ie find first those
with a minimum of depth – more likely

Introduction to Artificial Intelligence 39


Total number of combinations

Introduction to Artificial Intelligence 40


Heuristics
• Heuristic information
– Sort amounts in ascending sequence
– For each index
• Calculate minimum sum ahead
• Calculate maximum sum ahead
• Heuristic search
– Prune as soon as possible

Introduction to Artificial Intelligence 41


Heuristics
• Construction of Min/Max sum ahead

Introduction to Artificial Intelligence 42


Heuristics

Introduction to Artificial Intelligence 43


Heuristics
• Formula to calculate how many nodes are going to be pruned

Introduction to Artificial Intelligence 44


Heuristics
• Sign Reversal : try to prune as early as possible
• Decrease the gaps between minimum sum ahead
and maximum sum ahead as soon as possible
• Make sure the number with the highest absolute
value is at the front

• Reverse the sign of all amounts + the amount to


search if necessary

Introduction to Artificial Intelligence 45


Heuristics

Introduction to Artificial Intelligence 46


Heuristics

You might also like