1
By
Engr. Dr. Jawwad Ahmad
Search
ARTIFICIAL
INTELLIGENCE &
EXPERT SYSTEMS
2
Today’s Goal
 Search
 Problem Solving as Search
 Problem Types
 Components of Problem Solving
 Problem Solving Process
 Problem Formulation
 Trees, Graphs, & Representation
Engr. Dr. Jawwad Ahmad
3
Why Need Search?
Engr. Dr. Jawwad Ahmad
 A farmer went to a market and purchased a wolf, a goat, and
a cabbage.
 On his way home, the farmer came to the bank of a river and
rented a boat.
 But crossing the river by boat, the farmer could carry only
himself and a single one of his purchases: the wolf, the goat, or
the cabbage.
 If left unattended together, the wolf would eat the goat, or the
goat would eat the cabbage.
 The farmer's challenge was to carry himself and his purchases to
the far bank of the river, leaving each purchase intact.
4
Search & Search Algorithm
Engr. Dr. Jawwad Ahmad
 Search is the process of looking for a sequence of actions that
reaches the goal.
 A search algorithm takes a problem as input and returns a
solution in the form of an action sequence.
 Once a solution is found, the actions it recommends can be
carried out.
 There are many sequences of actions, each with their own utility,
and we want to find, or search for, the best one.
Now Consider another Search Problem: Travel in Romania
5
Travel in Romania
Engr. Dr. Jawwad Ahmad
6
Travel in Romania
Engr. Dr. Jawwad Ahmad
 On holiday in Romania; currently 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
 State Space
 Cities
 Actions
 Drive down different roads
 Transition Function
 Roads lead to different Cities
 Cost
 Distance
 Initial State
 Arad
 Goal Test/State
 Bucharest
7
Travel in Romania
Engr. Dr. Jawwad Ahmad
733
607
450
418
Engr. Dr. Jawwad Ahmad 8
Problem Type
 Static / Dynamic
 Previous problem was static: no attention to changes
in environment
 Observable / Partially Observable / Unobservable
 Previous problem was observable: it knew its initial
state
 Deterministic / Stochastic
 Previous problem was deterministic: no new percepts
were necessary, we can predict the future perfectly
 Discrete / continuous
 Previous problem was discrete: we can enumerate all
possibilities
Engr. Dr. Jawwad Ahmad 9
A Well – Defined Problem
 State Space
 Set of all states reachable from the initial state by
any sequence of actions
 Initial state, actions, and transition model implicitly
define the State Space of the problem
 Solution to the problem is a sequence of actions that
lead from the initial state to a goal state
 Quality of Solution – measured by cost function
 Optimal Solution has the lowest path cost among all
solutions
The process of removing detail from a
representation is called ABSTRACTION.
The choice of a good abstraction thus
involves removing as much detail as possible
while retaining validity and ensuring that
the abstract actions are easy to carry out.
A good problem formulation has the right
level of detail.
Engr. Dr. Jawwad Ahmad 10
Components of Problem Solving
 State Space forms “Directed Network” or “Graph”
 Path is the sequence of states
 Initial State
 The state the agent starts in
 Possible Actions
 The set of actions that can be executed in any state s
 Transition Model / Results (description of each action)
 The state or result obtained by implementing action a in
state s
 Goal test determines / evaluate whether the given state is a
goal state or not
 Path Cost: Function that assigns a numeric cost to each
path.
Engr. Dr. Jawwad Ahmad 11
Problem Solving Process
 The Environment
 We consider only the simplest environments:
 Episodic
 Single agent
 Fully observable
 Deterministic
 Static
 Discrete
 Known
Phases of
Problem
Solving
Process
Calculating
Cost /
Fitness of
Path
Testing the
Goal State
State Space
(with Initial
State)
Problem
Formulatio
n
Goal
Formulatio
n
Engr. Dr. Jawwad Ahmad 12
Problem Formulation
 A problem is defined by four items:
1. initial state e.g., “at Arad”
2. actions or successor function S(x) = set of action–state
pairs
 e.g., S(Arad) = {<Arad  Zerind, Zerind>, … }
3. goal test,
 e.g., x = “at Bucharest, Checkmate(x)”
4. path cost (additive)
 e.g., sum of distances, number of actions executed, etc.
 c(x, a, y) is the step cost, assumed to be ≥ 0
 A solution is a sequence of actions leading from the initial
state to a goal state
Engr. Dr. Jawwad Ahmad 13
Vacuum World State Space Graph
States: integer, dirt and robot locations 2 x 22
= 8 States (ignore dirt amounts etc.)
Actions: Left, Right, Suck, NoOp
Initial State: any
Goal Test: no dirt at all locations
Path Cost: 1 per action (0 for NoOp)
Goal State
Engr. Dr. Jawwad Ahmad 14
The 8-Puzzle
States: integer, locations of tiles (ignore intermediate positions)
Actions: move blank left, right, up,
down (ignore unjamming etc.)
Initial State: any
Goal Test: Goal State
Path Cost: 1 per move
Start State
Engr. Dr. Jawwad Ahmad 15
The 8 Queens Problem
States: any arrangement of n<=8 queens or in leftmost n columns, 1 per column, such
that no queen attacks any other
Actions: add queen to empty or leftmost
empty square such that it is not attacked by
other queens.
Initial State: no queens on the board
Goal Test: Goal State (8 queens on
the board, none attacked)
Path Cost: 1 per move
Goal State
Start State
Engr. Dr. Jawwad Ahmad 16
Trees, Graphs, & Representation
 Graph
 Finite set of vertices (nodes) that are connected by edges
(arcs)
 Cycle
 An arc leading back to the original node
 Connected Graph
 Every pair of nodes is connected by an arc
 Complete Graph
 Every node is connected to every other node
 Weighted Graph
 Arc may carry a weight implying cost is associated with a
path
 Adjacency Matrix
 One of the simplest ways of representing a graph is by N by N
matrix, where N = no of nodes
 Rows identify source nodes whereas columns identify
Undirected graph – symmetric matrix
Directed graph – non symmetric matrix
Engr. Dr. Jawwad Ahmad 17
Trees, Graphs, & Representation
 Tree
 Connected graph with NO cycles
 Trees usually have roots and are drawn with roots on top
 Two nodes within a tree at most have one path between them
 Since tree has only one path of access to any other node it is
impossible to have cycles.
Engr. Dr. Jawwad Ahmad 18
Tree Search Example
Engr. Dr. Jawwad Ahmad 19
Search Algorithm
 When solving a problem
1. Consider solution space as a number of actions that can be taken
2. Performing these actions result in a change of state of the environment
3. Taking one of the possible action, the environment may add alternatives
for new actions
4. Each action has its associate cost
 Solution to the problem is finding sequence of operators that
transition from the start to the goal state.
 A search algorithm takes a problem as input and returns a solution
in the form of an action sequence
 As in general problem solving
1. Some paths lead to dead – ends and some lead to solution
2. Possibility of multiple solutions
3. One solution may be better than the other
 Avoiding the dead ends and selecting the best solution is the result of
the chosen search strategy
Engr. Dr. Jawwad Ahmad 20
Search Algorithm Strategies
 A search algorithm strategy is defined by picking the order
of node expansion
 Strategies are evaluated along the following dimensions:
 completeness: does it always find a solution if one
exists?
 time complexity: number of nodes generated
 space complexity: maximum number of nodes in
memory
 optimality: does it always find a least-cost solution?
 Time and space complexity are measured in terms of
 b: maximum branching factor of the search tree
 d: depth of the least-cost solution
 m: maximum depth of the state space (may be ∞)
Engr. Dr. Jawwad Ahmad 21
The Towers of Hanoi
 The puzzle was invented by the French mathematician
Édouard Lucas in 1883
Engr. Dr. Jawwad Ahmad 22
The Towers of Hanoi
Engr. Dr. Jawwad Ahmad 23
Thank you

More Related Content

PPTX
AI_03_Solving Problems by Searching.pptx
PDF
Artificial Intelegince-chapter three-problem solving.pdf
PPT
22sch AI Module 2.ppt 22sch AI Module 2.ppt
PPT
22sch AI Module 2.ppt 22sch AI Module 2.ppt
DOCX
Adsa u2 ver 1.0.
PDF
Lecture is related to the topic of Artificial intelligence
PDF
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
DOCX
Searching techniques
AI_03_Solving Problems by Searching.pptx
Artificial Intelegince-chapter three-problem solving.pdf
22sch AI Module 2.ppt 22sch AI Module 2.ppt
22sch AI Module 2.ppt 22sch AI Module 2.ppt
Adsa u2 ver 1.0.
Lecture is related to the topic of Artificial intelligence
AI Chapter 3.pdfvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Searching techniques

Similar to Week 2 a - Search.ppsx this is used to search things (20)

PPTX
AI UNIT 2 PPT AI UNIT 2 PPT AI UNIT 2 PPT.pptx
PPTX
CptS 440 / 540 Artificial Intelligence
PPTX
Review And Evaluations Of Shortest Path Algorithms
PPTX
Review and evaluations of shortest path algorithms
PDF
problem solving in Artificial intelligence .pdf
PPTX
Lecture 3 Problem Solving.pptx
PPTX
Popular search algorithms
PDF
Ds33717725
PDF
Ds33717725
PDF
Week 4.pdf
PPTX
Lec#2
PDF
AI Chapter Two Solving problems by searching.pdf
PPTX
3. ArtificialSolving problems by searching.pptx
PPTX
FAI UNIT 6FAI UNIT 7 all important questions to be noted max pass
PPTX
heuristic technique.pptx...............................
PDF
5. 8519 1-pb
PPT
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
PPTX
Artificial intelligence with the help of
PPTX
Heuristic or informed search
PDF
Reinforcement Learning - DQN
AI UNIT 2 PPT AI UNIT 2 PPT AI UNIT 2 PPT.pptx
CptS 440 / 540 Artificial Intelligence
Review And Evaluations Of Shortest Path Algorithms
Review and evaluations of shortest path algorithms
problem solving in Artificial intelligence .pdf
Lecture 3 Problem Solving.pptx
Popular search algorithms
Ds33717725
Ds33717725
Week 4.pdf
Lec#2
AI Chapter Two Solving problems by searching.pdf
3. ArtificialSolving problems by searching.pptx
FAI UNIT 6FAI UNIT 7 all important questions to be noted max pass
heuristic technique.pptx...............................
5. 8519 1-pb
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Artificial intelligence with the help of
Heuristic or informed search
Reinforcement Learning - DQN
Ad

More from laraibjamal1 (7)

PPSX
Week 1 a - Introduction.ppsx this is good ppt
PPTX
Lecture 6.pptx artificial intellegince and tech
PDF
Week 9 Lecture.pdf software project management
PDF
Week 4 Lecture.pdf for software project management
PPTX
HRM Latest Trends in Employee Training and Development.pptx
PPTX
CONVERSO_2nd milestoneitisthe_ppttt.pptx
PPSX
Week 1 b - Agents.ppsx used in AI for be
Week 1 a - Introduction.ppsx this is good ppt
Lecture 6.pptx artificial intellegince and tech
Week 9 Lecture.pdf software project management
Week 4 Lecture.pdf for software project management
HRM Latest Trends in Employee Training and Development.pptx
CONVERSO_2nd milestoneitisthe_ppttt.pptx
Week 1 b - Agents.ppsx used in AI for be
Ad

Recently uploaded (20)

PPTX
Reproductive system-Human anatomy and physiology
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PDF
African Communication Research: A review
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2015).pdf
PDF
Nurlina - Urban Planner Portfolio (english ver)
PDF
semiconductor packaging in vlsi design fab
PPTX
Macbeth play - analysis .pptx english lit
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PDF
0520_Scheme_of_Work_(for_examination_from_2021).pdf
PDF
Civil Department's presentation Your score increases as you pick a category
PDF
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
PDF
Everyday Spelling and Grammar by Kathi Wyldeck
PDF
Controlled Drug Delivery System-NDDS UNIT-1 B.Pharm 7th sem
PPTX
BSCE 2 NIGHT (CHAPTER 2) just cases.pptx
PPTX
Climate Change and Its Global Impact.pptx
PDF
M.Tech in Aerospace Engineering | BIT Mesra
PDF
THE CHILD AND ADOLESCENT LEARNERS & LEARNING PRINCIPLES
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
Lecture on Viruses: Structure, Classification, Replication, Effects on Cells,...
Reproductive system-Human anatomy and physiology
Literature_Review_methods_ BRACU_MKT426 course material
African Communication Research: A review
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2015).pdf
Nurlina - Urban Planner Portfolio (english ver)
semiconductor packaging in vlsi design fab
Macbeth play - analysis .pptx english lit
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
0520_Scheme_of_Work_(for_examination_from_2021).pdf
Civil Department's presentation Your score increases as you pick a category
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
Everyday Spelling and Grammar by Kathi Wyldeck
Controlled Drug Delivery System-NDDS UNIT-1 B.Pharm 7th sem
BSCE 2 NIGHT (CHAPTER 2) just cases.pptx
Climate Change and Its Global Impact.pptx
M.Tech in Aerospace Engineering | BIT Mesra
THE CHILD AND ADOLESCENT LEARNERS & LEARNING PRINCIPLES
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
Lecture on Viruses: Structure, Classification, Replication, Effects on Cells,...

Week 2 a - Search.ppsx this is used to search things

  • 1. 1 By Engr. Dr. Jawwad Ahmad Search ARTIFICIAL INTELLIGENCE & EXPERT SYSTEMS
  • 2. 2 Today’s Goal  Search  Problem Solving as Search  Problem Types  Components of Problem Solving  Problem Solving Process  Problem Formulation  Trees, Graphs, & Representation Engr. Dr. Jawwad Ahmad
  • 3. 3 Why Need Search? Engr. Dr. Jawwad Ahmad  A farmer went to a market and purchased a wolf, a goat, and a cabbage.  On his way home, the farmer came to the bank of a river and rented a boat.  But crossing the river by boat, the farmer could carry only himself and a single one of his purchases: the wolf, the goat, or the cabbage.  If left unattended together, the wolf would eat the goat, or the goat would eat the cabbage.  The farmer's challenge was to carry himself and his purchases to the far bank of the river, leaving each purchase intact.
  • 4. 4 Search & Search Algorithm Engr. Dr. Jawwad Ahmad  Search is the process of looking for a sequence of actions that reaches the goal.  A search algorithm takes a problem as input and returns a solution in the form of an action sequence.  Once a solution is found, the actions it recommends can be carried out.  There are many sequences of actions, each with their own utility, and we want to find, or search for, the best one. Now Consider another Search Problem: Travel in Romania
  • 5. 5 Travel in Romania Engr. Dr. Jawwad Ahmad
  • 6. 6 Travel in Romania Engr. Dr. Jawwad Ahmad  On holiday in Romania; currently 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  State Space  Cities  Actions  Drive down different roads  Transition Function  Roads lead to different Cities  Cost  Distance  Initial State  Arad  Goal Test/State  Bucharest
  • 7. 7 Travel in Romania Engr. Dr. Jawwad Ahmad 733 607 450 418
  • 8. Engr. Dr. Jawwad Ahmad 8 Problem Type  Static / Dynamic  Previous problem was static: no attention to changes in environment  Observable / Partially Observable / Unobservable  Previous problem was observable: it knew its initial state  Deterministic / Stochastic  Previous problem was deterministic: no new percepts were necessary, we can predict the future perfectly  Discrete / continuous  Previous problem was discrete: we can enumerate all possibilities
  • 9. Engr. Dr. Jawwad Ahmad 9 A Well – Defined Problem  State Space  Set of all states reachable from the initial state by any sequence of actions  Initial state, actions, and transition model implicitly define the State Space of the problem  Solution to the problem is a sequence of actions that lead from the initial state to a goal state  Quality of Solution – measured by cost function  Optimal Solution has the lowest path cost among all solutions The process of removing detail from a representation is called ABSTRACTION. The choice of a good abstraction thus involves removing as much detail as possible while retaining validity and ensuring that the abstract actions are easy to carry out. A good problem formulation has the right level of detail.
  • 10. Engr. Dr. Jawwad Ahmad 10 Components of Problem Solving  State Space forms “Directed Network” or “Graph”  Path is the sequence of states  Initial State  The state the agent starts in  Possible Actions  The set of actions that can be executed in any state s  Transition Model / Results (description of each action)  The state or result obtained by implementing action a in state s  Goal test determines / evaluate whether the given state is a goal state or not  Path Cost: Function that assigns a numeric cost to each path.
  • 11. Engr. Dr. Jawwad Ahmad 11 Problem Solving Process  The Environment  We consider only the simplest environments:  Episodic  Single agent  Fully observable  Deterministic  Static  Discrete  Known Phases of Problem Solving Process Calculating Cost / Fitness of Path Testing the Goal State State Space (with Initial State) Problem Formulatio n Goal Formulatio n
  • 12. Engr. Dr. Jawwad Ahmad 12 Problem Formulation  A problem is defined by four items: 1. initial state e.g., “at Arad” 2. actions or successor function S(x) = set of action–state pairs  e.g., S(Arad) = {<Arad  Zerind, Zerind>, … } 3. goal test,  e.g., x = “at Bucharest, Checkmate(x)” 4. path cost (additive)  e.g., sum of distances, number of actions executed, etc.  c(x, a, y) is the step cost, assumed to be ≥ 0  A solution is a sequence of actions leading from the initial state to a goal state
  • 13. Engr. Dr. Jawwad Ahmad 13 Vacuum World State Space Graph States: integer, dirt and robot locations 2 x 22 = 8 States (ignore dirt amounts etc.) Actions: Left, Right, Suck, NoOp Initial State: any Goal Test: no dirt at all locations Path Cost: 1 per action (0 for NoOp)
  • 14. Goal State Engr. Dr. Jawwad Ahmad 14 The 8-Puzzle States: integer, locations of tiles (ignore intermediate positions) Actions: move blank left, right, up, down (ignore unjamming etc.) Initial State: any Goal Test: Goal State Path Cost: 1 per move Start State
  • 15. Engr. Dr. Jawwad Ahmad 15 The 8 Queens Problem States: any arrangement of n<=8 queens or in leftmost n columns, 1 per column, such that no queen attacks any other Actions: add queen to empty or leftmost empty square such that it is not attacked by other queens. Initial State: no queens on the board Goal Test: Goal State (8 queens on the board, none attacked) Path Cost: 1 per move Goal State Start State
  • 16. Engr. Dr. Jawwad Ahmad 16 Trees, Graphs, & Representation  Graph  Finite set of vertices (nodes) that are connected by edges (arcs)  Cycle  An arc leading back to the original node  Connected Graph  Every pair of nodes is connected by an arc  Complete Graph  Every node is connected to every other node  Weighted Graph  Arc may carry a weight implying cost is associated with a path  Adjacency Matrix  One of the simplest ways of representing a graph is by N by N matrix, where N = no of nodes  Rows identify source nodes whereas columns identify Undirected graph – symmetric matrix Directed graph – non symmetric matrix
  • 17. Engr. Dr. Jawwad Ahmad 17 Trees, Graphs, & Representation  Tree  Connected graph with NO cycles  Trees usually have roots and are drawn with roots on top  Two nodes within a tree at most have one path between them  Since tree has only one path of access to any other node it is impossible to have cycles.
  • 18. Engr. Dr. Jawwad Ahmad 18 Tree Search Example
  • 19. Engr. Dr. Jawwad Ahmad 19 Search Algorithm  When solving a problem 1. Consider solution space as a number of actions that can be taken 2. Performing these actions result in a change of state of the environment 3. Taking one of the possible action, the environment may add alternatives for new actions 4. Each action has its associate cost  Solution to the problem is finding sequence of operators that transition from the start to the goal state.  A search algorithm takes a problem as input and returns a solution in the form of an action sequence  As in general problem solving 1. Some paths lead to dead – ends and some lead to solution 2. Possibility of multiple solutions 3. One solution may be better than the other  Avoiding the dead ends and selecting the best solution is the result of the chosen search strategy
  • 20. Engr. Dr. Jawwad Ahmad 20 Search Algorithm Strategies  A search algorithm strategy is defined by picking the order of node expansion  Strategies are evaluated along the following dimensions:  completeness: does it always find a solution if one exists?  time complexity: number of nodes generated  space complexity: maximum number of nodes in memory  optimality: does it always find a least-cost solution?  Time and space complexity are measured in terms of  b: maximum branching factor of the search tree  d: depth of the least-cost solution  m: maximum depth of the state space (may be ∞)
  • 21. Engr. Dr. Jawwad Ahmad 21 The Towers of Hanoi  The puzzle was invented by the French mathematician Édouard Lucas in 1883
  • 22. Engr. Dr. Jawwad Ahmad 22 The Towers of Hanoi
  • 23. Engr. Dr. Jawwad Ahmad 23 Thank you