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

Ai Mcs101 Module 1 Notes

Artificial intelligence (AI) is a branch of computer science focused on creating machines that can mimic human intelligence and learn from data. The document outlines four main approaches to AI: acting humanly (Turing Test), thinking humanly (cognitive modeling), thinking rationally (laws of thought), and acting rationally (rational agent approach). It also discusses the foundations and current applications of AI, including robotics, speech recognition, and problem-solving agents.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Ai Mcs101 Module 1 Notes

Artificial intelligence (AI) is a branch of computer science focused on creating machines that can mimic human intelligence and learn from data. The document outlines four main approaches to AI: acting humanly (Turing Test), thinking humanly (cognitive modeling), thinking rationally (laws of thought), and acting rationally (rational agent approach). It also discusses the foundations and current applications of AI, including robotics, speech recognition, and problem-solving agents.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Module 1

 Artificial intelligence (AI) is a term to describe a branch of computer science that is


dedicated to creating intelligent machines that would learn to work and react like
humans.

 AI which stands for artificial intelligence refers to systems or machines that mimic
human intelligence to perform tasks and can iteratively improve themselves based
on the information they collect.

1.1 WHAT IS AI?

 The field of artificial intelligence, or AI, it attempts not just to understand but also to build
intelligent entities.
 AI currently encompasses a huge variety of subfields, ranging from the general (learning and
perception) to the specific, such as playing chess, proving mathematical theorems, writing poetry,
driving a car on a crowded street, and diagnosing diseases.
 AI is relevant to any intellectual task; it is truly a universal field.
 In Figure 1.1 we see eight definitions of AI, laid out along two dimensions.
 The definitions on top are concerned with thought processes and reasoning, whereas the ones on the
bottom address behavior.
 The definitions on the left measure success in terms of fidelity to human performance, whereas
RATIONALITY the ones on the right measure against an ideal performance measure, called
rationality.
 A system is rational if it does the “right thing,” given what it knows. Historically, all four approaches
to AI have been followed, each by different people with different methods.
 A human-centered approach must be in part an empirical science, involving observations and
hypotheses about human behavior.
 A rationalist approach involves a combination of mathematics and engineering.

Rohith Murthy ([email protected])


Four approaches to AI:
1. Acting humanly: The Turing Test approach
2. Thinking humanly: The cognitive modeling approach
3. Thinking rationally: The “laws of thought” approach
4. Acting rationally: The rational agent approach

1.1.1 Acting humanly: The Turing Test approach

 The Turing Test, proposed by Alan Turing (1950), was designed to provide a satisfactory
operational definition of intelligence.
 A computer passes the test if a human interrogator, after posing some written questions, cannot
tell whether the written responses come from a person or from a computer.
 The computer would need to possess the following capabilities:

 Turing’s test deliberately avoided direct physical interaction between the interrogator and the
computer, because physical simulation of a person is unnecessary for intelligence. However, the
so- called total Turing Test includes a video signal so that the interrogator can test the subject’s
perceptual abilities, as well as the opportunity for the interrogator to pass physical objects “through
the hatch.”

 To pass the total Turing Test, the computer will need


 COMPUTER VISION: computer vision to perceive objects, and
 ROBOTICS: robotics to manipulate objects and move about.

1.1.2 Thinking humanly: The cognitive modeling approach

 To say that a program thinks like a human, we must know how humans think. We can learn about
human thought in three ways:
• introspection—trying to catch our own thoughts as they go by;
• psychological experiments—observing a person in action;
• brain imaging—observing the brain in action.

 Once we have a sufficiently precise theory of the mind, it becomes possible to express the theory as
a computer program.
 If the program’s input–output behavior matches corresponding human behavior, that is evidence that
some of the program’s mechanisms could also be operating in humans.
For example, Allen Newell and Herbert Simon, who developed GPS, the “General Problem Solver”
(Newell and Simon, 1961), were not content merely to have their program solve problems correctly.
 They were more concerned with comparing the trace of its reasoning steps to traces of human
subjects solving the same problems.
 The interdisciplinary field of cognitive science brings together computer models from AI and
experimental techniques from psychology to construct precise and testable theories of the human
mind.
 The two fields continue to fertilize each other, most notably in computer vision, which incorporates
neurophysiological evidence into computational models.

Rohith Murthy ([email protected])


1.1.3 Thinking rationally: The “laws of thought” approach

 The Greek philosopher Aristotle was one of the first to attempt to codify “right thinking,” that is,
irrefutable reasoning processes.
 His syllogisms provided patterns for argument structures that always yielded correct conclusions
when given correct premises—for example, “Socrates is a man; all men are mortal; therefore,
Socrates is mortal.” These laws of thought were supposed to govern the operation of the mind; their
study initiated the field called logic.
 Logicians in the 19th century developed a precise notation for statements about all kinds of objects
in the world and the relations among them. (Contrast this with ordinary arithmetic notation, which
provides only for statements about numbers.)
 The so-called logicist tradition within artificial intelligence hopes to build on such programs to
create intelligent systems.
 There are two main obstacles to this approach:
 First, it is not easy to take informal knowledge and state it in the formal terms required by logical
notation, particularly when the knowledge is less than 100% certain.
Second, there is a big difference between solving a problem “in principle” and solving it in practice.

1.1.4 Acting rationally: The rational agent approach

 An agent is just something that acts. All computer programs do something, but computer
agents are expected to do more: operate autonomously, perceive their environment, persist
over a prolonged time period, adapt to change, and create and pursue goals.
 A rational agent is one that acts so as to achieve the best outcome or, when there is
uncertainty, the best expected outcome.
 Making correct inferences is sometimes part of being a rational agent, because one way to
act rationally is to reason logically to the conclusion that a given action will achieve one’s
goals and then to act on that conclusion.
 On the other hand, correct inference is not all of rationality; in some situations, there is no
provably correct thing to do, but something must still be done.
 All the skills needed for the Turing Test also allow an agent to act rationally.
 Knowledge representation and reasoning enable agents to reach good decisions.
 The rational-agent approach has two advantages over the other approaches:
First, it is more general than the “laws of thought” approach because correct inference is
just one of several possible mechanisms for achieving rationality.
Second, it is more amenable to scientific development than are approaches based on human
behavior or human thought.
 The standard of rationality is mathematically well defined and completely general, and can be
“unpacked” to generate agent designs that provably achieve it.
 Human behavior, on the other hand, is well adapted for one specific environment and is
defined by, well, the sum total of all the things that humans do.

1.2 THE FOUNDATIONS OF ARTIFICIAL INTELLIGENCE

In this section, we provide a brief history of the disciplines that contributed ideas, viewpoints, and
techniques to AI.

Rohith Murthy ([email protected])


Rohith Murthy ([email protected])
Figure 1.2 The parts of a nerve cell or neuron.
 Each neuron consists of a cell body, or soma,
that contains a cell nucleus.

 Branching out from the cell body are a number


of fibers called dendrites and a single long
fiber
called the axon.
 The axon stretches out for a long distance, much

longer than the scale in this diagram indicates.

 Typically, an axon is 1 cm long (100 times the diameter of the cell body), but can reach up to 1 meter.
 A neuron makes connections with 10 to 100,000 other neurons at junctions called synapses. Signals are
propagated from neuron to neuron by a complicated electrochemical reaction.
 The signals control brain activity in the short term and also enable long-term changes in the connectivity
of neurons. These mechanisms are thought to form the basis for learning in the brain.

 Most information processing goes on in the cerebral cortex, the outer layer of the brain. The basic
organizational unit appears to be a column of tissue about 0.5 mm in diameter, containing about 20,000
neurons and extending the full depth of the cortex about 4 mm in humans)

Rohith Murthy ([email protected])


Rohith Murthy ([email protected])
1.3 THE HISTORY OF ARTIFICIAL INTELLIGENCE (Refer Text Book 1)

Rohith Murthy ([email protected])


1.4 THE STATE OF THE ART
What can AI do today? A concise answer is difficult because there are so many activities in so many
subfields. Here we sample a few applications;
 Robotic vehicles:
 A driverless robotic car named STANLEY sped through the rough terrain of the Mojave
dessert at 22 mph, finishing the 132-mile course first to win the 2005 DARPAGrand
Challenge.
 STANLEY is a Volkswagen Touareg outfitted with cameras, radar, and laser rangefinders
to sense the environment and onboard software to command the steer ing, braking, and
acceleration (Thrun, 2006).
 The following year CMU’s BOSS won the Ur ban Challenge, safely driving in traffic
through the streets of a closed Air Force base, obeying traffic rules and avoiding pedestrians and
other vehicles.
 Speech recognition:
 A traveler calling United Airlines to book a flight can have the en tire conversation
guided by an automated speech recognition and dialog management system.
 Autonomous planning and scheduling:
 A hundred million miles from Earth, NASA’s Remote Agent program became the first
on-board autonomous planning program to control the scheduling of operations for a
spacecraft (Jonsson et al., 2000).
 REMOTE AGENT gen erated plans from high-level goals specified from the ground
and monitored the execution of those plans—detecting, diagnosing, and recovering
from problems as they occurred.
 Successor program MAPGEN (Al-Chang et al., 2004) plans the daily operations for
NASA’s Mars Exploration Rovers, and MEXAR2 (Cesta et al., 2007) did mission
planning—both logistics and science planning—for the European Space Agency’s
Mars Express mission in 2008.
 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).
 Kasparov said that he felt a “new kind of intelligence” across the board from him.
Newsweek magazine described the match as “The brain’s last stand.”
 The value of IBM’s stock increased by $18 billion. Human champions studied
Kasparov’s loss and were able to draw a few matches in subsequent years, but the most
recent human-computer matches have been won convincingly by the computer.
 Spam fighting:
 Each day, learning algorithms classify over a billion messages as spam, saving the
recipient from having to waste time deleting what, for many users, could comprise
80% or 90% of all messages, if not classified away by algorithms.
 Because the spammers are continually updating their tactics, it is difficult for a static
programmed approach to keep up, and learning algorithms work best (Sahami et al.,
1998; Goodman and Heckerman, 2004).

Rohith Murthy ([email protected])


 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 generated in hours a plan 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 30-year investment in AI.
 Robotics:
 The iRobot Corporation has sold over two million Roomba robotic vacuum cleaners for
home use.
 The company also deploys the more rugged PackBot to Iraq and Afghanistan, where it
is used to handle hazardous materials, clear explosives, and identify the location of
snipers.

 Machine Translation:
 A computer program automatically translates from Arabic to English, allowing an
English speaker to see the headline “Ardogan Confirms That Turkey Would Not
Accept Any Pressure, Urging Them to Recognize Cyprus.”
 The program uses a statistical model built from examples of Arabic-to-English
translations and from examples of English text totaling two trillion words (Brants et al.,
2007).
 None of the computer scientists on the team speak Arabic, but they do understand
statistics and machine learning algorithms.

These are just a few examples of artificial intelligence systems that exist today. Not magic or
science fiction—but rather science, engineering, and mathematics, to which this book provides an
introduction

Rohith Murthy ([email protected])


CHAPTER 3:
Problem-solving agent:
When the correct action to take is not immediately obvious, an agent may need to plan ahead:
to consider a sequence of actions that form a path to a goal state. Such an agent is called a
problem-solving agent, and the computational process it undertakes is called search.
Agents that use factored or structured representations of states are called planning agents.

 Simplest agents (Reflex agents), which base their actions on a direct mapping from states to actions.
Such agents cannot operate well in environments for which this mapping would be too large to store and
would take too long to learn.
 Goal-based agents, consider future actions and the desirability of their outcomes.
 Problem-solving agents use atomic representations, that is, states of the world are considered as wholes,
with no internal structure visible to the problem-solving algorithms.
 Goal-based agents that use more advanced factored or structured representations are usually called
planning agents.

There are several general-purpose search algorithms that can be used to solve these problems.
 Uninformed search algorithms—algorithms that are given no information about the problem other
than its definition. Although some of these algorithms can solve any solvable problem, none of them
can do so efficiently.
 Informed search algorithms, on the other hand, can do quite well given some guidance on where to
look for solutions.

3.1 PROBLEM-SOLVING AGENTS


 Reflex agents are too simple and have great difficulties in learning desired action
sequences
 Goal-based agents can succeed by considering Solving Problems by Searching Goal
future actions and the desirability of their outcomes.
 We now describe a special type of goal-based agents called problem-solving agents,
which try to find action sequences that lead to desirable states. These are uninformed
algorithms; they are given no hints or heuristics for the problem solution other than its
definition.
 We first need a goal formulation, based on the current situation and the performance
measure.
 Problem formulation is the process of deciding what actions and states to consider,
given a goal.
 In general, an agent with several options for action of unknown value can decide what
to do by first examining different possible sequences of actions that lead to states of
known value, and then choosing the best sequence.
 For now we assume that the environment is observable and Discrete so at any given
state there are only finitely many actions to choose from. We will assume the
environment is known, so the agent knows which states are reached by each action.
Finally, we assume that the environment is deterministic, so each action has exactly one
outcome.

Rohith Murthy ([email protected])


The process of looking for a sequence of actions that reaches the goal is called search. A search
algorithm takes a problem as input and returns a solution in the form of an action sequence.
Once a solution is found, the actions it recommends can be carried out. This is called the
execution phase. Thus, we have a simple “formulate, search, execute” design for the agent, as
shown in Figure 3.1.
Notice that while the agent is executing the solution sequence it ignores its percepts when
choosing an action because it knows in advance what they will be. An agent that carries out
its plans with its eyes closed, so to speak, must be quite certain of what is going on. Control
theorists call this an open-loop system, because ignoring the percepts breaks the loop
between agent and environment.

Intelligent agents are supposed to maximize their performance measure.

Rohith Murthy ([email protected])


Example Problem: Romania Tour
Imagine an agent enjoying a touring vacation in Romania. The agent wants to take in the
sights, improve its Romanian, enjoy the nightlife, avoid hangovers, and so on. The decision
problem is a complex one. Now, suppose the agent is currently in the city of Arad and has a
nonrefundable ticket to fly out of Bucharest the following day. The agent observes street
signs and sees that there are three roads leading out of Arad: one toward Sibiu, one to
Timisoara, and one to Zerind. None of these are the goal, so unless the agent is familiar with
the geography of Romania, it will not know which road to follow

Fig 3.2: A simplified road map of part of Romania.

Rohith Murthy ([email protected])


we will assume our agents always have access to information about the world, such as the
map in Figure 3.2. With that information, the agent can follow this four-phase problem-
solving process:
• Goal formulation: The agent adopts the goal of reaching Bucharest. Goals organize
behavior by limiting the objectives and hence the actions to be considered.
 Problem formulation: The agent devises a description of the states and actions necessary
to reach the goal—an abstract model of the relevant part of the world. For our agent, one
good model is to consider the actions of traveling from one city to an adjacent city, and
therefore the only fact about the state of the world that will change due to an action is the
current city.
 Search : Before taking any action in the real world, the agent simulates sequences of
actions in its model, searching until it finds a sequence of actions that reaches the goal.
Such a sequence is called a solution. The agent might have to simulate multiple sequences
that do not reach the goal, but eventually it will find a solution (such as going from Arad to
Sibiu to Fagaras to Bucharest), or it will find that no solution is possible.
 Execution: The agent can now execute the actions in the solution, one at a time.
It is an important property that in a fully observable, deterministic, known environment, the
solution to any problem is a fixed sequence of actions: drive to Sibiu, then Fagaras, then
Bucharest. If the model is correct, then once the agent has found a solution, it can ignore its
percepts while it is executing the actions—closing its eyes, so to speak—because the solution is
guaranteed to lead to the goal. Control theorists call this an open-loop system: ignoring the
percepts breaks the loop between agent and environment. If there is a chance that the model is
incorrect, or the environment is nondeterministic, then the agent would be safer using a
closed- loop approach that monitors the precepts.

• Formulate goal:
• be in Bucharest
• Formulate problem:
• states: various cities
• actions: drive between cities
• Find solution:
• sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest.
Single-State Problem Formulation

Rohith Murthy ([email protected])


A description of the possible actions available to the agent. Given a particular state s,
ACTIONS(s) returns the set of actions that can be executed in s. We say that each of
these actions is applicable in s. For example, from the state In(Arad), the applicable
actions are
{Go(Sibiu), Go(Timisoara), Go(Zerind)}.

A description of what each action does; the formal name for this is the transition model,
specified by a function RESULT(s, a) that returns the state that results from doing action a
in state s. We also use the term successor to refer to any state reachable from a given state
by a single action. For example, we have
RESULT(In(Arad),Go(Zerind)) = In(Zerind) .
A path cost function that assigns a numeric cost to each path. The step cost of taking action
a in state s to reach state s’ is denoted by c(s, a, s’).

Formulating problems:
Our formulation of the problem of getting to Bucharest is a model—an abstract
mathematical description—and not the real thing.

• Abstraction :The process of removing detail from a representation is called


abstraction. A good problem formulation has the right level of detail. If the actions
were at the level of “move the right foot forward a centimetre” or “turn the steering
wheel one degree left” the agent would probably never find its way out of the
parking lot, let alone to Bucharest.

• Level of abstraction: Think of the abstract states and actions we have chosen as
corresponding to large sets of detailed world states and detailed action sequences.
Now consider a solution to the abstract problem: for example, the path from Arad to
Sibiu to Rimnicu ,Vilcea to Pitesti to Bucharest. This abstract solution corresponds to
a large number of more detailed paths. For example, we could drive with the radio on
between Sibiu and Rimnicu Vilcea, and then switch it off for the rest of the trip.

• The abstraction is valid if we can elaborate any abstract solution into a solution in the
more detailed world; a sufficient condition is that for every detailed state that is “in
Arad,”there is a detailed path to some state that is “in Sibiu,” and so on.The
abstraction is useful if carrying out each of the actions in the solution is easier than the
original problem; in our case, the action “drive from Arad to Sibiu” can be carried
out without further search or planning by a driver with average skill.

Rohith Murthy ([email protected])


3.2 EXAMPLE PROBLEMS
A standardized problem is intended to illustrate or exercise various problem-solving
methods. It can be given a concise, exact description and hence is suitable as a benchmark for
problem researchers to compare the performance of algorithms. A real-world problem, such
as robot navigation, is one whose solutions people actually use, and whose formulation is
idiosyncratic not standardized, because, for example, each robot has different sensors that
produce different data.
Toy problems:
The first example we examine is the vacuum world.
A grid world problem is a two-dimensional rectangular array of square cells in which agents
can move from cell to cell. Typically, the agent can move to any obstacle-free adjacent cell—
horizontally or vertically and in some problems diagonally. Cells can contain objects, which
the agent can pick up, push, or otherwise act upon; a wall or other impassible obstacle in a
cell prevents an agent from moving into that cell. The vacuum world can be formulated as a
grid world problem as follows:

Figure 3.3 The state space for the vacuum world. Links denote actions: L = Left, R =Right, S = Suck.

• States: The state is determined by both the agent location and the dirt locations. The
agent is in one of two locations, each of which might or might not contain dirt. Thus,
there are 2 × 22 = 8 possible world states. A larger environment with n locations has n
x 2n states.
• Initial state: Any state can be designated as the initial state.
• Actions: In this simple environment, each state has just three actions: Left, Right, and
Suck. Larger environments might also include Up and Down.
• Transition model: The actions have their expected effects, except that moving Left in
the leftmost square, moving Right in the rightmost square, and Sucking in a clean
square have no effect. The complete state space is shown in Figure 3.3.
• Goal test: This checks whether all the squares are clean.
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.

Rohith Murthy ([email protected])


8-Puzzle:

The 8-puzzle, an instance of which is shown in Figure 3.3, consists of a 3×3 board with eight
numbered tiles and a blank space. A tile adjacent to the blank space can slide into the space.
The object is to reach a specified goal state, such as the one shown on the right of the figure.
The standard formulation is as follows:

Figure 3.4 A typical instance of the 8-puzzle.

The 8-puzzle belongs to the family of sliding-block puzzles, which are often used as test
problems for new search algorithms in AI. This family is known to be NP-complete, so one
does not expect to find methods significantly better in the worst case than the search
algorithms described in this chapter and the next. The 8-puzzle has 9!/2=181, 440 reachable
states and is easily solved. The 15-puzzle (on a 4×4 board) has around 1.3 trillion states, and
random instances can be solved optimally in a few milliseconds by the best search
algorithms. The 24- puzzle (on a 5 × 5 board) has around 1025 states, and random instances
take several hours to solve optimally.

8-Queens Problem:
The goal of the 8-queens problem is to place eight queens on a chessboard such that no
queen attacks any other. There are two main kinds of formulation. An incremental
formulation involves operators that augment the state description, starting with an empty
state; for the 8- queens problem, this means that each action adds a queen to the state. A
complete-state
formulation starts with all 8 queens on the board and moves them around.

Rohith Murthy ([email protected])


In either case, the path cost is of no interest because only the final state counts. The first
incremental formulation one might try is the following:

• States: Any arrangement of 0 to 8 queens on the board is a state.


• Initial state: No queens on the board.
• Actions: Add a queen to any empty square.
• Transition model: Returns the board with a queen added to the specified square.
• Goal test: 8 queens are on the board, none attacked.

In this formulation, we have 64 ・ 63 ・ ・ ・ 57 ≈ 1.8×1014 possible sequences to


investigate. A better formulation would prohibit placing a queen in any square that is already
attacked:

• States: All possible arrangements of n queens (0 ≤ n ≤ 8), one per column in the leftmost
n columns, with no queen attacking another.

• Actions: Add a queen to any square in the leftmost empty column such that it is not
attacked by any other queen.

This formulation reduces the 8-queens state space from 1.8×1014 to just 2,057, and solutions
are easy to find. Our final toy problem was devised by Donald Knuth (1964) and illustrates
how infinite state spaces can arise. Knuth conjectured that, starting with the number 4, a
sequence of factorial, square root, and floor operations will reach any desired positive integer.
For example, we can reach 5 from 4 as follows:

Rohith Murthy ([email protected])


The problem definition is very simple:

• States: Positive numbers.


• Initial state: 4.
• Actions: Apply factorial, square root, or floor operation (factorial for integers only).
• Transition model: As given by the mathematical definitions of the operations.
• Goal test: State is the desired positive integer.

Real-world problems

Consider the airline travel problems that must be solved by a travel-planning Web site:

Touring problems
 Touring problems are closely related to route-finding problems, but with an important
difference.
 Consider, for example, the problem “Visit every city in Figure 3.2 at least once, starting
and ending in Bucharest.”
 As with route finding, the actions correspond to trips between adjacent cities. The
state space, however, is quite different.
 Each state must include not just the current location but also the set of cities the agent
has visited.
 So the initial state would be In(Bucharest), Visited({Bucharest}), a typical intermediate state
would be In(Vaslui), Visited({Bucharest, Urziceni, Vaslui}), and the goal test would check
whether the agent is in Bucharest and all 20 cities have been visited.

The traveling salesperson problem (TSP)


 TSP is a touring problem in which each city must be visited exactly once.
 The aim is to find the shortest tour. The problem is known to be NP-hard, but an enormous
amount of effort has been expended to improve the capabilities of TSP algorithms.
 In addition to planning trips for traveling salespersons, these algorithms have been used for
tasks such as planning movements of automatic circuit-board drills and of stocking machines
on shop floors.

Rohith Murthy ([email protected])


A VLSI layout problem

 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 comes after the logical design phase and is usually split into two parts: cell
layout and channel routing.
 In cell layout, the primitive components of the circuit are grouped into cells, each of
which performs some recognized function.
 Each cell has a fixed footprint (size and shape) and requires a certain number of connections to
each of the other cells.
 The aim is to place the cells on the chip so that they do not overlap and so that there is room for
the connecting wires to be placed between the cells.
 Channel routing finds a specific route for each wire through the gaps between the cells.
These search problems are extremely complex, but definitely worth solving.

Robot navigation is a generalization of the route-finding problem described earlier.


 Rather than following a discrete set of routes, a robot can move in a continuous space with
(in principle) an infinite set of possible actions and states.
 For a circular robot moving on a flat surface, the space is essentially two-dimensional.
 When the robot has arms and legs or wheels that must also be controlled, the search space
becomes many-dimensional.
 Advanced techniques are required just to make the search space finite.

Airline travel problems:

States: Each state obviously includes a location (e.g., an airport) and the current time
Furthermore, because the cost of an action (a flight segment) may depend on previous
segments, their fare bases, and their status as domestic or international, the state must
record extra information about these “historical” aspects.

•Initial state: This is specified by the user’s query.


•Actions: Take any flight from the current location, in any seat class, leaving after the
current time, leaving enough time for within-airport transfer if needed.
• Transition model: The state resulting from taking a flight will have the flight’s destination
as the current location and the flight’s arrival time as the current time.
•Goal test: Are we at the final destination specified by the user?
•Path cost: This depends on monetary cost, waiting time, flight time, customs and
immigration procedures, seat quality, time of day, type of airplane, frequent-flyer mileage
awards, and so
on.
2) Route-finding problems 8) Robot navigation problems
3) GPS-based navigation 9) Automatic assembly sequencing
systems, Google maps 10) Internet searching
4) Touring problems 11) Searching paths in
5) Real-World Search Problems metabolic networks in
6) TSP (traveling salesperson problem) 12) Bioinformatics
7) VLSI layout problems 13) protein design

Rohith Murthy ([email protected])


3.3 SEARCHING FOR SOLUTIONS:

 A solution is an action sequence, so search algorithms work by considering various


possible action sequences.
 The possible action sequences starting at the initial state form a search tree with the initial state
at the root; the branches are actions and the nodes correspond to states in the state space of the
problem.
 Figure 3.6 shows the first few steps in growing the search tree for finding a route from
Arad to Bucharest.
 The root node of the tree corresponds to the initial state, In(Arad).
 The first step is to test whether this is a goal state. Then we need to consider taking
various actions.
 We do this by expanding the current state; that is, applying each legal action to the current
state, thereby generating a new set of states.
 In this case, we add three branches from the parent node In(Arad) leading to three new child
nodes: In(Sibiu), In(Timisoara), and In(Zerind).
 Each of these six nodes is a leaf node, that is, a node with no children in the tree.
 The set of all leaf nodes available for expansion at any given point is called the frontier.
 Search algorithms all share this basic structure; they vary primarily according to how they
choose which state to expand next—the so-called search strategy.

Rohith Murthy ([email protected])


As the saying goes, algorithms that forget their history are doomed to repeat it. The way to avoid exploring
redundant paths is to remember where one has been .To do this, we augment the algorithm with a data structure
called the explored set (also known as the closed list), which remembers every expanded node. Newly generated
nodes that match previously generated nodes—ones in the explored set or the frontier—can be discarded instead
of being added to the frontier. The new algorithm, called GRAPH-SEARCH, is shown informally in Figure 3.7.
The specific algorithms in this chapter draw on this general design.

Rohith Murthy ([email protected])


3.3.1 Infrastructure for search algorithms

Search algorithms require a data structure to keep track of the search tree that is being constructed.
For each node n of the tree, we have a structure that contains four components:
• n.STATE: the state in the state space to which the node corresponds;
• n.PARENT: the node in the search tree that generated this node;
• n.ACTION: the action that was applied to the parent to generate the node;

• n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to
the node, as indicated by the parent pointers.

Rohith Murthy ([email protected])


The node data structure is depicted in Figure 3.10. Notice how the PARENT pointer string the
nodes together into a tree structure. These pointers also allow the solution path to be extracted
when a goal node is found; we use the SOLUTION function to return the sequence of actions
obtained by following parent pointers back to the root.
The appropriate data structure for this is a queue. The operations on a queue are as follows:
• EMPTY?(queue) returns true only if there are no more elements in the queue.
• POP(queue) removes the first element of the queue and returns it.
• INSERT(element, queue) inserts an element and returns the resulting queue.

Queues are characterized by the order in which they store the inserted nodes. Three common
variants are the first-in, first-out or FIFO queue, which pops the oldest element of the queue;the
last-in, first-out or LIFO queue (also known as a stack), which pops the newest element of the
queue; and the priority queue, which pops the element of the queue with the highest
priority according to some ordering function.

3.3.2 Measuring problem-solving performance

We can evaluate an algorithm’s performance in four ways:


• Completeness: Is the algorithm guaranteed to find a solution when there is one?
• Optimality: Does the strategy find the optimal solution, as defined on page 68?
• Time complexity: How long does it take to find a solution?
• Space complexity: How much memory is needed to perform the search?

Complexity is expressed in terms of three quantities:


b, the branching factor or maximum number of successors of any node;
d, the depth of the shallowest goal node (i.e., the number of steps along the path from
the root); and m, the maximum length of any path in the state space.
m: maximum depth of the state space (may be ∞).
To assess the effectiveness of a search algorithm, we can consider just the search cost—which
typically depends on the time complexity but can also include a term for memory usage—or we
can use the total cost, which combines the search cost and the path cost of the solution found.

3.4 UNINFORMED SEARCH STRATEGIES

The Uninformed Search term means that the strategies have no additional information about
states beyond that provided in the problem definition. All they can do is generate successors and
distinguish a goal state from a non-goal state. All search strategies are distinguished by the order
in which nodes are expanded. Strategies that know whether one non-goal state is “more
promising” than another are called informed search or heuristic search strategies.
• Breadth-first search (BFS)
• Uniform-cost search
• Depth-first search (DFS)
• Depth-limited search
• Iterative deepening search
• Bidirectional Search

Rohith Murthy ([email protected])


3.4.1 Breadth-first search
• The root node is expanded first
• Then all successors of the root node are expanded
• Then all their successors and so on
• In general, all the nodes of a given depth are expanded
• before any node of the next depth is expanded.
• Uses a standard queue as data structure.
Pseudocode is given in Figure 3.11. Figure 3.12 shows the progress of the search on a
simple binary tree.
Imagine searching a uniform tree where every state has b successors. The root of the search tree
generates b nodes at the first level, each of which generates b more nodes, for a total of b 2 at the
second level. Each of these generates b more nodes, yielding b 3 nodes at the third level, and so on.
Now suppose that the solution is at depth d. In the worst case, it is the last node generated at that
level. Then the total number of nodes generated is

Rohith Murthy ([email protected])


Two lessons can be learned from Figure 3.13.

First, the memory requirements are a bigger problem for breadth-first search than is the
execution time. One might wait 13 days for the solution to an important problem with search
depth 12, but no personal computer has the petabyte of memory it would take. Fortunately, other
strategies require less memory.

The second lesson is that time is still a major factor. If your problem has a solution at depth 16,
then (given our assumptions) it will take about 350 years for breadth-first search (or indeed any
uninformed search) to find it. In general, exponential-complexity search problems cannot be
solved by uninformed methods for any but the smallest instances.

3.4.2 Uniform-cost search


• Modification to BFS generates Uniform-cost search, which works with any step-cost
function ( edge weights/costs):
• UCS expands the node n with lowest summed path cost g(n).
• To do this, the frontier is stored as a priority queue. (Sorted list data structure, better
heap data structure).
• The goal test is applied to a node when selected for expansion (not when it is generated).
• Also a test is added if a better node is found to a node on the frontier.

The algorithm is shown in Figure 3.14.

Rohith Murthy ([email protected])


Rohith Murthy ([email protected])
The Modifications come into play in the example shown in Figure 3.15, where the problem is
to get from Sibiu to Bucharest. The Uniform Search is similar to Dijkstra’s algorithm. It
requires that all step costs are non-negative. It may get stuck if there is a path with an infinite
sequence of zero cost steps. Otherwise it is complete.
3.4.3 Depth-first search
• DFS alwas expands the deepest node in the current frontier of the search tree.
• It uses a stack (LIFO queue last in first out)
• DFS is frequently programmed recursively, then the program call stack is the
LIFO queue.
• DFS is complete, if the graph is finite.
• The tree search version of DFS is complete on a finite tree, if a test is included
whether the node has already been visited
• DFS is incomplete on infinite trees or graphs.
• DFS has time complexity O(bm), if m is the maximum depth of any node (may be
infinite).
• DFS has space complexity of O(b m)
• As an alternative to the GRAPH-SEARCH-style implementation, it is common to
implement depth-first search with a recursive function that calls itself on each of its
children in turn.
In Figure 3.16, depth first search will explore the entire left subtree even if node C is a goal
node. If node J were also a goal node, then depth-first search would return it as a solution
instead of C, which would be a better solution; hence, depth-first search is not optimal.
The time complexity of depth-first graph search is bounded by the size of the state space
(which may be infinite, of course). A depth-first tree search, on the other hand, may generate
all of the O(bm) nodes in the search tree, where m is the maximum depth of any node; this
can be much greater than the size of the state space. Note that m itself can be much larger
than d (the depth of the shallowest solution) and is infinite if the tree is unbounded.
A variant of depth-first search called backtracking search uses still less memory. In
backtracking, only one successor is generated at a time rather than all successors; each
partially expanded node remembers which successor to generate next. In this way, only O(m)
memory is needed rather than O(bm). Backtracking search facilitates yet another memory-
saving (and time-saving) trick: the idea of generating a successor by modifying the current
state description directly rather than copying it first. This reduces the memory requirements
to just one state description and O(m) actions.

Rohith Murthy ([email protected])


3.4.4.Depth-limited search
• The failure of DFS in infinite search spaces can be prevented by giving it a
search limit I .This approach is called depth limited search
• Unfortunately, it is not complete if we choose I < d, where d is the depth of the
goal node.
• This happens easily, because d is unknown.
• Depth-limited search has time complexity O(b I).
• It has space complexity of O(b I).
• However, in some applications we know a depth limit (# nodes in a graph, maximum
diameter, …)
• Depth-first search can be viewed as a special case of depth-limited search with I =∞.

Rohith Murthy ([email protected])


3.4.2 Iterative deepening depth-first search
The iterative deepening search algorithm repeatedly applies depth-limited search with
increasing limits. It terminates when a solution is found or if the depth limited
search returns failure, meaning that no solution exists. This search is also frequently
called depth-first iterative deepening (DFID).

Iterative deepening search (or iterative deepening depth-first search) is a general strategy,
often used in combination with depth-first tree search, that finds the best depth limit. It does
this by gradually increasing the limit—first 0, then 1, then 2, and so on—until a goal is found.
This will occur when the depth limit reaches d, the depth of the shallowest goal node. The
algorithm is shown in Figure 3.18. Iterative deepening combines the benefits of depth-first
and breadth-first search. Like depth-first search, its memory requirements are modest: O(bd)
to be precise. Like breadth-first search, it is complete when the branching factor is finite and
optimal when the path cost is a nondecreasing function of the depth of the node. Figure 3.19
shows four iterations of on a binary search tree, where the solution is found on the fourth
iteration.

Rohith Murthy ([email protected])


The total number of nodes generated in the worst case is

3.4.3 Bidirectional search


The idea behind bidirectional search is to run two simultaneous searches—one
forward from the initial state and the other backward from the goal—hoping that the
two searches meet in the middle (Figure 3.20). The motivation is that bd/2 + bd/2 is
much less than bd, 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.
The time complexity of bidirectional search using breadth-first searches in both
directions is O(bd/2). The space complexity is also O(b d/2). We can reduce this by
roughly half if one of the two searches is done by iterative deepening, but at least one

Rohith Murthy ([email protected])


of the frontiers must be kept in memory so that the intersection check can be done. This space
requirement is the most significant weakness of bidirectional search.

Advantage:
delays exponential growth by reducing the exponent for time and space
complexity in half.
Disadvantage:
At every time point the two fringes must be compared. This requires an efficient
hashing data structure
Bidirectional search also requires to search backward (predecessors of a state).
This is not always possible.
3.4.4 Comparing uninformed search strategies
Figure 3.21 compares search strategies in terms of the four evaluation criteria set forth in Section
3.3.2. This comparison is for tree-search versions. For graph searches, the main differences are
that depth-first search is complete for finite state spaces and that the space and time
complexities are bounded by the size of the state space.

Rohith Murthy ([email protected])


INFORMED SEARCH STRATEGIES

 An informed search strategy—one that uses problem-specific knowledge beyond the


definition of the problem itself—can find solutions more efficiently than can an uninformed
strategy.
 The general approach we consider is called best-first search.
 Best-first search is an instance of the general TREE-SEARCH or GRAPH-SEARCH algorithm
in which a node is selected for expansion based on an evaluation function, f(n).
 The evaluation function is construed as a cost estimate, so the node with the lowest evaluation is
expanded first.
 The implementation of best-first graph search is identical to that for uniform-cost search, except
for the use of f instead of g to order the priority queue.
 The choice of f determines the search strategy.
 Most best-first algorithms include as a component of f a heuristic function, denoted h(n):

h(n) = estimated cost of the cheapest path from the state at node n to a goal state.

 Heuristic functions are the most common form in which additional knowledge of the
problem is imparted to the search algorithm.

3.5.1 Greedy best-first search


 Greedy best-first search tries to expand the node that is closest to the goal, on the grounds
that this is likely to lead to a solution quickly. Thus, it evaluates nodes by using just the
heuristic function; that is, f(n) = h(n).
 Let us see how this works for route-finding problems in Romania; we use the straightline
distance heuristic, which we will call hSLD .
 If the goal is Bucharest, we need to know the straight-line distances to Bucharest, which are
shown in Figure 3.22. For example, hSLD (In(Arad)) = 366.
 The values of hSLD cannot be computed from the problem description itself. Moreover, it takes
a certain amount of experience to know that hSLD is correlated with actual road distances and
is, therefore, a useful heuristic.
 Figure 3.23 shows the progress of a greedy best-first search using hSLD to find a path from
Arad to Bucharest. The first node to be expanded from Arad will be Sibiu because it is closer to
Bucharest than either Zerind or Timisoara. The next node to be expanded will be Fagaras
because it is closest. Fagaras in turn generates Bucharest, which is the goal. For this particular
problem, greedy best-first search using hSLD finds a solution without ever expanding a node
that is not on the solution path; hence, its search cost is minimal. It is not optimal, however: the
path via Sibiu and Fagaras to Bucharest is 32 kilometers longer than the path through Rimnicu
Vilcea and Pitesti. This shows why the algorithm is called “greedy”—at each step it tries to get
as close to the goal as it can.

Rohith Murthy ([email protected])


 Greedy best-first tree search is also incomplete even in a finite state space, much like depth-first
search.
 Consider the problem of getting from Iasi to Fagaras. The heuristic suggests that Neamt be
expanded first because it is closest to Fagaras, but it is a dead end.
 The solution is to go first to Vaslui—a step that is actually farther from the goal according to the
heuristic—and then to continue to Urziceni, Bucharest, and Fagaras.
 The algorithm will never find this solution, however, because expanding Neamt puts Iasi back
into the frontier, Iasi is closer to Fagaras than Vaslui is, and so Iasi will be expanded again,
leading to an infinite loop.
 The worst-case time and space complexity for the tree version is O(bm), where m is the
maximum depth of the search space.
 With a good heuristic function, however, the complexity can be reduced substantially.
 The amount of the reduction depends on the particular problem and on the quality of the heuristic.

3.5.2 A* search: Minimizing the total estimated solution cost

 The most widely known form of best-first search is called A∗ A search (pronounced “A-star search”).
 It evaluates nodes by combining g(n), the cost to reach the node, and h(n), the cost to get from the
node to the goal:
f(n) = g(n) + h(n)
 Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated cost of the
cheapest path from n to the goal, we have
f(n) = estimated cost of the cheapest solution through n
 Thus, if we are trying to find the cheapest solution, a reasonable thing to try first is the node with the

Rohith Murthy ([email protected])


lowest value of g(n) + h(n).
 It turns out that this strategy is more than just reasonable: provided that the heuristic function h(n)
satisfies certain conditions, A∗ search is both complete and optimal. The algorithm is identical to
UNIFORM-COST-SEARCH except that A∗ uses g + h instead of g.

Conditions for optimality: Admissibility and consistency

 The first condition we require for optimality is that h(n) be an admissible heuristic.
 An admissible heuristic is one that never overestimates the cost to reach the goal.
 Because g(n) is the actual cost to reach n along the current path, and f(n) = g(n) + h(n), we have as an
immediate consequence that f(n) never overestimates the true cost of a solution along the current path
through n.
 Admissible heuristics are by nature optimistic because they think the cost of solving the problem is
less than it actually is.
 An obvious example of an admissible heuristic is the straight-line distance hSLD that we used in
getting to Bucharest.
 Straight-line distance is admissible because the shortest path between any two points is a straight
line, so the straight line cannot be an overestimate.
 In Figure 3.24, we show the progress of an A∗ tree search for Bucharest.
 The values of g are computed from the step costs in Figure 3.2, and the values of hSLD are given in
Figure 3.22. Notice in particular that Bucharest first appears on the frontier at step (e), but it is not
selected for expansion because its f-cost (450) is higher than that of Pitesti (417).
 Another way to say this is that there might be a solution through Pitesti whose cost is as low as 417,
so the algorithm will not settle for a solution that costs 450.
 A second, slightly stronger condition called consistency (or sometimes monotonicity) is required
only for applications of A∗ to graph search.
 A heuristic h(n) is consistent if, for every node n and every successor n 1 of n generated by any action
a, the estimated cost of reaching the goal from n is no greater than the step cost of getting to n1 plus
the estimated cost of reaching the goal from n1:

 This is a form of the general triangle inequality, which stipulates that each side of a triangle cannot be
longer than the sum of the other two sides.
 Here, the triangle is formed by n, n1, and the goal Gn closest to n.
 For an admissible heuristic, the inequality makes perfect sense: if there were a route from n to Gn via
n1 that was cheaper than h(n), that would violate the property that h(n) is a lower bound on the cost to
reach Gn.
 Consistency is therefore a stricter requirement than admissibility, but one has to work quite hard to
concoct heuristics that are admissible but not consistent.
 Consider, for example, hSLD. We know that the general triangle inequality is satisfied when each
side is measured by the straight-line distance and that the straight-line distance between n and n1 is no
greater than c(n, a, n1). Hence, hSLD is a consistent heuristic.

Optimality of A*

A∗ has the following properties:


the tree-search version of A∗ is optimal if h(n) is admissible, while the graph-search
version is optimal if h(n) is consistent.
We show the second of these two claims since it is more useful. The argument essentially
mirrors the argument for the optimality of uniform-cost search, with g replaced by f—just as in the
A∗ algorithm itself.

Rohith Murthy ([email protected])


 The next step is to prove that whenever A∗ selects a node n for expansion, the optimal path to that
node has been found.
 Were this not the case, there would have to be another frontier node n1 on the optimal path from
the start node to n, by the graph separation property of Figure 3.9; because f is nondecreasing
along any path, n1 would have lower f-cost than n and would have been selected first.
 From the two preceding observations, it follows that the sequence of nodes expanded by A∗ using
GRAPH-SEARCH is in nondecreasing order of f(n).
 Hence, the first goal node selected for expansion must be an optimal solution because f is the true
cost for goal nodes (which have h = 0) and all later goal nodes will be at least as expensive.
 Figure 3.25 shows an example. Inside the contour labeled 400, all nodes have f(n) less than or
equal to 400, and so on.
 Then, because A∗ expands the frontier node of lowest f-cost, we can see that an A∗ search fans
out from the start node, adding nodes in concentric bands of increasing f-cost.
 With uniform-cost search (A∗ search using h(n)=0), the bands will be “circular” around the start
state.
 With more accurate heuristics, the bands will stretch toward the goal state and become more
narrowly focused around the optimal path.
 If C∗ is the cost of the optimal solution path, then we can say the following:

 Completeness requires that there be only finitely many nodes with cost less than or equal to
 C∗, a condition that is true if all step costs exceed some finite and if b is finite.

 That A∗ search is complete, optimal, and optimally efficient among all such algorithms is
rather satisfying.
 Unfortunately, it does not mean that A∗ is the answer to all our searching needs. The catch
is that, for most problems, the number of states within the goal contour search space is still
exponential in the length of the solution.
 The details of the analysis are beyond the scope of this book, but the basic results are as
follows. For problems with constant step costs, the growth in run time as a function of the
optimal solution depth d is analyzed in terms of the the absolute error or the relative error of
the heuristic.

Rohith Murthy ([email protected])


 The absolute error is

Rohith Murthy ([email protected])


3.6 HEURISTIC FUNCTIONS

 The 8-puzzle was one of the earliest heuristic search problems.


 The object of the puzzle is to slide the tiles horizontally or vertically into the empty space until
the configuration matches the goal configuration (Figure 3.28).

 The average solution cost for a randomly generated 8-puzzle instance is about 22 steps.
The branching factor is about 3.
 There is a long history of such heuristics for the 15-puzzle; here are two commonly
used candidates:

Rohith Murthy ([email protected])


3.6.1 The effect of heuristic accuracy on performance

 To test the heuristic functions h1 and h2, we generated 1200 random problems with solution
lengths from 2 to 24 (100 for each even number) and solved them with iterative deepening
search and with A∗ tree search using both h1 and h2.
 Figure 3.29 gives the average number of nodes generated by each strategy and the effective
branching factor.
 The results suggest that h2 is better than h1, and is far better than using iterative deepening
search.
 Even for small problems with d = 12, A∗ with h2 is 50,000 times more efficient than
uninformed iterative deepening search.

3.6.2 Generating admissible heuristics from relaxed problems


 We have seen that both h1 (misplaced tiles) and h2 (Manhattan distance) are fairly good heuristics
for the 8-puzzle and that h2 is better.
 How might one have come up with h2?
 Is it possible for a computer to invent such a heuristic mechanically?
 h1 and h2 are estimates of the remaining path length for the 8-puzzle, but they are also perfectly
accurate path lengths for simplified versions of the puzzle.

Rohith Murthy ([email protected])


 If the rules of the puzzle were changed so that a tile could move anywhere instead of just to the
adjacent empty square, then h1 would give the exact number of steps in the shortest solution.
 Similarly, if a tile could move one square in any direction, even onto an occupied square, then h2
would give the exact number of steps in the shortest solution.
 A problem with fewer restrictions on the actions is called a relaxed problem.
 The state-space graph of the relaxed problem is a supergraph of the original state space because the
removal of restrictions creates added edges in the graph.
 Because the relaxed problem adds edges to the state space, any optimal solution in the original problem
is, by definition, also a solution in the relaxed problem; but the relaxed problem may have better
solutions if the added edges provide short cuts.
 Hence, the cost of an optimal solution to a relaxed problem is an admissible heuristic for the original
problem.
 Furthermore, because the derived heuristic is an exact cost for the relaxed problem, it must obey the
triangle inequality and is therefore consistent.

 From (a), we can derive h2 (Manhattan distance).


 The reasoning is that h2 would be the proper score if we moved each tile in turn to its destination. The
heuristic derived from (b).
 From (c), we can derive h1 (misplaced tiles) because it would be the proper score if tiles could move to
their intended destination in one step.
 If the relaxed problem is hard to solve, then the values of the corresponding heuristic will be expensive
to obtain.12 A program called ABSOLVER can generate heuristics automatically from problem
definitions, using the “relaxed problem” method and various other techniques (Prieditis, 1993).
 ABSOLVER generated a new heuristic for the 8-puzzle that was better than any preexisting heuristic
and found the first useful heuristic for the famous Rubik’s Cube puzzle.
 One problem with generating new heuristic functions is that one often fails to get a single “clearly best”
heuristic.
 If a collection of admissible heuristics h1 ...hm is available for a problem and none of them dominates
any of the others, which should we choose? As it turns out, we need not make a choice.
 We can have the best of all worlds, by defining

 This composite heuristic uses whichever function is most accurate on the node in question.
 Because the component heuristics are admissible, h is admissible; it is also easy to prove that h is
consistent. Furthermore, h dominates all of its component heuristics.

Rohith Murthy ([email protected])


3.6.3 Generating admissible heuristics from subproblems: Pattern databases
 Admissible heuristics can also be derived from the solution cost of a subproblem of a given
problem.
 For example, Figure 3.30 shows a subproblem of the 8-puzzle instance in Figure 3.28.
 The subproblem involves getting tiles 1, 2, 3, 4 into their correct positions. Clearly, the cost of the
optimal solution of this subproblem is a lower bound on the cost of the complete problem.
 It turns out to be more accurate than Manhattan distance in some cases.
 The idea behind pattern databases is to store these exact solution costs for every possible
subproblem instance—in our example, every possible configuration of the four tiles and the
blank.
 Then we compute an admissible heuristic hDB for each complete state encountered during a
search simply by looking up the corresponding subproblem configuration in the database.
 The database itself is constructed by searching back13 from the goal and recording the cost of
each new pattern encountered; the expense of this search is amortized over many subsequent
problem instances.
 The choice of 1-2-3-4 is fairly arbitrary; we could also construct databases for 5-6-7-8, for 2-4-6-
8, and so on.
 Each database yields an admissible heuristic, and these heuristics can be combined, as explained
earlier, by taking the maximum value.
 A combined heuristic of this kind is much more accurate than the Manhattan distance; the
number of nodes generated when solving random 15-puzzles can be reduced by a factor of 1000.
 One might wonder whether the heuristics obtained from the 1-2-3-4 database and the 5-6-7-8
could be added, since the two subproblems seem not to overlap.
 Would this still give an admissible heuristic?
The answer is no, because the solutions of the 1-2-3-4 subproblem and the 5-6-7-8
subproblem for a given state will almost certainly share some moves—it is unlikely that
1- 2-3-4 can be moved into place without touching 5-6-7-8, and vice versa.
 But what if we don’t count those moves? That is, we record not the total cost of solving the 1-2-
3- 4 subproblem, but just the number of moves involving 1-2-3-4.
 Then it is easy to see that the sum of the two costs is still a lower bound on the cost of solving the
entire problem. This is the idea behind disjoint pattern databases.
 With such databases, it is possible to solve random 15-puzzles in a few milliseconds—the number
of nodes generated is reduced by a factor of 10,000 compared with the use of Manhattan
distance. For 24-puzzles, a speedup of roughly a factor of a million can be obtained.
 Disjoint pattern databases work for sliding-tile puzzles because the problem can be divided up in
such a way that each move affects only one subproblem—because only one tile is moved at a
time.
 For a problem such as Rubik’s Cube, this kind of subdivision is difficult because each move
affects 8 or 9 of the 26 cubies.

Rohith Murthy ([email protected])


Artificial Intelligence-MCS101

3.6.4 Learning heuristics from experience

 A heuristic function h(n) is supposed to estimate the cost of a solution beginning from the state at node
n. How could an agent construct such a function?
 One solution was given in the preceding sections—namely, to devise relaxed problems for which an
optimal solution can be found easily.
 Another solution is to learn from experience. “Experience” here means solving lots of 8-puzzles, for
instance.
 Each optimal solution to an 8-puzzle problem provides examples from which h(n) can be learned.
 Each example consists of a state from the solution path and the actual cost of the solution from that point.
 From these examples, a learning algorithm can be used to construct a function h(n) that can
(with luck) predict solution costs for other states that arise during search.
 Inductive learning methods work best when supplied with features of a state that are relevant
to predicting the state’s value, rather than with just the raw state description.
 For example, the feature “number of misplaced tiles” might be helpful in predicting the
actual distance of a state from the goal.
 Let’s call this feature x1(n). We could take 100 randomly generated 8-puzzle configurations
and gather statistics on their actual solution costs.
 We might find that when x1(n) is 5, the average solution cost is around 14, and so on.
 Given these data, the value of x1 can be used to predict h(n). Of course, we can use several features.
A second feature x2(n) might be “number of pairs of adjacent tiles that are not adjacent in the goal
state.” How should x1(n) and x2(n) be combined to predict h(n)? A common approach is to use a
linear combination:

 The constants c1 and c2 are adjusted to give the best fit to the actual data on solution costs.
 One expects both c1 and c2 to be positive because misplaced tiles and incorrect adjacent pairs
make the problem harder to solve.
 This heuristic does satisfy the condition that h(n)=0 for goal states, but it is not necessarily
admissible or consistent.

2024-25

Rohith Murthy ([email protected])

You might also like