Unit 1 Notes
Unit 1 Notes
Introduction to AI – AI Definition, The Foundations of AI, The History of AI, The State of
the Art
Intelligent Agents – Agents and Environment, The Concept of Rationality, The Nature of
Environments, The Structure of Agents
Solving Problems by Searching – Problem-Solving Agents, Searching for Solutions,
Uninformed Search Strategies, Heuristic Search Strategies, Heuristic Functions
Artificial Intelligence is defined in four ways, each offering a different perspective on what it
means to be "intelligent." These definitions can be categorized by whether they focus on
thinking versus acting and whether the goal is to mimic humanity versus achieving
rationality.
This approach is based on the famous Turing Test, proposed by Alan Turing in his 1950
paper, "Computing Machinery and Intelligence." The test defines intelligent behavior as a
machine's ability to exhibit human-level performance in a conversational setting, to the point
where a human interrogator cannot tell if they are conversing with a machine or another
human.
To pass the Turing Test, a machine would need to excel in several key areas:
A "total Turing Test" would add a physical component, requiring the agent to interact with
and perceive objects in the world, which would involve Computer Vision and Robotics.
This approach is rooted in the study of logic and the development of formal systems for
reasoning. The goal is to build intelligent systems that follow a process of "right thinking."
Logicist Tradition: This school of thought within AI aims to use formal logic to
represent knowledge and derive new conclusions. For example, a system could use
formal logic to deduce that "Socrates is mortal" from the premises "All men are
mortal" and "Socrates is a man."
Challenges: The main difficulty with this approach is that it is often hard to translate
real-world, informal knowledge into the precise formal language of logical notation.
Additionally, some problems can be solved without relying solely on logic.
This approach is based on the famous Turing Test, proposed by Alan Turing in his 1950
paper, "Computing Machinery and Intelligence." The test defines intelligent behavior as a
machine's ability to exhibit human-level performance in a conversational setting, to the point
where a human interrogator cannot tell if they are conversing with a machine or another
human.
To pass the Turing Test, a machine would need to excel in several key areas:
A "total Turing Test" would add a physical component, requiring the agent to interact with
and perceive objects in the world, which would involve Computer Vision and Robotics.
This approach is rooted in the study of logic and the development of formal systems for
reasoning. The goal is to build intelligent systems that follow a process of "right thinking."
Logicist Tradition: This school of thought within AI aims to use formal logic to
represent knowledge and derive new conclusions. For example, a system could use
formal logic to deduce that "Socrates is mortal" from the premises "All men are
mortal" and "Socrates is a man."
Challenges: The main difficulty with this approach is that it is often hard to translate
real-world, informal knowledge into the precise formal language of logical notation.
Additionally, some problems can be solved without relying solely on logic.
2. The Foundations of AI
AI is a modern field with deep roots in several older disciplines, which have provided the
necessary tools and ideas for its development.
Philosophy: The concepts of the mind, the source of knowledge (empiricism vs.
rationalism), and the connection between knowledge and action are all philosophical
inquiries that directly inform AI. Key contributions include the formalization of logic
by Aristotle and the idea of the mind as a physical system.
Mathematics: This discipline provides the formal tools for AI. Key contributions
include the development of algorithms, computability (can something be computed?),
and probability theory (for dealing with uncertainty).
Psychology: The study of the human mind and behavior provides insights into how to
build intelligent systems. The shift from behaviorism (focused on stimulus-response)
to cognitive psychology (which models the mind's internal workings) was
particularly influential.
Linguistics: The study of language structure and meaning provided the groundwork
for natural language processing (NLP). The development of formal language theory
by Noam Chomsky, for example, heavily influenced early AI.
Computer Engineering: The invention of the modern computer in the mid-20th
century provided the essential hardware. Without the stored-program computer, AI
would be a purely theoretical field.
Neuroscience: The study of the brain provides both inspiration and a source of data
for building AI. Concepts like neural networks and deep learning are directly inspired
by the structure of the human brain.
3. The History of AI
In 1956, John McCarthy coined the term "Artificial Intelligence" as the topic of the
Dartmouth Conference, the first conference devoted to the subject.
In 1957, The General Problem Solver (GPS) demonstrated by Newell, Shaw &
Simon
In 1958, John McCarthy (MIT) invented the Lisp language.
In 1959, Arthur Samuel (IBM) wrote the first game-playing program, for checkers, to
achieve sufficient skill to challenge a world champion.
In 1963, Ivan Sutherland's MIT dissertation on Sketchpad introduced the idea of
interactive graphics into computing.
In 1966, Ross Quillian (PhD dissertation, Carnegie Inst. of Technology; now CMU)
demonstrated semantic nets
In 1967, Dendral program (Edward Feigenbaum, Joshua Lederberg, Bruce Buchanan,
Georgia Sutherland at Stanford) demonstrated to interpret mass spectra on organic
chemical compounds. First successful knowledge-based program for scientific
reasoning.
In 1967, Doug Engelbart invented the mouse at SRI
In 1968, Marvin Minsky & Seymour Papert publish Perceptrons, demonstrating limits
of simple neural nets.
In 1972, Prolog developed by Alain Colmerauer.
In Mid 80’s, Neural Networks become widely used with the Backpropagation
algorithm (first described by Werbos in 1974).
1990, Major advances in all areas of AI, with significant demonstrations in machine
learning, intelligent tutoring, case-based reasoning, multi-agent planning, scheduling,
uncertain reasoning, data mining, natural language understanding and translation,
vision, virtual reality, games, and other topics.
In 1997, Deep Blue beats the World Chess Champion Kasparov
In 2002,iRobot, founded by researchers at the MIT Artificial Intelligence Lab,
introduced Roomba, a vacuum cleaning robot. By 2006, two million had been sold.
AI has achieved a level of performance that was once considered science fiction.
Robotics: AI-powered robots are used in manufacturing, medicine, and even homes.
Autonomous vehicles are an advanced application of AI in the real world. The Mars
Exploration Rover mentioned in the textbook is a prime example of an autonomous
robot.
Game-Playing: AI has long surpassed human performance in games. IBM's Deep
Blue defeated world chess champion Garry Kasparov in 1997. More recently,
Google's AlphaGo defeated the world champion of Go, a game far more complex
than chess, in 2016. The solution of the game of checkers is another landmark
mentioned in the book.
Natural Language Processing: Modern AI can perform high-quality machine
translation, understand human speech (e.g., Siri, Alexa), and extract information from
vast amounts of text.
Computer Vision: Systems can now recognize faces, identify objects in images, and
power surveillance and security systems.
Web Search and Recommender Systems: The search engines we use daily rely on
AI to rank pages, predict search queries, and provide personalized results.
Recommender systems (e.g., on Netflix and Amazon) use AI to suggest products and
content.
Machine Learning: The field has seen considerable theoretical progress, with a focus
on modern learning algorithms.
Vision: Computer vision has been a major area of progress, often incorporating
neurophysiological evidence into computational models.
Application of AI:
AI algorithms have attracted close attention of researchers and have also been applied
successfully to solve problems in engineering. Nevertheless, for large and complex
problems, AI algorithms consume considerable computation time due to stochastic
feature of the search approaches
Business; financial strategies
Engineering: check design, offer suggestions to create new product, expert systems
for all engineering problems
Manufacturing: assembly, inspection and maintenance
Medicine: monitoring, diagnosing
Education: in teaching
Fraud detection
Object identification
Information retrieval
Space shuttle scheduling
Agents and Environment
Agent: An Agent is anything that can be viewed as perceiving its environment through
sensors and acting upon that environment through actuators.
A human agent has eyes, ears, and other organs for sensors and hands, legs, mouth,
and other body parts for actuators.
A robotic agent might have cameras and infrared range finders for sensors and
various motors for actuators.
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.
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 example-the
vacuum-cleaner world shown in Fig 2. 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 Fig 3.
Fig 3: Partial tabulation of a simple agent function for the example: vacuum-cleaner world
shown in the Fig 2
Fig 3(i): The REFLEX-VACCUM-AGENT program is invoked for each new percept
(location, status) and returns an action each time
THE CONCEPT OF RATIONALITY
A rational agent is an AI that consistently "does the right thing" to achieve the best possible
outcome. This is defined not by the agent's internal state or beliefs, but by the consequences
of its actions on the environment.
Doing the Right Thing: The "right thing" is determined by a performance measure
that evaluates the desirability of the sequence of environment states generated by the
agent's actions.
Performance Measure: This measure is designed by the developer to evaluate the
agent's success. It should be based on the desired state of the environment, not on
how the agent thinks it is performing. This prevents an agent from "deluding" itself
into thinking it's successful when it isn't (e.g., the "sour grapes" phenomenon).
The rationality of an agent's actions at any given moment is not a fixed quality; it's dependent
on four key factors:
1. The Performance Measure: The success criteria that define what is considered
"good" behavior.
2. Prior Knowledge: The information the agent already has about its environment
before it starts operating.
3. Available Actions: The set of actions the agent can choose from at any given time.
4. Percept Sequence: The complete history of everything the agent has perceived so far.
The provided text uses a simple vacuum-cleaner agent to illustrate this definition. The agent's
task is to clean a two-square environment (A and B).
Is it Rational? The text claims that the agent is rational under a specific set of
circumstances:
o Performance Measure: One point is awarded for each clean square at each
time step.
o Knowledge: The agent knows the geography (two squares) but not the initial
dirt distribution or its starting location.
o Actions: The only actions available are Left, Right, and Suck.
o Percepts: The agent knows its location and whether the current square is dirty.
Given these conditions, the agent's simple rule—Suck if dirty, otherwise move to the
other square—is considered rational because it will achieve the highest possible
expected score over time.
When is it NOT Rational? The same agent can become irrational if the
circumstances change:
o If there's a penalty for moving, the agent's continuous oscillation after the
environment is clean would make it irrational. A better agent would stop
moving.
o If dirt can reappear, the agent's simple strategy of moving to the other square
might be insufficient. It would need to periodically check for new dirt.
o If the geography is unknown, the agent would need to explore its environment
rather than just switching between squares A and B.
Performance Measure: This defines the criteria for the agent's success. It should be
based on the desired state of the environment, not on the agent's internal behavior. For
example, for a taxi driver, a good performance measure would include safety, speed,
legality, and passenger comfort.
Environment: This refers to the real or virtual world in which the agent operates. It
includes everything the agent can potentially interact with. For a taxi, this would be
roads, other traffic, pedestrians, and customers. The complexity of the environment is
a major factor in the design of the agent.
Actuators: These are the mechanisms an agent uses to act upon the environment. For
a human, these are hands, legs, etc. For an automated taxi, they would include the
steering wheel, accelerator, brake, horn, and a display.
Sensors: These are the tools the agent uses to perceive the environment. For a human,
these are eyes, ears, etc. For a taxi, they would include cameras, sonar, a speedometer,
and a GPS.
An agent program is the concrete implementation of the agent function, which maps a
sequence of percepts to an action. This program runs on a physical computing device called
the architecture. The relationship is summarized as:
The key difference is that the agent program takes the current percept as input, while the
agent function considers the entire history of percepts. If the agent needs to rely on past
percepts, the program must have an internal memory to store them.
To overcome the limitations of the table-driven approach, AI research has developed more
sophisticated agent program designs. Here are four fundamental types, each adding a layer of
complexity and capability.
1. Simple Reflex Agents
These are the simplest agents, making decisions based only on the current percept. They use
a set of condition-action rules (e.g., if car-in-front-is-braking then initiate-braking) to map
percepts directly to actions.
3. Goal-Based Agents
These agents are more flexible than reflex agents because their actions are guided by explicit
goals—descriptions of desirable future states.
How it Works: They use their world model to determine a sequence of actions that
will lead to a goal state. This often involves search or planning algorithms.
Advantages: They are more flexible than reflex agents because their knowledge is
explicitly represented and can be easily modified. For instance, changing the
destination of a taxi is as simple as updating the goal.
4. Utility-Based Agents
Goals provide a binary distinction between "happy" and "unhappy" states, but they don't
allow for a nuanced comparison of different outcomes. Utility-based agents use a utility
function to provide a more general performance measure, specifying a degree of preference
for different states.
How it Works: These agents choose the action that is expected to maximize their
expected utility. This approach is essential for making rational decisions in situations
with conflicting goals (e.g., speed vs. safety) or uncertain outcomes.
A learning agent is an agent that can improve its own performance over time. It has four
main components:
Performance Element: This is the core of the agent, responsible for selecting actions.
Learning Element: This component is responsible for making improvements.
Critic: This component provides feedback to the learning element, telling it how well
the agent is doing with respect to a fixed performance standard.
Problem Generator: This component suggests actions that are designed to lead to
new and informative experiences, encouraging exploration over short-term
optimization.
This structure allows an agent to adapt to initially unknown environments and become more
competent through experience, moving beyond the limitations of its initial programming.
Introduction to Problem Solving, General problem solving
Problem solving is a process of generating solutions from observed data.
a problem is characterized by a set of goals,
a set of objects, and
a set of operations.
These could be ill-defined and may evolve during problem solving.
Searching Solutions:
To build a system to solve a problem:
1. Define the problem precisely
2. Analyze the problem
3. Isolate and represent the task knowledge that is necessary to solve the problem
4. Choose the best problem-solving techniques and apply it to the particular problem.
Defining the problem as State Space Search:
1. The state space representation forms the basis of most of the AI methods.
2. Formulate a problem as a state space search by showing the legal problem states, the
legal operators, and the initial and goal states.
3. A state is defined by the specification of the values of all attributes of interest in the
world
4. An operator changes one state into the other; it has a precondition which is the value
of certain attributes prior to the application of the operator, and a set of effects, which
are the attributes altered by the operator
5. The initial state is where you start
6. The goal state is the partial description of the solution
Formal Description of the problem:
1. 1. Define a state space that contains all the possible configurations of the relevant
objects.
2. 2. Specify one or more states within that space that describe possible situations from
which the problem solving process may start ( initial state)
3. 3. Specify one or more states that would be acceptable as solutions to the problem. (
goal states)
4. Specify a set of rules that describe the actions (operations) available
State-Space Problem Formulation:
Example: A problem is defined by four items:
1. initial state e.g., "at Arad‖
2. actions or successor function : S(x) = set of action–state pairs
e.g., S(Arad) = {<Arad Zerind, Zerind>, … }
3. goal test (or set of goal states)
e.g., x = "at Bucharest‖, Checkmate(x)
4. path cost (additive)
e.g., sum of distances, number of actions executed, etc.
c(x,a,y) is the step cost, assumed to be ≥ 0
A solution is a sequence of actions leading from the initial state to a goal state
Example: 8-queens problem
Control strategies
Control Strategies means how to decide which rule to apply next during the process of
searching for a solution to a problem.
Requirement for a good Control Strategy
1. It should cause motion
In water jug problem, if we apply a simple control strategy of starting each time from the top
of rule list and choose the first applicable one, then we will never move towards solution.
2. It should explore the solution space in a systematic manner
If we choose another control strategy, let us say, choose a rule randomly from the applicable
rules then definitely it causes motion and eventually will lead to a solution. But one may
arrive to same state several times. This is because control strategy is not systematic.
Systematic Control Strategies (Blind searches):
Now for each leaf node, generate all its successors by applying all the rules that are
appropriate.
8 Puzzle Problem
The 8 puzzle consists of eight numbered, movable tiles set in a 3x3 frame. One cell of the
frame is always empty thus making it possible to move an adjacent numbered tile into the
empty cell. Such a puzzle is illustrated in following diagram.
The program is to change the initial configuration into the goal configuration. A solution to
the problem is an appropriate sequence of moves, such as ―move tiles 5 to the right, move tile
7 to the left, move tile 6 to the down, etc‖.
Solution:
To solve a problem using a production system, we must specify the global database the rules,
and the control strategy. For the 8 puzzle problem that correspond to these three components.
These elements are the problem states, moves and goal. In this problem each tile
configuration is a state. The set of all configuration in the space of problem states or the
problem space, there are only 3, 62,880 different configurations o the 8 tiles and blank space.
Once the problem states have been conceptually identified, we must construct a computer
representation, or description of them . this description is then used as the database of a
production system. For the 8-puzzle, a straight forward description is a 3X3 array of matrix
of numbers. The initial global database is this description of the initial problem state.
Virtually any kind of data structure can be used to describe states.
A move transforms one problem state into another state. The 8-puzzle is conveniently
interpreted as having the following for moves. Move empty space (blank) to the left, move
blank up, move blank to the right and move blank down,. These moves are modeled by
production rules that operate on the state descriptions in the appropriate manner.
The rules each have preconditions that must be satisfied by a state description in order for
them to be applicable to that state description. Thus the precondition for the rule associated
with ―move blank up‖ is derived from the requirement that the blank space must not already
be in the top row.
The problem goal condition forms the basis for the termination condition of the production
system. The control strategy repeatedly applies rules to state descriptions until a description
of a goal state is produced. It also keeps track of rules that have been applied so that it can
compose them into sequence representing the problem solution. A solution to the 8-puzzle
problem is given in the following figure.
Example:- Depth – First – Search traversal and Breadth - First - Search traversal
for 8 – puzzle problem is shown in following diagrams.
Exhaustive Searches, BFS and DFS
Search is the systematic examination of states to find path from the start/root state to the goal
state.
Many traditional search algorithms are used in AI applications. For complex problems, the
traditional algorithms are unable to find the solution within some practical time and space
limits. Consequently, many special techniques are developed; using heuristic functions. The
algorithms that use heuristic functions are called heuristic algorithms. Heuristic algorithms
are not really intelligent; they appear to be intelligent because they achieve better
performance.
Heuristic algorithms are more efficient because they take advantage of feedback from the
data to direct the search path.
Uninformed search:Also called blind, exhaustive or brute-force search, uses no information
about the problem to guide the search and therefore may not be very efficient.
Informed Search: Also called heuristic or intelligent search, uses information about the
problem to guide the search, usually guesses the distance to a goal state and therefore
efficient, but the search may not be always possible.
Uninformed Search Methods
1. Breadth-first Search
2. Depth-first Search
3. Depth-limited Search
4. Iterative deepening depth-first search
5. Uniform cost search
6. Bidirectional Search
Algorithm:
1. Create a variable called NODE-LIST and set it to initial state
2. Until a goal state is found or NODE-LIST is empty do
a. Remove the first element from NODE-LIST and call it E. If NODE-LIST was
empty, quit
b. For each way that each rule can match the state described in E do:
i. Apply the rule to generate a new state
ii. If the new state is a goal state, quit and return this state
iii. Otherwise, add the new state to the end of NODE-LIST
BFS illustrated
Step 1: Initially fringe contains only one node corresponding to the source state A.
FRINGE: A
Step 2: A is removed from fringe. The node is expanded, and its children B and C are
generated. They are placed at the back of fringe.
FRINGE: B C
Step 3: Node B is removed from fringe and is expanded. Its children D, E are generated and
put at the back of fringe.
FRINGE: C D E
Step 4: Node C is removed from fringe and is expanded. Its children D and G are added to
the back of fringe.
FRINGE: D E D G
Step 5: Node D is removed from fringe. Its children C and F are generated and added to the
back of fringe.
FRINGE: E D G C F
Step 6: Node E is removed from fringe. It has no children.
FRINGE: D G C F
Step 7: D is expanded; B and F are put in OPEN.
FRINGE: G C F B F
Step 8: G is selected for expansion. It is found to be a goal node. So the algorithm returns the
path A C G by following the parent pointers of the node corresponding to G. The algorithm
terminates.
Breadth first search is:
One of the simplest search strategies
Complete. If there is a solution, BFS is guaranteed to find it.
If there are multiple solutions, then a minimal solution will be found
The algorithm is optimal (i.e., admissible) if all operators have the same cost.
Otherwise, breadth first search finds a solution with the shortest path length.
Time complexity : O(bd )
Space complexity : O(bd)
Optimality :Yes
o b - branching factor(maximum no of successors of any node),
o d – Depth of the shallowest goal node
o Maximum length of any path (m) in search space
Advantages: Finds the path of minimal length to the goal.
Disadvantages:
Requires the generation and storage of a tree whose size is exponential the depth of
the shallowest goal node.
The breadth first search algorithm cannot be effectively used unless the search space
is quite small.
Depth- First- Search
We may sometimes search the goal along the largest depth of the tree, and move up only
when further traversal along the depth is not possible. We then attempt to find alternative
offspring of the parent of the node (state) last visited. If we visit the nodes of a tree using the
above principles to search the goal, the traversal made is called depth first traversal and
consequently the search strategy is called depth first search.
Algorithm:
1. Create a variable called NODE-LIST and set it to initial state
2. Until a goal state is found or NODE-LIST is empty do
a. Remove the first element from NODE-LIST and call it E. If NODE-LIST was
empty, quit
b. For each way that each rule can match the state described in E do:
i. Apply the rule to generate a new state
ii. If the new state is a goal state, quit and return this state
iii. Otherwise, add the new state in front of NODE-LIST
DFS illustrated
FRINGE: A
Step 2: A is removed from fringe. A is expanded and its children B and C are put in front of
fringe.
FRINGE: B C
Step 3: Node B is removed from fringe, and its children D and E are pushed in front of
fringe.
FRINGE: D E C
Step 4: Node D is removed from fringe. C and F are pushed in front of fringe.
FRINGE: C F E C
Step 5: Node C is removed from fringe. Its child G is pushed in front of fringe.
FRINGE: G F E C
Step 6: Node G is expanded and found to be a goal node.
FRINGE: G F E C
The solution path A-B-D-C-G is returned and the algorithm terminates.
Depth first search is:
1. The algorithm takes exponential time.
2. If N is the maximum depth of a node in the search space, in the worst case the
algorithm will take time O(bd).
3. The space taken is linear in the depth of the search tree, O(bN).
Note that the time taken by the algorithm is related to the maximum depth of the search tree.
If the search tree has infinite depth, the algorithm may not terminate. This can happen if the
search space is infinite. It can also happen if the search space contains cycles. The latter case
can be handled by checking for cycles in the algorithm. Thus Depth First Search is not
complete.
Depth-Limited Search
• A depth-limited search algorithm is similar to depth-first search with a predetermined
limit.
• Depth-limited search can solve the drawback of the infinite path in the Depth-first
search.
• In this algorithm, the node at the depth limit will treat as it has no successor nodes
further.
Algorithm
Procedure DLS(node, goal, limit):
if node == goal then
return "SUCCESS"
else if limit == 0 then
return "CUTOFF"
else
cutoff_occurred ← false
for each child in Expand(node) do
result ← DLS(child, goal, limit - 1)
if result == "CUTOFF" then
cutoff_occurred ← true
else if result == "SUCCESS" then
return "SUCCESS"
end for
if cutoff_occurred then
return "CUTOFF"
else
return "FAILURE"
Example
Suppose we want to find a path in a graph using DLS with limit = 2:
A
/|\
B C D
/\
E F
Start at A.
Depth limit = 2.
Possible nodes explored: A → {B, C, D} → {E, F} (up to depth 2).
If goal = E, DLS finds it.
If goal = G (deeper), returns CUTOFF.
Properties
Completeness: No (unless depth limit ≥ depth of solution).
Optimality: No (may find a suboptimal solution).
Time complexity: O(bl)
o where b = branching factor, l = depth limit.
Space complexity: O(bl) (linear in depth).
Algorithm
Procedure IDDFS(start, goal, max_depth):
for depth from 0 to max_depth do
result ← DLS(start, goal, depth)
if result == "SUCCESS" then
return "SUCCESS"
return "FAILURE"
Uniform Cost Search is a path finding algorithm that expands the least cost node first,
ensuring that the path to the goal node has the minimum cost. Unlike other search algorithms
like Breadth-First Search (BFS), UCS takes into account the cost of each path, making it
suitable for weighted graphs where each edge has a different cost.
return "FAILURE"
Properties
Completeness: Yes (if step costs ≥ 0).
Optimality: Yes (returns the least-cost solution).
Time complexity: O(b1+⌊C∗/ε⌋)
o where C* is cost of optimal solution, and ε is minimum step cost.
Space complexity: Exponential in worst case (stores all frontier nodes).
Bidirectional Search
• Bidirectional search algorithm runs two simultaneous searches, one form initial state
called as forward-search and other from goal node called as backward-search, to find
the goal node.
• Bidirectional search replaces one single search graph with two small sub-graphs in
which one starts the search from an initial vertex and other starts from goal vertex.
The search stops when these two graphs intersect each other.
• Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Algorithm
Procedure BDS(start, goal):
if start == goal then
return "SUCCESS"
return "FAILURE"
Properties
• Completeness: Bidirectional Search is complete if we use BFS in both searches.
• Time Complexity: Time complexity of bidirectional search using BFS is O(bd/2).
• Space Complexity: Space complexity of bidirectional search is O(bd/2).
• Optimal: Bidirectional search is Optimal
Advantages:
• Bidirectional search is fast.
• Bidirectional search requires less memory
Disadvantages:
• Implementation of the bidirectional search tree is difficult.
• In bidirectional search, one should know the goal state in advance.
Advantages:
GBFS finds a solution without ever expanding a node that is not on the solution path; hence,
its search cost is minimal.
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.
Disadvantages:
Greedy best-first tree search is incomplete even in a finite state space. For Eg., 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.
• 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 .
• If we are trying to find the cheapest solution, a reasonable thing to try first is the node
with the lowest value of f(n)=g(n) + h(n).
Algorithm
1. Start with OPEN containing only initial node. Set that node’s g(n) value to 0, its h(n)
value to whatever it is, and its f(n) value to h+0 or h(n). Set CLOSED to empty list.
II. Otherwise pick the node on OPEN with the lowest f(n) value. Call it
BESTNODE.
IV. See if the BESTNODE is a goal state. If so exit and report a solution.
c. See if SUCCESSOR is the same as any node on OPEN. If so call the node
OLD. See whether it is cheaper to get to OLD via its current parent or
SUCCESSOR via BESTNODE by comparing their g values. If SUCCESSOR
is cheaper, then reset OLD’s parent to point to BESTNODE, record the new
cheaper path in g(OLD) and update f’(OLD).
Check to see if the new path is better. If so, set the parent link and g and f’ values
appropriately.
We must propagate the improvements to OLD’s successors. OLD points to successors. Each
successor, in turn, points to its successors, and so forth until each branch terminates with a
node that either is still on OPEN or has no successors.
So to propagate the new cost downward, do a depth-first traversal of the tree starting at OLD,
changing each node’s g value (and thus also its f’ value), terminating each branch when you
reach either a node with no successor or a node to which an equivalent or better path has
already been found.
e. If SUCCESSOR was not already on either OPEN or CLOSED, then put it on OPEN
and add it to the list of BESTNODE’s successors.
Compute
The simplest way to reduce memory requirements for A* is to adapt the idea of
ITERATIVE DEEPENING to the heuristic search context, resulting in the iterative-
deepening A* (IDA*) algorithm.
The main difference between IDA* and standard iterative deepening is that the cutoff
used is the f-cost (g + h) rather than the depth; at each iteration, the cutoff value is
the smallest f-cost of any node that exceeded the cutoff on the previous iteration.
IDA* is practical for many problems with unit step costs and avoids the substantial
overhead associated with keeping a sorted queue of nodes.
Its structure is similar to that of a recursive depth-first search, but rather than
continuing indefinitely down the current path, it uses the f-limit variable to
keep track of the f -value of the best alternative path available from any
ancestor of the current node.
If the current node exceeds this limit, the recursion unwinds back to the
alternative path.
As the recursion unwinds, RBFS replaces the f-value of each node along the
path with a backed-up value—the best f-value of its children. In this way,
RBFS remembers the f-value of the best leaf in the forgotten sub-tree and can
therefore decide whether it's worth re-expanding the sub-tree at some time
later.
Algorithm
successors ← Expand(node)
return (FAILURE, ∞)
while true do
Properties
2. Its space complexity is linear in the depth of the deepest optimal solution, but its time
complexity is rather difficult to characterize: it depends both on the accuracy of the
heuristic function and on how often the best path changes as nodes are
expanded.
3. IDA* and RBFS suffer from using too little memory. Between iterations, IDA*
retains only a single number: the current f-cost limit. RBFS retains more information
in memory, but it uses only linear space: even if more memory were available, RBFS
has no way to make use of it. Because they forget most of what they have done, both
algorithms may end up re-expanding the same states many times over.
To use all available memory, can use two algorithms :- MA* (memory-bounded A*) and
SMA* (simplified MA*).
1. SMA proceeds just like A*, expanding the best leaf until memory is full. At this
point, it cannot add a new node to the search tree without dropping an old one.
2. SMA* always drops the worst leaf node—the one with the highest f -value. Like
RBFS, SMA* then backs up the value of the forgotten node to its parent. In this way,
the ancestor of a forgotten sub-tree knows the quality of the best path in that sub-tree.
3. With this information, SMA* regenerates the sub-tree only when all other paths have
been shown to look worse than the path it has forgotten.
4. Another way of saying this is that, if all the descendants of a node n are forgotten,
then we will not know which way to go from n, but we will still have an idea of how
worthwhile it is to go anywhere from n.
5. SMA* expands the Best leaf and deletes the worst leaf.
6. To avoid selecting the same node for deletion and expansion, SMA* expands the
newest best leaf and deletes the oldest worst leaf.
7. These coincide when there is only one leaf, but in that case, the current search tree
must be a single path from root to leaf that fills all of memory.
8. If the leaf is not a goal node, then even if it is on an optimal solution path, that
solution is not reachable with the available memory. Therefore, the node can be
discarded exactly as if it had no successors.
9. SMA" is complete if there is any reachable solution—that is, if d, the depth of the
shallowest goal node, is less than the memory size (expressed in nodes).
10. It is optimal if any optimal solution is reachable; otherwise, it returns the best
reachable solution.
11. In practical terms, SMA* is a fairly robust choice for finding optimal solutions,
particularly when the state space is a graph, step costs are not uniform, and node
generation is expensive compared to the overhead of maintaining the frontier and the
explored set.
• In other words, the heuristic tells approximately how far the state is from the goal
state*.
• But for reasons which we will see, heuristics that only underestimate are very
desirable, and are called admissible.
• To shed light on the nature of heuristics in general, consider Heuristics for 8-puzzle
• Slide tiles vertically or horizontally into the empty space until the configuration
matches the goal configuration
• The average solution cost for a randomly generated 8-puzzle is about 22 steps
– So, an exhaustive search to depth 22 would look at about 322 states = 3.1*1010
states (where 3 is branching factor)
– By keeping track of repeated states, we could cut down this factor by about 1,
70, 000
– Because it is known that there are only 9!/2 = 1, 81, 440 distinct states that
are reachable
• The heuristic function should never over estimate the number of steps to the goal
– h2=the sum of the Manhattan distances of the tiles from their goal positions