02 solving problems by searching (us)
TRANSCRIPT
-
8/9/2019 02 Solving Problems by Searching (Us)
1/48
Artificial Intelligence
Solving problems by searching
Fall 2008
professor: Luigi Ceccaroni
-
8/9/2019 02 Solving Problems by Searching (Us)
2/48
Problem solving
e !ant:
"o automatically solve a problem
e nee#:
A representation of the problem
Algorithms that use some strategy to solve
the problem #efine# in that representation
-
8/9/2019 02 Solving Problems by Searching (Us)
3/48
Problem representation
$eneral:
% State space: a problem is #ivi#e# into a set
of resolution steps from the initial state to the
goal state
% Reduction to sub-problems: a problem is
arrange# into a hierarchy of sub&problems
Specific: $ame resolution
Constraints satisfaction
-
8/9/2019 02 Solving Problems by Searching (Us)
4/48
States
A problem is #efine# by its elements an# theirrelations'
In each instant of the resolution of a problem(
those elements have specific #escriptors )*o!to select them+, an# relations'
A stateis a representation of those elements ina given moment'
"!o special states are #efine#:% Initial state)starting point,
% Final state)goal state,
-
8/9/2019 02 Solving Problems by Searching (Us)
5/48
State mo#ification:
successor function A successor function is nee#e# to move
bet!een #ifferent states' A successor functionis a #escription of
possible actions( a set of operators' It is atransformation function on a staterepresentation( !hich convert it into anotherstate'
"he successor function #efines a relation of
accessibility among states' -epresentation of the successor function:
Con#itions of applicability "ransformation function
-
8/9/2019 02 Solving Problems by Searching (Us)
6/48
State space
"he state spaceis the set of all states
reachable from the initial state'
It forms a graph )or map, in !hich the no#es are
states an# the arcs bet!een no#es are actions' A pathin the state space is a se.uence of
states connecte# by a se.uence of actions'
"he solution of the problem is part of the mapforme# by the state space'
-
8/9/2019 02 Solving Problems by Searching (Us)
7/48
Problem solution
A solutionin the state space is a path from theinitial state to a goal state or( sometimes( /ust agoal state'
Path/solution cost: function that assigns anumeric cost to each path( the cost of applyingthe operators to the states
Solution .uality is measure# by the path costfunction( an# an optimal solutionhas the
lo!est path cost among all solutions' Solutions: any( an optimal one( all' Cost is
important #epen#ing on the problem an# thetype of solution sought'
-
8/9/2019 02 Solving Problems by Searching (Us)
8/48
Problem #escription
Components: State space )e1plicitly or implicitly #efine#, Initial state $oal state )or the con#itions it has to fulfill, Available actions )operators to change state, -estrictions )e'g'( cost, lements of the #omain !hich are relevant to the
problem )e'g'( incomplete 3no!le#ge of the starting
point, "ype of solution:
Se.uence of operators or goal state
Any( an optimal one )cost #efinition nee#e#,( all
-
8/9/2019 02 Solving Problems by Searching (Us)
9/48
1ample: 8&pu44le
8
2 3
4
1
6
!
-
8/9/2019 02 Solving Problems by Searching (Us)
10/48
1ample: 8&pu44le
State space: configuration of the eighttiles on the boar#
Initial state: any configuration
"oal state: tiles in a specific or#er
#perators or actions: 5blan3 moves6 Con#ition: the move is !ithin the boar#
"ransformation: blan3 moves Left( Right( Up(or Down
Solution: optimal se.uence of operators
-
8/9/2019 02 Solving Problems by Searching (Us)
11/48
1ample: n.ueens
)n 7 ( n 7 8,
-
8/9/2019 02 Solving Problems by Searching (Us)
12/48
1ample: n.ueens
)n 7 ( n 7 8, State space: configurations from 0 to n .ueens
on the boar# !ith only one .ueen per ro! an#column
Initial state: configuration !ithout .ueens on the
boar# "oal state: configuration !ith n .ueens such that
no .ueen attac3s any other #perators or actions: place a .ueen on the
boar# Con#ition: the ne! .ueen is not attac3e# by any
other alrea#y place# "ransformation: place a ne! .ueen in a particular
s.uare of the boar#
Solution: one solution )cost is not consi#ere#,
-
8/9/2019 02 Solving Problems by Searching (Us)
13/48
-
8/9/2019 02 Solving Problems by Searching (Us)
14/48
Search as goal satisfaction
Satisfying a goal
Agent 3no!s !hat the goal is
Agent cannot evaluate interme#iate solutions
)uninforme#,
"he environment is:
Static
bservable
9eterministic
-
8/9/2019 02 Solving Problems by Searching (Us)
15/48
1ample: holi#ay in -omania
n holi#ay in -omania; currently in Ara#
Flight leaves tomorro! from :00 Let?s configure this to be an AI problem
-
8/9/2019 02 Solving Problems by Searching (Us)
16/48
-omania
hat?s the problem+
Accomplish a goal
-each :00
So this is a goal&base# problem
-
8/9/2019 02 Solving Problems by Searching (Us)
17/48
-omania
hat?s an e1ample of a non&goal&base#
problem+
Live long an# prosper
@a1imi4e the happiness of your trip to
-omania
9on?t get hurt too much
-
8/9/2019 02 Solving Problems by Searching (Us)
18/48
-omania
hat .ualifies as a solution+
ou canBcannot reach :00
"he actions one ta3es to travel from Ara# to
-
8/9/2019 02 Solving Problems by Searching (Us)
19/48
-omania
hat a##itional information #oes one
nee#+
A map
-
8/9/2019 02 Solving Problems by Searching (Us)
20/48
A state space Which cities could you bein?
An initial state Which city do you start
from?A goal state
Which city do you aim to
reach?
A function #efining state
transitions
When in city foo, the
following cities can be
reached
A function #efining the
5cost6 of a state
se.uence
How long does it take to
travel through a city
sequence?
@ore concrete problem
#efinition
-
8/9/2019 02 Solving Problems by Searching (Us)
21/48
@ore concrete problem
#efinition
A state space Choose a representation
An initial stateChoose an element from the
representation
A goal stateCreate goal_function(state)such
that TR! is returned upon reaching
goal
A function #efining state
transitions
successor_function(statei)"
#$actiona, statea%, $actionb, stateb%,
&'
A function #efining the 5cost6 of a
state se.uencecost (sequence) " number
-
8/9/2019 02 Solving Problems by Searching (Us)
22/48
Important notes about this
e1ample Static environment )available states(
successor function( an# cost functions #on?t
change,
bservable )the agent 3no!s !here it is, 9iscrete )the actions are #iscrete,
9eterministic )successor function is al!ays
the same,
-
8/9/2019 02 Solving Problems by Searching (Us)
23/48
"ree search algorithms
-
8/9/2019 02 Solving Problems by Searching (Us)
24/48
-
8/9/2019 02 Solving Problems by Searching (Us)
25/48
Implementation: general search
algorithm,l*orithm$eneral Search
penDstates'insert )InitialDstate,
Current7 penDstates'first),
$hile notisDfinal+)Current, and notpenDstates'empty+), do
penDstates'#eleteDfirst),
Close#Dstates'insert)Current,
Successors7 generateDsuccessors)Current,
Successors7 processDrepeate#)Successors( Close#Dstates(
penDstates,
penDstates'insert)Successors,
Current7 penDstates'first),
ehile
e,l*orithm
-
8/9/2019 02 Solving Problems by Searching (Us)
26/48
-
8/9/2019 02 Solving Problems by Searching (Us)
27/48
,rad
1ample: Ara#
-
8/9/2019 02 Solving Problems by Searching (Us)
28/48
,rad
.erind %!& imisoara %118& Sibiu %140&
1ample: Ara#
-
8/9/2019 02 Solving Problems by Searching (Us)
29/48
,rad
.erind %!& imisoara %118& Sibiu %140&
1ample: Ara#
-
8/9/2019 02 Solving Problems by Searching (Us)
30/48
,rad
.erind %!& imisoara %118& Sibiu %140&
radea %1!1& Fara*as %& Rimnicu ilcea %80&
1ample: Ara#
-
8/9/2019 02 Solving Problems by Searching (Us)
31/48
Implementation: states vs'
no#es State
)-epresentation of, a physical configuration
Eo#e
9ata structure constituting part of a search
tree
Inclu#esparent, children, depth, path costg)1,
States #o not have parents( chil#ren(#epth( or path cost
-
8/9/2019 02 Solving Problems by Searching (Us)
32/48
Search strategies
A strategy is #efine# by pic3ing the or#er of no#e
e1pansion
Strategies are evaluate# along the follo!ing
#imensions: Completeness % #oes it al!ays fin# a solution if
one e1ists+
"ime comple1ity % number of no#es
generate#Be1pan#e#
Space comple1ity % ma1imum no#es in memory
ptimality % #oes it al!ays fin# a least&cost
solution+
-
8/9/2019 02 Solving Problems by Searching (Us)
33/48
Search strategies
"ime an# space comple1ity are measure# in
terms of:
b % ma1imum branching factor of the search tree
)may be infinite, # % #epth of the least&cost solution
m % ma1imum #epth of the state space )may be
infinite,
-
8/9/2019 02 Solving Problems by Searching (Us)
34/48
Gninforme# Search Strategies
Gninforme# strategies use only the
information available in the problem
#efinition
-
8/9/2019 02 Solving Problems by Searching (Us)
35/48
>H
Eo#es
pen no#es:
$enerate#( but not yet e1plore#
1plore#( but not yet e1pan#e#
Close# no#es:
1plore# an# e1pan#e#
>H
-
8/9/2019 02 Solving Problems by Searching (Us)
36/48
-
8/9/2019 02 Solving Problems by Searching (Us)
37/48
Space cost of
-
8/9/2019 02 Solving Problems by Searching (Us)
38/48
Properties of brea#th&first
search Complete+
es )if b )ma1 branch factor,is finite,
"ime+
= b b2
J b#
b)b#
&=, 7 )b#=
,( i'e'( e1ponential in # Space+
)b#=, )3eeps every no#e in memory,
ptimal+
nly if cost 7 = per step( other!ise not optimal in general Space is the big problem; it can easily generate no#es at
=0 @
-
8/9/2019 02 Solving Problems by Searching (Us)
39/48
-
8/9/2019 02 Solving Problems by Searching (Us)
40/48
-
8/9/2019 02 Solving Problems by Searching (Us)
41/48
=
9epth&limite# search
It is #epth&first search !ith an impose#
limit on the #epth of e1ploration( to
guarantee that the algorithm en#s'
=
-
8/9/2019 02 Solving Problems by Searching (Us)
42/48
2
"reatment of repeate# states
-
8/9/2019 02 Solving Problems by Searching (Us)
43/48
-
8/9/2019 02 Solving Problems by Searching (Us)
44/48
Iterative #eepening search
-
8/9/2019 02 Solving Problems by Searching (Us)
45/48
H
Iterative #eepening search
"he algorithm consists of iterative( #epth&first
searches( !ith a ma1imum #epth that increases at
each iteration' @a1imum #epth at the beginning is ='
-
8/9/2019 02 Solving Problems by Searching (Us)
46/48
Iterative #eepening search
-
8/9/2019 02 Solving Problems by Searching (Us)
47/48
Summary
All uninforme# searching techni.ues are more ali3e
than #ifferent'
-
8/9/2019 02 Solving Problems by Searching (Us)
48/48
8
Gninforme# vs' informe#