Professional Documents
Culture Documents
Uninformed search (or blind search): strategies use only the information
available in the problem definition. The term Uninformed means that they
have no information about the number of steps or the path cost from the
current state to the goal
Informed (or heuristic) search strategies know whether one state is more
promising than another
1. Brute Force Search Algorithms
Brute Force Search: Uninformed strategies (defined by order in which
nodes are expanded):
1. Depth-First Search:
2. Breadth-First Search:
3. Uniform-cost search
4. Iterative deepening
5. Bidirectional search
1. Depth-First Search:
❖ This algorithm finds whether the goal can be reached or not. But the
path it has to follow has not been mentioned. In order to remember the
path, all that has to be done is to establish a pointer from each generated
node to node “a” (in algorithm)
Algorithm for Depth-First Search:
Step 1: Put the initial node on a list START.
Step 3: Remove the first node from START. Call this node as a .
Step 5: Else if node a has a successor, generate all of them and add
them at the beginning of START.
Step 6: Go to Step 2.
Cont..
Expand deepest unexpanded node
• Implementation:
• fringe = Last In First Out (LIPO) queue, i.e., put successors at
front.
•
Is A a goal state?
Cont.…
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
queue=[B,C]
Is B a goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
•
queue=[D,E,C]
Is D = goal state?
Cont.…
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
queue=[H,I,E,C]
Is H = goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
queue=[I,E,C]
Is I = goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
queue=[E,C]
Is E = goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
•
queue=[J,K,C]
Is J = goal state?
Cont.…
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
•
queue=[K,C]
Is K = goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
•
queue=[C]
Is C = goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
queue=[F,G]
Is F = goal state?
Cont..
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
•
queue=[L,M,G]
Is L = goal state?
Cont.…
• Expand deepest unexpanded node
• Implementation:
• fringe = LIFO queue, i.e., put successors at front
•
queue=[M,G]
Is M = goal state?
❖The important factors to be considered in any searching
procedure are the time- complexity and space-complexity.
• Space? O(bm), i.e., linear space! (we only need to remember a single path +
expanded unexplored nodes)
⮚Many problems have very deep or even infinite search trees, so depth-first search will never
be able to recover from an unlucky choice at one of the nodes near the top of the tree.
⮚The search will always continue downward without backing up, even when a shallow solution
exists. Thus, on these problems depth-first search will either get stuck in an infinite loop and
never return a solution, or it may eventually find a solution path that is longer than the optimal
solution.
⮚That means depth-first search is neither complete nor optimal. Because of this, depth-first
search should be avoided for search trees with large or infinite maximum depths
2. Breadth-First Search:
❖One simple search strategy is a breadth-first search. In this strategy, the
root node is expanded first, then all the nodes generated by the root node
are expanded next, and then their successors, and so on. In general, all the
nodes at depth d in the search tree are expanded before the nodes at depth d
+ 1.
❖
If there is a solution, breadth-first search is guaranteed to find it, and if there are
several solutions, breadth-first search will always find the shallowest goal state
first.
❖
In terms of the four criteria, breadth-first search is complete, and it is optimal
provided the path cost is a non decreasing function of the depth of the node.
(This condition is usually satisfied only when all operators have the same cost.
The memory requirements are a bigger problem for breadth-first search than the
execution time.
Algorithm for BFS:
Step 1: Put the initial nod on a list START.
Step 3: Remove the first node from START. Call this node as a .
Step 5: Else if node a have successors, generate all of them and add them
at the tail of START.
Step 6: Go to Step 2.
Cont..
• This is also a brute search procedure like depth-first search. Here
searching progresses level by level, unlike depth-first search, this
goes deep into the tree. An operator is employed to generate all
possible children of a node. The algorithm is given above. As in
case of depth-first search, if a pointer is introduced in the
algorithm, then the entire path scanned can be identified.
Cont..
❖The root node is expanded first Then all successors of the root node
are expanded
• … and so on
❖ In general, all the nodes of a given depth are expanded before any
node of the next depth is expanded.
❖ Fringe is the collection of nodes that have been generated but not
yet expanded.
❖ The set of all leaf nodes available for expansion at any given
point is called the frontier.
❖Implementation:
Is A a goal state?
• Expand shallowest unexpanded node
• Implementation:
• fringe is a FIFO queue, i.e., new successors go at end
Expand:
fringe = [B,C]
Is B a goal state?
• Expand shallowest unexpanded node
• Implementation:
• fringe is a FIFO queue, i.e., new successors go at end
Expand:
fringe=[C,D,E]
Is C a goal state?
• Expand shallowest unexpanded node
• Implementation:
• fringe is a FIFO queue, i.e., new successors go at end
•
Expand:
fringe=[D,E,F,G]
Is D a goal state?
Properties of breadth-first search
• Complete? Yes it always reaches goal (if b is finite)
• Time? 1+b+b2+b3+… +bd + (bd+1) = O(bd+1)
(this is the number of nodes we generate)
• Space? O(bd+1) (keeps every node in memory,
either in fringe or on a path to fringe).
• Optimal? Yes (if we guarantee that deeper solutions are less optimal,
e.g. step-cost=1).
❖Breadth-first search finds the shallowest goal state, but this may not
always be the least-cost solution for a general path cost function.
Uniform cost search modifies the breadth-first Searching strategy by
always expanding the lowest-cost node on the fringe (as measured by
the path cost g(n)), rather than the lowest-depth node. It is easy to see
that breadth-first search is just uniform cost search with g(n) =
DEPTH(n).
Cont..
❑To do this, the frontier is stored as a priority queue. (Sorted list data
structure, better heap data structure).
❑The goal test is applied to a node when selected for expansion (not
when it is generated).
❑This will occur when the depth limit reaches d, the depth of the
shallowest goal node.
❑Iterative deepening combines the benefits of depth-first and breadth-
first search.
❑It searches forward from initial state and backward from goal state till both
meet to identify a common state. The path from initial state is concatenated
with the inverse path from the goal state. Each search is done only up to
half of the total path.
❑Bidirectional search is implemented by replacing the goal test with a
check to see whether the frontiers of the two searches intersect; if they
do, a solution has been found.
❖Stops when frontiers intersect. Works well only when there are a
unique start and a unique goal stats.
❑In AI heuristic search has a general meaning and a more specialized technics .
❑ It leads to a solution along the most probable path, omitting the least
promising ones .
❑ It should enable one to avoid the examination of dead ends, and to use
already gathered data
Heuristic Evaluation Functions
1. Problems for which no exact algorithms are known and one needs to
• Key Idea: avoid expanding paths that are already expensive, but
expand most promising first.
• A* is the best first search in which the cost associated with a node f(n)
Best first search with f(n)=g(n) + h(n)
⮚ g(n) =the cost of path from the initial state to node n
⮚The sum of the evaluation function value and the cost along the
path leading to that state is called fitness number.
⮚A heuristic h(n)is admissible if for every node n, h(n) ≤h*(n), where
h*(n)is the true cost to reach the goal state from n
Step 3: Remove the first node from START. Call this node “a “
Step 5: Else If node “a” has successors, generate all of them. Estimate the fitness
number of the successors by totaling the evaluation function value and the cost
function value. Sort the list by fitness number.
Step 3: Remove the first node from START. Call this node “a”
Step 5: Else If node “a “have successors, generate all of them. Find out
how far they are from the goal node.
Step 6: Go to Step 2.
Unfortunately, hill climbing search often gets stuck for the following reasons:
✔Local maxima: a local maximum is a peak that is higher than each of its
neighboring states, but lower than the global maximum
✔Ridges: Ridges result in a sequence of local maxima that is very difficult for
greedy algorithms to navigate.
❑This structure is called not simply an AND graph but rather an AND-OR
Graph. An example of an AND-OR Graph is given in figure. And arcs are
indicated with a line connecting all the components.
❑This algorithm should find a path from the starting node of the
graph to a set of nodes representing solution states. node.
The end of chapter three
ARTIFICIAL INTELLIGENCE
CHAPTER 4
Knowledge and Reasoning
Expert system
Compiled By Tedy D.
Introduction
❑Knowledge is a description of the world and it is a progression that
starts with data.
❑By organizing or analyzing the data, we understand what the data
means, and this becomes information
90
Fig. Knowledge Progression
• Data is viewed as collection of disconnected facts
• Example : It is raining
92
• Knowledge emerges when relationships among patterns are identified
and understood; Provides answers as "how“
94
• A knowledge model tells that, as the degree of “connectedness” and
“understanding” increases, we progress from data through
information and knowledge to wisdom
95
• Knowledge is a description of the world
• The knowledge can be extracted from its sources i.e. tacit knowledge
from experts and by observation and explicit knowledge through
document analysis.
Propositional logic
• Proposition : A proposition is classified as a declarative sentence
which is either true or false.
❖∧ ...and [conjunction]
❖∨ ...or [disjunction]
❖¬ ...not [negation]
Propositional logic is a weak language
⮚Hard to identify “individuals” (e.g., Mary, 3)
• To express this particular rule, we will use unary predicates Cat and
Mammal , thus, "Spot is a cat“ is represented by Cat(Spof),and "Spot
is a mammal“ by Mammal(Spot). In English, what we want to say is
that for any object x,if x is a cat then x is a mammal. First-order
logic lets us do this as follows:
• All 4th students are smart. Assume the universe of discourse of x are
4th students ∀ x 4th (x, ) ⇒ smart(x)
Existential quantification(∃)
• (∃ x)P(x) means that P holds for some value of x in the domain associated
with that variable. E.g., (∃ x) mammal(x) ∧ lays-eggs(x)
(∃ x)smart(x)
Agents that Reason Logically( Logical Agents):
• The central component of a knowledge based agent is its
knowledgebase. Informally ,a knowledge base is a set of
representations of facts about the world. Each individual
representation "is called a sentence.(Here "sentence“ is used as a
technical term.
Sentence is related to the sentences of English and other natural
languages, but is not identical.)The sentences are expressed in a
language called a knowledge representation language.
❖Domain database:
✔Contains facts about the ES’s subject
❖Explanation facility:
✔Explain the reasoning of the system to a user
• The problem must be suitable for an expert system to solve it. Find the experts
in task domain for the ES project. Establish cost effectiveness of the system.
• Knowledge Representation
Knowledge Acquisition
❖Less Production Cost − Production cost is reasonable. This makes them affordable.
❖Speed − They offer great speed. They reduce the amount of work an individual puts
in.
❖Less Error Rate − Error rate is low as compared to human errors.
❖Steady response − They work steadily without getting motional, tensed or fatigued.
• THE END
INDIVIDUAL Assignment
1. Draw any types of structure and Write a program for ( Brute Force Search
Depth-First Search: Breadth-First Search: Uniform-cost search: Iterative
deepening or Bidirectional search). You can you use one of the following
programing language
(20%)
Submission date August 31 G.C OR August 25 E.C
NB:- You have to write by your hand and it must be clear.
Test 1 will be Next Week Wednesday.
February 25 G.C / February 17 E.C