Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 67

ARTIFICIAL

INTELLIGENCE AND MACHINE LEARNING


(18CS71)

Module 1

Dr. Venkatesh Shankar


BE.,M.Tech., PhD.
YIT, Mangalore.
• What is Artificial Intelligence?
• It is a branch of Computer Science that pursues creating
the computers or machines as intelligent as human
beings.
• It is the science and engineering of making intelligent
machines, especially intelligent computer programs.
• It is related to the similar task of using computers to
understand human intelligence, but AI does not have to
confine itself to methods that are biologically observable
• Definition: Artificial Intelligence is the study of how to
make computers do things, which, at the moment,
people do better.
• Artificial Intelligence is a way of making a computer, a
computer-controlled robot, or a software think intelligently,
in the similar manner the intelligent humans think.
• From a business perspective AI is a set of very powerful
tools, and methodologies for using those tools to solve
business problems.
• From a programming perspective, AI includes the study of
symbolic programming, problem solving, and search.
AI Vocabulary
• Intelligence relates to tasks involving higher mental
processes, e.g. creativity, solving problems,pattern
recognition, classification, learning, induction, deduction,
building analogies,optimization, language processing
• Problems of AI:
• Intelligence does not imply perfect understanding; every
intelligent being has limited perception, memory and
computation. Many points on the spectrum of intelligence
versus cost are viable, from insects to humans.
• AI seeks to understand the computations required from
intelligent behavior and to produce computer systems that
exhibit intelligence. Aspects of intelligence studied by AI
include perception, communicational using human languages,
reasoning, planning, learning and memory.
• The following questions are to be considered before we can
step forward:
1. What are the underlying assumptions about intelligence?
2. What kinds of techniques will be useful for solving AI
problems?
3. At what level human intelligence can be modelled?
4. When will it be realized when an intelligent program has
been built?
• Branches of AI:
• A list of branches of AI is given below. However some
branches are surely missing, because no one has identified
them yet. Some of these may be regarded as concepts or
topics rather than full branches.
• Logical AI — In general the facts of the specific situation in
which it must act, and its goals are all represented by sentences
of some mathematical logical language.
• Learning from experience — There are some rules expressed in
logic for learning.
• Planning — Planning starts with general facts about the world
(especially facts about the effects of actions), facts about the
particular situation and a statement of a goal. From these,
planning programs generate a strategy for achieving the goal.
• Epistemology — This is a study of the kinds of knowledge that
are required for solving problems in the world.
• Ontology — Ontology is the study of the kinds of things that
exist. In AI the programs and sentences deal with various kinds of
objects and we study what these kinds are and what their basic
properties are. Ontology assumed importance from the 1990s.
• Heuristics — A heuristic is a way of trying to discover
something or an idea embedded in a program. The term is
used variously in AI. Heuristic functions are used in some
approaches to search or to measure how far a node in a
search tree seems to be from a goal.

• Genetic programming — Genetic programming is an


automated method for creating a working computer program
from a high-level problem statement of a problem. Genetic
programming starts from a high-level statement of ‘what
needs to be done’ and automatically creates a computer
program to solve the problem.
• Applications of AI
• AI has applications in all fields of human study, such as finance and economics,
environmental engineering, chemistry, computer science, and so on. Some of the
applications of AI are listed below:
Perception
Machine vision
Speech understanding
Touch ( tactile or haptic) sensation
Robotics
Natural Language Processing
Natural Language Understanding
Speech Understanding
Language Generation
Machine Translation
Planning
Expert Systems
Machine Learning
Theorem Proving
Symbolic Mathematics
Game Playing
• AI Technique:
Artificial Intelligence research during the last three
decades has concluded that Intelligence requires
knowledge. To compensate overwhelming quality,
knowledge possesses less desirable properties.
• A. It is huge.
• B. It is difficult to characterize correctly.
• C. It is constantly varying.
• D. It differs from data by being organized in a way
that corresponds to its application.
• E. It is complicated.
An AI technique is a method that exploits
knowledge that is represented so that:
• The knowledge captures generalizations that share properties, are
grouped together, rather than being allowed separate
representation.
• It can be understood by people who must provide it—even though
for many programs bulk of the data comes automatically from
readings.
• In many AI domains, how the people understand the same people
must supply the knowledge to a program.
• It can be easily modified to correct errors and reflect changes in real
conditions.
• It can be widely used even if it is incomplete or inaccurate.
• It can be used to help overcome its own sheer bulk by helping to
narrow the range of possibilities that must be usually considered.
• In order to characterize an AI technique let us consider
initially OXO or tic-tac-toe and use a series of different
approaches to play the game.
• Example-1: Tic-Tac-Toe
1.1 The first approach (simple)
• The Tic-Tac-Toe game consists of a nine element vector called BOARD; it
represents the numbers 1 to 9 in three rows.
• The second approach
The structure of the data is as before but we use 2 for a blank, 3 for an X
and 5 for an O. A variable called TURN indicates 1 for the first move and 9
for the last. The algorithm consists of three actions:
MAKE2 which returns 5 if the centre square is blank; otherwise it returns
any blank non corner square, i.e. 2, 4, 6 or 8. POSSWIN (p) returns 0 if
player p cannot win on the next move and otherwise returns the number
of the square that gives a winning move.
• The final approach
• The structure of the data consists of BOARD which contains a
nine element vector, a list of board positions that could result
from the next move and a number representing an estimation
of how the board position leads to an ultimate win for the
player to move.
• This algorithm looks ahead to make a decision on the next
move by deciding which the most promising move or the
most suitable move at any stage would be and selects the
same.
• Example-2: Question Answering
• Let us consider Question Answering systems that accept input
in English and provide answers also in English.
• This problem is harder than the previous one as it is more
difficult to specify the problem properly.
• Another area of difficulty concerns deciding whether the
answer obtained is correct, or not, and further what is meant
by ‘correct’. For example, consider the following situation:
Text
• Rani went shopping for a new Coat. She found a red one she
really liked.
• When she got home, she found that it went perfectly with her
favourite dress.
• Algorithm
Answering a question requires the following four steps to be
followed:
• Compare the template against the questions and store all
successful matches to produce a set of text patterns.
• Pass these text patterns through a substitution process to
change the person or voice and produce an expanded set of
text patterns.
• Apply each of these patterns to the text; collect all the
answers and then print the answers.
• Question
• 1. What did Rani go shopping for?
• 2. What did Rani find that she liked?
• 3. Did Rani buy anything?
• Method 1---Data Structures
• A set of templates that match common questions and
produce patterns used to match against inputs.
• Templates and patterns are used so that a template that
matches a given question is associated with the
corresponding pattern to find the answer in the input text.
• In question 1 we use the template WHAT DID X Y which
generates Rani go shopping for z and after substitution we
get Rani goes shopping for z and Rani went shopping for z
giving z [equivalence] a new coat

• In question 2 we need a very large number of templates and


also a scheme to allow the insertion of ‘find’ before ‘that she
liked’; the insertion of ‘really’ in the text; and the substitution
of ‘she’ for ‘Rani’ gives the answer ‘a red one’.

• Question 3 cannot be answered.


• Method 2---------- Data Structures
• A structure called English consists of a dictionary, grammar
and some semantics about the vocabulary we are likely to
come across. This data structure provides the knowledge to
convert English text into a storable internal form and also to
convert the response back into English.
• The structured representation of the text is a processed form
and defines the context of the input text by making explicit all
references such as pronouns.
• There are three types of such knowledge representation
systems: production rules of the form ‘if x then y’, slot and
filler systems and statements in mathematical logic. The
system used here will be the slot and filler system.
• Take, for example sentence:
• ‘She found a red one she really liked’.
• Event2 Event2
• instance: finding instance: liking
• tense: past tense: past
• agent: Rani modifier: much
• object: Thing1 object: Thing1
• Thing1
• instance: coat
• colour: red
The question is stored in two forms: as input and in the above
form.
Algorithm
• Convert the question to a structured form using English know how,
then use a marker to indicate the substring (like ‘who’ or ‘what’) of
the structure, that should be returned as an answer. If a slot and filler
system is used a special marker can be placed in more than one slot.
• The answer appears by matching this structured form against the
structured text.
• The structured form is matched against the text and the requested
segments of the question are returned.

• Examples
• Both questions 1 and 2 generate answers via a new coat and a red
coat respectively.
• Question 3 cannot be answered, because there is no direct response.
• Method 3-------- Data Structures
• World model contains knowledge about objects, actions and
situations that are described in the input text. This structure is
used to create integrated text from input text.
• The diagram shows how the system’s knowledge of shopping
might be represented and stored. This information is known as a
script and in this case is a shopping script figure 1.1
• Convert the question to a structured form using both the
knowledge contained in Method 2 and the World model,
generating even more possible structures, since even more
knowledge is being used. Sometimes filters are introduced to
prune the possible answers.
• To answer a question, the scheme followed is: Convert the
question to a structured form as before but use the world model
to resolve any ambiguities that may occur. The structured form is
matched against the text and the requested segments of the
question are returned.
• Both questions 1 and 2 generate answers, as in the previous
program. Question 3 can now be answered. The shopping
script is instantiated and from the last sentence the path the
one used to form the representation. ‘M’ is bound to the red
coat-got home. ‘Rani buys a red coat’ comes from the
integrated text generates that she bought a red coat.
PROBLEMS, PROBLEM SPACES AND SEARCH
• To solve the problem of building a system you should take the following steps:
1. Define the problem accurately including detailed specifications and what
constitutes a suitable solution.
2. Scrutinize the problem carefully, for some features may have a central affect on
the chosen method of solution.
3. Segregate and represent the background knowledge needed in the solution of
the problem.
4. Choose the best solving techniques for the problem to solve a solution.
• 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.
• • A ‘problem space’ is an abstract space.
A problem space encompasses all valid states that can be generated
by the
application of any combination of operators on any combination of
objects.
The problem space may contain one or more solutions. A solution is a
combination of operations and objects that achieve the goals.
• A ‘search’ refers to the search for a solution in a problem space.
Search proceeds with different types of ‘search control strategies’.
The depth-first search and breadth-first search are the two common
search
strategies.
AI - General Problem Solving
• Problem solving has been the key area of concern for Artificial Intelligence.
Problem solving is a process of generating solutions from observed or given data.
It is however not always possible to use direct methods (i.e. go directly from data
to solution). Instead, problem solving often needs to use indirect or model based
methods.
• General Problem Solver (GPS) was a computer program created in 1957 by
Simon and Newell to build a universal problem solver machine. GPS was based on
Simon and Newell’s theoretical work on logic machines. GPS
• To build a system to solve a particular problem, we need to:
 Define the problem precisely – find input situations as well as final situations for
an acceptable solution to the problem
 Analyze the problem
 Isolate and represent task knowledge necessary to solve the problem
 Choose the best problem-solving technique(s) and apply to the particular problem
Problem definitions
• A problem is defined by its ‘elements’ and their ‘relations’. To provide a
formal description of a problem, we need to do the following:
a. Define a state space that contains all the possible configurations of the
relevant objects, including some impossible ones.
b. Specify one or more states that describe possible situations, from which
the problem solving process may start. These states are called initial
states.
c. Specify one or more states that would be acceptable solution to the
problem.
These states are called goal states.
• To simplify search algorithms, it is often convenient to logically and
programmatically represent a problem space as a tree. A tree usually
decreases the complexity of a search at a cost. Here, the cost is due to
duplicating some nodes on the tree that were linked numerous times in the
graph, e.g. node B and node D.
• A tree is a graph in which any two vertices are connected by exactly one
path. Alternatively, any connected graph with no cycles is a tree.
• Problem solving:
• The term, Problem Solving relates to analysis in AI. Problem solving may
be characterized as a systematic search through a range of possible
actions to reach some predefined goal or solution. Problem-solving
methods are categorized as special purpose and general purpose.

• A special-purpose method is tailor-made for a particular problem, often


exploits very specific features of the situation in which the problem is
embedded.

• A general-purpose method is applicable to a wide variety of problems. One


General-purpose technique used in AI is ‘means-end analysis’: a step-
bystep, or incremental, reduction of the difference between current state
and final goal.
DEFINING PROBLEM AS A STATE SPACE
SEARCH
• To solve the problem of playing a game, we require the rules of the game
and targets for winning as well as representing positions in the game. The
opening position can be defined as the initial state and a winning position
as a goal state.
• The number of rules that are used must be minimized and the set can be
created by expressing each rule in a form as possible. The representation
of games leads to a state space representation and it is common for well-
organized games with some structure.
• This representation allows for the formal definition of a problem that
needs the movement from a set of initial positions to one of a set of target
positions. It means that the solution involves using known techniques and
a systematic search. This is quite a common method in Artificial
Intelligence
• State Space Search
• A state space represents a problem in terms of states and operators that
change states.
A state space consists of:
• A representation of the states the system can be in. For example, in
aboard game, the board represents the current state of the game.
• A set of operators that can change one state into another state. In a
board game, the operators are the legal moves from any given state. Often
the operators are represented as programs that change a state
representation to represent the new state.
• An initial state.
• A set of final states; some of these may be desirable, others undesirable.
This set is often represented implicitly by a program that detects terminal
states.
The Water Jug Problem
• In this problem, we use two jugs called four and three; four holds a
maximum of four gallons of water and three a maximum of three gallons
of water. How can we get two gallons of water in the four jug?
• The state space is a set of prearranged pairs giving the number of gallons
of water in the pair of jugs at any time, i.e., (four, three) where four = 0, 1,
2, 3 or 4 and three = 0, 1, 2 or 3.
• The start state is (0, 0) and the goal state is (2, n) where n may be any but
it is limited to three holding from 0 to 3 gallons of water or empty.
PRODUCTION SYSTEMS
• Production systems provide appropriate structures for performing and
describing search
• processes. A production system has four basic components as enumerated
below.
 A set of rules each consisting of a left side that determines the
applicability of the rule and a right side that describes the operation to be
performed if the rule is applied.
 A database of current facts established during the process of inference.
 A control strategy that specifies the order in which the rules will be
compared with facts in the database and also specifies how to resolve
conflicts in selection of several rules or selection of more facts.
 A rule firing module.
• Example: Eight puzzle (8-Puzzle)

• The 8-puzzle is a 3 × 3 array containing eight square pieces, numbered 1


through 8, and one empty space. A piece can be moved horizontally or
vertically into the empty space, in effect exchanging the positions of the
piece and the empty space.
• There are four possible moves, UP (move the blank space up), DOWN,
LEFT and RIGHT. The aim of the game is to make a sequence of moves that
will convert the board from the start state into the goal state:
Example: Missionaries and Cannibals
• The Missionaries and Cannibals problem illustrates the use of state
space search for planning under constraints:
Three missionaries and three cannibals wish to cross a river using a
two person boat. If at any time the cannibals outnumber the
missionaries on either side of the river, they will eat the missionaries.
How can a sequence of boat trips be performed that will get everyone
to the other side of the river without any missionaries being eaten?
• State representation:
1. BOAT position: original (T) or final (NIL) side of the river.
2. Number of Missionaries and Cannibals on the original side of the
river.
3. Start is (T 3 3); Goal is (NIL 0 0).
OPERATORS-------------
Control Strategies
• Search-related terms
• • Algorithm’s performance and complexity
• Ideally we want a common measure so that we can compare approaches in order to
select
• the most appropriate algorithm for a given situation.
•  Performance of an algorithm depends on internal and external factors.
• Internal factors/ External factors
•  Time required to run
•  Size of input to the algorithm
•  Space (memory) required to run
•  Speed of the computer
•  Quality of the compiler
•  Complexity is a measure of the performance of an algorithm. Complexity
• measures the internal factors, usually in time than space.
• Computational complexity\
• It is the measure of resources in terms of Time and Space.
•  If A is an algorithm that solves a decision problem f, then run-time of A is the
number of steps taken on the input of length n.
•  Time Complexity T(n) of a decision problem f is the run-time of the ‘best’
algorithm A for f.
•  Space Complexity S(n) of a decision problem f is the amount of memory used by
the ‘best’ algorithm A for f.
• ‘Big - O’ notation
• The Big-O, theoretical measure of the execution of an algorithm,
usually indicates the time or the memory needed, given the
problem size n, which is usually the number of items.
• Big-O notation
• The Big-O notation is used to give an approximation to the run-
time- efficiency of an algorithm; the letter ‘O’ is for order of
magnitude of operations or space at run-time.
• The Big-O of an Algorithm A
•  If an algorithm A requires time proportional to f(n), then algorithm
A is said to be of order f(n), and it is denoted as O(f(n)).
•  If algorithm A requires time proportional to n2, then the order of
the algorithm is said to be O(n2).
•  If algorithm A requires time proportional to n, then the order of
the algorithm is said to be O(n).
HEURISTIC SEARCH TECHNIQUES
Search Algorithms
Many traditional search algorithms are used in AI applications. For complex
problems, the traditional algorithms are unable to find the solutions 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 algorithms or Brute-force algorithms, search through the
search space all possible candidates for the solution checking whether each
candidate satisfies the problem’s statement.
• Informed search algorithms use heuristic functions that are specific to the
problem, apply them to guide the search through the search space to try to
reduce the amount of time spent in searching.
• A good heuristic will make an informed search dramatically outperform
any uninformed search: for example, the Traveling Salesman Problem
(TSP), where the goal is to find is a good solution instead of finding the
best solution.
• Some prominent intelligent search algorithms are stated below:
• 1. Generate and Test Search
• 2. Best-first Search
• 3. Greedy Search
• 4. A* Search
• 5. Constraint Search
• 6. Means-ends analysis
• There are some more algorithms. They are either improvements or
combinations of these.

• Hierarchical Representation of Search Algorithms: A Hierarchical


representation of most search algorithms is illustrated below.
The representation begins with two types of search:
• Uninformed Search: Also called blind, exhaustive or brute-force search,
it 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, this uses
information about the problem to guide the search—usually guesses the
distance to a goal state and is therefore efficient, but the search may not
be always possible.
• Breadth-first search
• A Search strategy, in which the highest layer of a decision tree is searched
completely before proceeding to the next layer is called Breadth-first search
(BFS).
1. Create a variable called LIST and set it to be the starting state.
2. Loop until a goal state is found or LIST is empty, Do
a. Remove the first element from the LIST and call it E. If the LIST is empty, quit.
• b. For every path each rule can match the state 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 LIST.
• Advantages
1. Guaranteed to find an optimal solution (in terms of shortest number of steps
to reach the goal).
2. Can always find a goal node if one exists (complete).
• Disadvantages
1. High storage requirement: exponential with tree depth.
• Depth-first search
• A search strategy that extends the current path as far as possible before backtracking to
the last choice point and trying the next alternative path is called Depth-first search (DFS).
• Algorithm
Depth-first search applies operators to each newly generated state, trying to drive directly
toward the goal.
1. If the starting state is a goal state, quit and return success.
2. Otherwise, do the following until success or failure is signalled:
a. Generate a successor E to the starting state. If there are no more successors, then signal
failure.
b. Call Depth-first Search with E as the starting state.
c. If success is returned signal success; otherwise, continue in the loop.
• Advantages
1. Low storage requirement: linear with tree depth.
2. Easily programmed: function call stack does most of the work of maintaining state of the
search.
• Disadvantages
1. May find a sub-optimal solution (one that is deeper or more costly than the best
solution).
2. Incomplete: without a depth bound, may not find a solution even if one exists.
• 2.4.2.3 Bounded depth-first search
• Depth-first search can spend much time (perhaps infinite time) exploring a very
deep path that does not contain a solution, when a shallow solution exists. An easy
way to solve this problem is to put a maximum depth bound on the search. Beyond
the depth bound, a failure is generated automatically without exploring any
deeper.
Problems:
• 1. It’s hard to guess how deep the solution lies.
• 2. If the estimated depth is too deep (even by 1) the computer time used is
dramatically increased.
• 3. If the estimated depth is too shallow, the search fails to find a solution; all that
computer time is wasted.
Heuristics
• A heuristic is a method that improves the efficiency of the search process. These
are like tour guides. There are good to the level that they may neglect the points in
general interesting directions; they are bad to the level that they may neglect
points of interest to particular individuals.
• Heuristic search
To find a solution in proper time rather than a complete solution in unlimited time
we use heuristics. ‘A heuristic function is a function that maps from problem state
descriptions to measures of desirability, usually represented as numbers’. Heuristic
search methods use knowledge about the problem domain and choose promising
operators first.
• For finding a solution, by using the heuristic technique, one should carry out the
following steps:
1. Add domain—specific information to select what is the best path to continue
searching along.
2. Define a heuristic function h(n) that estimates the ‘goodness’ of a node n.
Specifically, h(n) = estimated cost(or distance) of minimal cost path from n to a goal
state.
3. The term, heuristic means ‘serving to aid discovery’ and is an estimate, based on
domain specific information that is computable from the current state description
of how close we are to a goal.
Heuristic search techniques
For complex problems, the traditional algorithms, presented above, are unable to find the
solution within some practical time and space limits. Consequently, many special techniques
are developed, using heuristic functions.
• Blind search is not always possible, because it requires too much time or Space (memory).
Heuristics are rules of thumb; they do not guarantee a solution to a problem.
• Heuristic Search is a weak technique but can be effective if applied correctly; it requires
domain specific information.
Characteristics of heuristic search
• Heuristics are knowledge about domain, which help search and reasoning in
its domain.
• Heuristic search incorporates domain knowledge to improve efficiency over
blind search.
• Heuristic is a function that, when applied to a state, returns value as
estimated merit of state, with respect to goal.
Heuristics might (for reasons) underestimate or overestimate the merit of a
state with respect to goal.
Heuristics that underestimate are desirable and called admissible.
• Heuristic evaluation function estimates likelihood of given state leading to goal
state.
• Heuristic search function estimates cost from current state to goal, presuming
function is efficient.
• Generate and Test Strategy
Generate-And-Test Algorithm
• Generate-and-test search algorithm is a very simple algorithm that guarantees to
find a solution if done systematically and there exists a solution.
• Algorithm: Generate-And-Test
1.Generate a possible solution.
2.Test to see if this is the expected solution.
3.If the solution has been found quit else go to step 1.
• Hill Climbing
• Hill Climbing is heuristic search used for mathematical optimization problems in
the field of Artificial Intelligence .
• Given a large set of inputs and a good heuristic function, it tries to find a
sufficiently good solution to the problem. This solution may not be the global
optimal maximum.
Algorithm for Simple Hill climbing :
Step 1 : Evaluate the initial state. If it is a goal state then stop and return success.
Otherwise, make initial state as current state.
Step 2 : Loop until the solution state is found or there are no new operators present
which can be applied to current state.
a) Select a state that has not been yet applied to the current state and apply it to
produce a new state.
b) Perform these to evaluate new state
i. If the current state is a goal state, then stop and return success.
ii. If it is better than the current state, then make it current state and proceed
further.
iii. If it is not better than the current state, then continue in the loop until a
solution is found.
Step 3 : Exit.
A* Search Algorithm
• A* is a type of search algorithm. Some problems can be solved by representing the
world in the initial state, and then for each action we can perform on the world we
generate states for what the world would be like if we did so.
• If you do this until the world is in the state that we specified as a solution, then the
route from the start to this goal state is the solution to your problem.
• Some terminology
• A node is a state that the problem's world can be in. In path finding a node would
be just a 2d coordinate of where we are at the present time . In the 8-puzzle it is
the positions of all the tiles.
• Next all the nodes are arranged in a graph where links between nodes represent
valid steps in solving the problem. These links are known as edges. In the 8-puzzle
diagram the edges are shown as blue lines. See figure 1 below.
• State space search, then, is solving a problem by beginning with the start state, and
then for each node we expand all the nodes beneath it in the graph by applying all
the possible moves that can be made at each point.
• 8 Puzzle
• Let's look at the 8 puzzle in more detail. This is a simple sliding tile puzzle on a 3*3
grid where one tile is missing and you can move the other tiles into the gap until
you get the puzzle into the goal position. See figure 1.
Implementing A*
• We are now ready to look at the operation of the A* algorithm. What we
need to do is start with the goal state and then generate the graph
downwards from there. Let's take the 8-puzzle in figure 1. We ask how
many moves can we make from the start state? The answer is 2, there are
two directions we can move the blank tile, and so our graph expands.
• Let's start with the OPEN list. This is where we will remember which nodes
we haven't yet expanded. When the algorithm begins the start state is
placed on the open list, it is the only state we know about and we have
not expanded it.
• So we will expand the nodes from the start and put those on the OPEN list
too. Now we are done with the start node and we will put that on the
CLOSED list. The CLOSED list is a list of nodes that we have expanded.

f=g+h
• Traditionally this has been represented by the letters f, g and h. 'g' is the sum of
all the costs it took to get here, 'h' is our heuristic function, the estimate of what
it will take to get to the goal. 'f' is the sum of these two. We will store each of
these in our nodes.
• Using the f, g and h values the A* algorithm will be directed, subject to
conditions we will look at further on, towards the goal and will find it in the
shortest route possible.
• So far we have looked at the components of the A*, let's see how they all fit
together to make the algorithm :
Advantages:
• It is complete and optimal.
• It is the best one from other techniques. It is used to solve very complex
problems.
• It is optimally efficient, i.e. there is no other optimal algorithm guaranteed to
expand fewer nodes than A*.
Disadvantages:
• This algorithm is complete if the branching factor is finite and every action has
fixed cost.
• The speed execution of A* search is highly dependant on the accuracy of the
heuristic algorithm that is used to compute h (n).
AO* Search: (And-Or) Graph
• AO* is best algorithm for solving cyclic AND-OR Graph
• The Depth first search and Breadth first search given earlier for OR trees
or graphs can be easily adopted by AND-OR graph. The main difference
lies in the way termination conditions are determined, since all goals
following an AND nodes must be realized; where as a single goal node
following an OR node will do. So for this purpose we are using AO*
algorithm.
Like A* algorithm here we will use two arrays and one heuristic function.
OPEN:
• It contains the nodes that has been traversed but yet not been marked
solvable or unsolvable. CLOSE:
• It contains the nodes that have already been processed
• Algorithm:
• Step 1: Place the starting node into OPEN.
• Step 2: Compute the most promising solution tree say T0.
• Step 3: Select a node n that is both on OPEN and a member of T0.
Remove it from OPEN and place it in CLOSE
• Step 4: If n is the terminal goal node then leveled n as solved and
leveled all the ancestors of n as solved. If the starting node is
marked as solved then success and exit.
• Step 5: If n is not a solvable node, then mark n as unsolvable. If
starting node is marked as unsolvable, then return failure and exit.
• Step 6: Expand n. Find all its successors and find their h (n) value,
push them into OPEN.
• Step 7: Return to Step 2.
• Step 8: Exit.
• Advantages:
• It is an optimal algorithm.
• If traverse according to the ordering of nodes. It can be used for both OR and AND
graph.
• Disadvantages:
• Sometimes for unsolvable nodes, it can’t find the optimal path. Its complexity is
than other algorithms.
• PROBLEM REDUCTION
• Problem Reduction with 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.
• 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 ancestor 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.
(c) If successor is not a terminal node, compute it 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
• AO* Search Procedure.
• 1. Place the start node on open.
• 2. Using the search tree, compute the most promising solution tree TP .
• 3. Select node n that is both on open and a part of tp, remove n from
open and place it no closed.
• 4. If n is a goal node, label n as solved. If the start node is solved, exit with
success where tp is the solution tree, remove all nodes from open with a
solved ancestor.
• 5. If n is not solvable node, label n as unsolvable. If the start node is
labeled as unsolvable, exit with failure. Remove all nodes from open ,with
unsolvable ancestors.
• 6. Otherwise, expand node n generating all of its successor compute the
cost of for each newly generated node and place all such nodes on open.
• 7. Go back to step(2)
Note: AO* will always find minimum cost solution
MEANS - ENDS ANALYSIS
• Most of the search strategies either reason forward of backward however,
often a mixture o the two directions is appropriate. Such mixed strategy
would make it possible to solve the major parts of problem first and solve
the smaller problems the arise when combining them together. Such a
technique is called "Means - Ends Analysis".
• The means -ends analysis process centers around finding the difference
between current state and goal state. The problem space of means - ends
analysis has an initial state and one or more goal state, a set of operate
with a set of preconditions their application and difference functions that
computes the difference between two state a(i) and s(j). A problem is
solved using means – ends analysis by
1. Computing the current state s1 to a goal state s2 and computing their
difference .
2. Satisfy the preconditions for some recommended operator op is selected,
then to reduce the difference .
3. The operator OP is applied if possible. If not the current state is solved a
goal is created and
means- ends analysis is applied recursively to reduce the sub goal.
4. If the sub goal is solved state is restored and work resumed on the original
problem.
• means- ends analysis I useful for many human planning activities. Consider
the example of planing for an office worker. Suppose we have a different
table of three rules:
• 1. If in out current state we are hungry , and in our goal state we are not
hungry , then either the "visit hotel" or "visit Canteen " operator is
recommended.
• 2. If our current state we do not have money , and if in your goal state we
have money, then the "Visit our bank" operator or the "Visit secretary"
operator is recommended.
• 3. If our current state we do not know where something is , need in our
goal state we do know, then either the "visit office enquiry" , "visit
secretary" or "visit co worker " operator is recommended.

You might also like