search in artificial intelligence

38
7/23/2019 Search in Artificial Intelligence http://slidepdf.com/reader/full/search-in-artificial-intelligence 1/38 L03 - SEARCH AS PROBLEM SOLVING METHOD Outline of this Letu!e Search as Problem-Solving Strategy Problem-solving agents What is search? Problem types Problem formulation Example problems Searching for solutions Basic search algorithms Se"!h "s P!o#le$-Sol%in& St!"te&' Many problems can be viewed as reaching a goal state from a given starting point often there is an underlying state space that defines the problem and its possible solutions in a more formal way the space can be traversed by applying a successor function operators! to proceed from one state to the next if possible" information about the specific problem or the general domain is used to improve the search experience from previous instances of the problem strategies expressed as heuristics simpler versions of the problem constraints on certain aspects of the problem P!o#le$-sol%in& "&ents #$

Upload: kofi

Post on 18-Feb-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 1/38

L03 - SEARCH AS PROBLEM SOLVING METHOD

Outline of this Letu!e• Search as Problem-Solving Strategy

• Problem-solving agents

• What is search?

• Problem types

• Problem formulation

• Example problems

• Searching for solutions

• Basic search algorithms

Se"!h "s P!o#le$-Sol%in& St!"te&'Many problems can be viewed as reaching a goal state from a given starting point

often there is an underlying state space that defines the problem and its possiblesolutions in a more formal way

• the space can be traversed by applying a successor function operators! to proceed

from one state to the next

• if possible" information about the specific problem or the general domain is used to

improve the search

experience from previous instances of the problem

strategies expressed as heuristics

simpler versions of the problem

constraints on certain aspects of the problem

P!o#le$-sol%in& "&ents

#$

Page 2: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 2/38

%gents whose tas& it is to solve a particular problem need'

  &o"l fo!$ul"tion

what is the goal state?

what are important characteristics of the goal state?

how does the agent &now that it has reached the goal?

are there several possible goal states?

o are they equal or are some more preferable?

  (!o#le$ fo!$ul"tion

what are the possible states of the world relevant for solving the problem? what information is accessible to the agent?

how can the agent progress from state to state?

)h"t is Se"!h*  (he basic idea of search'

• Before actually doing something in order to solve a problem)pu**le" the possible

solutions will be explored+

• Search is an important approach to general-purpose problem-solving+

• Search techni,ues are the most important and pervasive general %

 programming techni,ue+

• Search . /mental! exploration of possibilities0

• When we ma&e a decision we can not be sure that we have made the best one unless we

explore various possibilities to at least some degree!

#1

Page 3: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 3/38

E+"$(les of Se"!h

• Before deciding on a move" a chess player will consider a number of possible moves"

weighing up the probable benefits of each+

• When trying to solve 2ubi&3s cube" a person may try a few moves in their head before

deciding on the next move+

 

(o solve a ma*e" we may follow some path which leads to a dead-end+ We then have to

go bac& to a previous choice-point and try an alternative+

Anothe! E+"$(le of Se"!h

n deciding to travel in 2omania" say from %rad to Bucharest" we would loo& at different routes

on a map before choosing one+ 4ow many possible routes are there?!

##

Page 4: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 4/38

Ho, to Se"!h

• Search is particularly useful for tac&ling problems for which a /direct0

method)algorithm is not &nown

- (raveling salesperson problem+

  - Many optimi*ation problems for example' best schedule for

5lympic 6ames!

• n the early days of %" it was thought that searching through possibilities  was enough+ 4owever" in interesting domains e+g+ chess! there are too

many possibilities+

• We need to search /intelligently0' evaluate possibilities without having to

investigate every single possibility+o!$ul"tion of Se"!h P!o#le$s

%ll search problems can be cast into the following general form'

• nitial State" such as

  - Starting city for a route 7(raveling Problem8  - % 9umbled 2ubi&3s 72ubi&3s :ube Problem8

• 6oal State 52 a test for goal state!" such as

- ;estination city 7(raveling Problem8

  - (he solved 2ubi&3s cube 72ubi&3s :ube Problem8

• (he permissible operators" such as

  - 6o to city x" the next city 7(raveling Problem8  - 2otate sub-cube 72ubi&3s :ube Problem8

(he problem formulation should therefore have'

• formal specification for the tas& of the agent which include

goal specification

states of the world

actions of the agent

identify the type of the problem what &nowledge does the agent have about the state of the world and the

conse,uences of its own actions

does the execution of the tas& re,uire up-to-date information

sensing is necessary during the execution

St"te "n. St"te S("e

#<

Page 5: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 5/38

• nitial state and 6oal state are essential in search+ So what is a state?

• % st"te is one status of the problem+ t captures all relevant information about the

 problem at that status" such as

% partial route from starting city to city =1" city =#" >" city =! 7(raveling Problem8

% unsolved 2ubi&3s cube the orientation of all sub-cubes of the cube!72ubi&3s :ube Problem8

• St"te S("e is the collection of all states - all possible statuses of the problem and the

transitions from one state to another state+ Sometimes it is also &nown as Se"!h S("e

or St"te G!"(h+

%ll possible routes 7(raveling Problem8

%ll possible combinations of sub-cubes 72ubi&3s :ube Problem8

o!$ul"tion fo! Se"!h P!o#le$

E+"$(le/ Ro$"ni"

n deciding to travel in 2omania" say from %rad to Bucharest" we would loo& at different routes

on a map before choosing one+

• o!$ul"te &o"l' be in Bucharest

#

Page 6: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 6/38

• o!$ul"te (!o#le$'

states' various cities

actions' drive between cities

• in. solution' se,uence of cities" for example' %rad" Sibiu" @agaras" Bucharest

%s a Sin&le-st"te (!o#le$ formulation

(his will be defined by four items" namely'

1+ initi"l st"te' for example' Aat %radA

#+ "tions o! suesso! funtion Sx! . set of action-state pairs

for example' S%rad! . C%rad D erind" erindF" > G

<+ &o"l test" can be

explicit " for example' x . Aat BucharestAimplicit " for example' :hec&matex!

+ ("th ost additive!

for example' sum of distances" number of actions executed" etc+

cx" a" y! is the step cost" assumed to be H $

% solution is a se,uence of actions leading from the initial state to a goal state

Seletin& " st"te s("e

• 2eal world is absurdly complex D state space must be abstracted for problem solving

• %bstract! state . set of real states

• %bstract! action . complex combination of real actions

@or example" A%rad D erindA represents a complex set of possible routes" detours"

rest stops" etc+

#I

Page 7: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 7/38

• @or guaranteed realisability" any real state Ain %radA must get to some real state Ain

erindA

• %bstract! solution . set of real paths that are solutions in the real world

• Each abstract action should be AeasierA than the original problem

P!o#le$ t'(es  Search problems can be categori*ed into several groups'

  Sin&le-st"te (!o#le$s

(he states are deterministic" fully observable+ (he next state can be

determined exactly and the solution is a se,uence+

%ccessible world and &nowledge of its actions allow the agent to &now

which state it will be in after a se,uence of actions

  Confo!$"nt (!o#le$s "lso 1no,n "s Senso! less (!o#le$ OR Multi-st"te(!o#le$2

(he states are non-observable - %gent may have no idea where it is+ (he

solution is a se,uence+

(he world is only partially accessible" and the agent has to consider several

 possible states as the outcome of a se,uence of actions

  Contin&en' (!o#le$s

t is nondeterministic and)or partially observable+ (he percepts provide new

information about current state often interleaveG search" execution+ (he

solution is usually a tree+

%t some points in the se,uence of actions" sensing may be re,uired to decide

which action to ta&eJ this leads to a tree of se,uences

  E+(lo!"tion (!o#le$s

  (he state space is un&nown+

the agent doesn3t &now the outcome of its actions" and must experiment to

#K

Page 8: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 8/38

discover states of the world and outcomes of actions

%s an illustration of these problem types we have the following'

Sin&le-st"te" start in LI+

Solution?' [Right, Suck]

#

Page 9: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 9/38

Confo!$"nt Senso! less2" start in 1,2,3,4,5,6,,!G for e"ample# Right goes

to 2,4,6,!GSolution?' [Right, Suck, $eft, Suck]

  Contingency

  Nondeterministic: Suck  may dirty a clean carpet   Partially observable: location, dirt at current location.

  Percept: [L, Clean], i.e., start in #5 or #7

Solution? [Right, if dirt then Suck]

)ell-Define. P!o#le$s  (hese are problems with a readily available formal specification

  initi"l st"te

starting point from which the agent sets out

  "tions o(e!"to!s suesso! funtions2

describe the set of possible actions

 

st"te s("e

set of all states reachable from the initial state by any se,uence of actions

  ("th

se,uence of actions leading from one state in the state space to another 

  &o"l test

determines if a given state is the goal state

  solution

 path from the initial state to a goal state

  se"!h ost

time and memory re,uired to calculate a solution

 

("th ost

#N

Page 10: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 10/38

determines the expenses of the agent for executing the actions in a path

sum of the costs of the individual actions in a path

  tot"l ost

sum of search cost and path cost

overall cost for finding a solution

C"te&o!' of P!o#le$s(here are two categories of problems'

(oy problems are'

Oacuum world

N-pu**le

N-,ueens

:rypt-arithmetic

Oacuum agent

Missionaries and :annibals

2eal-world problems are'

2oute finding

(ouring problems

(raveling salesperson

OS layout

2obot navigation

%ssembly se,uencing

Web search

#Q

Page 11: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 11/38

)ell-Define. P!o#le$s fo! the To' P!o#le$s

45 Si$(le V"uu$ )o!l.t is a made-up world'

• (here are only two s,uares"

• and an vacuum cleaner which can perceive which s,uare it is in and whether

there is dirt in the s,uare+

• (he cleaner can choose to move left" move right" suc& up the dirt" or do nothing+

• (he goal is to have no dirt in both s,uares+

 

hence it is well formulated as follows'

  st"tes two locations

dirty" clean

  initi"l st"te

any legitimate state

<$

Page 12: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 12/38

• suesso! funtion operators!

left" right" suc& 

  &o"l test

all s,uares clean

 

("th ost

one unit per action

P!o(e!ties' discrete locations" discrete dirt binary!" deterministic

V"uu$ ,o!l. st"te s("e &!"(h

• st"tes*' integer dirt and robot location

<1

Page 13: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 13/38

• "tions*' eft" 2ight" Suc& 

• &o"l test*' no dirt at all locations

• ("th ost*' 1 per action

65 Mo!e Co$(le+ V"uu$ A&ent  st"tes

configuration of the room

dimensions" obstacles" dirtiness

  initi"l st"te

locations of agent" dirt

• suesso! funtion operators!

move" turn" suc& 

  &o"l test all s,uares clean

  ("th ost

one unit per action

P!o(e!ties' discrete locations" discrete dirt" deterministic" % & 2' states for dirtdegree % " ' locations

35 7-Pu88le  st"tes

location of tiles including blan& tile!

  initi"l st"te

any legitimate configuration

• suesso! funtion operators!

move tile

alternatively' move blan& 

  &o"l test any legitimate configuration of tiles

  ("th ost

one unit per move

P!o(e!ties' abstraction leads to discrete configurations" discrete moves"

<#

Page 14: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 14/38

  deterministic

QR)# . 1N1"$ reachable states

  A ("!tiul"! 7-(u88le (!o#le$

• st"tes*/ locations of tiles

• "tions*' move blan& left" right" up" down

• &o"l test*' is the goal state given

• ("th ost*' one unit per move

7Note' optimal solution of n-Pu**le family is P-hard8

95 7-:ueens @or incremental formulation

  st"tes

arrangement of up to N ,ueens on the board

  initi"l st"te

empty board

• suesso! funtion operators!

add a ,ueen to any s,uare

  &o"l test

all ,ueens on board no ,ueen attac&ed

  ("th ost

irrelevant all solutions e,ually valid!

P!o(e!ties' <T1$1 possible se,uencesJ can be reduced to #"$I

@or complete-state formulation

<<

Page 15: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 15/38

  st"tes

arrangement of N ,ueens on the board

  initi"l st"te

all N ,ueens on board

• suesso! funtion operators!

move a ,ueen to a different s,uare

  &o"l test

no ,ueen attac&ed

  ("th ost

irrelevant all solutions e,ually valid!

P!o(e!ties' good strategies can reduce the number of possible se,uences

considerably

;5 7-:ueens Refine.

• simple solutions may lead to very high search costs K fields" N ,ueens ..F KN possible se,uences

• more refined solutions trim the search space" but may introduce other

constraints

 place ,ueens on /unattac&ed0 places

much more efficient

may not lead to a solutions depending on the initial moves

move an attac&ed ,ueen to another s,uare in the same column" if possible to

an /unattac&ed0 s,uare

much more efficient

<5 C!'(t-"!ith$eti  st"tes

 pu**le with letters and digits

  initi"l st"te

only letters present

• suesso! funtion operators!

replace all occurrences of a letter by a digit not used yet

  &o"l test

only digits in the pu**le

calculation is correct

  ("th ost

all solutions are e,ually valid

<

Page 16: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 16/38

=5 Mission"!ies "n. C"nni#"ls 

st"tes

number of missionaries" cannibals" and boats on the ban&s of a river 

illegal states

missionaries are outnumbered by cannibals on either bank 

  initi"l st"tes

all missionaries" cannibals" and boats are on one ban& 

• suesso! funtion operators!

transport a set of up to two participants to the other ban& 

{1 missionary} | { 1cannibal} | {2 missionaries} | {2 cannibals} |

{1 missionary and 1 cannibal}

 

&o"l test nobody left on the initial river ban& 

  ("th ost

number of crossings

/Mission"!ies "n. C"nni#"ls0 is also &nown as /C"##"&e "n. Go"ts0"

/Shee( "n. )ol%es0" /Mie "n. C"ts0" etc

The Mission"!ies "n. C"nni#"ls (!o#le$ is a classic % pu**le that can be defined as follows'

(' o'e ba'k of a ri)er are three missio'aries a'% three ca''ibals* +here is o'e boat a)ailable

that ca' hol% up to to people a'% that they oul% like to use to cross the ri)er* -f the ca''ibals

e)er out'umber the missio'aries o' either of the ri)er.s ba'ks, the missio'aries ill get eate'* /o ca' the boat be use% to safely carry all the missio'aries a'% 

ca''ibals across the ri)er0

(he initial state is shown to the right here" where blac& triangles represent

missionaries and red circles represent cannibals+

Searching for a Solution(his problem can be solved by searching for a solution" which is a se,uence of actions that leads

from the initial state to the goal state+ (he goal state is effectively a mirror image of the initial

state+ (he complete search space is shown in figure 1+

<I

Page 17: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 17/38

 igure 1# Searchspace for the issio'aries a'% a''ibals problem

%rrows in figure 1 represent state transitions and are labeled with actions" e+g+ #c represents the

action of two cannibals crossing the river+ (he initial state is shown again on the left" whereas thegoal state is all the way to the right+

)ell-Define. P!o#le$s fo! the Re"l-,o!l. P!o#le$s

45 Route in.in&  st"tes

locations

  initi"l st"te

starting point

• suesso! funtion operators!

move from one location to another 

  &o"l test

arrive at a certain location

  ("th ost

may be ,uite complex

money" time" travel comfort" scenery" +++

<K

Page 18: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 18/38

65 T!"%elin& S"les(e!son 

st"tes

locations ) cities

illegal states

each city may be visited only once visited cities must be &ept as state information

  initi"l st"te

starting point

no cities visited

• suesso! funtion operators!

move from one location to another one

  &o"l test

all locations visited agent at the initial location

  ("th ost

distance between locations

35 VLSI L"'out  st"tes

 positions of components" wires on a chip

 

initi"l st"te

incremental' no components placed

complete-state' all components placed e+g+ randomly" manually!

• suesso! funtion operators!

incremental' place components" route wire

complete-state' move component" move wire

  &o"l test

all components placed

components connected as specified

  ("th ost

<

Page 19: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 19/38

may be complex

distance" capacity" number of connections per component

95 Ro#ot N"%i&"tion

  st"tes locations

 position of actuators

  initi"l st"te

start position dependent on the tas&!

• suesso! funtion operators!

movement" actions of actuators

 

&o"l test tas&-dependent

  ("th ost

may be very complex

distance" energy consumption

;5 Asse$#l' Se>uenin&  st"tes

location of components

  initi"l st"te

no components assembled

suesso! funtion operators!  place component

  &o"l test

system fully assembled

("th ost

number of moves

<N

Page 20: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 20/38

<5 Ro#oti "sse$#l'

• st"tes*' real-valued coordinates of robot 9oint angles parts of the ob9ect to be

assembled

• "tions*' continuous motions of robot 9oints

• &o"l test*' complete assembly

• ("th ost*' time to execute

Se"!hin& fo! Solutions

• (raversal of the search space

from the initial state to a goal state

legal se,uence of actions as defined by successor function operators!

6eneral procedure chec& for goal state

expand the current state

determine the set of reachable states

return /failure0 if the set is empty

select one from the set of reachable states

move to the selected state

<Q

Page 21: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 21/38

• % search tree is generated

nodes are added as more states are visited

Se"!h Te!$inolo&'

• Search tree

generated as the search space is traversed

the search space itself is not necessarily a tree" fre,uently it is a graph

the tree specifies possible paths through the search space

expansion of nodes

as states are explored" the corresponding nodes are e"pa'%e%  by applying

the successor function

this generates a new set of (child) nodes

the fri'ge frontier! is the set of nodes not yet visited

newly generated nodes are added to the fringe search strategy

determines the selection of the next node to be expanded

can be achieved by ordering the nodes in the fringe

eg !ueue ("#"$)% stack (&#"$)% 'best node with respect to some

measure (cost)

E+"$(le/ G!"(h Se"!h

• (he graph describes the search state! space

each node in the graph represents one state in the search space

e+g+ a city to be visited in a routing or touring problem

• (his graph has additional information

names and properties for the states e+g+ S" <!

lin&s between nodes" specified by the successor function

 properties for lin&s distance" cost" name" +++!

G!"(h "n. T!ee

$

Page 22: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 22/38

Below is a graph

• (he tree is generated by traversing the graph as shown below!

• (he same node in the graph may appear repeatedly in the tree

• (he arrangement of the tree depends on the traversal strategy search method!

• (he initial state becomes the root node of the tree

• n the fully expanded tree" the goal states are the leaf nodes

• :ycles in graphs may result in infinite branches

T!ee se"!h "l&o!ith$s

1

Page 23: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 23/38

B"si i.e"'

offline" simulated exploration of state space by generating successors of already-explored states

also &nown as Uexpanding states!

Gene!"l T!ee Se"!h Al&o!ith$

funtion (2EE-SE%2:4 problem, fri'ge! !etu!ns  solutio'

 fri'ge # SE2(M%VE-5;E(%-S(%(E7 problem8!" fri'ge!

  loo( .o

  if  EMP(? fri'ge then !etu!n failure

  'o%e '. 2EM5OE-@2S( fri'ge!

  if 65%-(ES(7 problem8 applied to S(%(E7'o%e] succee%s

then !etu!n S5X(5'o%e

   fri'ge # SE2(-%E=P%;'o%e, problem!" fri'ge!

T!ee se"!h e+"$(le ? @sin& t!"%el in Ro$"ni" initi"l ste(2

T!ee se"!h e+"$(le ? fi!st e+("nsion

#

Page 24: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 24/38

T!ee se"!h e+"$(le ? seon. e+("nsion

I$(le$ent"tion/ &ene!"l t!ee se"!h

<

Page 25: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 25/38

I$(le$ent"tion/ &ene!"l Se"!h "l&o!ith$

funtion 6EE2%-SE%2:4 problem, 7898-:;: ! !etu!ns  solutio''o%es # M%VE-YXEXEM%VE-5;E(%-S(%(E7 problem8!! loo( .o

  if 'o%es is empty then !etu!n failure

  'o%e '. 2EM5OE-@25('o%es!

  if 65%-(ES(7 problem8 applied to S(%(E'o%e succee%s

then !etu!n 'o%e

  'o%es # YXEX6-@'o%es, E=P%;'o%e, 5PE2%(52S7 problem8!!

  en.

I$(le$ent"tion/ st"tes %s5 no.es

Page 26: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 26/38

• % st"te is a representation of! a physical configuration

• % no.e is a data structure constituting part of a search tree includes state" parent node"

action" path cost gx!" depth

(he xpand  function creates new nodes" filling in the various fields and using the  *uccessor"n 

of the problem to create the corresponding states+

Se"!h st!"te&ies• % search strategy is defined by pic&ing the order of node expansion

• Strategies are evaluated along the following dimensions'

o$(leteness'

o does it always find a solution if one exists?

o if there is a solution" will it be found

ti$e o$(le+it''

o number of nodes generated

o how long does it ta&e to find the solution

o does not include the time to perform actions s("e o$(le+it''

o maximum number of nodes in memory

o memory re,uired for the search

o(ti$"lit''

o does it always find a least-cost solution?

o will the best solution be found

(ime 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 Z!

Se"!h "n. P"th Cost

I

Page 27: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 27/38

(he search cost  indicates how expensive it is to generate a solution

time complexity e+g+ number of nodes generated! is usually the

main factor  sometimes space complexity memory usage! is considered as well

(he  path cost  indicates how expensive it is to execute the solution found in the search distinct from the search cost" but often related

(he total cost  is the sum of search and path costs

Seletion of " Se"!h St!"te&'

Most of the effort is often spent on the selection of an appropriate search strategy for a

given problem which may be one of the following'

uninformed search blind search!

use only the information available in the problem definition number of steps" path cost un&nown

agent &nows when it reaches a goal

informed search heuristic search!

agent has bac&ground information about the problem

o map% costs of actions

Some of the Xninformed Search strategies are'

Breadth-first search

;epth-first search

Xniform-cost search

;epth-limited search

terative deepening search

Bi-directional search

:onstraint satisfaction

Some of the nformed Search strategies are'

Best-first search

6reedy best-first search

%T search

4euristics ocal search algorithms

4ill-climbing search

Simulated annealing search

ocal beam search

K

Page 28: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 28/38

@ninfo!$e. se"!h st!"te&ies use onl' the info!$"tion "%"il"#le in the

(!o#le$ .efinition2

 

B!e".th-fi!st se"!h Expand shallowest unexpanded node

mplementation'

fringe is a @@5 ,ueue" i+e+" new successors go at end'

,ueue .%

fringe is a @@5 ,ueue" i+e+" new successors go at end'

,ueue' %" B" :

Page 29: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 29/38

fringe is a @@5 ,ueue" i+e+" new successors go at end',ueue . %" B" :" ;" E

fringe is a @@5 ,ueue" i+e+" new successors go at end'

,ueue . %" B" :" ;" E" @" 6

N

Page 30: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 30/38

 

P!o(e!ties of B!e".th-fi!st se"!h

Co$(lete* es if b is finite!

Ti$e* 1[b[b#[b<[+ [bd [ bbd-1! . 5bd[1!

S("e* 5bd[1! &eeps every node in memory!

O(ti$"l* es if cost . 1 per step!

 *pace is the bigger problem (more than time)

 

@nifo!$-ost se"!h Expand least-cost unexpanded node

mplementation'

fringe . ,ueue ordered by path cost

E,uivalent to breadth-first if step costs all e,ual

Properties of Xniform-cost search

Co$(lete* es" if step cost H \

Q

Page 31: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 31/38

Ti$e* L of nodes with g ] cost of optimal solution" 5b ceiling:T)\!! where

:T is the cost of the optimal solution

S("e* L of nodes with g ] cost of optimal solution" 5bceiling:T)\!!

O(ti$"l* es - nodes expanded in increasing order of gn!

 

De(th-fi!st se"!h

Expand deepest unexpanded node

mplementation'

fringe . @5 ,ueue" i+e+" put successors at front

I$

Page 32: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 32/38

%t this stage" the @5 ,ueue will contain' :" B" %+

(he output ,ueue will contain' no nodes+

%t this stage" the @5 ,ueue will contain' M" 6" @" :" %+

(he output ,ueue will contain' 4" " ;" ^" V" E" B" nodes in that order!+

Properties of depth-first search

Co$(lete* o' fails in infinite-depth spaces" spaces with loops

Modify to avoid repeated states along pathà complete in finite spaces

Ti$e* 5bm!' terrible if m is much larger than d

 but if solutions are dense" may be much faster than breadth-first

S("e* 5bm!" i+e+" linear spaceR

O(ti$"l* o

I1

Page 33: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 33/38

 

De(th-li$ite. se"!h

t is the same as depth-first search with depth limit l+ (his is because nodes at depth l

have no successors

2ecursive implementation' 2ecursive application of depth-first search!

  Ite!"ti%e .ee(enin& se"!h

I#

Page 34: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 34/38

Ite!"ti%e .ee(enin& se"!h l 0

Ite!"ti%e .ee(enin& se"!h l 4

I<

Page 35: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 35/38

Ite!"ti%e .ee(enin& se"!h l 6

Ite!"ti%e .ee(enin& se"!h l 3

I

Page 36: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 36/38

terative deepening search

 umber of nodes generated in a depth-limited search to depth d

 with branching factor b' ;S . b$ [ b1 [ b# [ > [ bd-# [ bd-1 [ bd 

 umber of nodes generated in an iterative deepening search to depth d with

 branching factor b'

 ;S . d[1!b$

 [ d b1

 [ d-1!b#

 [ > [ <bd-#

 [#bd-1

 [ 1bd

 

@or b . 1$" d . I"

 ;S . 1 [ 1$ [ 1$$ [ 1"$$$ [ 1$"$$$ [ 1$$"$$$ . 111"111

 ;S . K [ I$ [ $$ [ <"$$$ [ #$"$$$ [ 1$$"$$$ . 1#<"IK

5verhead . 1#<"IK - 111"111!)111"111 . 11_

  P!o(e!ties of ite!"ti%e .ee(enin& se"!h

Co$(lete* es

Ti$e* d[1!b$ [ d b1 [ d-1!b# [ > [ bd . 5bd!

S("e* 5bd!

O(ti$"l* es" if step cost . 1

Su$$"!' of "l&o!ith$s

II

Page 37: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 37/38

Re(e"te. st"tes@ailure to detect repeated states can turn a linear problem into an exponential oneR

G!"(h se"!h

IK

Page 38: Search in Artificial Intelligence

7/23/2019 Search in Artificial Intelligence

http://slidepdf.com/reader/full/search-in-artificial-intelligence 38/38

Su$$"!'• Problem formulation usually re,uires abstracting away real-world details to define a state

space that can feasibly be explored

• Oariety of uninformed search strategies

• terative deepening search uses only linear space and not much more time than other

uninformed algorithms