0% found this document useful (0 votes)
6 views30 pages

AI Lecture 10

The lecture discusses problem-solving through search strategies, focusing on state space search and backtracking algorithms. It covers various examples like Tic-Tac-Toe and the Traveling Salesperson problem, explaining the concepts of search trees, cycles, and handling repeated states. The backtracking technique is highlighted as a method for systematically exploring paths in a state space, applicable to various problems such as parsing and constraint satisfaction.

Uploaded by

abdoantar264
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views30 pages

AI Lecture 10

The lecture discusses problem-solving through search strategies, focusing on state space search and backtracking algorithms. It covers various examples like Tic-Tac-Toe and the Traveling Salesperson problem, explaining the concepts of search trees, cycles, and handling repeated states. The backtracking technique is highlighted as a method for systematically exploring paths in a state space, applicable to various problems such as parsing and constraint satisfaction.

Uploaded by

abdoantar264
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Artificial Intelligence

Lecture 10
Problem Solving as Search
& State Space Search

Dr. Mahmoud Bassiouni


mbassiouni@eelu.edu.eg
Lecture 3: Solving Problem by Searching,
.. & .. State Space Search Strategies and Structures
3.1 Solving problems by Searching ▪ Example: Tic-Tac-Toe
▪ Solving Problems by Searching ▪ Example: Traveling Salesperson
▪ Types of Agents (Reflex vs. Planning) ▪ State Space Search Strategies
▪ State Space Search ▪ Selecting Search Strategy
▪ Example: Tic-Tac-Toe Game
3.3 Basic Idea of Search & the Backtracking
▪ Example: Mechanical Fault Diagnosing Search Algorithm
▪ How human beings think? ▪ Search: Basic idea
▪ Heuristic Search ▪ Search Tree
3.2 State Space Search Graph & Strategies ▪ Tree Search Algorithm Outline
▪ Search problem components ▪ Tree Search Example
▪ Example: Romania ▪ Handling repeated states
▪ State Space & State Space Graph ▪ Backtracking Search
▪ Example: Vacuum World ▪ Backtracking Algorithm Data Structures
▪ Example: The 8-Puzzle ▪ Backtracking Algorithm
▪ Example: Robot Motion Planning 3.4 Practice Exercises (Solved Problems)
Search ..?
Given:
✓ Initial state
✓ Actions
✓ Transition model
✓ Goal state
✓ Path cost

How do we find the optimal solution?


Search: Basic idea
o Based idea of any search even if the this search is heuristic,
informed or uninformed.
o Is that you begin from a start state and it expands to a list of all
possible successor states. (second state to the start state)
o The successor states are put in something called frontier or
sometimes called fringe. They are considered to be my boundaries
(boundary of the states that I can reach currently) in my situation
o They are states that I can reach, but I didn’t go the them and I do
not know if they are the goal state or not. Also, I do not know who
are there children or even if they have a children or not.
o All of these are added in a frontier or a fringe. Then, after that we
take or pick a state in the fringe. Each search algorithm we select a
state in the fringe different from the other searching algorithm.
Search: Basic idea
o After you select a state from the fringe of the frontier you check is
it the goal or not.
o If it is not the goal that we keep expanding. We will repeat the
same steps. Expand, we see the successor state, add them in the
fringe.
o Then we select one of the states in the fringe and see if it is the
goal. If it is the goal we return the goal with the complete path
from the start to the end
o If it is not the goal we expand its children. Any search algorithm do
this thing even if it is an exhaustive search (blind, uninformed) or
heuristic or informed search.
o Also the main aim of any search is not to move on a lot of states
several times to reach the goal.
Search: Basic idea
o Start State

Start
Search: Basic idea
o We will move to one of the five states
o I do not if any of them is the goal or not until now
o Also, I do not know from an state of them where we can go

o The search algorithm we select one of these states. This is


currently called the fringe or the frontier.
o Each search algorithm will select a one different from the other.
Search: Basic idea
We consider we selected the blue one. And we moved to it
If that blue state the goal (Yes or No)
No let’s consider it is not the goal
Search: Basic idea
From the blue one where we can move?
We can move to the group of the three states
We will add the three states to the fringe we have that had the
our four states.
Search: Basic idea
Then, the searching algorithm we select one of the seven frontiers
or fringe. Is it the goal (Yes or No)
Lets consider it is not the goal.
Search: Basic idea
Does it have a children? Yes Put the children states in the fringe
Fringe now will have Six + the children (Four) will reach a total of 10
states in the fringe
Search: Basic idea
We will select one state in the fringe (Now it has 9 states)
Is it the goal Let’s consider it is not the goal
No
Search: Basic idea
Does it have children
Yes one child put it in the fringe
(Fringe now has 10 states)
Search: Basic idea
We will select a state in the fringe
Is it the goal No
(Fringe now has 9 states)
Search: Basic idea
Does it have a children yes
Put it in the fringe.
Then, the fringe consists of (10 states till now)
Search: Basic idea
Select or pick one from the state from the fringe
Is it the goal NO
Then, the fringe consists of (9 states till now)
Search: Basic idea
Expand its children and put them in the fringe
Then, the fringe consists of (11 states till now)
And so on till you reach your goal
Search Tree (theWhat-if tree) Starting
State
▪ The difference is that each search algorithm
selects the node or the state from the fringe. Action
In a way different from other search Successor
algorithm. State

▪ The search tree we built is called or known as


(What- if tree). They are not actions you are
doing in the environment, but you are thinking
about the possibilities. You build a tree for all …
your possibilities in order to reach the goal.
Frontier
That’s why it is called (What-if tree).
Goal
▪ If you do this action. What kind of state I will State
go to If I am in a state and I do an another
action. What kind of state I will go to
Search Tree (theWhat-if tree) Starting
“What if” tree of sequences of actions and State

outcomes; Action
▪ The root node corresponds to the starting state. Successor
▪ The children of a node correspond to the State
successor states of that node’s state.
▪ A path through the tree corresponds to a
sequence of actions.
▪ A solution is a path ending in the goal state …
Frontier
Goal
State
Search Tree (theWhat-if tree) Starting
State
Nodes vs. States ..? A state is a representation of the
Action
world, while a node is a data structure that is part of the
search tree. Node must keep pointer to parent, path Successor
State
cost, possibly other info.

• State is the current representation of the world →


In tic-tac-toc the game has X or O is called the state
• Node is the representation of the state → When I
represent the state in a matrix or a board with 1’s to

X or 0 to the O’s is called node
Frontier
Goal
State
TreeSearchAlgorithmOutline
Initialize the frontier using the starting state.

While the frontier is not empty:

• Choose a frontier node according to search strategy

and take it off the frontier.

• If the node contains the goal state, return solution.


• Else expand the node and add its children to the

frontier.
Stopping criteria will be based on two options:
First is to reach the goal
Second is when the frontier or fringe is empty.
Tree Search Example

Starting state is Arad and the goal state is Bucharest

Start: Arad
Goal: Bucharest
Tree Search Example

From Arad where Can I go


I can go to the three cities (Sibiu, Timisoara, Zeind)
We will move to one of the three paths let’s say sibiu

Start: Arad
Goal: Bucharest
Tree Search Example

Start: Arad
Goal: Bucharest
Tree Search Example
One problem here exists is that we started from Arad and we reach
Arad once again.
This is called cycle or a loop and here in this problem it is direct and it
appeared after two steps only. You can have a problem the cycle are
large and appear after 6 or 7 steps or even more than that.
For Example in the 8 puzzle you can move the blank up or down more
than one time till you reach the same beginning you started with after 9
or 10 moves
This is big problem you moved to Arad and then you can move from
Arad to Sibie again and then to Arad and this cycle will not stop. The
tree is not finite tree. You should detect that there exist cycles
especially in the problems that contain cycles so that you can break
these cycles.
We must find a way to handle the cycles found or the repeated states.
Handling Repeated States
To handle repeated states:
1. Every time you expand a node, add that state to the
explored set; do not put explored states on the frontier
again.
2. Every time you add a node to the frontier, check
whether it already exists with a higher path cost, and if
yes, replace that node with the new one.
Backtracking Search
“Backtracking is a technique for systematically trying all
paths through a state space”
Backtracking is a technique that is based on trying all the paths in the
state space. Therefore backtracking search is considered as blind
search or uninformed search algorithms.
It begins at the start state and moves in a path till reaching or finding
a goal then quit and brings back the solution path. If he find a dead
end then it back track to the most recent unexamined node and
continue down one of its branches.
Backtracking algorithm is known as the depth first search. Both move
on the tree in the same way. The difference is in the data structure
used in to build the algorithm. Each one is implemented in a way
different from the other in the data structure.
Backtracking Search

Start
Node

Dead Dead Dead Dead


End End End End
Backtracking Implementation and Applications
Backtracking is implemented using Important
1- Three lists:
State list: (states in the current path being tried if you found the goal
then the state list is the path of your solution)
New state list: (nodes awaiting evaluations which are fringe or frontier
or sometime called open list),
Dead end List: (list that have states and its descendants failed to
contain the goal node) The dead end is important because we need to
check it first before adding in the new state list we need to see if it is in
the dead end to prevent cycles
Current State: Finally, I have pointer to the current state.

Backtracking is used in different problems such as


1- Parsing problems if you have statement in the programming
language and it is fixed or matched with a Grammer of the language.
2- Constraint satisfaction problems: Problems that have several
constraints and you try to meet them such as Sudoku or crosswords.
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy