Báo cáo môn Trí tuệ nhân tạo cuối kì về khái niệm, kĩ thuật, ứng dụng của AI. Viết những khái niệm chung của môn học AI, giúp hiểu những thuật toán xoay quanh chủ đề này. Từ đó, hình thành tư duy lập trình trong AI, có kiến thức sâu rộng trong lĩnh vực này.
Trang 1HCMC UNIVERSITY OF TECHNOLOGY AND EDUCATION
FACULTY FOR HIGH-QUALITY TRAINING
Lecturer: Ph.D Nguyen Nhat Quang
Trang 2REPORT ARTIFICIAL INTELLIGENCE
GROUP 01
HCMC December 27, 2020 Last update: December 29, 2020
ARTIFICIAL INTELLIGENCE
Trang 3STUDENT LIST
Chau Kim Toa Member 18110056@student.hcmute.edu.vn 18110056 Mai Ho An Thuy Member 18110052@student.hcmute.edu.vn 18110052 Phan Ngoc Bao
Trang 4The present report is the outcome of our team’s works To meet the requirements
“Work in groups of 3 students each, write a report and demo the algorithmlearned.”, we have tried to watch lecture videos, read documentations on thehttps://quang-tran-ute.mn.co/ to understand and do it
Hope this report would illustrate our effort as well as knowledge in working as ateam and solving problem
Now that nothing is entirely perfect, this report might have some mistakes, and wewould appreciate all the evaluation and feedback
Since the invention of computers or machines, their capability to perform varioustasks went on growing exponentially Humans have developed the power ofcomputer systems in terms of their diverse working domains, their increasingspeed, and reducing size with respect to time
A branch of Computer Science named Artificial Intelligence pursues creating thecomputers or machines as intelligent as human beings
CHAPTER 01 Artificial Intelligence
1. What is Artificial Intelligence?
According to the father of Artificial Intelligence John McCarthy, it is “The scienceand engineering of making intelligent machines, especially intelligent computerprograms”
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
AI is accomplished by studying how human brain thinks, and how humans learn,decide, and work while trying to solve a problem, and then using the outcomes ofthis study as a basis of developing intelligent software and systems
Trang 54. What Contributes to AI?
Artificial intelligence is a science and technology based on disciplines such as
Computer Science, Biology, Psychology, Linguistics, Mathematics, andEngineering A major thrust of AI is in the development of computer functionsassociated with human intelligence, such as reasoning, learning, and problemsolving
Out of the following areas, one or multiple areas can contribute to build anintelligent system
Trang 65 Programming Without and With AI
6. What is AI Technique?
In the real world, the knowledge has some unwelcomed properties:
Its volume is huge, next to unimaginable
It is not well-organized or well-formatted
It keeps changing constantly
AI Technique is a manner to organize and use the knowledge efficiently in such away that:
It should be perceivable by the people who provide it
It should be easily modifiable to correct errors
It should be useful in many situations though it is incomplete or inaccurate
AI techniques elevate the speed of execution of the complex program it is equippedwith
Trang 7o Natural Language Processing
It is possible to interact with the computer that understands natural languagespoken
A spying aeroplane takes photographs which are used to figure out spatial
information or map of the areas
Doctors use clinical expert system to diagnose the patient
Police use computer software that can recognize the face of criminal withthe
stored portrait made by forensic artist
o Speech Recognition
Some intelligent systems are capable of hearing and comprehending the language
in terms of sentences and their meanings while a human talks to it It can handle
Trang 8different accents, slang words, noise in the background, change in human’s noisedue to cold, etc.
o Handwriting Recognition
The handwriting recognition software reads the text written on paper by a pen or
on screen by a stylus It can recognize the shapes of the letters and convert it intoeditable text
o Intelligent Robots
Robots are able to perform the tasks given by a human They have sensors to detectphysical data from the real world such as light, heat, temperature, movement,sound, bump, and pressure They have efficient processors, multiple sensors andhuge memory, to exhibit intelligence In addition, they are capable of learning fromtheir mistakes and they can adapt to the new environment
Trang 98 History of AI:
Trang 109 What is Intelligence?
The ability of a system to calculate, reason, perceive relationships and analogies,learn from experience, store and retrieve information from memory, solveproblems, comprehend complex ideas, use natural language fluently, classify,generalize, and adapt new situations
Trang 1110.INTELLIGENT AGENTS
A rational agent is one that does the right thing Obviously, this is better than doingthe wrong thing, but what does it mean? As a first approximation, we will say thatthe right action is the one that will cause the agent to be most successful Thatleaves us with the problem of deciding how and when to evaluate the agent'ssuccess
In summary, what is rational at any given time depends on four things:
• The performance measure that defines degree of success
• Everything that the agent has perceived so far We will call this completeperceptual history
the percept sequence
• What the agent knows about the environment
• The actions that the agent can perform
Agent Terminology
· Performance Measure of Agent − It is the criteria, which determines
how successful an agent is
· Behavior of Agent − It is the action that agent performs after any
given sequence of percepts
· Percept − It is agent’s perceptual inputs at a given instance.
· Percept Sequence − It is the history of all that an agent has perceived
Trang 1211.1 What is Ideal Rational Agent?
An ideal rational agent is the one, which is capable of doing expected actions tomaximize its performance measure, on the basis of −
Its percept sequence
Its built-in knowledge base
Rationality of an agent depends on the following :
· The performance measures, which determine the degree of success.
· Agent’s Percept Sequence till now.
· The agent’s prior knowledge about the environment.
· The actions that the agent can carry out.
A rational agent always performs right action, where the right action means theaction that causes the agent to be most successful in the given percept sequence.The problem the agent solves is characterized by Performance Measure,Environment, Actuators, and Sensors (PEAS)
The Structure of Intelligent Agents
Agent’s structure can be viewed as −
Agent = Architecture + Agent Program
Architecture = the machinery that an agent executes on
Agent Program = an implementation of an agent function
Simple Reflex Agents
They choose actions only based on the current percept
They are rational only if a correct decision is made only on the basis of current precept
Their environment is completely observable
Condition-Action Rule − It is a rule that maps a state (condition) to an action.
Model Based Reflex Agents
They use a model of the world to choose their actions They maintain an internalstate
Trang 13Internal State − It is a representation of unobserved aspects of current state
depending on percept history
Updating the state requires the information about −
How the world evolves
How the agent’s actions affect the world
· Goal Based Agents
They choose their actions in order to achieve goals Goal-based approach is moreflexible than reflex agent since the knowledge supporting a decision is explicitlymodeled, thereby allowing for modifications
Goal − It is the description of desirable situations.
· Utility Based Agents
They choose actions based on a preference (utility) for each state
Goals are inadequate when −
· There are conflicting goals, out of which only few can be achieved
· Goals have some uncertainty of being achieved and you need to weighlikelihood of success against the importance of a goal
The Nature of Environments
Some programs operate in the entirely artificial environment confined to
keyboard input, database, computer file systems and character output on a screen
In contrast, some software agents (software robots or softbots) exist in rich,
unlimited softbots domains The simulator has a very detailed, complex
environment The software agent needs to choose from a long array of actions in
real time A softbot designed to scan the online preferences of the customer and
show interesting items to the customer works in the real as well as an artificial
environment
The most famous artificial environment is the Turing Test environment, in
which one real and other artificial agents are tested on equal ground This is a verychallenging environment as it is highly difficult for a software agent to perform aswell as a human
Turing Test
The success of an intelligent behavior of a system can be measured with Turing
Trang 14Two persons and a machine to be evaluated participate in the test Out of the twopersons, one plays the role of the tester Each of them sits in different rooms Thetester is unaware of who is machine and who is a human He interrogates thequestions by typing and sending them to both intelligences, to which he receivestyped responses.
This test aims at fooling the tester If the tester fails to determine machine’sresponse from the human response, then the machine is said to be intelligent
10 Properties of Environment
The environment has multifold properties −
· Discrete / Continuous − If there are a limited number of distinct,
clearly defined, states of the environment, the environment is discrete (Forexample, chess); otherwise it is continuous (For example, driving)
· Observable / Partially Observable − If it is possible to determine the
complete state of the environment at each time point from the percepts it isobservable; otherwise it is only partially observable
· Static / Dynamic − If the environment does not change while an agent
is acting, then it is static; otherwise it is dynamic
· Single agent / Multiple agents − The environment may contain other
agents which may be of the same or different kind as that of the agent
· Accessible / Inaccessible − If the agent’s sensory apparatus can have
access to the complete state of the environment, then the environment isaccessible to that agent
· Deterministic / Non-deterministic − If the next state of the
environment is completely determined by the current state and the actions
of the agent, then the environment is deterministic; otherwise it is deterministic
non-· Episodic / Non-episodic − In an episodic environment, each episode
consists of the agent perceiving and then acting The quality of its actiondepends just on the episode itself Subsequent episodes do not depend onthe actions in the previous episodes Episodic environments are muchsimpler because the agent does not need to think ahead
· CHAPTER 02 Artificial Intelligence – Issues
AI is developing with such an incredible speed, sometimes it seemsmagical There is an opinion among researchers and developers that AIcould grow so immensely strong that it would be difficult for humans tocontrol
Trang 15Humans developed AI systems by introducing into them every possibleintelligence they could, for which the humans themselves now seemthreatened.
o Threat to Privacy
An AI program that recognizes speech and understands natural language istheoretically capable of understanding each conversation on e-mails andtelephones
o Threat to Human Dignity
AI systems have already started replacing the human beings in fewindustries It should not replace people in the sectors where they are holdingdignified positions which are pertaining to ethics such as nursing, surgeon,judge, police officer, etc
o Threat to SafetyThe self-improving AI systems can become so mighty than humans thatcould be very difficult to stop from achieving their goals, which may lead tounintended consequen
11 Ethics and Laws for AI
There are many opinions that the development of AI will bring great good tohumans such as eradicate poverty, eradicate racism But there are other opinionsthat AI will bring destruction to cease the end of humanity So how to make sure
AI can go in the direction it wants, not vice versa So to be sure, besides thedirection of algorithm development, it is necessary to follow some rules to ensurethe creation of good AI, not bad AI, which is ethics and AI laws
Trang 1613.1 Ethics:
Ethics has 3 main types:
+ Virtue ethics: a gesture of acting according to one's own virtue, humanity,helping people and saving people because it is obvious that you should do
+ Deontology: is the act of following the rules, based on right or wrong to handlesituations and helping people in distress when they think that is what they must do.+ Consequentialism: Actions based on results, effects received to make decisions,these effects may affect others
- Issue: definition of legal issue
- Rule: the laws that govern matters (food hygiene and unsafe,
information leaks and violations of traffic safety, )
- Application: consider the problem at any point or not (whether or not violated)
- Conclusion: Traffic violations
CHAPTER 03: SOLVING PROBLEMS BY SEARCHING
I.SEARCHING FOR SOLUTIONS:
We have seen how to define a problem, and how to recognize a solution.The remaining part — finding a solution — is done by a search through the statespace The idea is to maintain and extend a set of partial solution sequences In thissection, we show how to generate these sequences and how to keep track of themusing suitable data structures
Trang 17II.TWO MAIN STEPS OF SEARCH ALGORITHMS:
1.Choosing a Node:
Example:
To solve the route-finding problem from Bến Tre to TP.HCM, for example,
we start off with just the initial state, Bến Tre The first step is to test if this is agoal state Clearly it is not, but it is important to check so that we can solve trickproblems like "starting in Bến Tre, get to Bến Tre." Because this is not a goal state,
we need to consider some other states This is done by applying the operators tothe current state, thereby generating a new set of states The process is calledexpanding the state In this case, we get three new states, "An Giang," "TP.HCM,"and "Cần Thơ," because there is a direct one-step route from Bến Tre to these threecities If there were only one possibility, we would just take it and continue Butwhenever there are multiple possibilities, we must make a choice about which one
to consider further This is the essence of search — choosing one option andputting the others aside for later, in case the first choice does not lead to a solution.The choice of which state to expand first is determined by the search strategy
Trang 18It is helpful to think of the search process as building up a search tree that issuperimposed over the state space The root of the search tree is a search nodecorresponding to the initial state The leaf nodes of the tree correspond to statesthat do not have successors in the tree, either because they have not been expandedyet, or because they were expanded, but generated the empty set At each step, thesearch algorithm chooses one leaf node to expand
a The Initial State
b After Expanding Bến Tre
c After Expanding An Giang
Trang 19Conceptual algorithm #1 - TREE SEARCH
function GENERAL-SEARCH(problem, strategy) returns a solution, or
failure
initialize the search tree using the initial state of problem
loop do
if there are no candidates for expansion then return failure
choose a leaf node for expansion according to strategy
if the node contains a goal state then return the corresponding solution
else expand the node and add the resulting nodes to the search tree
end
Trang 20It is important to distinguish between the state space and the search tree Forthe route finding problem, there are only 11 states in the state space, one for eachcity But there are an infinite number of paths in this state space, so the search tree
Trang 21Data structures for search trees
There are many ways to represent nodes, but in this chapter, we will assume
a node is a data structure with five components:
• the state in the state space to which the node corresponds;
• the node in the search tree that generated this node (this is called the parentnode);
• the operator that was applied to generate the node;
• the number of nodes on the path from the root to this node (the depth of thenode);
• the path cost of the path from the initial state to the node
The node data type is thus:
datatype node
components: STATE, PARENT-NODE, OPERATOR, DEPTH,
PATH-COST
It is important to remember the distinction between nodes and states A node
is a bookkeeping data structure used to represent the search tree for a particularproblem instance as generated by a particular algorithm A state represents aconfiguration (or set of configurations) of the world
Thus, nodes have depths and parents, whereas states do not (Furthermore, it
is quite possible for two different nodes to contain the same state, if that state isgenerated via two different sequences of actions.) The EXPAND function isresponsible for calculating each of the components of the nodes it generates
We also need to represent the collection of nodes that are waiting to be
expanded — this collection is called the fringe or frontier The simplest
representation would be a set of nodes
The search strategy then would be a function that selects the next node to beexpanded from this set Although this is conceptually straightforward, it could becomputationally expensive, because the strategy function might have to look atevery element of the set to choose the best one Therefore, we will assume that the
collection of nodes is implemented as a queue The operations on a queue are as
follows:
• MAKE-QUEUE(Elements) creates a queue with the given elements
• EMPTY?(Queue) returns true only if there are no more elements in thequeue
• REMOVE-FRONT(Queue) removes the element at the front of the queueand returns it
Trang 22• QUEUlNG-FN(Elements,Queue) inserts a set of elements into the queue.Different varieties of the queuing function produce different varieties of the searchalgorithm.
With these definitions, we can write a more formal version of the generalsearch algorithm
function GENERAL-SEARCH(problem, QUEUING-FN) returns a
III DEVELOPING SEARCH ALGORITHMS
The majority of work in the area of search has gone into finding theright search strategy for a problem In our study of the field we will evaluate
strategies in terms of four criteria:
• Completeness: is the strategy guaranteed to find a solution when there is
one?
• Time complexity: how long does it take to find a solution?
• Space complexity: how much memory does it need to perform the search?
• Optimality: does the strategy find the highest-quality solution when there
are several different solutions?
1.Two types of search algorithms
1.1. Uninformed search
The term means that they have no information about the number ofsteps or the path cost from the current state to the goal — all they can do isdistinguish a goal state from a non goal state Uninformed search is also
sometimes called blind search.
Trang 231.2 Informed search
Consider again the route-finding problem From the initial state inBến Tre, there are three actions leading to three new states: An Giang,TP.HCM, and Cần Thơ An uninformed search has no preference amongthese, but a more clever agent might notice that the goal, An Giang, issoutheast of Bến Tre, and that only TP.HCM is in that direction, so it islikely to be the best choice
Strategies that know whether one non-goal state is better than another
are called informed search strategies or heuristic search strategies
2.Breadth-first search
2.1 Definition:
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 nodeare expanded next, and then their successors, and so on In general, all thenodes at depth d in the search tree are expanded before the nodes at depth d+ 1 Breadth-first search can be implemented by calling the GENERAL-SEARCH algorithm with a queuing function that puts the newly generatedstates at the end of the queue, after all the previously generated states:
function BREADTH-FIRST-SEARCH(problem) returns a solution or failure return GENERAL-SEARCH( problem,ENQUEUE- AT-END)
Breadth-first search is a very systematic strategy because it considersall the paths of length 1 first, then all those of length 2, and so on
Breadth-first search is a simple strategy in which:
• the root node is expanded first
• then all the successors of the root node are expanded next
• then their successors, and so on
Trang 24• CHILD-NODE(problem, parent, action): The CHILD-NODE functiontakes a parent node and an action and returns the resulting child node
B Breadth-first search algorithm
1 Let vertex start in Frontier
2 If Frontier is empty, search fails, finish searching
3 Take out the top vertex in Frontier and call it O Put O in Explored
4 If O is the target, the search is successful and ends the search
5 Find all sub vertices of O that are not in Frontier and Explored to the Frontierend
6 Go back to step 2
Measuring algorithm's performance
Complete: (if b is finite), the shallowest solution is returned
Time: 1+b+b^2+b^3+… +b^d = O
Space: O (bd) (keeps every node in memory)
Optimal: if step costs are all identical or path cost is a nondecreasingfunction of the depth of the node
Space: is the bigger problem (more than time)
Time: requirement is still a major factor
How Bad is BFS?
With b = 10; 1 million nodes/sec; 1k bytes/node
- It takes 13 days for the solution to a problem with search depth 12, nodes 10^12
- 350 years at depth 16
Trang 25When certain conditions are met, the first solution that is found is guaranteed
to be the cheapest solution, because if there were a cheaper path that was asolution, it would have been expanded earlier, and thus would have been foundfirst
2 Uniform-cost search algorithm
Trang 261 Let vertex start on Frontier
2 If Frontier is empty, search fails, end the search
3 Take out the top of the head in Frontier and call it O Put O in Explored
4 If O is the target, the search is successful and ends the search
5 Find all the sub vertices of O that are not in Frontier and Explored to thebeginning of Open
6 Go back to step 2
For a state space with branching factor b and maximum depth m, depth-firstsearch requires storage of only bm nodes, in contrast to the b^d that would berequired by breadth-first search in the case where the shallowest goal is at depth d
Measuring algorithm's performance
Complete: if step cost ≥ ε
Time: O (b ceiling(C*/ ε) ) where C * is the cost of the optimalsolution
# of nodes with g ≤ cost of optimal solution
Space: O (b ceiling(C*/ ε))
# of nodes with g ≤ cost of optimal solution
Optimal: yes, nodes expanded in increasing order of g(n)
Uniform-Cost Search is Optimal:
Uniform-cost search expands nodes in order of their optimal path cost
Hence, the first goal node selected for expansion must be the optimalsolution
D Depth-first search (DFS)
Trang 27Depth-first search always expands one of the nodes at the deepest level ofthe tree Only when the search hits a dead end (a non goal node with no expansion)does the search go back and expand nodes at shallower levels This strategy can beimplemented by GENERAL-SEARCH with a queuing function that always putsthe newly generated states at the front of the queue Because the expanded nodewas the deepest, its successors will be even deeper and are therefore now thedeepest
2 Depth-first search (DFS) algorithm
1 Let vertex start on Frontier
2 If Frontier is empty, search fails, end the search
3 Take out the top of the head in Frontier and call it O Put O in Explored
4 If O is the target, the search is successful and ends the search
5 Find all the sub vertices of O that are not in Frontier and Explored to thebeginning of Open
6 Go back to step 2
Properties of DFS
- Properties of DFS depend strongly on whether the graph-search or tree-search
version is used
Measuring algorithm's performance
Analysis of DFS + Tree Search:
Complete: No: fails in infinite-depth spaces, or spaces with loops
Modify to avoid repeated states along path
-> complete in finite spaces
Trang 28 Time: O (bm): terrible if m is much larger than d but if solutions are
dense, may be much faster than breadth-first
Space: O (bm), i.e., linear space!
Optimal: No
Analysis of DFS + Graph Search
Complete: No: also fails in infinite-depth spaces
Yes: for finite state spaces
Time: O (bm): terrible if m is much larger than d but if solutions aredense, may be much faster than breadth-first
Space: Not linear any more, because of explored set
Optimal: No
Compare between BFS vs DFS
BFS (Breadth First Search) DFS (Depth First Search)
1 Uses Queue data structure for
finding the shortest path
Uses Stack data structure
2 can be used to find the single source
shortest path in an unweighted
graph, because in BFS, we reach a
vertex with a minimum number of
edges from a source vertex
might traverse through more edges
to reach a destination vertex from a
source
3 more suitable for searching vertices
which are closer to the given source
more suitable when there aresolutions away from source
4 considers all neighbors first and
therefore not suitable for decision
making trees used in games or
puzzles
more suitable for game or puzzleproblems We make a decision, thenexplore all paths through thisdecision And if this decision leads
to a win situation, we stop
5 The Time complexity of BFS is
O(V + E) when Adjacency List is
used and O(V^2) when Adjacency
Matrix is used, where V stands for
vertices and E stands for edges
The Time complexity of DFS is alsoO(V + E) when Adjacency List isused and O(V^2) when AdjacencyMatrix is used, where V stands forvertices and E stands for edges
E Depth-limited search
1 Definition:
Trang 29Depth-limited search avoids the pitfalls of depth-first search by imposing acutoff on the maximum depth of a path This cutoff can be implemented with aspecial depth-limited search algorithm, or by using the general search algorithmwith operators that keep track of the depth
For example, on the map of Romania, there are 20 cities, so we know that ifthere is a solution, then it must be of length 19 at the longest We can implementthe depth cutoff using operators of the form "If you are in city A and have travelled
a path of less than 19 steps, then generate a new state in city B with a path lengththat is one greater." With this new operator set, we are guaranteed to find thesolution if it exists, but we are still not guaranteed to find the shortest solution first:depth-limited search is complete but not optimal If we choose a depth limit that istoo small, then depth-limited search is not even complete The time and spacecomplexity of depth-limited search is similar to depth-first search It takes O(b')time and O(bl) space, where is the depth limit
2 Depth-limited search algorithm (TREE-SEARCH version)
Disadvantages of Depth Limited Search:
The depth limit is compulsory for this algorithm to execute.
The goal node may not exist in the depth limit set earlier which will push
the user to iterate further adding execution time
The goal node will not be found if it does not exist in the desired limit.
F Iterative deepening search
1 Definition
Iterative deepening search is a strategy that sidesteps the issue of choosingthe best depth limit by trying all possible depth limits: first depth 0, then depth 1,
Trang 30The iterative deepening algorithm is a combination of DFS and BFSalgorithms This search algorithm finds out the best depth limit and does it bygradually increasing the limit until a goal is found.
This algorithm performs depth-first search up to a certain "depth limit", and
it keeps increasing the depth limit after each iteration until the goal node is found
This Search algorithm combines the benefits of Breadth-first search's fastsearch and depth-first search's memory efficiency
The iterative search algorithm is useful uninformed search when searchspace is large, and depth of goal node is unknown
2 Iterative deepening search algorithm
3 Advantages and disadvantages
Advantages: It combines the benefits of BFS and DFS search algorithm in terms
of fast search and memory efficiency
Disadvantages: The main drawback of IDDFS is that it repeats all the work of the
previous phase
4 Comparing uninformed search strategies
Completeness: This algorithm is complete if the branching factor is finite.
Time Complexity: Let's suppose b is the branching factor and depth is d then the
worst-case time complexity is O(bd)
Space Complexity: The space complexity of IDDFS will be O(bd).
Optimal: IDDFS algorithm is optimal if path cost is a non- decreasing function of
the depth of the node
Chapter 04: Informed Search Methods
In which we see how information about the state space can prevent
Trang 31Chapter 3 showed that uninformed search strategies can find solutions toproblems by systematically generating new states and testing them against thegoal Unfortunately, these strategies are incredibly inefficient in most cases Thischapter shows how an informed search strategy — one that uses problem-specificknowledge — can find solutions more efficiently It also shows how optimizationproblems can be solved.
I Best-First Search
1 Definition
The Breadth First Search (BFS) is an algorithm for traversing or searchingtree or graph data structures It explores all the nodes at the present depth beforemoving on to the nodes at the next depth level
Idea: use an evaluation function f(n) for each node
f(n) provides an estimate for the total cost
→ Expand the node n with smallest f(n)
2 Uninformed vs informed strategy
The Uninformed Search (or Blind Search) as the name suggests issearching without “information” about the goal node
The Informed Search (or Heuristic Search) is searching with
“information” about the goal node
It uses knowledge for the searching
It is highly efficient It is mandatory and efficient
Cost is low Cost is high
It consumes less time It consumes moderate time
It provides the direction regarding No suggestion is given regarding the
Trang 32the solution solution in it.
It is less lengthy while
implementation
It is more lengthy while implemented
Greedy Search, A* Search, Graph
Search
Depth First Search, Breadth First Search
3 Algorithm
Pick a node and enqueue all its adjacent nodes into a queue
Dequeue a node from the queue, mark it as visited and enqueue all itsadjacent nodes into a queue
Repeat this process until the queue is empty or you meet a goal
The program can be stuck in an infinite loop if a node is revisited and wasnot marked as visited before Hence, prevent exploring nodes that are visited bymarking them as visited
f(n)= g(n)
Heuristic function h(n) estimates the cost of the path from node n to the goal.For example: the distance calculated by the flight path from node n to thedestination
Trang 33II Best-first search is NOT optimal
Best first search is not optimal In fact, even if your heuristic function isexactly right, best first search is never guaranteed to be optimal Here is a counterexample Consider the following graph:
Trang 34The green numbers are the actual costs and the red numbers are the exact heuristicfunction Let's try to find a path from node S to node G Best first search wouldgive you S->A->G following the heuristic function However, if you look at thegraph closer, you would see that the path S->B->C->G has lower cost of 5 instead
of 6 Thus, this is an example of best first search performing suboptimal underperfect heuristic function
III A* Search Algorithm
1 Definition:
A* search is the most commonly known form of best-first search It usesheuristic function h(n), and cost to reach the node n from the start state g(n) It hascombined features of UCS and greedy best-first search, by which it solve theproblem efficiently A* search algorithm finds the shortest path through the searchspace using the heuristic function This search algorithm expands less search treeand provides optimal result faster A* algorithm is similar to UCS except that ituses g(n)+h(n) instead of g(n)
In A* search algorithm, we use search heuristic as well as the cost to reachthe node Hence we can combine both costs as following, and this sum is called as
a fitness number.