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

lecture_3

Uploaded by

monsefomran616
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lecture_3

Uploaded by

monsefomran616
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

‫األكاديمية الليبية للدراسات‬

‫العليا‬
‫فرع الجبل األخضر‬
Artificial Intelligence

Lecture 3 : Search Algorithms & Knowledge


Representation in AI

‫ محمد لعبيدي‬. ‫دكتور‬


Search problems in AI

Search Algorithms in AI

Knowledge Representation in AI
Search problems

A search problem consists of:


• A State Space. Set of all possible states where you can be.
• A Start State. The state from where the search begins.
• A Goal Test. A function that looks at the current state returns whether or not it is
the goal state.
The Solution to a search problem is a sequence of actions, called the plan that
transforms the start state to the goal state. This plan is achieved through search
algorithms.
Search Algorithms in AI
Types of search algorithms:
There are many powerful search algorithms that can be used to solve problems
in AI . We will study six of the fundamental search algorithms, divided into two
categories, as shown below.
Uninformed Search Algorithms
The search algorithms in this section have no additional information on the goal
node other than the one provided in the problem definition. The plans to reach
the goal state from the start state differ only by the order and/or length of
actions. Uninformed search is also called Blind search .The following
uninformed search algorithms are discussed in this section.

• Depth First Search


• Breadth First Search
• Uniform Cost Search
Depth First Search
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph
data structures. The algorithm starts at the root node (selecting some arbitrary node
as the root node in the case of a graph) and explores as far as possible along each
branch before backtracking. It uses last in- first-out strategy and hence it is
implemented using a stack.
Question. Which solution would DFS find to Solution. The equivalent search tree for the below
move from node S to node G if run on the graph is as follows. As DFS traverses the tree
graph below? “deepest node first”, it would always pick the deeper
branch until it reaches the solution (or it runs out of
nodes, and goes to the next branch). The traversal is
shown in blue arrows.

Path: S -> A -> B -> C -> G


Breadth First Search
Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph
data structures. It starts at the tree root (or some arbitrary node of a graph,
sometimes referred to as a ‘search key’), and explores all of the neighbour nodes at
the present depth prior to moving on to the nodes at the next depth level. It is
implemented using a queue.
Solution. The equivalent search tree for
Question. Which solution would BFS find to
the above graph is as follows. As BFS
move from node S to node G if run on the
traverses the tree “shallowest node first”,
graph below?
it would always pick the shallower branch
until it reaches the solution (or it runs out
of nodes, and goes to the next branch).
The traversal is shown in blue arrows.

Path: S -> D -> G


Uniform Cost Search
UCS is different from BFS and DFS because here the costs come into play. In other
words, traversing via different edges might not have the same cost. The goal is to
find a path where the cumulative sum of costs is the least.

Solution. The equivalent search tree for the above graph is


Question. Which solution would UCS find to
as follows. The cost of each node is the cumulative cost of
move from node S to node G if run on the graph
reaching that node from the root. Based on the UCS
below?
strategy, the path with the least cumulative cost is chosen.
Note that due to the many options in the fringe, the
algorithm explores most of them so long as their cost is
low, and discards them when a lower-cost path is found;
these discarded traversals are not shown below. The actual
traversal is shown in blue.
:Informed Search Algorithms

These kind of algorithms have information on the goal state, which helps in more
efficient searching. This information is obtained by something called a heuristic.
In this section, we will discuss the following search algorithms.

• Greedy Search
• A* Tree Search
• A* Graph Search

Search Heuristics: In an informed search, a heuristic is a function that estimates how


close a state is to the goal state. For example – Manhattan distance, Euclidean distance,
etc. (Lesser the distance, closer the goal.) Different heuristics are used in different
informed algorithms.
Greedy Search
In greedy search, we expand the node closest to the goal node. The “closeness” is estimated
by a heuristic h(x).

Heuristic: A heuristic h is defined as- h(x) = Estimate of distance of node x from the goal
node. Lower the value of h(x), closer is the node from the goal.
Strategy: Expand the node closest to the goal state, i.e. expand the node with a lower h value.

Solution. Starting from S, we can traverse to A(h=9)


Example:
or D(h=5). We choose D, as it has the lower heuristic
Question. Find the path from S to G using
cost. Now from D, we can move to B(h=4) or E(h=3).
greedy search. The heuristic values h of each
We choose E with a lower heuristic cost. Finally,
node below the name of the node.
from E, we go to G(h=0). This entire traversal is
shown in the search tree below, in blue.
:A* Tree Search
A* Tree Search, or simply known as A* Search, combines the strengths of uniform-cost
search and greedy search. In this search, the heuristic is the summation of the cost in UCS,
denoted by g(x), and the cost in the greedy search, denoted by h(x). The summed cost is
denoted by f(x). Solution. Starting from S, the algorithm computes g(x) + h(x)
Strategy: Choose the node with the for all nodes in the fringe at each step, choosing the node with
lowest f(x) value. the lowest sum. The entire work is shown in the table below.
Note that in the fourth set of iterations, we get two paths with
Question. Find the path to reach from S equal summed cost f(x), so we expand them both in the next
to G using A* search. set. The path with a lower cost on further expansion is the
chosen path.
A* Graph Search
A* tree search works well, except that it takes time re-exploring the branches it has already explored. In
other words, if the same node has expanded twice in different branches of the search tree, A* search
might explore both of those branches, thus wasting time
A* Graph Search, or simply Graph Search, removes this limitation by adding this rule: do not expand
the same node more than once.
Solution. We solve this question pretty much the same
Question. Use graph searches to find way we solved last question, but in this case, we keep a
paths from S to G in the following graph. track of nodes explored so that we don’t re-explore
them.
f= 0+7-7

f= 2+5-7

f= 3+4+3-7
f= 2+1+4-7

f= 3+2+2-7
f= 3+1+3-7

f= 4+3 -7

Path: S -> D -> B -> C -> E -> G


Knowledge Representation in AI
Knowledge Representation in AI describes the representation of knowledge.
Basically, it is a study of how the beliefs, intentions, and judgments of an intelligent
agent can be expressed suitably for automated reasoning. One of the primary purposes
of Knowledge Representation includes modelling intelligent behaviour for an agent.
Artificial Intelligent Systems usually consist of various components to display their
intelligent behaviour. Some of these components include:
• Perception
• Learning
• Knowledge Representation & Reasoning
• Planning
• Execution
References Style

• Type of resources : (Journal , Book, Conferences, Reliable website )

• Resources you can use :(Google Scholar - Google Books - Microsoft Academic -
WorldWideScience Science.gov - Wolfram Alpha - Refseek – BASE- Infotopia )

• How to cite website: Name of website, The title, Access Date, URL

You might also like