2. State Space Search, Study notes of Artificial Intelligence

Search tree is created by searching through the state space. Search tree can be infinite even if the state space is finite. NB: state space contains cycles ...

Typology: Study notes

2021/2022

Uploaded on 09/07/2022

zaafir_ij
zaafir_ij šŸ‡¦šŸ‡Ŗ

4.4

(61)

884 documents

1 / 53

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Artificial Intelligence
2. State Space Search
Prof. Jan ˇ
Snajder
Assoc. Prof. Marko ˇ
Cupi“c
Prof. Bojana Dalbelo BaˇsiĀ“c
University of Zagreb
Faculty of Electrical Engineering and Computing
Academic Year 2021/2022
Creative Commons Attribution–NonCommercial–NoDerivs 3.0 v3.8
ˇ
Snajder, ˇ
CupiĀ“c, Dalbelo BaˇsiĀ“c (UNIZG FER) IAI – State space search Academic Year 2021/2022 1 / 53
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download 2. State Space Search and more Study notes Artificial Intelligence in PDF only on Docsity!

Introduction to Artificial Intelligence

2. State Space Search

Prof. Jan Snajderˇ Assoc. Prof. Marko Cupi“ˇ c Prof. Bojana Dalbelo BaˇsiĀ“c

University of Zagreb Faculty of Electrical Engineering and Computing

Academic Year 2021/

Creative Commons Attribution–NonCommercial–NoDerivs 3.0 v3.

Motivation

Many analytical problems can be solved by searching through a space of possible states Starting from an initial state, we try to reach a goal state Sequence of actions leading from initial to goal state is the solution to the problem The issues: large number of states and many choices to make in each state Search must be performed in a systematic manner

Formal description of the problem

Let S be a set of states (state space) A search problem consists of initial state, transitions between states, and a goal state (or many goal states)

Search problem

problem = (s 0 , succ, goal) (^1) s 0 ∈ S is the initial state (^2) succ : S → ā„˜(S) is a successor function defining the state transitions (^3) goal : S → {>, ⊄} is a test predicate to check if a state is a goal state

The successor function can be defined either explicitly (as a map from input to output states) or implicitly (using a set of operators that act on a state and transform it into a new state)

An example: A journey through Istria

How to reach Buzet from Pula? problem = (s 0 , succ, goal) s 0 = Pula succ(Pula) = {Barban, Medulin, Vodnjan} succ(Vodnjan) = {Kanfanar , Pula} .. . goal(Buzet) = > goal(Motovun) = ⊄ goal(Pula) = ⊄ .. .

Another example: 8-puzzle

initial state:

goal state:

What sequence of actions leads to the goal state? problem = (s 0 , succ, goal) s 0 =

succ( ) =

goal( ) = >

goal( ) = ⊄

goal( ) = ⊄ .. .

State space search – the basic idea

State space search amounts to a search through a directed graph (digraph) graph nodes = states arcs (directed edges) = transitions between states Graph may be defined explicitly or implicitly Graph may contain cycles If we also need the transition costs, we work with a weighted directed graph

State space vs. search tree

Search tree is created by searching through the state space Search tree can be infinite even if the state space is finite NB: state space contains cycles ⇒ search tree is infinite

State vs. node

Node n is a data structure comprising the search tree A node stores a state, as well as some additional data:

Node data structure

n = (s, d) s – state d – depth of the node in the search tree

state(n) = s, depth(n) = d

initial(s) = (s, 0)

Node expansion

When expanding a node, we must update all components stored within it:

Node expansion

function expand(n, succ) return { (s, depth(n) + 1) | s ∈ succ(state(n)) }

The function gets more complex as we store more data in a node (e.g., a pointer to the parent node)

Comparing problems and algorithms

Problem properties: |S| – number of states b – search tree branching factor d – depth of the optimal solution in the search tree m – maximum depth of the search tree (possibly āˆž) Algorithm properties: (^1) Completeness – an algorithm is complete iff it finds a solution whenever the solution exists (^2) Optimality (admissibility) – an algorithm is optimal iff the solution it finds is optimal (has the smallest cost) (^3) Time complexity (number of generated nodes) (^4) Space complexity (number of stored nodes)

Search strategies

There are two types of strategies: Blind (uninformed) search Heuristic (directed, informed) search

Today we focus on blind search.

Blind search

(^1) Breadth-first search (BFS) (^2) Uniform cost search (^3) Depth-first search (DFS) (^4) Depth-limited search (^5) Iterative deepening search

Breadth-first search – implementation

We get the BFS strategy if we always insert the generated nodes at the end of the open nodes list

Breadth-first search

function breadthFirstSearch(s 0 , succ, goal) open ← [ initial(s 0 ) ] while open 6 = [ ] do n ← removeHead(open) if goal(state(n)) then return n for m ∈ expand(n, succ) do insertBack(m, open) return fail

List open now functions as a queue (FIFO)

Breadth-first search – example of execution

(^0) open = [ (Pula, 0) ] (^1) expand(Pula, 0) = {(Vodnjan, 1), (Barban, 1), (Medulin, 1)} open = [ (Vodnjan, 1), (Barban, 1), (Medulin, 1) ] (^2) expand(Vodnjan, 1) = {(Kanfanar , 2), (Pula, 2)} open = [ (Barban, 1), (Medulin, 1), (Kanfanar , 2), (Pula, 2) ] (^3) expand(Barban, 1) = {(Labin, 2), (Pula, 2)} open = [ (Medulin, 1), (Kanfanar , 2), (Pula, 2), (Labin, 2), (Pula, 2) ] (^4) expand(Medulin, 1) = {(Pula, 2)} open = [ (Kanfanar , 2), (Pula, 2), (Labin, 2), (Pula, 2), (Pula, 2) ] (^5) expand(Kanfanar , 2) = {(Baderna, 3), (Rovinj , 3), (Vodnjan, 3)(Zminj , 3)} open = [ (Pula, 2), (Labin, 2), (Pula, 2), (Pula, 2), (Baderna, 3),... .. .