Agenda
ď§ Search Algorithmsin AI
ď§ Search Algorithm Terminologies
ď§ Properties of Search Algorithms
ď§ Types of Search Algorithms
ď§ Search Algorithm over Graph
FCI-Minia University 2
3.
Search Algorithms inAI
3
ď Problem-Solving Agents:
ď§ ArtificialIntelligence is the study of buildingagents that act rationally.
ď§ Rational agents or Problem-solving agents in AI mostly used these search
strategies or algorithms to solve a specific problem and provide the best result.
Problem-solving agents are the goal-based agents and use atomic representation.
ď§ Search Algorithms are one of the most important areas of Artificial
Intelligence.
ď§ Search Algorithms are universal problem-solving methods.
4.
Agenda
ď§ Search Algorithmsin AI
ď§Search Algorithm Terminologies
ď§ Properties of Search Algorithms
ď§ Types of search algorithms
ď§ Search over Graph
FCI-Minia University 4
5.
5
Search Algorithm Terminologies
ď§Search: Searching is a step by step procedure to solve a search-problem in a given search space.
ď§ A Search Problem can have three main factors:
ďź Search Space: Search space represents a set of possible solutions, which a system may have.
ďź Start State: It is a state from where agent begins the search.
ďź Goal test: It is a function which observe the current state and returns whether the goal state is
achieved or not.
ď§ Search tree: A tree representation of search problem is called Search tree.
ďź The root of the search tree is the root node which is corresponding to the initial state.
ď§ Actions: It gives the description of all the available actions to the agent.
ď§ Transition model: A description of what each action do, can be represented as a transition model.
ď§ Path Cost: It is a function which assigns a numeric cost to each path.
ď§ Solution: It is an action sequence (Path) which leads from the start node to the goal node.
ď§ Optimal Solution: If a solution has the lowest cost among all solutions.
6.
Agenda
ď§ Search Algorithmsin AI
ď§ Search Algorithm Terminologies
ď§Properties of Search Algorithms
ď§ Types of Search Algorithms
ď§ Search Algorithm over Graph
FCI-Minia University 6
7.
Properties of SearchAlgorithms
ď There are the Four essential properties of search algorithms to compare the efficiency
of these algorithms:
ď§ Completeness: A search algorithm is said to be complete if it guarantees to return a
solution if at least any solution exists for any random input.
ď§ Optimality: If a solution found for an algorithm is guaranteed to be the best solution
(lowest path cost) among all other solutions, then such a solution for is said to be an
optimal solution.
ď§ Time Complexity: Time complexity is a measure of time for an algorithm to complete its
task.
ď§ Space Complexity: It is the maximum storage space required at any point during the
search, as the complexity of the problem. 7
8.
Agenda
ď§ Search Algorithmsin AI
ď§ Search Algorithm Terminologies
ď§ Properties of Search Algorithms
ď§Types of Search Algorithms
ď§ Search Algorithm over Graph
FCI-Minia University 8
9.
9
Types of searchalgorithms
ď Based on the search problems we can classify the search algorithms into:
1. Uninformed Search (Blind Search)Algorithms.
2. Informed Search (Heuristic Search) Algorithms.
10.
10
ďUninformed/BlindSearch:
ď§ Uninformed Searchdoes not contain any domain knowledge such as closeness, the location of the
goal.
ď§ Uninformed Search operates in a brute-force way as it only includes information about how to
traverse the tree and how to identify leaf and goal nodes.
ď§ Uninformed Search applies a way in which search tree is searched without any information about
the search space like initial state operators and test for the goal, so it is also called blind search.
ď§ Uninformed Search examines each node of the tree until it achieves the goal node.
ď§ It can be divided into 5 main types:
Breadth-first search Iterative deepening depth-first search
Uniform costsearch BidirectionalSearch
Depth-first search
Types of Search Algorithms
11.
FCI-Minia University 11
ďInformedSearch
ď§ Informed Search Algorithms use domain knowledge.
ď§ In an informed search, problem information is available which can guide the search.
ď§ Informed Search strategy can find a solution more efficiently than an uninformed search
strategy.
ď§ Informed Search is also called a Heuristic Search.
ď§ A heuristic is a way which might not always be guaranteed for best solutions but
guaranteed to find a good solution in reasonable time.
ď§ Informed Search can solve much complex problem which could not be solved in another
way.
ď§ An example of informed search algorithms .
Greedy Search A* Search
Types of Search Algorithms
12.
Agenda
ď§ Search Algorithmsin AI
ď§ Search Algorithm Terminologies
ď§ Properties of Search Algorithms
ď§ Types of Search Algorithms
ď§Search Algorithm over Graph
FCI-Minia University 12
13.
Search over Graph
13
ďPythonrepresentations of graph components:
ď§ Graph nodes (Vertices): A "graph" in mathematics and computer science consists of "nodes",
also known as "vertices".
ď§ Nodes may or may not be connected with one another.
ďź the node "a" is connected with the node "c",
ďź but "a" is not connected with "b".
ď§ Graph edge: The connecting line between two nodes is called an edge.
ď§ Undirected graph: If the edges between the nodes are undirected, the graph is called an
undirected graph.
ď§ Directed graph: If an edge is directed from one vertex (node) to another, a graph is called a
directed graph. An directed edge is called an arc.
14.
Usages of Graphin AI
FCI-Minia University 14
ď§ Though graphs may look very theoretical, many practical problems can be represented by
graphs.
ď§ They are often used to model problems or situations in physics, biology, psychology and
above all in computer science using graph.
ď§ In computer science, graphs are used to represent networks of communication, data
organization, computational devices, the flow of computation.
ď§ They are used to represent the data organization, like the file system of an operating
system, or communication networks. The link structure of websites can be seen as a graph
as well.
15.
Graph Implementation
FCI-Minia University15
ď Graph can be implemented in python using data type (dictionary)
ď§ The keys of the dictionaryare the nodes of our graph.
ď§ The values of the dictionary are lists with the nodes, which are connecting by an
edge.
graph = { "a" : ["c"],
"b" : ["c", "e"],
"c" : ["a", "b", "d", "e"],
"d" : ["c"],
"e" : ["c", "b"],
"f" : [] }
16.
16
ď Declarationof graphClass
ď Declarationof Functionsthat generating a list of graph nodes and edges
FCI-Minia University 25
Assignment
1.Try to update the Method of find_path() to be find_all_paths() finds all the paths
between a start node to an end node.