Prolm solving y srh Tomáš voo Dprtmnt o Cyrntis, Vision or Roots n Autonomous ystms Mrh 5, 208 / 3
Outlin rh prolm. tt sp grphs. rh trs. trtgis, whih tr rnhs to hoos? trtgy/algorithm proprtis? Progrmming instrstrutur 2 / 3
Exmpl: Romni Or 7 Nmt 75 Zrin 87 5 Isi Ar 40 iiu 99 Fgrs 92 8 80 Timisor Rimniu Vil 42 Lugoj Pitsti 2 97 70 98 Mhi 46 0 85 Urzini 75 38 Buhrst Dort 20 90 Criov iurgiu Vslui Hirsov 86 Eori 3 / 3
Exmpl: Romni ol: in Buhrst Prolm ormultion: stts: position in ity (itis) tions: riv twn itis olution: qun o itis (pth) Or 7 Nmt Zrin 87 75 5 Isi Ar 40 92 iiu 99 Fgrs 8 Vslui 80 Timisor Rimniu Vil 42 Lugoj Pitsti 2 97 70 98 Hirsov Mhi 46 0 85 Urzini 75 38 86 Buhrst Dort 20 90 Criov Eori iurgiu 4 / 3
Exmpl: Th 8-puzzl 7 2 4 5 2 3 5 6 4 5 6 8 3 7 8 stts? tions? solution? ost? trt tt ol tt 5 / 3
Exmpl: Vuum lnr L R L R L R R L R R L L L R L R stts? tions? solution? ost? 6 / 3
A rh Prolm tt sp (inluing trt/initil stt): position, or onigurtion, Ations: riv to, Up, Down, Lt... Trnsition mol: ivn stt n tion rturn stt (n ost) ol tst: Ar w on? 7 / 3
tt p rphs tt sp grph: srh prolm Nos r strt worl onigurtions Ars rprsnt tion rsults rprsnttion o ol tst is st o gol nos Eh stt ours only on in stt (srh) sp. 8 / 3
rh Trs Hr w strt Possil uturs A wht i tr o plns n thir outoms trt no is th root Chilrn r sussors Nos show stts, ut orrspon to plns tht hiv thos stts Wht os th lst itm mn, tully? 9 / 3
tt p rphs vs. rh Trs How ig is th srh tr? 0 / 3
rh tr or Romni () Th initil stt Ar iiu Timisor Zrin Ar Fgrs Or Rimniu Vil Ar Lugoj Ar Or () Atr xpning Ar Ar iiu Timisor Zrin Ar Fgrs Or Rimniu Vil Ar Lugoj Ar Or () Atr xpning iiu Ar iiu Timisor Zrin Ar Fgrs Or Rimniu Vil Ar Lugoj Ar Or / 3
rh lmnts iiu Timisor Zrin Ar Fgrs Or Rimniu Vil Ar Lugoj Ar Or () Atr xpning iiu Ar iiu Timisor Zrin Ar Fgrs Or Rimniu Vil Ar Lugoj Ar Or Expn plns - possil wys (tr nos). Mng/Mintn ring (or rontir) o plns unr onsirtion. Expn nw nos wisly(?). 2 / 3
iiu Zrin Rimniu Vil Tr srh lgorithmar Ar Fgrs Or Lugoj Ar Or () Atr xpning iiu Ar iiu Timisor Zrin Ar Fgrs Or Rimniu Vil Ar Lugoj Ar Or untion tr srh(prolm) rturn solution or ilur initiliz y using th initil stt o th prolm loop i no nits or xpnsion thn rturn ilur ls hoos l no or xpnsion n i i th no ontins gol stt thn rturn th solution n i Expn th no n th rsulting nos to th tr n loop n untion 3 / 3
Exmpl o tr srh Whih nos to xplor? Wht r th proprtis o strtgy/lgorithm? 4 / 3
rh (lgorithm) proprtis Complt? urnt to in solution (i xists)? Optiml? urnt to in th lst ost pth? Tim omplxity? How mny stps - n oprtion with no? p omplxity? How mny nos to rmmr? How mny nos in tr? Wht r tr prmtrs? 5 / 3
Dpth-First rh (DF) Wht r th DF proprtis? 6 / 3
DF proprtis Complt? Optiml? Tim omplxity? p omplxity? 7 / 3
Brth-First rh (BF) Wht r th BF proprtis? 8 / 3
BF proprtis Complt? Optiml? Tim omplxity? p omplxity? 9 / 3
DF vs BF 20 / 3
DF with limit pth, mxpth=2 Do not ollow nos with pth > mxpth 2 / 3
Itrtiv pning DF (ID-DF) trt with mxpth = Prorm DF with limit pth. Rport suss or ilur. I ilur, orgt vrything, inrs mxpth n rpt DF Is it not trril wst to orgt vrything twn stps? 22 / 3
Cost snsitiv srh 3.5,0 2,,2,2,,2,2,,2 In BF, DF, no ±pth ws th no-vlu. How ws th pth tully omput? How to vlut nos with pth ost? 23 / 3
Uniorm Cost rh (UC).5,0 2,,,3 3,2,2.5,2,2,3,4,3 Whn to hk th gol (n stop) th srh? Whn visiting or xpning th no? 24 / 3
Whn to stop, whn visiting or xpning?.5,0 2,,,3.2 3 0.5,2,2.5,2.2,2,3,4,3,2.7,3 25 / 3
iorm#cost#r Exmpl: rph with osts 3 2 p 5 8 9 2 h 8 2 q r 2 26 / 3
UC proprtis 27 / 3
Progrmming Tr rh 28 / 3
Inrstrutur or (tr) srh lgorithms Wht shoul tr no n now? n.stt n.prnt n.pthost Prhps w my somthing ltr, i n... 29 / 3
How to orgniz nos? Th Python xmpls r just suggstions,... A ynmilly link strutur (list()). A no (list.insrt(no)). Tk no n rmov rom th strutur (no=list.pop()). Chk th Python mouls hpq n quu 2 or inspirtion. https://os.python.org/3.5/lirry/hpq.html 2 https://os.python.org/3.5/lirry/quu.html 30 / 3
Wht is th solution? W stop whn ol is rh. How o w ontrut th pth? 3 / 3