Notes Artificial Intelligence Unit 1
Notes Artificial Intelligence Unit 1
Introduction to AI
What is artificial intelligence?
Artificial Intelligence is the branch of computer science concerned with making computers
behave like humans.
Major AI textbooks define artificial intelligence as "the study and design of intelligent
agents," where an intelligent agent is a system that perceives its environment and takes
actions which maximize its chances of success. John McCarthy, who coined the term in
1956, defines it as "the science and engineering of making intelligent machines, especially
intelligent computer programs."
The definitions of AI according to some text books are categorized into four approaches and
are summarized in the table below :
Systems that think like humans
―The exciting new effort to make computers think … machines with minds,in the full and
literal sense.‖(Haugeland,1985)
Systems that think rationally
―The study of mental faculties through the use of computer models.‖
(Charniak and McDermont,1985)
Systems that act like humans
The art of creating machines that perform functions that require intelligence when
performed by people.‖(Kurzweil,1990)
Systems that act rationally
“Computational intelligence is the study of the design of intelligent agents.‖(Poole et
al.,1998)
The four approaches in more detail are as follows :
(a)Acting humanly : The Turing Test approach
o Test proposed by Alan Turing in 1950
o The computer is asked questions by a human interrogator.
The computer passes the test if a human interrogator, after posing some written questions,
cannot tell whether the written responses come from a person or not. Programming a
computer to pass ,the computer need to possess the following capabilities :
Natural language processing to enable it to communicate successfully in English.
Knowledge representation to store what it knows or hears
Automated reasoning to use the stored information to answer questions and to draw new
conclusions.
Machine learning to adapt to new circumstances and to detect and extrapolate patterns
To pass the complete Turing Test, the computer will need
Computer vision to perceive the objects, and Robotics to manipulate objects and move
about.
(b)Thinking humanly : The cognitive modelling approach We need to get inside actual
working of the human mind :
(a) through introspection – trying to capture our own thoughts as they go by;
(b) through psychological experiments
Allen Newell and Herbert Simon, who developed GPS, the - General Problem Solver‖ tried
to trace the reasoning steps to traces of human subjects solving the same problems. The
interdisciplinary field of cognitive science brings together computer models from AI and
experimental techniques from psychology to try to construct precise and testable theories
of the workings of the human mind
(c)Thinking rationally : The “laws of thought approach”
The Greek philosopher Aristotle was one of the first to attempt to codify ―right thinkin
,that is irrefutable reasoning processes. His syllogism 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 a field called logic.
(d)Acting rationally : The rational agent approach
An agent is something that acts. Computer agents are not mere programs ,but they are
expected to have the following attributes also :
(a) operating under autonomous control,
(b) perceiving their environment,
(c) persisting over a prolonged time period,
(e) adapting to change.
A rational agent is one that acts so as to achieve the best outcome.
INTELLIGENT AGENTS
Agents and environments
An agent is anything that can be viewed as perceiving its environment through sensors and
acting upon that environment through actuators. This simple idea is illustrated in Figure 1.
o A human agent has eyes, ears, and other organs for sensors and hands, legs, mouth, and
other body parts for actuators.
o A robotic agent might have cameras and infrared range finders for sensors and various
motors for actuators.
o A software agent receives keystrokes, file contents, and network packets as sensory
inputs and acts on the environment by displaying on the screen, writing files, and sending
network packets.
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.
Rational Agent
A rational agent is one that does the right thing-conceptually speaking, every entry in the
table for the agent function is filled out correctly. Obviously, doing the right thing is
better than doing the wrong thing. The right action is the one that will cause the agent to be
most successful.
Performance measures
A performance measure embodies the criterion for success of an agent's behaviour. When
an agent is plunked down in an environment, it generates a sequence of actions according
to the precepts it receives. This sequence of actions causes the environment to go through a
sequence of states. If the sequence is desirable, then the agent has performed well.
Rationality
What is rational at any given time depends on four things:
o The performance measure that defines the criterion of success. o The agent's prior
knowledge of the environment.
o The actions that the agent can perform.
o The agent's percept sequence to date.
This leads to a definition of a rational agent:
For each possible percept sequence, a rational agent should select an action that is
expected to maximize its performance measure, given the evidence provided by the percept
sequence and whatever built-in knowledge the agent has.
Omniscience, learning, and autonomy
An omniscient agent knows the actual outcome of its actions and can act accordingly; but
omniscience is impossible in reality.
Doing actions in order to modify future precepts-sometimes called information gathering-is
an important part of rationality.
Our definition requires a rational agent not only to gather information, but also to learn as
much as possible from what it perceives.
To the extent that an agent relies on the prior knowledge of its designer rather than on its
own precepts, we say that the agent lacks autonomy. A rational agent should be
autonomous-it should learn what it can to compensate for partial or incorrect prior
knowledge.
Task environments
We must think about task environments, which are essentially the "problems" to which
rational agents are the "solutions."
Specifying the task environment
The rationality of the simple vacuum-cleaner agent, needs specification of o the
performance measure
o the environment
o the agent's actuators and sensors.
PEAS
All these are grouped together under the heading of the task environment. We call this the
PEAS (Performance, Environment, Actuators, Sensors) description.
In designing an agent, the first step must always be to specify the task environment as fully
as possible.
S.NO RGPV QUESTIONS Year Marks
Q.1 Explain Artificial Intelligence. Also discuss June 2014 7
the areas where it can be used.
Q.2 What are the characteristics of AI June,2010 6
problems? Explain the areas where AI can
be applied
Q.3 Define artificial intelligence. Also tell the June,2005 10
areas where it can be used.
Unit-01/Lecture-02
Various types of production systems
A Knowledge representation formalism consists of collections of condition-action
rules(Production Rules or Operators), a database which is modified in accordance with the
rules, and a Production System Interpreter which controls the operation of the rules i.e The
'control mechanism' of a Production System, determining the order in which Production
Rules are fired.
A system that uses this form of knowledge representation is called a production system.
A production system consists of rules and factors. Knowledge is encoded in a declarative
from which comprises of a set of rules of the form
Situation ------------ Action
SITUATION that implies ACTION.
Example:-
IF the initial state is a goal state THEN quit.
The major components of an AI production system are
i. A global database
ii. A set of production rules and
iii. A control system
The goal database is the central data structure used by an AI production system. The
production system. The production rules operate on the global database. Each rule has a
precondition that is either satisfied or not by the database. If the precondition is satisfied,
the rule can be applied. Application of the rule changes the database. The control system
chooses which applicable rule should be applied and ceases computation when a
termination condition on the database is satisfied. If several rules are to fire at the same
time, the control system resolves the conflicts.
Four classes of production systems:-
1. A monotonic production system
2. A non monotonic production system
Partially commutative, monotonic production systems are useful for solving ignorable
problems. These systems are important for man implementation standpoint because they
can be implemented without the ability to backtrack to previous states, when it is
discovered that an incorrect path was followed. Such systems increase the efficiency since it
is not necessary to keep track of the changes made in the search process.
Monotonic partially commutative systems are useful for problems in which changes occur
but can be reversed and in which the order of operation is not critical (ex: 8 puzzle
problem).
Production systems that are not partially commutative are useful for many problems in
which irreversible changes occur, such as chemical analysis. When dealing with such
systems, the order in which operations are performed is very important and hence correct
decisions have to be made at the first time itself.
Language Independence
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 convenjently
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 keep 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.
8 – puzzle problem is shown in following diagrams.
Water-Jug Problem
Statement :- We are given 2 jugs, a 4 liter one and a 3- liter one. Neither has any measuring
markers on it. There is a pump that can be used to fill the jugs with water. How can we get
exactly 2 liters of water in to the 4-liter jugs?
Solution:-
The state space for this problem can be defined as
{ ( i ,j ) i = 0,1,2,3,4 j = 0,1,2,3}
‘i’ represents the number of liters of water in the 4-liter jug and ‘j’ represents the number of
liters of water in the 3-liter jug. The initial state is ( 0,0) that is no water on each jug. The
goal state is to get ( 2,n) for any value of ‘n’.
To solve this we have to make some assumptions not mentioned in the problem. They are
The various operators (Production Rules) that are available to solve this problem may be
stated as given in the following figure.
The Missionaries and Cannibals Problem Statement
Three missionaries and three cannibals find themselves on one side of a river. They have
would like to get to the other side. But the missionaries are not sure what else the cannibals
agreed to. So the missionaries managed the trip across the river in such a way that the
number of missionaries on either side of the river is never less than the number of cannibals
who are on the same side. The only boar available holds only two at a time. How can
everyone get across the river without the missionaries risking being eaten?
Solution:-
The state for this problem can be defined as
{(i, j)/ i=0, 1, 2, 3, : j=0, 1, 2, 3} where i represents the number missionaries in one side of a
river . j represents the number of cannibals in the same side of river. The initial state is (3,3),
that is three missionaries and three cannibals on one side of a river , (Bank 1) and ( 0,0) on
another side of the river (bank 2) . the goal state is to get (3,3) at bank 2 and (0,0) at bank 1.
5. There is no restriction on the number of trips that can be made to reach of the goal.
Breadth-first search on a simple binary tree. At each stage, the node to be expanded next is
indicated by a marker.
Properties of breadth-first-search
Fig. stages in greedy best-first search for Bucharest using straight-line distance heuristic
hSLD. Nodes are labeled with their h-values.
Below Figure shows the progress of 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.
Properties of greedy search
o Complete?? No–can get stuck in loops, e.g., Iasi ! Neamt ! Iasi ! Neamt !
Complete in finite space with repeated-state checking
o Time?? O(bm), but a good heuristic can give dramatic improvement o Space?? O(bm)—
keeps all nodes in memory
o Optimal?? No
Greedy best-first search is not optimal,and it is incomplete.
The worst-case time and space complexity is O(bm),where m is the maximum depth of the
search space.
A* Search
A* Search is the most widely used form of best-first search. The evaluation function f(n) is
obtained by combining
(1) g(n) = the cost to reach the node,and
(2) h(n) = the cost to get from the node to the goal : f(n) = g(n) + h(n).
A* Search is both optimal and complete. A* is optimal if h(n) is an admissible heuristic. The
obvious example of admissible heuristic is the straight-line distance hSLD. It cannot be an
overestimate.
A Search is optimal if h(n) is an admissible heuristic – that is,provided that h(n) never
overestimates the cost to reach the goal.
An obvious example of an admissible heuristic is the straight-line distance hSLD that we
used in getting to Bucharest. The values of ‗g ‗ are computed from the step costs shown in
the Romania map Also the values of hSLD are given in Figure.
*
Fig. Stages in A Search for Bucharest. Nodes are labeled with f = g + h . The h-values are
the straight-line distances to Bucharest taken from previous figure
S.NO RGPV QUESTIONS Year Marks
Q.1 What do you understand by heuristic? Explain hill June.2014 7
climbing method compare it with generate and test
method
Q.2 Why heuristic search techniques are considered to June.2011 10
be more powerful than the traditional search
techniques?
Q.3 What do you understand by heuristic? Explain hill June.2006 10
climbing method compare it with generate and test
method
Unit-01/Lecture-05
LOCAL SEARCH ALGORITHMS AND OPTIMIZATION PROBLEMS
o In many optimization problems, the path to the goal is irrelevant; the goal state itself is the
solution
o For example, in the 8-queens problem, what matters is the final configuration of queens,
not the order in which they are added.
o In such cases, we can use local search algorithms. They operate using a single current
state(rather than multiple paths) and generally move only to neighbours of that state.
o The important applications of these class of problems are (a) integrated-circuit design,
(b)Factory-floor layout,(c) job-shop scheduling,(d)automatic programming,
(e)telecommunications network optimization,(f)Vehicle routing,and (g) portfolio
management.
Key advantages of Local Search Algorithms
(1) They use very little memory – usually a constant amount; and
(2) they can often find reasonable solutions in large or infinite(continuous) state spaces for
which systematic algorithms are unsuitable.
OPTIMIZATION PROBLEMS
Inaddition to finding goals,local search algorithms are useful for solving pure optimization
problems,in which the aim is to find the best state according to an objective function.
Fig. The hill-climbing search algorithm (steepest ascent version), which is the most basic
local search technique. At each step the current node is replaced by the best neighbour; the
neighbour with the highest VALUE. If the heuristic cost estimate h is used, we could find the
neighbour with the lowest h.
Hill-climbing is sometimes called greedy local search because it grabs a good neighbor state
without thinking ahead about where to go next. Greedy algorithms often perform quite
well. Problems with hill-climbing
Hill-climbing often gets stuck for the following reasons :
o Local maxima : a local maximum is a peak that is higher than each of its neighboring
states,but lower than the global maximum. Hill-climbing algorithms that reach the vicinity
of a local maximum will be drawn upwards towards the peak,but will then be stuck with
nowhere else to go
o Ridges : A ridge is shown in Figure 2.10. Ridges results in a sequence of local maxima that
is very difficult for greedy algorithms to navigate.
o Plateaux : A plateau is an area of the state space landscape where the evaluation function
is flat. It can be a flat local maximum,from which no uphill exit exists,or a shoulder,from
which it is possible to make progress.
Fig.Illustration of why ridges cause difficulties for hill-climbing. The grid of states(dark
circles) is superimposed on a ridge rising from left to right,creating a sequence of local
maxima that are not directly connected to each other. From each local maximum,all th
available options point downhill.
Hill-climbing variations
Stochastic hill-climbing
o Random selection among the uphill moves.
o The selection probability can vary with the steepness of the uphill move.
First-choice hill-climbing
o cfr. stochastic hill climbing by generating successors randomly until a better one is found.
Random-restart hill-climbing
o Tries to avoid getting stuck in local maxima. Simulated annealing search
A hill-climbing algorithm that never makes ―downhill‖ moves towards states with lower
value(or higher cost) is guaranteed to be incomplete,because it can stuck on a local
maximum.In contrast,a purely random walk –that is,moving to a successor choosen
uniformly at random from the set of successors – is complete,but extremely inefficient.
Simulated annealing is an algorithm that combines hill-climbing with a random walk in
someway that yields both efficiency and completeness.
Figure shows simulated annealing algorithm. It is quite similar to hill climbing. Instead of
picking the best move,however,it picks the random move. If the move improves the
situation,it is always accepted. Otherwise,the algorithm accepts the move with some
probability less than 1. The probability decreases exponentially with the ―badness‖ of the
move – the amount E by which the evaluation is worsened.
Simulated annealing was first used extensively to solve VLSI layout problems in the early
1980s. It has been applied widely to factory scheduling and other large-scale optimization
tasks.
The SIMULATED ANNEALING algorithm
This differs from the basic Hill climbing algorithm by choosing the best successor rather than
the first successor that is better. This indicates that it has elements of the breadth first
algorithm.
otherwise make the current state this initial state and proceed;
3 Repeat
set Target to be the state that any successor of the current state can better;
for each operator that can be applied to the current state
Both the basic and this method of hill climbing may fail to find a solution by reaching a state
from which no subsequent improvement can be made and this state is not the solution.
Local maximum state is a state which is better than its neighbours but is not better than
states faraway. These are often known as foothills. Plateau states are states which have
approximately the same value and it is not clear in which direction to move in order to reach
the solution. Ridge states are special typesw of local maximum states. The surrounding area
is basically unfriendly and makes it difficult to escape from, in single steps, and so the path
peters out when surrounded by ridges. Escape relies on: backtracking to a previous good
state and proceed in a completely different direction--- involves keeping records of the
current path from the outset; making a gigantic leap forward to a different part of the
search space perhaps by applying a sensible small step repeatedly, good for plateaux;
applying more than one rule at a time before testing, good for ridges.
None of these escape strategies can guarantee success.
Dec.2013, 8
June-2006,07
Dec.2005 5
Dec.2006
UNIT-01/LECTURE-07
Best first Search
Best-first search is a search algorithm which explores a graph by expanding the most
promising node chosen according to a specified rule.
Judea Pearl described best-first search as estimating the promise of node n by a "heuristic
evaluation function f(n) which, in general, may depend on the description of n, the
description of the goal, the information gathered by the search up to that point, and most
important, on any extra knowledge about the problem domain."
Some authors have used "best-first search" to refer specifically to a search with a heuristic
that attempts to predict how close the end of a path is to a solution, so that paths which are
judged to be closer to a solution are extended first. This specific type of search is called
greedy best-first search.
Efficient selection of the current best candidate for extension is typically implemented using
a priority queue.
The A* search algorithm is an example of best-first search, as is B*. Best-first algorithms are
often used for path finding in combinatorial search. (Note that neither A* nor B* is a greedy
best-first search as they incorporate the distance from start in addition to estimated
distances to the goal.)
An algorithm implementing best-first search follows.[3]
Note that this version of the algorithm is not complete, i.e. it does not always find a possible
path between two nodes, even if there is one. For example, it gets stuck in a loop if it arrives
at a dead end, that is a node with the only successor being its parent. It would then go back
to its parent, add the dead-end successor to the OPEN list again, and so on.
The following version extends the algorithm to use an additional CLOSED list, containing all
nodes that have been evaluated and will not be looked at again. As this will avoid any node
being evaluated twice, it is not subject to infinite loops.
Also note that the given pseudo code of both versions just terminates when no path is
found. An actual implementation would of course require special handling of this case.
Best-first search in its most basic form consists of the following algorithm (adapted from
Pearl, 1984):
The first step is to define the OPEN list with a single node, the starting node. The second
step is to check whether or not OPEN is empty. If it is empty, then the algorithm returns
failure and exits. The third step is to remove the node with the best score, n, from OPEN and
place it in CLOSED. The fourth step “expands” the node n, where expansion is the
identification of successor nodes of n. The fifth step then checks each of the successor
nodes to see whether or not one of them is the goal node. If any successor is the goal node,
the algorithm returns success and the solution, which consists of a path traced backwards
from the goal to the start node. Otherwise, the algorithm proceeds to the sixth step. For
every successor node, the algorithm applies the evaluation function, f, to it, then checks to
see if the node has been in either OPEN or CLOSED. If the node has not been in either, it gets
added to OPEN. Finally, the seventh step establishes a looping structure by sending the
algorithm back to the second step. This loop will only be broken if the algorithm returns
success in step five or failure in step two.
1. Define a list, OPEN, consisting solely of a single node, the start node, s.
3. Remove from the list the node n with the best score (the node where f is the
minimum), and move it to a list, CLOSED.
4. Expand node n.
5. IF any successor to n is the goal node, return success and the solution (by tracing the
path from the goal node to s).
Pearl adds a third step to the FOR loop that is designed to prevent re-expansion of nodes
that have already been visited. This step has been omitted above because it is not common
to all best-first search algorithms.
A is an initial node, which is expand to B,C and D. A heuristic function, say cost of reaching
the goal , is applied to each of these nodes, since D is most promising, it is expanded next,
producing two successor nodes E and F. Heuristic function is applied to them. Now out of
the four remaining ( B,C and F) B looks more promising and hence it is expand generating
nodes G and H . Again when evaluated E appears to be the next stop J has to be expanded
giving rise to nodes I and J. In the next step J has to be expanded, since it is more promising .
this process continues until a solution is found.
Above figure shows the best - first search tree. Since a search tree may generate duplicate
nodes, usually a search graph is preferred.
The best - first search is implemented by an algorithm known as A* algorithm. The algorithm
searches a directed graph in which each node represents a point in the problem space. Each
node will contain a description of the problem state it represents and it will have links to its
parent nodes and successor nodes. In addition it will also indicate how best it is for the
search process. A* algorithm uses have been generated, heuristic functions applied to them,
but successors not generated. The list CLOSED contains nodes which have been examined,
i.e., their successors generated.
A heuristic function f estimates the merits of each generated node. This function f has two
components g and h. the function g gives the cost of getting from the initial state to the
current node. The function h is an estimate of the addition cost of getting from current node
to a goal state. The function f (=g+h) gives the cost of getting from the initial state to a goal
state via the current node.
S.NO RGPV QUESTION YEAR MARKS
Q.1 Find the OPEN and CLOSED list nodes June.2013 10
for the diagram given below.
B C
D E
UNIT-01/LECTURE-08
A* algorithm
A* uses a best-first search and finds a least-cost path from a given initial node to one goal
node (out of one or more possible goals). As A* traverses the graph, it follows a path of the
lowest expected total cost or distance, keeping a sorted priority queue of alternate path
segments along the way.
the past path-cost function, which is the known distance from the starting node to the
current node x (usually denoted g(x))
a future path-cost function, which is an admissible "heuristic estimate" of the distance
from x to the goal (usually denoted h(x)).
The h(x) part of the f(x) function must be an admissible heuristic; that is, it must not
overestimate the distance to the goal. Thus, for an application like routing, h(x) might
represent the straight-line distance to the goal, since that is physically the smallest possible
distance between any two points or nodes.
If the heuristic h satisfies the additional condition h(x) <= d(x,y) + h(y) for every edge (x, y) of
the graph (where d denotes the length of that edge), then h is called monotone, or
consistent. In such a case, A* can be implemented more efficiently—roughly speaking, no
node needs to be processed more than once (see closed set below)—and A* is equivalent to
running Dijkstra's algorithm with the reduced cost d'(x, y) := d(x, y) + h(y) - h(x).
Process
Like all informed search algorithms, it first searches the routes that appear to be most likely
to lead towards the goal. What sets A* apart from a greedy best-first search is that it also
takes the distance already traveled into account; the g(x) part of the heuristic is the cost
from the starting point, not simply the local cost from the previously expanded node.
Starting with the initial node, it maintains a priority queue of nodes to be traversed, known
as the open set or fringe. The lower f(x) for a given node x, the higher its priority. At each
step of the algorithm, the node with the lowest f(x) value is removed from the queue, the f
and g values of its neighbors are updated accordingly, and these neighbors are added to the
queue. The algorithm continues until a goal node has a lower f value than any node in the
queue (or until the queue is empty). (Goal nodes may be passed over multiple times if there
remain other nodes with lower f values, as they may lead to a shorter path to a goal.) The f
value of the goal is then the length of the shortest path, since h at the goal is zero in an
admissible heuristic.
The algorithm described so far gives us only the length of the shortest path. To find the
actual sequence of steps, the algorithm can be easily revised so that each node on the path
keeps track of its predecessor. After this algorithm is run, the ending node will point to its
predecessor, and so on, until some node's predecessor is the start node.
Additionally, if the heuristic is monotonic (or consistent, see below), a closed set of nodes
already traversed may be used to make the search more efficient.
Algorithm:
1. Start with OPEN containing the initial node. Its g=0 and f ' = h '
2. Repeat
Else pick the BESTNODE on OPEN with lowest f ' value and place it on CLOSED
Else
3. If SUCCESSOR is the same as any node on OPEN, call that node OLS and add OLD to
BESTNODE 's successors. Check g(OLD) and g(SUCCESSOR). It g(SUCCESSOR) is cheaper then
reset OLD 's parent link to point to BESTNODE. Update g(OLD) and f '(OLD).
4. If SUCCESSOR was not on OPEN , see if it is on CLOSED . if so call the node CLOSED OLD ,
and better as earlier and set the parent link and g and f ' values appropriately.
5. If SUCCESSOR was not already on earlier OPEN or CLOSED, then put it on OPEN and add it
to the list of BESTNODE 's successors.
Best first searches will always find good paths to a goal after exploring the entire state
space. All that is required is that a good measure of goal distance be used.
The A* Algorithm
If h' rarely overestimates h by more than d then the A* algorithm will rarely find a solution
whose cost is d greater than the optimal solution.
UNIT-01/LECTURE-09
AO* algorithms
AO* algorithm (pronounced ``A-O-star'') an algorithm similar to A* for heuristic search of an
AO* Algorithm
1. Initialise the graph to start node
2. Traverse the graph following the current path accumulating nodes that have not yet
been expanded or solved
3. Pick any of these nodes and expand it and if it has no successors call this value
FUTILITY otherwise calculate only f' for each of the successors.
4. If f' is 0 then mark the node as SOLVED
5. Change the value of f' for the newly created node to reflect its successors by back
propagation.
6. Wherever possible use the most promising routes and if a node is marked as SOLVED
then mark the parent node as SOLVED.
7. If starting node is SOLVED or value greater than FUTILITY, stop, else repeat from 2.
AO* Algorithm2.
The AO* ALGORITHM
The problem reduction algorithm we just described is a simplification of an algorithm
described in Martelli and Montanari, Martelli and Montanari and Nilson. Nilsson calls it the
AO* algorithm , the name we assume.
1. Place the start node s on open.
2. Using the search tree constructed thus far, compute the most promising solution tree T
3. Select a node n that is both on open and a part of T. Remove n from open and place it on
closed.
4. If n is a terminal goal node, label n as solved. If the solution of n results in any of n’s
ancestors being solved, label all the ancestors as solved. If the start node s is solved, exit
with success where T is the solution tree. Remove from open all nodes with a solved
ancestor.
5. If n is not a solvable node (operators cannot be applied), label n as unsolvable. If the start
node is labeled as unsolvable, exit with failure. If any of n’s ancestors become unsolvable
because n is, label them unsolvable as well. Remove from open all nodes with unsolvable
ancestors.
6. Otherwise, expand node n generating all of its successors. For each such successor node
that contains more than one sub problem, generate their successors to give individual sub
problems. Attach to each newly generated node a back pointer to its predecessor. Compute
the cost estimate h* for each newly generated node and place all such nodes that do not yet
have descendents on open. Next, recomputed the values of h* at n and each ancestor of n.
7. Return to step 2.
Problem Reduction with AO* Algorithm.
PROBLEM REDUCTION ( AND - OR graphs - AO * Algorithm)
When a problem can be divided into a set of sub problems, where each sub problem can be
solved separately and a combination of these will be a solution, AND-OR graphs or AND - OR
trees are used for representing the solution. The decomposition of the problem or problem
reduction generates AND arcs. One AND are may point to any number of successor nodes.
All these must be solved so that the arc will rise to many arcs, indicating several possible
solutions. Hence the graph is known as AND - OR instead of AND. Figure shows an AND - OR
graph.
An algorithm to find a solution in an AND - OR graph must handle AND area appropriately.
A* algorithm can not search AND - OR graphs efficiently. This can be understand from the
give figure.
FIGURE : AND - OR graph
In figure (a) the top node A has been expanded producing two area one leading to B and
leading to C-D . the numbers at each node represent the value of f ' at that node (cost of
getting to the goal state from current state). For simplicity, it is assumed that every
operation(i.e. applying a rule) has unit cost, i.e., each are with single successor will have a
cost of 1 and each of its components. With the available information till now , it appears
that C is the most promising node to expand since its f ' = 3 , the lowest but going through B
would be better since to use C we must also use D' and the cost would be 9(3+4+1+1).
Through B it would be 6(5+1).
Thus the choice of the next node to expand depends not only n a value but also on whether
that node is part of the current best path form the initial mode. Figure (b) makes this
clearer. In figure the node G appears to be the most promising node, with the least f ' value.
But G is not on the current beat path, since to use G we must use GH with a cost of 9 and
again this demands that arcs be used (with a cost of 27). The path from A through B, E-F is
better with a total cost of (17+1=18). Thus we can see that to search an AND-OR graph, the
following three things must be done.
1. traverse the graph starting at the initial node and following the current best path, and
accumulate the set of nodes that are on the path and have not yet been expanded.
2. Pick one of these unexpanded nodes and expand it. Add its successors to the graph and
computer f ' (cost of the remaining distance) for each of them.
3. Change the f ' estimate of the newly expanded node to reflect the new information
produced by its successors. Propagate this change backward through the graph. Decide
which of the current best path.
The propagation of revised cost estimation backward is in the tree is not necessary in A*
algorithm. This is because in AO* algorithm expanded nodes are re-examined so that the
current best path can be selected. The working of AO* algorithm is illustrated in figure as
follows:
Referring the figure. The initial node is expanded and D is Marked initially as promising
node. D is expanded producing an AND arc E-F. f ' value of D is updated to 10. Going
backwards we can see that the AND arc B-C is better . it is now marked as current best path.
B and C have to be expanded next. This process continues until a solution is found or all
paths have led to dead ends, indicating that there is no solution. An A* algorithm the path
from one node to the other is always that of the lowest cost and it is independent of the
paths through other nodes.
The algorithm for performing a heuristic search of an AND - OR graph is given below. Unlike
A* algorithm which used two lists OPEN and CLOSED, the AO* algorithm uses a single
structure G. G represents the part of the search graph generated so far. Each node in G
points down to its immediate successors and up to its immediate predecessors, and also has
with it the value of h' cost of a path from itself to a set of solution nodes. The cost of getting
from the start nodes to the current node "g" is not stored as in the A* algorithm. This is
because it is not possible to compute a single such value since there may be many paths to
the same state. In AO* algorithm serves as the estimate of goodness of a node. Also a there
should value called FUTILITY is used. The estimated cost of a solution is greater than
FUTILITY then the search is abandoned as too expansive to be practical.
For representing above graphs AO* algorithm is as follows
AO* ALGORITHM:
1. Let G consists only to the node representing the initial state call this node INTT. Compute
h' (INIT).
2. Until INIT is labeled SOLVED or hi (INIT) becomes greater than FUTILITY, repeat the
following procedure.
(I) Trace the marked arcs from INIT and select an unbounded node NODE.
(II) Generate the successors of NODE . if there are no successors then assign FUTILITY as
h' (NODE). This means that NODE is not solvable. If there are successors then for each
one called SUCCESSOR, that is not also an ancester of NODE do the following
(a) add SUCCESSOR to graph G
(b) if successor is not a terminal node, mark it solved and assign zero to its h ' value.
(III) propagate the newly discovered information up the graph by doing the following . let S
be a set of nodes that have been marked SOLVED. Initialize S to NODE. Until S is empty
repeat the following procedure;
(a) select a node from S call if CURRENT and remove it from S.
(b) compute h' of each of the arcs emerging from CURRENT , Assign minimum h' to
CURRENT.
(c) Mark the minimum cost path a s the best out of CURRENT.
(d) Mark CURRENT SOLVED if all of the nodes connected to it through the new marked
are have been labeled SOLVED.
(e) If CURRENT has been marked SOLVED or its h ' has just changed, its new status
must be propagate backwards up the graph . hence all the ancestors of CURRENT are added
to S.
AO* Search Procedure.
The first requirement of a control strategy is that it must cause motion. The second
requirement of a control strategy is that issue must be systematic. We will explain these two
with respect to water jug problem. If we have implemented choosing the first operator and
then the one which matches the first one, then we would not have solved the problem. If
we follow any strategy which can cause some motion then will lead to a solution. But if it is
not followed systematically, and then got the solution. One day to follow a systematic
control strategy is to construct a tree with the initial state as its root. By applying all possible
combinations from the first level leaf nodes. Continue the process until some rule produces
a goal state. For the water jug problem a tree can be constructed as given in following
diagram.
The control strategy for the search process is called breadth first search. Other systematical
control strategies are also available . for example, we can select one single branch of a tree
until it yields a solution or until some pre specified depth has been reached. If not we go
back and explore to other branches . this is called depth – first – search. The water jug
problems will lead to an answer by adoption any control strategy because the problem is
simple. This is not always the case.