mirror of
https://github.com/NotXia/unibo-ai-notes.git
synced 2025-12-14 18:51:52 +01:00
Add FAIKR non-informed search
This commit is contained in:
BIN
src/fundamentals-of-ai-and-kr/img/_bfs.pdf
Normal file
BIN
src/fundamentals-of-ai-and-kr/img/_bfs.pdf
Normal file
Binary file not shown.
BIN
src/fundamentals-of-ai-and-kr/img/_dfs.pdf
Normal file
BIN
src/fundamentals-of-ai-and-kr/img/_dfs.pdf
Normal file
Binary file not shown.
BIN
src/fundamentals-of-ai-and-kr/img/_search_tree.pdf
Normal file
BIN
src/fundamentals-of-ai-and-kr/img/_search_tree.pdf
Normal file
Binary file not shown.
BIN
src/fundamentals-of-ai-and-kr/img/_ucs.pdf
Normal file
BIN
src/fundamentals-of-ai-and-kr/img/_ucs.pdf
Normal file
Binary file not shown.
85
src/fundamentals-of-ai-and-kr/img/non_informed_tree.drawio
Normal file
85
src/fundamentals-of-ai-and-kr/img/non_informed_tree.drawio
Normal file
@ -0,0 +1,85 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-09-30T10:53:02.134Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0" etag="HIlGrnAEbyHg43-qtSPV" version="22.0.0" type="device">
|
||||
<diagram name="Pagina-1" id="VzRX3VsKA3ARjDLkncGv">
|
||||
<mxGraphModel dx="989" dy="514" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-1" value="1" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="364" y="170" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-2" value="3" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="260" y="260" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-3" value="7" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="364" y="260" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-4" value="2" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="260" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-5" value="6" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="210" y="350" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-6" value="5" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="310" y="350" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-7" value="4" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fontFamily=Times New Roman;fontSize=24;" parent="1" vertex="1">
|
||||
<mxGeometry x="460" y="350" width="50" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-8" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;fontFamily=Times New Roman;fontSize=24;" parent="1" source="2uR5KkTxT499U1MgxyAB-2" target="2uR5KkTxT499U1MgxyAB-1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="410" y="380" as="sourcePoint" />
|
||||
<mxPoint x="460" y="330" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-9" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;fontFamily=Times New Roman;fontSize=24;" parent="1" source="2uR5KkTxT499U1MgxyAB-3" target="2uR5KkTxT499U1MgxyAB-1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="410" y="380" as="sourcePoint" />
|
||||
<mxPoint x="460" y="330" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-10" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;fontFamily=Times New Roman;fontSize=24;" parent="1" source="2uR5KkTxT499U1MgxyAB-4" target="2uR5KkTxT499U1MgxyAB-1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="410" y="380" as="sourcePoint" />
|
||||
<mxPoint x="460" y="330" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-11" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;fontFamily=Times New Roman;fontSize=24;" parent="1" source="2uR5KkTxT499U1MgxyAB-5" target="2uR5KkTxT499U1MgxyAB-2" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="410" y="380" as="sourcePoint" />
|
||||
<mxPoint x="460" y="330" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-12" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;fontFamily=Times New Roman;fontSize=24;" parent="1" source="2uR5KkTxT499U1MgxyAB-6" target="2uR5KkTxT499U1MgxyAB-2" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="410" y="380" as="sourcePoint" />
|
||||
<mxPoint x="460" y="330" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-13" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;fontFamily=Times New Roman;fontSize=24;" parent="1" source="2uR5KkTxT499U1MgxyAB-7" target="2uR5KkTxT499U1MgxyAB-4" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="370" y="360" as="sourcePoint" />
|
||||
<mxPoint x="420" y="310" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-14" value="<div align="right"><font style="font-size: 20px;" face="Times New Roman"><i>c</i>=4 (4)</font></div>" style="text;html=1;strokeColor=none;fillColor=none;align=right;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="270" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-15" value="<div align="right"><font style="font-size: 20px;" face="Times New Roman"><i>c</i>=4 (8)</font></div>" style="text;html=1;strokeColor=none;fillColor=none;align=right;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="130" y="360" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-16" value="<div><font style="font-size: 20px;" face="Times New Roman"><i>c</i>=2 (6)</font></div>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="360" y="360" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-17" value="<div><font style="font-size: 20px;" face="Times New Roman"><i>c</i>=3 (5)</font></div>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="510" y="360" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-18" value="<div><font style="font-size: 20px;" face="Times New Roman"><i>c</i>=2 (2)</font></div>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="510" y="270" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="2uR5KkTxT499U1MgxyAB-19" value="<div><font style="font-size: 20px;" face="Times New Roman"><i>c</i>=9 (9)</font></div>" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="358" y="305" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
100
src/fundamentals-of-ai-and-kr/img/search_tree.drawio
Normal file
100
src/fundamentals-of-ai-and-kr/img/search_tree.drawio
Normal file
@ -0,0 +1,100 @@
|
||||
<mxfile host="app.diagrams.net" modified="2023-09-30T08:39:29.638Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0" etag="wNwkhq1XYC7xy40uFgd9" version="21.8.1" type="device">
|
||||
<diagram name="Pagina-1" id="CXlOY20UPXUAhCokS_2Q">
|
||||
<mxGraphModel dx="1195" dy="622" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-1" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="384" y="144" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-2" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="300" y="270" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-3" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="384" y="270" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-4" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="470" y="270" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-10" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="dcn3nJ8A0_6me1Pj84pl-2" target="dcn3nJ8A0_6me1Pj84pl-1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="400" y="350" as="sourcePoint" />
|
||||
<mxPoint x="450" y="300" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-11" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="dcn3nJ8A0_6me1Pj84pl-3" target="dcn3nJ8A0_6me1Pj84pl-1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="400" y="350" as="sourcePoint" />
|
||||
<mxPoint x="450" y="300" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-12" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="dcn3nJ8A0_6me1Pj84pl-1" target="dcn3nJ8A0_6me1Pj84pl-4">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="400" y="350" as="sourcePoint" />
|
||||
<mxPoint x="450" y="260" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-13" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="393.5" y="370" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-14" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="470" y="370" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-15" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
||||
<mxGeometry x="544" y="370" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-16" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="dcn3nJ8A0_6me1Pj84pl-13" target="dcn3nJ8A0_6me1Pj84pl-4">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="525" y="480" as="sourcePoint" />
|
||||
<mxPoint x="529" y="370" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-17" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="dcn3nJ8A0_6me1Pj84pl-14" target="dcn3nJ8A0_6me1Pj84pl-4">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="525" y="480" as="sourcePoint" />
|
||||
<mxPoint x="529" y="370" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-18" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" target="dcn3nJ8A0_6me1Pj84pl-15" source="dcn3nJ8A0_6me1Pj84pl-4">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="529" y="370" as="sourcePoint" />
|
||||
<mxPoint x="575" y="390" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-19" value="<font style="font-size: 24px;" face="Times New Roman">Root</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="324" y="149" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-20" value="<font style="font-size: 24px;" face="Times New Roman">Expansion</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="524" y="196.6" width="110" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-22" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="520" y="269.6" as="sourcePoint" />
|
||||
<mxPoint x="520" y="184" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-23" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="510" y="269.6" as="sourcePoint" />
|
||||
<mxPoint x="530" y="269.6" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-24" value="" style="endArrow=none;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="510" y="184" as="sourcePoint" />
|
||||
<mxPoint x="530" y="184" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-25" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="428" y="193" as="sourcePoint" />
|
||||
<mxPoint x="494" y="258" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="dcn3nJ8A0_6me1Pj84pl-26" value="<font style="font-size: 24px;" face="Times New Roman">Strategy</font>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;rotation=43.5;" vertex="1" parent="1">
|
||||
<mxGeometry x="414" y="197" width="110" height="28.9" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
@ -9,9 +9,34 @@
|
||||
\usepackage{marginnote}
|
||||
\usepackage[bottom]{footmisc}
|
||||
\usepackage{scrlayer-scrpage}
|
||||
\usepackage{algorithm, listings}
|
||||
\usepackage{array, makecell}
|
||||
\geometry{ margin=3cm, lmargin=1.5cm, rmargin=4.5cm, marginparwidth=3cm }
|
||||
\hypersetup{ colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=black, linktoc=all }
|
||||
|
||||
\definecolor{codegreen}{rgb}{0,0.6,0}
|
||||
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
|
||||
\definecolor{codepurple}{rgb}{0.58,0,0.82}
|
||||
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
|
||||
\lstdefinestyle{mystyle}{
|
||||
commentstyle = \color{codegreen},
|
||||
keywordstyle = \color{magenta},
|
||||
numberstyle = \tiny\color{codegray},
|
||||
stringstyle = \color{codepurple},
|
||||
basicstyle = \footnotesize\ttfamily,
|
||||
breakatwhitespace = false,
|
||||
breaklines = true,
|
||||
captionpos = b,
|
||||
keepspaces = true,
|
||||
numbers = none,
|
||||
showspaces = false,
|
||||
showstringspaces = true,
|
||||
showtabs = false,
|
||||
tabsize = 3
|
||||
}
|
||||
\lstset{style=mystyle}
|
||||
\lstset{language=Python}
|
||||
|
||||
\NewDocumentEnvironment{descriptionlist}{}{%
|
||||
\begin{description}[labelindent=1em]
|
||||
}{
|
||||
@ -60,6 +85,7 @@
|
||||
\pagenumbering{arabic}
|
||||
|
||||
\input{sections/_intro.tex}
|
||||
\input{sections/_search.tex}
|
||||
|
||||
|
||||
\end{document}
|
||||
182
src/fundamentals-of-ai-and-kr/sections/_search.tex
Normal file
182
src/fundamentals-of-ai-and-kr/sections/_search.tex
Normal file
@ -0,0 +1,182 @@
|
||||
\chapter{Search problems}
|
||||
|
||||
|
||||
|
||||
\section{Search strategies}
|
||||
\begin{description}
|
||||
\item[Solution space] \marginnote{Solution space}
|
||||
Set of all the possible sequences of actions an agent may apply.
|
||||
Some of these lead to a solution.
|
||||
|
||||
\item[Search algorithm] \marginnote{Search algorithm}
|
||||
Takes a problem as input and returns a sequence of actions that solves the problem (if exists).
|
||||
\end{description}
|
||||
|
||||
|
||||
\subsection{Search tree}
|
||||
\begin{description}
|
||||
\item[Expansion] \marginnote{Expansion}
|
||||
Starting from a state, apply a successor function and generate a new state.
|
||||
|
||||
\item[Search strategy] \marginnote{Search strategy}
|
||||
Choose which state to expand.
|
||||
Usually is implemented using a fringe that decides which is the next node to expand.
|
||||
|
||||
\item[Search tree] \marginnote{Search tree}
|
||||
Tree structure to represent the expansion of all states starting from a root
|
||||
(i.e. the representation of the solution space).
|
||||
|
||||
Nodes are states and branches are actions.
|
||||
A leaf can be a state to expand, a solution or a dead-end.
|
||||
\Cref{alg:search_tree_search} describes a generic tree search algorithm.
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\includegraphics[width=0.25\textwidth]{img/_search_tree.pdf}
|
||||
\caption{Search tree}
|
||||
\end{figure}
|
||||
|
||||
Each node contains:
|
||||
\begin{itemize}
|
||||
\item The state
|
||||
\item The parent node
|
||||
\item The action that led to this node
|
||||
\item The depth of the node
|
||||
\item The cost of the path from the root to this node
|
||||
\end{itemize}
|
||||
\end{description}
|
||||
|
||||
\begin{algorithm}
|
||||
\caption{Tree search algorithm} \label{alg:search_tree_search}
|
||||
\begin{lstlisting}
|
||||
def treeSearch(problem, fringe):
|
||||
fringe.push(problem.initial_state)
|
||||
# Get a node in the fringe and expand it if it is not a solution
|
||||
while fringe.notEmpty():
|
||||
node = fringe.pop()
|
||||
if problem.isGoal(node.state):
|
||||
return node.solution
|
||||
fringe.pushAll(expand(node, problem))
|
||||
return FAILURE
|
||||
|
||||
def expand(node, problem):
|
||||
successors = set()
|
||||
# List all neighboring nodes
|
||||
for action, result in problem.successor(node.state):
|
||||
s = new Node(
|
||||
parent=node, action=action, state=result, depth=node.dept+1,
|
||||
cost=node.cost + problem.pathCost(node, s, action)
|
||||
)
|
||||
successors.add(s)
|
||||
return successors
|
||||
\end{lstlisting}
|
||||
\end{algorithm}
|
||||
|
||||
|
||||
\subsection{Strategies}
|
||||
\begin{description}
|
||||
\item[Non-informed strategy] \marginnote{Non-informed strategy}
|
||||
Domain knowledge not available. Usually does an exhaustive search.
|
||||
|
||||
\item[Informed strategy] \marginnote{Informed strategy}
|
||||
Use domain knowledge by using heuristics.
|
||||
\end{description}
|
||||
|
||||
|
||||
\subsection{Evaluation}
|
||||
\begin{description}
|
||||
\item[Completeness] \marginnote{Completeness}
|
||||
if the strategy is guaranteed to find a solution (when exists).
|
||||
|
||||
\item[Time complexity] \marginnote{Time complexity}
|
||||
time needed to complete the search.
|
||||
|
||||
\item[Space complexity] \marginnote{Space complexity}
|
||||
memory needed to complete the search.
|
||||
|
||||
\item[Optimality] \marginnote{Optimality}
|
||||
if the strategy finds the best solution (when more solutions are possible).
|
||||
\end{description}
|
||||
|
||||
|
||||
|
||||
\section{Non-informed search}
|
||||
|
||||
\subsection{Breadth-first search (BFS)}
|
||||
\marginnote{Breadth-first search}
|
||||
Always expands the less deep node. The fringe is implemented as a queue (FIFO).
|
||||
|
||||
\begin{center}
|
||||
\def\arraystretch{1.2}
|
||||
\begin{tabular}{c | m{10cm}}
|
||||
\hline
|
||||
\textbf{Completeness} & Yes \\
|
||||
\hline
|
||||
\textbf{Optimality} & Only if cost is uniform (i.e. all edges have same cost) \\
|
||||
\hline
|
||||
\textbf{\makecell{Time and space\\complexity}}
|
||||
& $O(b^d)$, where the depth is $d$ and the branching factor is $b$ (i.e. each non-leaf node has $b$ children) \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
|
||||
The exponential space complexity makes BFS impractical for large problems.
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\includegraphics[width=0.40\textwidth]{img/_bfs.pdf}
|
||||
\caption{BFS visit order}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\subsection{Uniform-cost search}
|
||||
\marginnote{Uniform-cost search}
|
||||
Same as BFS, but always expands the node with the lowest cumulative cost.
|
||||
|
||||
\begin{center}
|
||||
\def\arraystretch{1.2}
|
||||
\begin{tabular}{c | m{10cm}}
|
||||
\hline
|
||||
\textbf{Completeness} & Yes \\
|
||||
\hline
|
||||
\textbf{Optimality} & Yes \\
|
||||
\hline
|
||||
\textbf{\makecell{Time and space\\complexity}}
|
||||
& $O(b^d)$, with depth $d$ and branching factor $b$ \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\includegraphics[width=0.60\textwidth]{img/_ucs.pdf}
|
||||
\caption{Uniform-cost search visit order. $(n)$ is the cumulative cost}
|
||||
\end{figure}
|
||||
|
||||
|
||||
\subsection{Depth-first search}
|
||||
\marginnote{Depth-first search}
|
||||
Always expands the deepest node. The fringe is implemented as a stack (LIFO).
|
||||
|
||||
\begin{center}
|
||||
\def\arraystretch{1.2}
|
||||
\begin{tabular}{c | m{10cm}}
|
||||
\hline
|
||||
\textbf{Completeness} & No \\
|
||||
\hline
|
||||
\textbf{Optimality} & No \\
|
||||
\hline
|
||||
\textbf{Time complexity}
|
||||
& $O(b^d)$, with depth $d$ and branching factor $b$ \\
|
||||
\hline
|
||||
\textbf{Space complexity}
|
||||
& $O(b \cdot d)$, with depth $d$ and branching factor $b$ \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\end{center}
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\includegraphics[width=0.40\textwidth]{img/_dfs.pdf}
|
||||
\caption{DFS visit order}
|
||||
\end{figure}
|
||||
Reference in New Issue
Block a user