Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

CMP 446 BASIC SEARCH

STRATEGIES
DR. S.A. AREKETE
COURSE CONTENTS
• Problem spaces (states, goals and operators), problem solving by
search, Factored representation (factoring state into variables),
Uninformed search (breadth-first, depth-first, depth-first with
iterative deepening), Heuristics and informed search (hill-
climbing, generic best-first, A*), Space and time efficiency of
search, Two-player games (Introduction to mini-max search),
Constraint satisfaction (backtracking and local search methods),
Review of propositional and predicate logic (cross-reference
DS/Basic Logic), Resolution and theorem proving (propositional
logic only), Forward chaining, backward chaining, Review of
probabilistic reasoning, Bayes theorem
Work Plan
Week# Topics Activity/Assignments

1 Problem spaces (states, goals and operators), problem solving by search, Factored
representation (factoring state into variables)
2-4 Uninformed search (Random Search, Generate and test breadth-first, depth-first, depth-first Assignment 1
with iterative deepening)
5-6 Heuristics and informed search (hill-climbing, generic best-first, A*), Space and time
efficiency of search, Two-player games (Introduction to mini-max search)
7 Continuous Assessment Test 1

8 Student Presentations

9 Space and time efficiency of search, Two-player games (Introduction to mini-max search), Assignment 2
Constraint satisfaction (backtracking and local search methods)
10 Constraint satisfaction (backtracking and local search methods), Review of propositional and
predicate logic (cross-reference DS/Basic Logic),
11-12 Resolution and theorem proving (propositional logic only), Forward chaining, backward Assignment 3
chaining, Review of probabilistic reasoning, Bayes theorem

13 Revision
SEARCH IN INTELLIGENT SYSTEMS
• Search is a natural part of most peoples’ lives.
• You must have misplaced house keys or the TV’s remote control,
and then retraced our footsteps around our home, overturning
cushions and checking pockets?
• At times a search might be more cerebral.
• You have probably had occasions when you simply cannot recall the
name of a place you have visited, the name of an actor in a movie you
had really enjoyed, or the words to a song you once knew so well.
• It could be seconds (or longer, as one grows older) before the memory
ceases to elude you.
SEARCH IN INTELLIGENT SYSTEMS..
• Many algorithms are devoted to searching and sorting through a list.
• Certainly, one would agree that searching is facilitated if the data is
organized in logical order.
• Imagine how cumbersome it would be to search through a phone
book of a relatively large city if the names and phone numbers were
arranged randomly.
• It should therefore come as no surprise that search and organization
play important roles in the design of intelligent systems.
• Perhaps it is the search for the name of a locale once visited, or the
next number in a sequence
STATE-SPACE GRAPHS
• State-space graphs display a representation of a problem
whereby possible alternative paths leading to a solution can be
explored and analyzed.
• A solution to a particular problem will correspond to a path
through a state-space graph.
• Sometimes we search for any solution to a problem; at other
times we desire a shortest (or optimal) solution.
FORMAL DESCRIPTION OF A PROBLEM
• In AI, we will formally define a problem as
• a space of all possible configurations where each
configuration is called a state, thus, we use the term
• state space
• an initial state
• one or more goal states
• a set of rules/operators which move the problem from one
state to the next
FORMAL DESCRIPTION OF A PROBLEM..
• In some cases, we may enumerate all possible states
(see monkey & banana problem on the next slide)
• but usually, such an enumeration will be overwhelmingly
large so we only generate a portion of the state space, the
portion we are currently examining
• we will view our state space as a graph or network and apply
graph algorithms to search through the space
The Monkey & Bananas Problem
• A monkey is in a cage and bananas are suspended from
the ceiling, the monkey wants to eat a banana but
cannot reach them
• in the room are a chair and a stick
• if the monkey stands on the chair and waves the stick, he can
knock a banana down to eat it
• what are the actions the monkey should take?
The Monkey & Bananas Problem..
• Initial state:
• monkey on ground
• with empty hand
• bananas suspended
• Goal state:
• monkey eating
• Actions:
• climb chair/get off
• grab X
• wave X
• eat X
The False Coin Problem
• A well-known problem in computer science is the False Coin
Problem.
• There are 12 coins, one of which is known to be false, or
counterfeit.
• It is not known, however, whether the false coin is lighter or heavier
than the others.
• An ordinary balance scale can be used to determine if any two sets of
coins weigh the same or if one set is heavier or lighter than the other.
• To solve the problem, you should be able to create a procedure to
identify the false coin by weighing only three combinations of coins.
The False Coin Problem..
• We first solve a simpler instance of this problem involving only
six coins; it also requires comparing three sets of coins as in the
original problem above, but in this case the sets are smaller.
• We call this the Mini False Coin Problem.
• We use the notation Ci1 Ci2...Cir: Cj1 Cj2…Cjr to indicate that the r
coins Ci1 Ci2...Cir are being weighed against the r coins Cj1 Cj2…Cjr.
• The result will be that the two sets of coins weigh the same or
that they do not.
The False Coin Problem..
• We will not require further knowledge about whether the coins
on the left weigh more or less than the coins on the right.
• That would be needed in the solution to the full false coin problem.
• Finally, we employ the notation [Ck1 Ck2…Ckm] to indicate that a
subset of m coins is the smallest set known to contain the false
coin.
• One solution to this Mini False Coin Problem is provided in
Figure 2.1.
The False Coin Problem..
• Figure 2.1 is an example of a state-space tree.
• A state-space tree consists of nodes and branches.
• An oval is a node and represents a state of the problem.
• Arcs between nodes represent operators (or results of operators) that
take the state-space tree to new nodes.
• Consult the node in Figure 2.1 labeled with (*).
• This node [C1 C2 C3 C4] indicates that the false coin might be any one of
C1, C2, C3, or C4.
The False Coin Problem..
• We have decided to weigh C1
and C2 versus C5 and C6
(operator applied).
• If the result is that these sets
of two coins each are equal in
weight, then we know that
the false coin must be one of
C3 or C4; if they are unequal
then we are sure that one of
C1 or C2 is the false coin.
Why?
The False Coin Problem..
• There are two special types of
nodes.
• The first is a start node that
represents the start state of a
problem.
• In Figure 2.1, the start node is
[C1 C2 C3 C4 C5 C6], which
indicates that when we begin,
the false coin could be any
one of the six coins.
The False Coin Problem..
• Another special type of node
corresponds to a final or
terminal state of the problem.
• The state-space tree in Figure
2.1 has six terminal nodes;
each labeled [Ci], where i =
1,…,6 and where the value of
i specifies which coin is false.
The False Coin Problem..
• The state-space tree for a problem contains all states that a
problem could be in, as well as all possible transitions between
these states.
• In fact, because loops often occur, such a structure is more
generally called a state-space graph.
• The solution for a problem often entails a search through this
structure (whether it is a tree or graph) that begins at a start
state and culminates at a final or goal state.
• Sometimes we are concerned with finding a solution (whatever
its cost); at other times we might desire a solution of minimum
cost.
The False Coin Problem..
• By the cost of a solution, we are referring to the number of operators
required to reach a goal state and not to the amount of work required
to actually find this solution.
• An analogy to computer science might be that we are equating a
solution’s cost with running time rather than software development
time.
• We have used the terms node and state interchangeably.
• However, these are distinct concepts.
• In general, a state-space graph can contain many nodes that
represent the same problem state, as shown in Figure 2.2.
• Revisiting the Mini False Coin Problem, we observe that by weighing
two different sets of coins, we can arrive at distinct nodes that
represent the same state.
The False Coin Problem..
• A solution to the Mini False
Coin Problem is shown in
Figure 2.1.
• It might be true that the
person solving this problem is
wearing a blue shirt, or that
someone else needed a tall cup
of coffee before tackling the
12-coin version of the problem.
• Such details, however, are, and
should remain, extraneous to a
solution.
• Abstraction allows you to
exorcise such minutiae.
Structures for State Space Search
--Graph Theory
• A graph is a set of nodes or states and a set of arcs that connect
the nodes.
• A labelled graph has one or more descriptors (labels) attached to
each node that distinguish that node from any other node in the
graph.
• In a state space graph, these descriptors identify states in a problem-
solving process.
• If there are no descriptive differences between two nodes, they are
considered the same.
• The arc between two nodes is indicated by the labels of the
connected nodes.
Structures for State Space Search..
--Graph Theory
• The arcs of a graph may also be
labelled.
• When arc labels are used, they can to
indicate either:
• a named relationship (as in a semantic
network), or
• to attach weights to arcs (as in the
traveling salesperson problem).
• If there are different arcs between the
same two nodes (as in Figure 3.2),
these can also be distinguished through
labelling.
Structures for State Space Search
--Graph Theory
• A graph is directed if arcs have an
associated directionality.
• The arcs in a directed graph are usually
drawn as arrows or have an arrow
attached to indicate direction.
• Arcs that can be crossed in either
direction may have two arrows
attached but more often have no
direction indicators at all.
• Figure 3.3 is a labelled, directed graph:
• arc (a, b) may only be crossed from node a
to node b, but arc (b, c) is crossable in
either direction.
Structures for State Space Search
--Graph Theory
• A rooted graph has a unique node, called the root,
such that there is a path from the root to all nodes
within the graph.
• In drawing a rooted graph, the root is usually
drawn at the top of the page, above the other
nodes.
• The state space graphs for games are usually
rooted graphs with the start of the game as the
root.
• The initial moves of the tic-tac-toe game graph are
represented by the rooted graph of Figure II.5.
• This is a directed graph with all arcs having a single
direction.
• Note that this graph contains no cycles; players
cannot (as much as they might sometimes wish!)
undo a move.
Structures for State Space Search
--Graph Theory
• A tree is a graph in which two nodes have at most one path
between them.
• Trees often have roots, in which case they are usually drawn
with the root at the top, like a rooted graph.
• Because each node in a tree has only one path of access from
any other node, it is impossible for a path to loop or cycle
through a sequence of nodes.
Structures for State Space Search
--Graph Theory
• For rooted trees or graphs, relationships
between nodes include parent, child, and
sibling.
• These are used in the usual familial fashion
with the parent preceding its child along a
directed arc.
• The children of a node are called siblings.
• Similarly, an ancestor comes before a
descendant in some path of a directed graph.
• In Figure 3.4, b is a parent of nodes e and f
(which are, therefore, children of b and
siblings of each other).
• Nodes a and c are ancestors of states g, h, and
i, and g, h, and i are descendants of a and c.
Structures for State Space Search
--Graph Theory
Structures for State Space Search
--Graph Theory
• The edges in a rooted tree are directed away from the root.
• Each node in a rooted tree has a unique parent.
• Two nodes are said to be connected if a path exists that includes them
both.
STATE SPACE SEARCH
• A state space is represented by a four-tuple [N,A,S,GD], where:
• N is the set of nodes or states of the graph.
• These correspond to the states in a problem-solving process.
• A is the set of arcs (or links) between nodes.
• These correspond to the steps in a problem-solving process.
• S, a nonempty subset of N, contains the start state(s) of the problem.
• GD, a nonempty subset of N, contains the goal state(s) of the problem.
• The states in GD are described using either:
1. A measurable property of the states encountered in the search.
2. A measurable property of the path developed in the search, for example, the sum of the
transition costs for the arcs of the path.
• A solution path is a path through this graph from a node in S to a node in GD.

You might also like