SlideShare una empresa de Scribd logo
1 de 71
CSE 412: Artificial IntelligenceCSE 412: Artificial Intelligence
Fall 2018Fall 2018
Topic – 3: Solving ProblemsTopic – 3: Solving Problems
by Searchingby Searching
Tajim Md. Niamat Ullah Akhund
Lecturer
Department of Computer Science and Engineering
Daffodil International University
Email: tajim.cse@diu.edu.bd
Topic ContentsTopic Contents
Problem Solving AgentsProblem Solving Agents
Problem Formulation and Search SpacesProblem Formulation and Search Spaces
Example ProblemsExample Problems
Tree Search AlgorithmTree Search Algorithm
 Breadth-First SearchBreadth-First Search
 Uniform-Cost SearchUniform-Cost Search
 Depth-First SearchDepth-First Search
 Depth Limited SearchDepth Limited Search
 Iteratively Deepening SearchIteratively Deepening Search
 Bidirectional SearchBidirectional Search 2
IntroductionIntroduction
In this topic, we see how an agent can find
a sequence of actions that achieves its
goals, when no single action will do.
3
Majidur RahmanMajidur Rahman
Problem-SolvingProblem-Solving AgentAgent
Four general steps in problem solving:
• Goal formulation
– What are the successful world states
• Problem formulation
– What actions and states to consider given the goal
• Search
– Examine different possible sequences of actions that
lead to states of known value and then choose the
best sequence
• Execute
– Perform actions on the basis of the solution
4
Majidur RahmanMajidur Rahman
Example: RomaniaExample: Romania
5
Majidur RahmanMajidur Rahman
Example: RomaniaExample: Romania
On holiday the agent is in Romania visiting in
Arad. Flight leaves tomorrow from Bucharest.
• Formulate goal
– Be in Bucharest
• Formulate problem
– States: various cities
– Actions: drive between cities
• Find solution
– Sequence of cities; e.g. Arad, Sibiu, Fagaras,
Bucharest,…
6
Majidur RahmanMajidur Rahman
Problem TypeProblem Type
Given how we have defined the problem:
• Environment is fully observable
• Environment is deterministic
• Environment is sequential
• Environment is static
• Environment is discrete
• Environment is single-agent
7
Majidur RahmanMajidur Rahman
Problem FormulationProblem Formulation
A problem is defined by:
 An initial state, e.g. In(Arad)
 A successor function S(x) = set of action-state pairs
• S(In(Arad)) = {(Go(Sibiu), In(Sibiu)), (Go(Zerind), In(Zerind)),
(Go(Timisoara), In(Timisoara))}
• initial state + successor function = state space
 Goal test
• Explicit, e.g. x=‘In(Bucharest)’
 Path cost (assume additive)
• e.g. sum of distances, number of actions executed, …
A solution is a sequence of actions from initial to
goal state
 the optimal solution has the lowest path cost
8
Majidur RahmanMajidur Rahman
Vacuum WorldVacuum World
State space of the vacuum world
9
Majidur RahmanMajidur Rahman
Example ProblemsExample Problems
The problem-solving approach has been applied to
a vast array of task environments.
Some of the best known are listed here,
distinguishing between toy and real-world problems.
A toy problem is intended to illustrate or exercise
various problem-solving methods.
It is usable by different researchers to compare the
performance of algorithms.
 A real-world problem is one whose solutions
people actually care about.
We will mainly focus on toy problems in this topic.
10
Majidur RahmanMajidur Rahman
Toy Problems: 8-PuzzleToy Problems: 8-Puzzle
 States: location of each tile plus blank
 Initial state: Any state can be initial
 Actions: Move blank {Left, Right, Up, Down}
 Goal test: Check whether goal configuration is reached
 Path cost: Number of actions to reach goal
11
Majidur RahmanMajidur Rahman
Toy Problems: 8-QueensToy Problems: 8-Queens
Place eight queens on a chessboard such that
no queen attacks any other.
Two kinds of problem formulation:
• Complete-state formulation
• Incremental formulation
12
Majidur RahmanMajidur Rahman
Toy Problems: 8-QueensToy Problems: 8-Queens
Complete-state formulation
• States: Any arrangement of 0 to 8 queens on the board
• Initial state: No queens
• Actions: Add queen to any empty square
• Goal test: 8 queens on board and none attacked
• Path cost: N/A
64.63.62…..57 ≈ 3 x 1014
possible sequences to investigate
13Tajim Md. Niamat Ullah AkhundTajim Md. Niamat Ullah Akhund
Incremental formulation
• States: n (0 to 8) queens on the board, one per column in
the n leftmost columns with no queen attacking any other
• Actions: Add queen in leftmost empty column such that
the queen is not attacking any other queen
• 2057 possible sequences to investigate; solutions are
easy to find
But with 100 queens the problem is much harder
14
Toy Problems: 8-QueensToy Problems: 8-Queens
Real-World ProblemsReal-World Problems
 Route-finding problems
 Touring problems
 Traveling Salesman problem
 VLSI layout problem
 Robot navigation
 Automatic assembly sequencing
 Internet searching
15
Majidur RahmanMajidur Rahman
Basic Search AlgorithmsBasic Search Algorithms
How do we find the solutions of previous
problems?
• Search the state space
– State space can be represented by a search tree
– Root of the tree is the initial state
– Children generated through successor function
• In general we may have a search graph rather
than tree (same state can be reached through
multiple paths)
16
Majidur RahmanMajidur Rahman
Simple Tree Search ExampleSimple Tree Search Example
17
Majidur RahmanMajidur Rahman
Simple Tree Search ExampleSimple Tree Search Example
18
Majidur RahmanMajidur Rahman
Simple Tree Search ExampleSimple Tree Search Example
19
Majidur RahmanMajidur Rahman
State Space vs. Search TreeState Space vs. Search Tree
• A state corresponds
to a configuration of
the world
• A node is a data
structure in a search
tree
– e.g. node = <state,
parent-node, action,
path-cost, depth>
20
Majidur RahmanMajidur Rahman
Search StrategiesSearch Strategies
 A search strategy is defined by picking the order of node
expansion
 Problem-solving performance is measured in four ways:
• Completeness: Is a solution found if one exists?
• Optimality: Does the strategy find the optimal solution?
• Time Complexity: How long does it take to find a solution?
• Space Complexity: How much memory is needed to perform
the search?
 Time and space complexity are measured in terms of
problem difficulty defined by:
• b - branching factor of the search tree
• d - depth of the shallowest goal node
• m - maximum length of any path in the state space
21
Majidur RahmanMajidur Rahman
Uninformed Search StrategiesUninformed Search Strategies
• Uninformed search (or blind search)
– Strategies have no additional information about states beyond
that provided in the problem definition
• Informed (or heuristic) search
– Search strategies know whether one state is more promising
than another
• Uninformed strategies (defined by order in which nodes
are expanded):
– Breadth-first search
– Uniform-cost search
– Depth-first search
– Depth-limited search
– Iterative deepening search
– Bidirectional search
22
Majidur RahmanMajidur Rahman
Breadth-First SearchBreadth-First Search
• Expand shallowest unexpanded node
• 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: fringe/frontier is a FIFO queue
23
Breadth-First SearchBreadth-First Search
24
Majidur RahmanMajidur Rahman
Breadth-First SearchBreadth-First Search
25
Majidur RahmanMajidur Rahman
Breadth-First SearchBreadth-First Search
26
Majidur RahmanMajidur Rahman
Breadth-First SearchBreadth-First Search
• Completeness: is a solution always found
if one exists?
– YES
• If shallowest goal node is at some finite depth d
• If branching factor b is finite
• BF search is optimal if the path cost is a
non-decreasing function of the depth of
the node
27
Majidur RahmanMajidur Rahman
Breadth-First SearchBreadth-First Search
• Time complexity: Assume a state space where
every state has b successors
– Assume solution is at depth d
– Worst case: expand all but the last node at depth d
– Total number of nodes generated:
– b + b2
+ b3
+ ...+ bd
+ (bd +1
− b) = O(bd +1
)
• Space complexity: every node generated must
remain in memory, so same as time complexity
28
Majidur RahmanMajidur Rahman
Breadth-First SearchBreadth-First Search
• Memory requirements are a bigger problem than
execution time.
29
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
• Extension of BF-search:
– Expand node with lowest path cost
• Implementation: fringe = queue ordered by
path cost
• UC-search is the same as BF-search
when all step costs are equal
30
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
 Let us consider the following search tree, where A
and G are the initial and goal node, respectively.
31
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
32
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
33
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
34
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
35
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
36
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
 Let us consider the another search tree, where A
and G are the initial and goal node, respectively.
37
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
38
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
39
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
40
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
41
Majidur RahmanMajidur Rahman
Uniform-Cost SearchUniform-Cost Search
• Completeness:
– YES, if step-cost > some small positive constant ε
• Optimality:
– nodes expanded in order of increasing path cost
– YES, if complete
• Time and space complexity:
– Uniform-cost search is guided by path costs rather than
depths, so its complexity cannot easily be characterized
in terms of b and d.
– Instead, assume C* is the cost of the optimal solution
– Assume that every action costs at least ε
– Worst-case: O(bC*/ε
)
42
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
43
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
44
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
45
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
46
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
47
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
48
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
49
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
50
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
51
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
52
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
53
Majidur RahmanMajidur Rahman
Depth-First SearchDepth-First Search
• Expand deepest unexpanded node
• Implementation: fringe is a LIFO queue (= stack)
54
Majidur RahmanMajidur Rahman
DF-Search: EvaluationDF-Search: Evaluation
• Completeness:
– Is a solution always found if one exists?
– No (unless search space is finite and no loops
are possible)
• Optimality:
– Is the least-cost solution always found?
– No
55
Majidur RahmanMajidur Rahman
DF-Search: EvaluationDF-Search: Evaluation
• Time complexity: O(bm
)
• In general, time is terrible if m (maximal
depth) is much larger than d (depth of
shallowest solution)
– But if there exist many solutions then faster
than BF-search
• Space complexity: O(bm)
– Backtracking search uses even less memory
(one successor instead of all b)
56
Majidur RahmanMajidur Rahman
Depth-Limited SearchDepth-Limited Search
• DF-search with depth limit l
– i.e. nodes at depth l have no successors
– Problem knowledge can be used
• Solves the infinite-path problem
• If l < d then incompleteness results
• Time complexity: O(bl
)
• Space complexity: O(bl)
57
Majidur RahmanMajidur Rahman
Depth-Limited Search withDepth-Limited Search with ll = 2= 2
58
Majidur RahmanMajidur Rahman
Depth-Limited Search withDepth-Limited Search with ll = 2= 2
59
Majidur RahmanMajidur Rahman
Depth-Limited Search withDepth-Limited Search with ll = 2= 2
60
Majidur RahmanMajidur Rahman
Depth-Limited Search withDepth-Limited Search with ll = 2= 2
61
Majidur RahmanMajidur Rahman
Iterative Deepening SearchIterative Deepening Search
• A general strategy to find best depth limit l
– Goal is found at depth d, the depth of the
shallowest goal-node
– Often used in combination with DF-search
• Combines benefits of DF- and BF-search
62
Majidur RahmanMajidur Rahman
ID-Search: ExampleID-Search: Example
63
Majidur RahmanMajidur Rahman
ID-Search: ExampleID-Search: Example
64
Majidur RahmanMajidur Rahman
ID-Search: ExampleID-Search: Example
65Majidur RahmanMajidur Rahman
ID-Search: ExampleID-Search: Example
66Majidur RahmanMajidur Rahman
Bidirectional SearchBidirectional Search
Two simultaneous searches run from start and goal.
– Motivation:
– One forward from the initial state
– Other backward from goal
– Stops when the two searches meet in the middle
• Check whether the node belongs to the other fringe before
expansion
67
bd/2
+bd/2
≠bd
Bidirectional SearchBidirectional Search
Time complexity: O(bd/2
)
Space complexity: O(bd/2
)
– This space complexity is the most significant
weakness of bidirectional search.
Completeness and Optimality: Yes
– If step costs are uniform
– If both searches are breadth-first search.
68Majidur RahmanMajidur Rahman
The reduction in time complexity makes
bidirectional search attractive, but how do we
search backwards?
The predecessor of each node should be
efficiently computable.
– When actions are easily reversible.
Bidirectional SearchBidirectional Search
Majidur RahmanMajidur Rahman
Summary of AlgorithmsSummary of Algorithms
70
Majidur RahmanMajidur Rahman
********** ********** If You Need Me ********** **********
Mail: tajim.cse@diu.edu.bd
Website: https://www.tajimiitju.blogspot.com
ORCID: https://orcid.org/0000-0002-2834-1507
LinkedIn: https://www.linkedin.com/in/tajimiitju
ResearchGate: https://www.researchgate.net/profile/Tajim_Md_Niamat_Ullah_Akhund
YouTube: https://www.youtube.com/tajimiitju?sub_confirmation=1
SlideShare: https://www.slideshare.net/TajimMdNiamatUllahAk
Facebook: https://www.facebook.com/tajim.mohammad
GitHub: https://github.com/tajimiitju
Google+: https://plus.google.com/+tajimiitju
Gmail: tajim.mohammad.3@gmail.com
Twitter: https://twitter.com/Tajim53
Thank you
Tajim Md. Niamat Ullah AkhundTajim Md. Niamat Ullah Akhund

Más contenido relacionado

La actualidad más candente

Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic Agents
Nuruzzaman Milon
 

La actualidad más candente (20)

AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
State Space Search in ai
State Space Search in aiState Space Search in ai
State Space Search in ai
 
State space search
State space searchState space search
State space search
 
Artificial Intelligence -- Search Algorithms
Artificial Intelligence-- Search Algorithms Artificial Intelligence-- Search Algorithms
Artificial Intelligence -- Search Algorithms
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
Informed search (heuristics)
Informed search (heuristics)Informed search (heuristics)
Informed search (heuristics)
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
Hill climbing algorithm
Hill climbing algorithmHill climbing algorithm
Hill climbing algorithm
 
AI_Session 10 Local search in continious space.pptx
AI_Session 10 Local search in continious space.pptxAI_Session 10 Local search in continious space.pptx
AI_Session 10 Local search in continious space.pptx
 
Problem Solving
Problem Solving Problem Solving
Problem Solving
 
Informed search
Informed searchInformed search
Informed search
 
Artificial intelligence- Logic Agents
Artificial intelligence- Logic AgentsArtificial intelligence- Logic Agents
Artificial intelligence- Logic Agents
 
Planning
PlanningPlanning
Planning
 
I.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AII.BEST FIRST SEARCH IN AI
I.BEST FIRST SEARCH IN AI
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
A* Search Algorithm
A* Search AlgorithmA* Search Algorithm
A* Search Algorithm
 
search strategies in artificial intelligence
search strategies in artificial intelligencesearch strategies in artificial intelligence
search strategies in artificial intelligence
 

Similar a AI Lecture 3 (solving problems by searching)

Session 4 Agent types in Internet of things
Session 4 Agent types in Internet of thingsSession 4 Agent types in Internet of things
Session 4 Agent types in Internet of things
SKCTCSE
 
02 problem solving_search_control
02 problem solving_search_control02 problem solving_search_control
02 problem solving_search_control
Praveen Kumar
 

Similar a AI Lecture 3 (solving problems by searching) (20)

Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Lecture 3 Problem Solving.pptx
Lecture 3 Problem Solving.pptxLecture 3 Problem Solving.pptx
Lecture 3 Problem Solving.pptx
 
AI: AI & problem solving
AI: AI & problem solvingAI: AI & problem solving
AI: AI & problem solving
 
chapter3part1.ppt
chapter3part1.pptchapter3part1.ppt
chapter3part1.ppt
 
Searching
SearchingSearching
Searching
 
Session 6 Search Introduction in Internet of things
Session 6 Search Introduction in Internet of thingsSession 6 Search Introduction in Internet of things
Session 6 Search Introduction in Internet of things
 
Session 4 Agent types in Internet of things
Session 4 Agent types in Internet of thingsSession 4 Agent types in Internet of things
Session 4 Agent types in Internet of things
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
AI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptxAI_03_Solving Problems by Searching.pptx
AI_03_Solving Problems by Searching.pptx
 
Lecture 3 problem solving
Lecture 3   problem solvingLecture 3   problem solving
Lecture 3 problem solving
 
Search 1
Search 1Search 1
Search 1
 
Jarrar: Un-informed Search
Jarrar: Un-informed SearchJarrar: Un-informed Search
Jarrar: Un-informed Search
 
Ai popular search algorithms
Ai   popular search algorithmsAi   popular search algorithms
Ai popular search algorithms
 
Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...Searching is the universal technique of problem solving in Artificial Intelli...
Searching is the universal technique of problem solving in Artificial Intelli...
 
Lecture 07 search techniques
Lecture 07 search techniquesLecture 07 search techniques
Lecture 07 search techniques
 
state-spaces29Sep06.ppt
state-spaces29Sep06.pptstate-spaces29Sep06.ppt
state-spaces29Sep06.ppt
 
Module_2_rks in Artificial intelligence in Expert System
Module_2_rks in Artificial intelligence in Expert SystemModule_2_rks in Artificial intelligence in Expert System
Module_2_rks in Artificial intelligence in Expert System
 
AI(Module1).pptx
AI(Module1).pptxAI(Module1).pptx
AI(Module1).pptx
 
Search problems in Artificial Intelligence
Search problems in Artificial IntelligenceSearch problems in Artificial Intelligence
Search problems in Artificial Intelligence
 
02 problem solving_search_control
02 problem solving_search_control02 problem solving_search_control
02 problem solving_search_control
 

Más de Tajim Md. Niamat Ullah Akhund

Más de Tajim Md. Niamat Ullah Akhund (20)

AI Lecture 7 (uncertainty)
AI Lecture 7 (uncertainty)AI Lecture 7 (uncertainty)
AI Lecture 7 (uncertainty)
 
AI Lecture 6 (logical agents)
AI Lecture 6 (logical agents)AI Lecture 6 (logical agents)
AI Lecture 6 (logical agents)
 
AI Lecture 5 (game playing)
AI Lecture 5 (game playing)AI Lecture 5 (game playing)
AI Lecture 5 (game playing)
 
AI Lecture 2 (intelligent agents)
AI Lecture 2 (intelligent agents)AI Lecture 2 (intelligent agents)
AI Lecture 2 (intelligent agents)
 
AI Lecture 1 (introduction)
AI Lecture 1 (introduction)AI Lecture 1 (introduction)
AI Lecture 1 (introduction)
 
Course outline (cse 412 - artificial intelligence)
Course outline (cse   412 - artificial intelligence)Course outline (cse   412 - artificial intelligence)
Course outline (cse 412 - artificial intelligence)
 
Artificial intelligence LAB 1 overview &amp; intelligent systems
Artificial intelligence LAB 1   overview &amp; intelligent systemsArtificial intelligence LAB 1   overview &amp; intelligent systems
Artificial intelligence LAB 1 overview &amp; intelligent systems
 
Matlab lecture 9 – simpson 1,3 and trapezoidal method@taj
Matlab lecture 9 – simpson 1,3 and trapezoidal method@tajMatlab lecture 9 – simpson 1,3 and trapezoidal method@taj
Matlab lecture 9 – simpson 1,3 and trapezoidal method@taj
 
Matlab lecture 8 – newton's forward and backword interpolation@taj copy
Matlab lecture 8 – newton's forward and backword interpolation@taj   copyMatlab lecture 8 – newton's forward and backword interpolation@taj   copy
Matlab lecture 8 – newton's forward and backword interpolation@taj copy
 
Matlab lecture 7 – regula falsi or false position method@taj
Matlab lecture 7 – regula falsi or false position method@tajMatlab lecture 7 – regula falsi or false position method@taj
Matlab lecture 7 – regula falsi or false position method@taj
 
Matlab lecture 6 – newton raphson method@taj copy
Matlab lecture 6 – newton raphson method@taj   copyMatlab lecture 6 – newton raphson method@taj   copy
Matlab lecture 6 – newton raphson method@taj copy
 
Matlab lecture 5 bisection method@taj
Matlab lecture 5  bisection method@tajMatlab lecture 5  bisection method@taj
Matlab lecture 5 bisection method@taj
 
Matlab lecture 4 loops@taj
Matlab lecture 4  loops@tajMatlab lecture 4  loops@taj
Matlab lecture 4 loops@taj
 
Matlab lecture 3 – commands, the m files, data types, bitwise op, set@taj
Matlab lecture 3 – commands, the m files, data types, bitwise op, set@tajMatlab lecture 3 – commands, the m files, data types, bitwise op, set@taj
Matlab lecture 3 – commands, the m files, data types, bitwise op, set@taj
 
Matlab lecture 2 matlab basic syntax &amp; variables @taj
Matlab lecture 2   matlab basic syntax &amp; variables @tajMatlab lecture 2   matlab basic syntax &amp; variables @taj
Matlab lecture 2 matlab basic syntax &amp; variables @taj
 
Matlab lecture 1 - installation of matlab, introduction and course outline@taj
Matlab lecture 1 - installation of matlab, introduction and course outline@tajMatlab lecture 1 - installation of matlab, introduction and course outline@taj
Matlab lecture 1 - installation of matlab, introduction and course outline@taj
 
Circuit lab 10 verification of norton's theorem@taj
Circuit lab 10  verification of norton's theorem@tajCircuit lab 10  verification of norton's theorem@taj
Circuit lab 10 verification of norton's theorem@taj
 
Circuit lab 9 verification of maximum power transfer theorem@taj
Circuit lab 9  verification of maximum power transfer theorem@tajCircuit lab 9  verification of maximum power transfer theorem@taj
Circuit lab 9 verification of maximum power transfer theorem@taj
 
Circuit lab 8 verification of thevenin's theorem@taj
Circuit lab 8  verification of thevenin's theorem@tajCircuit lab 8  verification of thevenin's theorem@taj
Circuit lab 8 verification of thevenin's theorem@taj
 
Circuit lab 7 verification of superposition theorem@taj
Circuit lab 7  verification of superposition theorem@tajCircuit lab 7  verification of superposition theorem@taj
Circuit lab 7 verification of superposition theorem@taj
 

Último

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 

Último (20)

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 

AI Lecture 3 (solving problems by searching)

  • 1. CSE 412: Artificial IntelligenceCSE 412: Artificial Intelligence Fall 2018Fall 2018 Topic – 3: Solving ProblemsTopic – 3: Solving Problems by Searchingby Searching Tajim Md. Niamat Ullah Akhund Lecturer Department of Computer Science and Engineering Daffodil International University Email: tajim.cse@diu.edu.bd
  • 2. Topic ContentsTopic Contents Problem Solving AgentsProblem Solving Agents Problem Formulation and Search SpacesProblem Formulation and Search Spaces Example ProblemsExample Problems Tree Search AlgorithmTree Search Algorithm  Breadth-First SearchBreadth-First Search  Uniform-Cost SearchUniform-Cost Search  Depth-First SearchDepth-First Search  Depth Limited SearchDepth Limited Search  Iteratively Deepening SearchIteratively Deepening Search  Bidirectional SearchBidirectional Search 2
  • 3. IntroductionIntroduction In this topic, we see how an agent can find a sequence of actions that achieves its goals, when no single action will do. 3 Majidur RahmanMajidur Rahman
  • 4. Problem-SolvingProblem-Solving AgentAgent Four general steps in problem solving: • Goal formulation – What are the successful world states • Problem formulation – What actions and states to consider given the goal • Search – Examine different possible sequences of actions that lead to states of known value and then choose the best sequence • Execute – Perform actions on the basis of the solution 4 Majidur RahmanMajidur Rahman
  • 6. Example: RomaniaExample: Romania On holiday the agent is in Romania visiting in Arad. Flight leaves tomorrow from Bucharest. • Formulate goal – Be in Bucharest • Formulate problem – States: various cities – Actions: drive between cities • Find solution – Sequence of cities; e.g. Arad, Sibiu, Fagaras, Bucharest,… 6 Majidur RahmanMajidur Rahman
  • 7. Problem TypeProblem Type Given how we have defined the problem: • Environment is fully observable • Environment is deterministic • Environment is sequential • Environment is static • Environment is discrete • Environment is single-agent 7 Majidur RahmanMajidur Rahman
  • 8. Problem FormulationProblem Formulation A problem is defined by:  An initial state, e.g. In(Arad)  A successor function S(x) = set of action-state pairs • S(In(Arad)) = {(Go(Sibiu), In(Sibiu)), (Go(Zerind), In(Zerind)), (Go(Timisoara), In(Timisoara))} • initial state + successor function = state space  Goal test • Explicit, e.g. x=‘In(Bucharest)’  Path cost (assume additive) • e.g. sum of distances, number of actions executed, … A solution is a sequence of actions from initial to goal state  the optimal solution has the lowest path cost 8 Majidur RahmanMajidur Rahman
  • 9. Vacuum WorldVacuum World State space of the vacuum world 9 Majidur RahmanMajidur Rahman
  • 10. Example ProblemsExample Problems The problem-solving approach has been applied to a vast array of task environments. Some of the best known are listed here, distinguishing between toy and real-world problems. A toy problem is intended to illustrate or exercise various problem-solving methods. It is usable by different researchers to compare the performance of algorithms.  A real-world problem is one whose solutions people actually care about. We will mainly focus on toy problems in this topic. 10 Majidur RahmanMajidur Rahman
  • 11. Toy Problems: 8-PuzzleToy Problems: 8-Puzzle  States: location of each tile plus blank  Initial state: Any state can be initial  Actions: Move blank {Left, Right, Up, Down}  Goal test: Check whether goal configuration is reached  Path cost: Number of actions to reach goal 11 Majidur RahmanMajidur Rahman
  • 12. Toy Problems: 8-QueensToy Problems: 8-Queens Place eight queens on a chessboard such that no queen attacks any other. Two kinds of problem formulation: • Complete-state formulation • Incremental formulation 12 Majidur RahmanMajidur Rahman
  • 13. Toy Problems: 8-QueensToy Problems: 8-Queens Complete-state formulation • States: Any arrangement of 0 to 8 queens on the board • Initial state: No queens • Actions: Add queen to any empty square • Goal test: 8 queens on board and none attacked • Path cost: N/A 64.63.62…..57 ≈ 3 x 1014 possible sequences to investigate 13Tajim Md. Niamat Ullah AkhundTajim Md. Niamat Ullah Akhund
  • 14. Incremental formulation • States: n (0 to 8) queens on the board, one per column in the n leftmost columns with no queen attacking any other • Actions: Add queen in leftmost empty column such that the queen is not attacking any other queen • 2057 possible sequences to investigate; solutions are easy to find But with 100 queens the problem is much harder 14 Toy Problems: 8-QueensToy Problems: 8-Queens
  • 15. Real-World ProblemsReal-World Problems  Route-finding problems  Touring problems  Traveling Salesman problem  VLSI layout problem  Robot navigation  Automatic assembly sequencing  Internet searching 15 Majidur RahmanMajidur Rahman
  • 16. Basic Search AlgorithmsBasic Search Algorithms How do we find the solutions of previous problems? • Search the state space – State space can be represented by a search tree – Root of the tree is the initial state – Children generated through successor function • In general we may have a search graph rather than tree (same state can be reached through multiple paths) 16 Majidur RahmanMajidur Rahman
  • 17. Simple Tree Search ExampleSimple Tree Search Example 17 Majidur RahmanMajidur Rahman
  • 18. Simple Tree Search ExampleSimple Tree Search Example 18 Majidur RahmanMajidur Rahman
  • 19. Simple Tree Search ExampleSimple Tree Search Example 19 Majidur RahmanMajidur Rahman
  • 20. State Space vs. Search TreeState Space vs. Search Tree • A state corresponds to a configuration of the world • A node is a data structure in a search tree – e.g. node = <state, parent-node, action, path-cost, depth> 20 Majidur RahmanMajidur Rahman
  • 21. Search StrategiesSearch Strategies  A search strategy is defined by picking the order of node expansion  Problem-solving performance is measured in four ways: • Completeness: Is a solution found if one exists? • Optimality: Does the strategy find the optimal solution? • Time Complexity: How long does it take to find a solution? • Space Complexity: How much memory is needed to perform the search?  Time and space complexity are measured in terms of problem difficulty defined by: • b - branching factor of the search tree • d - depth of the shallowest goal node • m - maximum length of any path in the state space 21 Majidur RahmanMajidur Rahman
  • 22. Uninformed Search StrategiesUninformed Search Strategies • Uninformed search (or blind search) – Strategies have no additional information about states beyond that provided in the problem definition • Informed (or heuristic) search – Search strategies know whether one state is more promising than another • Uninformed strategies (defined by order in which nodes are expanded): – Breadth-first search – Uniform-cost search – Depth-first search – Depth-limited search – Iterative deepening search – Bidirectional search 22 Majidur RahmanMajidur Rahman
  • 23. Breadth-First SearchBreadth-First Search • Expand shallowest unexpanded node • 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: fringe/frontier is a FIFO queue 23
  • 27. Breadth-First SearchBreadth-First Search • Completeness: is a solution always found if one exists? – YES • If shallowest goal node is at some finite depth d • If branching factor b is finite • BF search is optimal if the path cost is a non-decreasing function of the depth of the node 27 Majidur RahmanMajidur Rahman
  • 28. Breadth-First SearchBreadth-First Search • Time complexity: Assume a state space where every state has b successors – Assume solution is at depth d – Worst case: expand all but the last node at depth d – Total number of nodes generated: – b + b2 + b3 + ...+ bd + (bd +1 − b) = O(bd +1 ) • Space complexity: every node generated must remain in memory, so same as time complexity 28 Majidur RahmanMajidur Rahman
  • 29. Breadth-First SearchBreadth-First Search • Memory requirements are a bigger problem than execution time. 29 Majidur RahmanMajidur Rahman
  • 30. Uniform-Cost SearchUniform-Cost Search • Extension of BF-search: – Expand node with lowest path cost • Implementation: fringe = queue ordered by path cost • UC-search is the same as BF-search when all step costs are equal 30 Majidur RahmanMajidur Rahman
  • 31. Uniform-Cost SearchUniform-Cost Search  Let us consider the following search tree, where A and G are the initial and goal node, respectively. 31 Majidur RahmanMajidur Rahman
  • 37. Uniform-Cost SearchUniform-Cost Search  Let us consider the another search tree, where A and G are the initial and goal node, respectively. 37 Majidur RahmanMajidur Rahman
  • 42. Uniform-Cost SearchUniform-Cost Search • Completeness: – YES, if step-cost > some small positive constant ε • Optimality: – nodes expanded in order of increasing path cost – YES, if complete • Time and space complexity: – Uniform-cost search is guided by path costs rather than depths, so its complexity cannot easily be characterized in terms of b and d. – Instead, assume C* is the cost of the optimal solution – Assume that every action costs at least ε – Worst-case: O(bC*/ε ) 42 Majidur RahmanMajidur Rahman
  • 43. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 43 Majidur RahmanMajidur Rahman
  • 44. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 44 Majidur RahmanMajidur Rahman
  • 45. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 45 Majidur RahmanMajidur Rahman
  • 46. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 46 Majidur RahmanMajidur Rahman
  • 47. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 47 Majidur RahmanMajidur Rahman
  • 48. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 48 Majidur RahmanMajidur Rahman
  • 49. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 49 Majidur RahmanMajidur Rahman
  • 50. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 50 Majidur RahmanMajidur Rahman
  • 51. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 51 Majidur RahmanMajidur Rahman
  • 52. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 52 Majidur RahmanMajidur Rahman
  • 53. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 53 Majidur RahmanMajidur Rahman
  • 54. Depth-First SearchDepth-First Search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue (= stack) 54 Majidur RahmanMajidur Rahman
  • 55. DF-Search: EvaluationDF-Search: Evaluation • Completeness: – Is a solution always found if one exists? – No (unless search space is finite and no loops are possible) • Optimality: – Is the least-cost solution always found? – No 55 Majidur RahmanMajidur Rahman
  • 56. DF-Search: EvaluationDF-Search: Evaluation • Time complexity: O(bm ) • In general, time is terrible if m (maximal depth) is much larger than d (depth of shallowest solution) – But if there exist many solutions then faster than BF-search • Space complexity: O(bm) – Backtracking search uses even less memory (one successor instead of all b) 56 Majidur RahmanMajidur Rahman
  • 57. Depth-Limited SearchDepth-Limited Search • DF-search with depth limit l – i.e. nodes at depth l have no successors – Problem knowledge can be used • Solves the infinite-path problem • If l < d then incompleteness results • Time complexity: O(bl ) • Space complexity: O(bl) 57 Majidur RahmanMajidur Rahman
  • 58. Depth-Limited Search withDepth-Limited Search with ll = 2= 2 58 Majidur RahmanMajidur Rahman
  • 59. Depth-Limited Search withDepth-Limited Search with ll = 2= 2 59 Majidur RahmanMajidur Rahman
  • 60. Depth-Limited Search withDepth-Limited Search with ll = 2= 2 60 Majidur RahmanMajidur Rahman
  • 61. Depth-Limited Search withDepth-Limited Search with ll = 2= 2 61 Majidur RahmanMajidur Rahman
  • 62. Iterative Deepening SearchIterative Deepening Search • A general strategy to find best depth limit l – Goal is found at depth d, the depth of the shallowest goal-node – Often used in combination with DF-search • Combines benefits of DF- and BF-search 62 Majidur RahmanMajidur Rahman
  • 67. Bidirectional SearchBidirectional Search Two simultaneous searches run from start and goal. – Motivation: – One forward from the initial state – Other backward from goal – Stops when the two searches meet in the middle • Check whether the node belongs to the other fringe before expansion 67 bd/2 +bd/2 ≠bd
  • 68. Bidirectional SearchBidirectional Search Time complexity: O(bd/2 ) Space complexity: O(bd/2 ) – This space complexity is the most significant weakness of bidirectional search. Completeness and Optimality: Yes – If step costs are uniform – If both searches are breadth-first search. 68Majidur RahmanMajidur Rahman
  • 69. The reduction in time complexity makes bidirectional search attractive, but how do we search backwards? The predecessor of each node should be efficiently computable. – When actions are easily reversible. Bidirectional SearchBidirectional Search Majidur RahmanMajidur Rahman
  • 70. Summary of AlgorithmsSummary of Algorithms 70 Majidur RahmanMajidur Rahman
  • 71. ********** ********** If You Need Me ********** ********** Mail: tajim.cse@diu.edu.bd Website: https://www.tajimiitju.blogspot.com ORCID: https://orcid.org/0000-0002-2834-1507 LinkedIn: https://www.linkedin.com/in/tajimiitju ResearchGate: https://www.researchgate.net/profile/Tajim_Md_Niamat_Ullah_Akhund YouTube: https://www.youtube.com/tajimiitju?sub_confirmation=1 SlideShare: https://www.slideshare.net/TajimMdNiamatUllahAk Facebook: https://www.facebook.com/tajim.mohammad GitHub: https://github.com/tajimiitju Google+: https://plus.google.com/+tajimiitju Gmail: tajim.mohammad.3@gmail.com Twitter: https://twitter.com/Tajim53 Thank you Tajim Md. Niamat Ullah AkhundTajim Md. Niamat Ullah Akhund