ai1&2
ai1&2
.w
te
ARTIFICIAL INTELLIGENCE
o
VI SEMESTER CSE
n
se
/c
:/ UNITI
p
tt
1.1 INTRODUCTION
h
te
o
n
se
/c
1.1 Introduction to AI
:/
p
tt
1.1.1 What is artificial intelligence?
Artificial Intelligence is the branch of computer science concerned with making computers
h
The computer passes the test if a human interrogator,after posing some written questions,cannot tell
whether the written responses come from a person or not. Programming a computer to pass ,the
computer need to possess the following capabilities :
te
To pass the complete Turing Test,the computer will need
o
Computer vision to perceive the objects,and
n
Robotics to manipulate objects and move about.
se
(b)Thinking humanly : The cognitive modeling approach
/c
We need to get inside actual working of the human mind :
(a) through introspection – trying to capture our own thoughts as they go by;
(b) through psychological experiments
:/
Allen Newell and Herbert Simon,who developed GPS,the “General Problem Solver”
p
tried to trace the reasoning steps to traces of human subjects solving the same problems.
The interdisciplinary field of cognitive science brings together computer models from AI
tt
and experimental techniques from psychology to try to construct precise and testable
h
te
Brains and digital computers perform quite different tasks and have different properties. Tablere 1.1
shows that there are 10000 times more neurons in the typical human brain than there are gates in
o
the CPU of a typical highend computer. Moore’s Law predicts that the CPU’s gate count will equal
the brain’s neuron count around 2020.
n
se
Psycology(1879 – present)
The origin of scientific psychology are traced back to the wok if German physiologist Hermann von
Helmholtz(18211894) and his student Wilhelm Wundt(1832 – 1920)
/c
In 1879,Wundt opened the first laboratory of experimental psychology at the university of Leipzig.
In US,the development of computer modeling led to the creation of the field of cognitive science.
:/
The field can be said to have started at the workshop in September 1956 at MIT.
p
Computer engineering (1940present)
tt
For artificial intelligence to succeed, we need two things: intelligence and an artifact. The
computer has been the artifact of choice.
h
A1 also owes a debt to the software side of computer science, which has supplied the
operating systems, programming languages, and tools needed to write modern programs
Linguistics (1957present)
Modem linguistics and AI, then, were "born" at about the same time, and grew up
together, intersecting in a hybrid field called computational linguistics or natural language
processing.
te
able to prove theorems that many students of mathematics would find quite tricky.
Lisp was invented by John McCarthy in 1958 while he was at the Massachusetts Institute of
o
Technology (MIT). In 1963, McCarthy started the AI lab at Stanford.
Tom Evans's ANALOGY program (1968) solved geometric analogy problems that appear in IQ tests, such as
n
the one in Figure 1.1
se
/c
:/
p
tt
h
Figure 1.1 The Tom Evan’s ANALOGY program could solve geometric analogy problems as
shown.
te
memory.
A1 becomes a science (1987present)
o
In recent years, approaches based on hidden Markov models (HMMs) have come to dominate the area.
Speech technology and the related field of handwritten character recognition are already making the
n
transition to widespread industrial and consumer applications.
se
The Bayesian network formalism was invented to allow efficient representation of, and rigorous reasoning
with, uncertain knowledge.
The emergence of intelligent agents (1995present)
/c
One of the most important environments for intelligent agents is the Internet.
plans from highlevel goals specified from the ground, and it monitored the operation of the
spacecraft as the plans were executeddetecting, diagnosing, and recovering from problems
as they occurred.
Game playing: IBM's Deep Blue became the first computer program to defeat the
world champion in a chess match when it bested Garry Kasparov by a score of 3.5 to 2.5 in
an exhibition match (Goodman and Keene, 1997).
Autonomous control: The ALVINN computer vision system was trained to steer a car
to keep it following a lane. It was placed in CMU's NAVLAB computercontrolled minivan
and used to navigate across the United Statesfor 2850 miles it was in control of steering the
vehicle 98% of the time.
Diagnosis: Medical diagnosis programs based on probabilistic analysis have been able
to perform at the level of an expert physician in several areas of medicine.
Logistics Planning: During the Persian Gulf crisis of 1991, U.S. forces deployed a
Dynamic Analysis and Replanning Tool, DART (Cross and Walker, 1994), to do automated
logistics planning and scheduling for transportation. This involved up to 50,000 vehicles,
cargo, and people at a time, and had to account for starting points, destinations, routes, and
conflict resolution among all parameters. The AI planning techniques allowed a plan to be
generated in hours that would have taken weeks with older methods. The Defense Advanced
Research Project Agency (DARPA) stated that this single application more than paid back
DARPA's 30year investment in AI.
Robotics: Many surgeons now use robot assistants in microsurgery. HipNav (DiGioia
et al., 1996) is a system that uses computer vision techniques to create a threedimensional
model of a patient's internal anatomy and then uses robotic control to guide the insertion of a
hip replacement prosthesis.
Language understanding and problem solving: PROVERB (Littman et al., 1999) is a
computer program that solves crossword puzzles better than most humans, using constraints
on possible word fillers, a large database of past puzzles, and a variety of information sources
including dictionaries and online databases such as a list of movies and the actors that appear
in them.
te
o A human agent has eyes, ears, and other organs for sensors and hands, legs, mouth, and other body
parts for actuators.
o
o A robotic agent might have cameras and infrared range finders for sensors and various motors for
actuators.
n
o A software agent receives keystrokes, file contents, and network packets as sensory inputs and acts
on the environment by displaying on the screen, writing files, and sending network packets.
se
/c
:/
p
tt
h
Figure 1.2 Agents interact with environments through sensors and actuators.
Percept
We use the term percept to refer to the agent's perceptual inputs at any given instant.
Percept Sequence
An agent's percept sequence is the complete history of everything the agent has ever perceived.
Agent function
Mathematically speaking, we say that an agent's behavior is described by the agent function
that maps any given percept sequence to an action.
Agent program
Internally, The agent function for an artificial agent will be implemented by an agent program. It is
important to keep these two ideas distinct. The agent function is an abstract mathematical
description; the agent program is a concrete implementation, running on the agent architecture.
To illustrate these ideas, we will use a very simple examplethe vacuumcleaner world
shown in Figure 1.3. This particular world has just two locations: squares A and B. The vacuum
agent perceives which square it is in and whether there is dirt in the square. It can choose to move
left, move right, suck up the dirt, or do nothing. One very simple agent function is the following: if
the current square is dirty, then suck, otherwise move to the other square. A partial tabulation of this
agent function is shown in Figure 1.4.
e
.w
te
o
n
Figure 1.3 A vacuumcleaner world with just two
se
locations.
/c
Agent function
:/
p
Percept Sequence Action
tt
[A, Clean] Right
[A, Dirty] Suck
h
Rational Agent
A rational agent is one that does the right thingconceptually speaking, every entry in
the table for the agent function is filled out correctly. Obviously, doing the right thing is
better than doing the wrong thing. The right action is the one that will cause the agent to be
most successful.
Performance measures
A performance measure embodies the criterion for success of an agent's behavior. When
an agent is plunked down in an environment, it generates a sequence of actions according
to the percepts it receives. This sequence of actions causes the environment to go through a
sequence of states. If the sequence is desirable, then the agent has performed well.
Rationality
What is rational at any given time depends on four things:
o The performance measure that defines the criterion of success.
e
.w
o The agent's prior knowledge of the environment.
o The actions that the agent can perform.
te
o The agent's percept sequence to date.
o
This leads to a definition of a rational agent:
For each possible percept sequence, a rational agent should select an action that is ex
n
pected to maximize its performance measure, given the evidence provided by the percept
se
sequence and whatever builtin knowledge the agent has.
/c
An omniscient agent knows the actual outcome of its actions and can act accordingly; but
omniscience is impossible in reality.
:/
Doing actions in order to modify future perceptssometimes called information gatheringis
p
an important part of rationality.
Our definition requires a rational agent not only to gather information, but also to learn
tt
as much as possible from what it perceives.
To the extent that an agent relies on the prior knowledge of its designer rather than
h
on its own percepts, we say that the agent lacks autonomy. A rational agent should be
autonomousit should learn what it can to compensate for partial or incorrect prior knowledge.
Task environments
We must think about task environments, which are essentially the "problems" to which rational agents are
the "solutions."
Specifying the task environment
The rationality of the simple vacuumcleaner agent, needs specification of
o the performance measure
o the environment
o the agent's actuators and sensors.
PEAS
All these are grouped together under the heading of the task environment.
We call this the PEAS (Performance, Environment, Actuators, Sensors) description.
In designing an agent, the first step must always be to specify the task environment as fully
as possible.
Agent Type Performance Environments Actuators Sensors
Measure
Taxi driver Safe: fast, legal, Roads,other Steering,accelerator, Cameras,sonar,
comfortable trip, traffic,pedestrians, brake, Speedometer,GPS,
maximize profits customers Signal,horn,display Odometer,engine
sensors,keyboards,
accelerometer
Figure 1.5 PEAS description of the task environment for an automated taxi.
e
.w
te
o
n
se
/c
:/
p
tt
h
te
In sequential environments, on the other hand, the current decision
could affect all future decisions. Chess and taxi driving are sequential:
o
Discrete vs. continuous.
The discrete/continuous distinction can be applied to the state of the environment, to
n
the way time is handled, and to the percepts and actions of the agent. For example, a
se
discretestate environment such as a chess game has a finite number of distinct states.
Chess also has a discrete set of percepts and actions. Taxi driving is a continuous
state and continuoustime problem: the speed and location of the taxi and of the other
/c
vehicles sweep through a range of continuous values and do so smoothly over time.
Taxidriving actions are also continuous (steering angles, etc.).
:/
p
Single agent vs. multiagent.
An agent solving a crossword puzzle by itself is clearly in a
tt
singleagent environment, whereas an agent playing chess is in a twoagent environ
ment.
h
As one might expect, the hardest case is partially observable, stochastic, sequential, dynamic,
continuous, and multiagent.
Agent programs
The agent programs all have the same skeleton: they take the current percept as input from the
sensors and return an action to the actuatom6 Notice the difference between the agent program,
which takes the current percept as input, and the agent function, which takes the entire percept
history. The agent program takes just the current percept as input because nothing more is available
from the environment; if the agent's actions depend on the entire percept sequence, the agent will
have to remember the percepts.
te
return action
o
n
Figure 1.8 The TABLEDRIVENAGENT program is invoked for each new percept and
returns an action each time.
se
Drawbacks:
/c
• Table lookup of perceptaction pairs defining all possible conditionaction rules necessary
to interact in an environment
• Problems
:/
– Too big to generate and to store (Chess has about 10^120 states, for example)
p
– No knowledge of nonperceptual parts of the current state
– Not adaptive to changes in the environment; requires entire table to be updated if
tt
changes occur
h
The simplest kind of agent is the simple reflex agent. These agents select actions on the basis of the
current percept, ignoring the rest of the percept history. For example, the vacuum agent whose agent function
is tabulated in Figure 1.10 is a simple reflex agent, because its decision is based only on the current location
and on whether that contains dirt.
o Select action on the basis of only the current percept.
E.g. the vacuumagent
o Large reduction in possible percept/action situations(next page).
o Implemented through conditionaction rules
If dirty then suck
e
.w
A Simple Reflex Agent: Schema
te
o
n
se
/c
:/
p
tt
h
Figure 1.10 A simple reflex agent. It acts according to a rule whose condition matches
the current state, as defined by the percept.
Figure 1.11 The agent program for a simple reflex agent in the twostate vacuum environment. This
program implements the agent function tabulated in the figure 1.4.
Characteristics
o Only works if the environment is fully observable.
o Lacking history, easily get stuck in infinite loops
o One solution is to randomize actions
o
Modelbased reflex agents
The most effective way to handle partial observability is for the agent to keep track of the part of the
world it can't see now. That is, the agent should maintain some sort of internal state that depends
e
.w
on the percept history and thereby reflects at least some of the unobserved aspects of the current
state.
te
Updating this internal state information as time goes by requires two kinds of knowledge to be
encoded in the agent program. First, we need some information about how the world evolves
o
independently of the agentfor example, that an overtaking car generally will be closer behind than
it was a moment ago. Second, we need some information about how the agent's own actions affect
n
the worldfor example, that when the agent turns the steering wheel clockwise, the car turns to the
se
right or that after driving for five minutes northbound on the freeway one is usually about five miles
north of where one was five minutes ago. This knowledge about "how the world working whether
implemented in simple Boolean circuits or in complete scientific theoriesis called a model of the
/c
world. An agent that uses such a MODELBASED model is called a modelbased agent.
:/
p
tt
h
Figure 1.13 Model based reflex agent. It keeps track of the current state of the world using an internal
model. It then chooses an action in the same way as the reflex agent.
Goalbased agents
Knowing about the current state of the environment is not always enough to decide what to do. For example, at a
road junction, the taxi can turn left, turn right, or go straight on. The correct decision depends on where the taxi is
trying to get to. In other words, as well as a current state description, the agent needs some sort of goal
information that describes situations that are desirablefor example, being at the passenger's destination. The agent
program can combine this with information about the results of possible actions (the same information as
was used to update internal state in the reflex agent) in order to choose actions that achieve the goal. Figure
1.13 shows the goalbased agent's structure.
e
.w
te
o
n
se
/c
:/
p
tt
h
Utilitybased agents
Goals alone are not really enough to generate highquality behavior in most environments. For
example, there are many action sequences that will get the taxi to its destination (thereby achieving
the goal) but some are quicker, safer, more reliable, or cheaper than others. Goals just provide a
crude binary distinction between "happy" and "unhappy" states, whereas a more general
performance measure should allow a comparison of different world states according to exactly
how happy they would make the agent if they could be achieved. Because "happy" does not sound
very scientific, the customary terminology is to say that if one world state is preferred to another,
then it has higher utility for the agent.
Figure 1.15 A modelbased, utilitybased agent. It uses a model of the world, along with
a utility function that measures its preferences among states of the world. Then it chooses the
action that leads to the best expected utility, where expected utility is computed by averaging
over all possible outcome states, weighted by the probability of the outcome.
e
.w
• Certain goals can be reached in different ways.
– Some are better, have a higher utility.
te
• Utility function maps a (sequence of) state(s) onto a real number.
• Improves on goals:
o
– Selecting between conflicting goals
– Select appropriately between several goals based on likelihood of success.
n
se
/c
:/
p
tt
h
te
– Goalbased agents act in order to achieve their goal(s).
– Utilitybased agents maximize their own utility function.
o
• All agents can improve their performance through learning.
n
se
1.3.1 Problem Solving by Search
An important aspect of intelligence is goalbased problem solving.
/c
The solution of many problems can be described by finding a sequence of actions that lead to a
desirable goal. Each action changes the state and the aim is to find the sequence of actions and
:/
states that lead from the initial (start) state to a final (goal) state.
p
A welldefined problem can be described by:
tt
Initial state
Operator or successor function for any state x returns s(x), the set of states reachable
h
Goal formulation,based on the current situation and the agent’s performance measure,is the first
step in problem solving.
The agent’s task is to find out which sequence of actions will get to a goal state.
Problem formulation is the process of deciding what actions and states to consider given a goal.
te
actions: drive between cities
o
Find solution:
sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
n
Problem formulation
se
A problem is defined by four items:
initial state e.g., “at Arad"
/c
successor function S(x) = set of actionstate pairs
e.g., S(Arad) = {[Arad > Zerind;Zerind],….}
:/
goal test, can be
explicit, e.g., x = at Bucharest"
p
implicit, e.g., NoDirt(x)
path cost (additive)
tt
e.g., sum of distances, number of actions executed, etc.
h
Search
An agent with several immediate options of unknown value can decide what to do by examining
different possible sequences of actions that leads to the states of known value,and then choosing the
best sequence. The process of looking for sequences actions from the current state to reach the goal
state is called search.
The search algorithm takes a problem as input and returns a solution in the form of action
sequence. Once a solution is found,the execution phase consists of carrying out the recommended
action..
Figure 1.18 shows a simple “formulate,search,execute” design for the agent. Once solution has been
executed,the agent will formulate a new goal.
te
• Static : The entire process carried out without paying attention to changes that
might be occurring in the environment.
o
• Observable : The initial state is known and the agent’s sensor detects all aspects that
n
are relevant to the choice of action
• Discrete : With respect to the state of the environment and percepts and actions so
se
that alternate courses of action can be taken
• Deterministic : The next state of the environment is completely determined by the
/c
current state and the actions executed by the agent. Solutions to the problem are
single sequence of actions
An agent carries out its plan with eye closed. This is called an open loop system because ignoring
:/
the percepts breaks the loop between the agent and the environment.
p
tt
h
A path cost function assigns numeric cost to each action. For the Romania problem the cost
of path might be its length in kilometers.
The step cost of taking action a to go from state x to state y is denoted by c(x,a,y). The step
cost for Romania are shown in figure 1.18. It is assumed that the step costs are non negative.
A solution to the problem is a path from the initial state to a goal state.
An optimal solution has the lowest path cost among all solutions.
e
.w
te
o
n
se
/c
:/
p
tt
h
o States: The agent is in one of two locations.,each of which might or might not contain dirt.
Thus there are 2 x 22 = 8 possible world states.
o Initial state: Any state can be designated as initial state.
o Successor function : This generates the legal states that results from trying the three actions
(left, right, suck). The complete state space is shown in figure 2.3
o Goal Test : This tests whether all the squares are clean.
o Path test : Each step costs one ,so that the the path cost is the number of steps in the path.
The 8puzzle
An 8puzzle consists of a 3x3 board with eight numbered tiles and a blank space. A tile adjacent to
the balank space can slide into the space. The object is to reach the goal state ,as shown in figure 2.4
Example: The 8puzzle
te
The 8puzzle has 9!/2 = 181,440 reachable states and is easily solved.
The 15 puzzle ( 4 x 4 board ) has around 1.3 trillion states,an the random instances can be
o
solved optimally in few milli seconds by the best search algorithms.
The 24puzzle (on a 5 x 5 board) has around 1025 states ,and random instances are still quite
n
difficult to solve optimally with current machines and algorithms.
se
8queens problem
/c
The goal of 8queens problem is to place 8 queens on the chessboard such that no queen
attacks any other.(A queen attacks any piece in the same row,column or diagonal).
:/
Figure 2.5 shows an attempted solution that fails: the queen in the right most column is
attacked by the queen at the top left.
p
An Incremental formulation involves operators that augments the state description,starting
with an empty state.for 8queens problem,this means each action adds a queen to the state.
tt
A completestate formulation starts with all 8 queens on the board and move them around.
h
In either case the path cost is of no interest because only the final state counts.
te
o
ROUTEFINDING PROBLEM
Routefinding problem is defined in terms of specified locations and transitions along links
n
between them. Routefinding algorithms are used in a variety of applications,such as routing in
se
computer networks,military operations planning,and air line travel planning systems.
/c
The airline travel problem is specifies as follows :
o States : Each is represented by a location(e.g.,an airport) and the current time.
:/
o Initial state : This is specified by the problem.
o Successor function : This returns the states resulting from taking any scheduled
p
flight(further specified by seat class and location),leaving later than the current time plus
tt
the withinairport transit time,from the current airport to another.
o Goal Test : Are we at the destination by some prespecified time?
h
o Path cost : This depends upon the monetary cost,waiting time,flight time,customs and
immigration procedures,seat quality,time of dat,type of air plane,frequentflyer mileage
awards, and so on.
TOURING PROBLEMS
Touring problems are closely related to routefinding problems,but with an important difference.
Consider for example,the problem,”Visit every city at least once” as shown in Romania map.
As with routefinding the actions correspond to trips between adjacent cities. The state space,
however,is quite different.
The initial state would be “In Bucharest; visited{Bucharest}”.
A typical intermediate state would be “In Vaslui;visited {Bucharest,Urziceni,Vaslui}”.
The goal test would check whether the agent is in Bucharest and all 20 cities have been visited.
VLSI layout
A VLSI layout problem requires positioning millions of components and connections on a chip
to minimize area ,minimize circuit delays,minimize stray capacitances,and maximize
manufacturing yield. The layout problem is split into two parts : cell layout and channel
routing.
ROBOT navigation
ROBOT navigation is a generalization of the routefinding problem. Rather than a discrete set
of routes,a robot can move in a continuous space with an infinite set of possible actions and
states. For a circular Robot moving on a flat surface,the space is essentially twodimensional.
When the robot has arms and legs or wheels that also must be controlled,the search space
becomes multidimensional. Advanced techniques are required to make the search space finite.
e
.w
AUTOMATIC ASSEMBLY SEQUENCING
The example includes assembly of intricate objects such as electric motors. The aim in assembly
te
problems is to find the order in which to assemble the parts of some objects. If the wrong order
is choosen,there will be no way to add some part later without undoing somework already done.
o
Another important assembly problem is protein design,in which the goal is to find a sequence of
Amino acids that will be fold into a threedimensional protein with the right properties to cure
n
some disease.
se
INTERNET SEARCHING
In recent years there has been increased demand for software robots that perform Internet
/c
searching.,looking for answers to questions,for related information,or for shopping deals. The
searching techniques consider internet as a graph of nodes(pages) connected by links.
:/
p
1.3.3 SEARCHING FOR SOLUTIONS
tt
h
SEARCH TREE
Having formulated some problems,we now need to solve them. This is done by a search through
the state space. A search tree is generated by the initial state and the successor function that
together define the state space. In general,we may have a search graph rather than a search
tree,when the same state can be reached from multiple paths.
Figure 1.23 shows some of the expansions in the search tree for finding a route from Arad to
Bucharest.
Figure 1.23 Partial search trees for finding a route from Arad to Bucharest. Nodes that have
been expanded are shaded.; nodes that have been generated but not yet expanded are outlined in
bold;nodes that have not yet been generated are shown in faint dashed line
The root of the search tree is a search node corresponding to the initial state,In(Arad). The first
step is to test whether this is a goal state. The current state is expanded by applying the successor
function to the current state,thereby generating a new set of states. In this case,we get three new
states: In(Sibiu),In(Timisoara),and In(Zerind). Now we must choose which of these three
possibilities to consider further. This is the essense of search following up one option now and
putting the others aside for latter,in case the first choice does not lead to a solution.
Search strategy . The general treesearch algorithm is described informally in Figure 1.24
.
Tree Search
e
.w
te
o
n
se
/c
Figure 1.24 An informal description of the general treesearch algorithm
:/
p
tt
The choice of which state to expand is determined by the search strategy. There are an infinite
number paths in this state space ,so the search tree has an infinite number of nodes.
h
Figure 1.25 Nodes are data structures from which the search tree is
constructed. Each has a parent,a state, Arrows point from child to parent.
Fringe
Fringe is a collection of nodes that have been generated but not yet been expanded. Each element
of the fringe is a leaf node,that is,a node with no successors in the tree. The fringe of each tree
consists of those nodes with bold outlines.
e
.w
The collection of these nodes is implemented as a queue.
The general tree search algorithm is shown in Figure 2.9
te
o
n
se
/c
:/
p
tt
h
te
Strategies that know whether one non goal state is “more promising” than another are called
Informed search or heuristic search strategies.
o
There are five uninformed search strategies as given below.
n
o Breadthfirst search
se
o Uniformcost search
o Depthfirst search
o Depthlimited search
/c
o Iterative deepening search
:/
1.3.4.1 Breadthfirst search
p
Breadthfirst search is a simple strategy in which the root node is expanded first,then all
successors of the root node are expanded next,then their successors,and so on. In general,all the
tt
nodes are expanded at a given depth in the search tree before any nodes at the next level are
h
expanded.
Breathfirstsearch is implemented by calling TREESEARCH with an empty fringe that is a
firstinfirstout(FIFO) queue,assuring that the nodes that are visited first will be expanded first.
In otherwards,calling TREESEARCH(problem,FIFOQUEUE()) results in breadthfirstsearch.
The FIFO queue puts all newly generated successors at the end of the queue,which means that
Shallow nodes are expanded before deeper nodes.
Figure 1.27 Breadthfirst search on a simple binary tree. At each stage ,the node to be expanded next
is indicated by a marker.
Properties of breadthfirstsearch
te
lowest path cost. uniformcost search does not care about the number of steps a path has,but only
about their total cost.
o
n
se
/c
:/
p
tt
h
2.5.1.3 DEPTHFIRSTSEARCH
Depthfirstsearch always expands the deepest node in the current fringe of the search tree. The
progress of the search is illustrated in figure 1.31. The search proceeds immediately to the
deepest level of the search tree,where the nodes have no successors. As those nodes are
expanded,they are dropped from the fringe,so then the search “backs up” to the next shallowest
node that still has unexplored successors.
e
.w
te
o
n
se
/c
:/
p
tt
h
Figure 1.31 Depthfirstsearch on a binary tree. Nodes that have been expanded and have no
descendants in the fringe can be removed from the memory;these are shown in black. Nodes at
depth 3 are assumed to have no successors and M is the only goal node.
This strategy can be implemented by TREESEARCH with a lastinfirstout (LIFO) queue,also
known as a stack.
Depthfirstsearch has very modest memory requirements.It needs to store only a single path
from the root to a leaf node,along with the remaining unexpanded sibling nodes for each node on
the path. Once the node has been expanded,it can be removed from the memory,as soon as its
descendants have been fully explored(Refer Figure 2.12).
For a state space with a branching factor b and maximum depth m,depthfirstsearch requires
storage of only bm + 1 nodes.
Using the same assumptions as Figure 2.11,and assuming that nodes at the same depth as the goal
node have no successors,we find the depthfirstsearch would require 118 kilobytes instead of 10
petabytes,a factor of 10 billion times less space.
Drawback of Depthfirstsearch
The drawback of depthfirstsearch is that it can make a wrong choice and get stuck going down
very long(or even infinite) path when a different choice would lead to solution near the root of the
search tree. For example ,depthfirstsearch will explore the entire left subtree even if node C is a
goal node.
e
.w
BACKTRACKING SEARCH
A variant of depthfirst search called backtracking search uses less memory and only one successor
te
is generated at a time rather than all successors.; Only O(m) memory is needed rather than O(bm)
o
1.3.4.4 DEPTHLIMITEDSEARCH
n
The problem of unbounded trees can be alleviated by supplying depthfirstsearch with a pre
se
determined depth limit l.That is,nodes at depth l are treated as if they have no successors. This
approach is called depthlimitedsearch. The depth limit soves the infinite path problem.
/c
Depth limited search will be nonoptimal if we choose l > d. Its time complexity is O(bl) and its
space compleiy is O(bl). Depthfirstsearch can be viewed as a special case of depthlimited search
with l = oo
:/
Sometimes,depth limits can be based on knowledge of the problem. For,example,on the map of
p
Romania there are 20 cities. Therefore,we know that if there is a solution.,it must be of length 19 at
the longest,So l = 10 is a possible choice. However,it oocan be shown that any city can be reached
tt
from any other city in at most 9 steps. This number known as the diameter of the state space,gives
h
te
Figure 2.15 shows the four iterations of ITERATIVEDEEPENING_SEARCH on a binary search
tree,where the solution is found on the fourth iteration.
o
n
se
/c
:/
p
tt
h
Figure 1.33 The iterative deepening search algorithm ,which repeatedly applies depthlimited
search with increasing limits. It terminates when a solution is found or if the depth limited search
resturns failure,meaning that no solution exists.
e
.w
te
o
n
se
/c
:/
p
tt
h
te
S S
o
S
n
A D
Limit = 0
se
Limit = 1
/c
S S S
A
:/ D A D
p
tt
B D A E
Limit = 2
h
Figure 1.35
Figure 1.36
e
.w
In general,iterative deepening is the prefered uninformed search method when there is a
large search space and the depth of solution is not known.
te
1.3.4.6 Bidirectional Search
The idea behind bidirectional search is to run two simultaneous searches –
o
one forward from he initial state and
n
the other backward from the goal,
stopping when the two searches meet in the middle (Figure 1.37)
se
The motivation is that bd/2 + bd/2 much less than ,or in the figure ,the area of the two small circles is
less than the area of one big circle centered on the start and reaching to the goal.
/c
:/
p
tt
h
Figure 1.38 Evaluation of search strategies,b is the branching factor; d is the depth of the
shallowest solution; m is the maximum depth of the search tree; l is the depth limit. Superscript
caveats are as follows: a complete if b is finite; b complete if step costs >= E for positive E; c
optimal if step costs are all identical; d if both directions use breadthfirst search.
te
A A
o
B B B
n
C C C
se
C C
Figure 1.39
/c
:/
p
tt
h
Figure 1.40
e
.w
te
o
n
se
/c
Figure 1.41 The General graph search algorithm. The set closed can be implemented with a hash
:/
table to allow efficient checking for repeated states.
p
Do not return to the previous state.
tt
• Do not create paths with cycles.
h
o No sensor
o Initial State(1,2,3,4,5,6,7,8)
o After action [Right] the state (2,4,6,8)
o After action [Suck] the state (4, 8)
o After action [Left] the state (3,7)
o After action [Suck] the state (8)
e
.w
o Answer : [Right,Suck,Left,Suck] coerce the world into state 7 without any
sensor
te
o Belief State: Such state that agent belief to be there
o
(SLIDE 7) Partial knowledge of states and actions:
– sensorless or conformant problem
n
– Agent may have no idea where it is; solution (if any) is a sequence.
se
– contingency problem
– Percepts provide new information about current state; solution is a tree or
/c
policy; often interleave search and execution.
– If uncertainty is caused by actions of another agent: adversarial problem
:/
– exploration problem
– When states and actions of the environment are unknown.
p
tt
h
Figure
e
.w
te
o
n
se
/c
:/
p
tt
h
Figure
Time and space complexity are always considered with respect to some measure of the problem
difficulty. In theoretical computer science ,the typical measure is the size of the state space.
In AI,where the graph is represented implicitly by the initial state and successor function,the
complexity is expressed in terms of three quantities:
e
.w
b,the branching factor or maximum number of successors of any node;
d,the depth of the shallowest goal node; and
te
m,the maximum length of any path in the state space.
o
Searchcost typically depends upon the time complexity but can also include the term for
memory usage.
n
Total–cost – It combines the searchcost and the path cost of the solution found.
se
/c
:/
p
tt
h