Add code to report

main
Gasper Spagnolo 2022-11-11 14:48:53 +01:00
parent e399ec32e9
commit 94ff174be4
7 changed files with 130 additions and 25 deletions

View File

@ -10,10 +10,16 @@
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.1.6}Results}{4}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Solution to the first maze}}{4}{}\protected@file@percent }
\newlabel{image:task_1_maze_1}{{1}{4}}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces Solution to the second maze}}{4}{}\protected@file@percent }
\newlabel{image:task_1_maze_4}{{2}{4}}
\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces Solution to the fourth maze}}{4}{}\protected@file@percent }
\newlabel{image:task_1_maze_2}{{3}{4}}
\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces Example of solution using the critical section}}{5}{}\protected@file@percent }
\newlabel{image:task_1_broken_solution.png}{{4}{5}}
\gdef \@abspage@last{5}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces Solution to the second maze}}{5}{}\protected@file@percent }
\newlabel{image:task_1_maze_4}{{2}{5}}
\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces Solution to the fourth maze}}{5}{}\protected@file@percent }
\newlabel{image:task_1_maze_2}{{3}{5}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}Task 2}{5}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.2.1}Task description}{5}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces Example of solution using the critical section}}{6}{}\protected@file@percent }
\newlabel{image:task_1_broken_solution.png}{{4}{6}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.3}Task 3}{6}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.3.1}Task description}{6}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.4}Task 4}{6}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {2.4.1}Task description}{6}{}\protected@file@percent }
\gdef \@abspage@last{7}

View File

@ -1,5 +1,5 @@
# Fdb version 3
["pdflatex"] 1668173225 "solution.tex" "solution.pdf" "solution" 1668173226
["pdflatex"] 1668174467 "solution.tex" "solution.pdf" "solution" 1668174467
"/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-ts1.enc" 1650183167 2900 1537cc8184ad1792082cd229ecc269f4 ""
"/usr/share/texmf-dist/fonts/map/fontname/texfonts.map" 1650183167 3524 cb3e574dea2d1052e39280babc910dc8 ""
"/usr/share/texmf-dist/fonts/tfm/jknappen/ec/tcrm0900.tfm" 1650183167 1536 c4f439db76ef96a9c53bc437f35ffe20 ""
@ -60,8 +60,8 @@
"images/task_1_maze_1.png" 1668172516 710 43064669273650dfbed9c0cc6fabcd6f ""
"images/task_1_maze_2.png" 1668172594 1008 3c4a6780b53a0d5f210b92134871c99b ""
"images/task_1_maze_4.png" 1668172642 1705 f7a57d75e6d72aea9a0ee3f665d50352 ""
"solution.aux" 1668173226 1805 accdde8e734f12534ca5b985b0ffe71c "pdflatex"
"solution.tex" 1668173225 8243 91e9f4053a9fbc18ce03eeaa78ccf9d9 ""
"solution.aux" 1668174467 2444 ec73992920b6701b96ff4a887373b303 "pdflatex"
"solution.tex" 1668174466 11592 169bf2cf5ca482b811a98bc7590e219e ""
(generated)
"solution.aux"
"solution.log"

View File

@ -200,8 +200,8 @@ INPUT /usr/share/texmf-dist/fonts/tfm/public/cm/cmbx10.tfm
INPUT /usr/share/texmf-dist/fonts/tfm/jknappen/ec/tcrm1000.tfm
OUTPUT solution.pdf
INPUT /var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map
INPUT /usr/share/texmf-dist/fonts/tfm/jknappen/ec/tcrm0900.tfm
INPUT /usr/share/texmf-dist/fonts/tfm/public/cm/cmtt9.tfm
INPUT /usr/share/texmf-dist/fonts/tfm/jknappen/ec/tcrm0900.tfm
INPUT /usr/share/texmf-dist/fonts/tfm/public/cm/cmti10.tfm
INPUT ./images/task_1_maze_1.png
INPUT ./images/task_1_maze_1.png

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Arch Linux) (preloaded format=pdflatex 2022.11.9) 11 NOV 2022 14:27
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Arch Linux) (preloaded format=pdflatex 2022.11.9) 11 NOV 2022 14:47
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
@ -149,45 +149,69 @@ File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
)) [1
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2]
<./images/task_1_maze_1.png, id=18, 55.20625pt x 75.28125pt>
Overfull \hbox (28.27066pt too wide) in paragraph at lines 111--111
[]\OT1/cmtt/m/n/9 (critical_situation or (self.maze[x+1][y] == "." or self.maze[x+1][y] == "E")):[]
[]
Overfull \hbox (28.27066pt too wide) in paragraph at lines 111--111
[]\OT1/cmtt/m/n/9 (critical_situation or (self.maze[x-1][y] == "." or self.maze[x-1][y] == "E")):[]
[]
Overfull \hbox (23.54572pt too wide) in paragraph at lines 111--111
[]\OT1/cmtt/m/n/9 (critical_situation or(self.maze[x][y+1] == "." or self.maze[x][y+1] == "E")):[]
[]
Overfull \hbox (28.27066pt too wide) in paragraph at lines 111--111
[]\OT1/cmtt/m/n/9 (critical_situation or (self.maze[x][y-1] == "." or self.maze[x][y-1] == "E")):[]
[]
[3]
<./images/task_1_maze_1.png, id=23, 55.20625pt x 75.28125pt>
File: ./images/task_1_maze_1.png Graphic file (type png)
<use ./images/task_1_maze_1.png>
Package pdftex.def Info: ./images/task_1_maze_1.png used on input line 119.
Package pdftex.def Info: ./images/task_1_maze_1.png used on input line 156.
(pdftex.def) Requested size: 28.45274pt x 38.79956pt.
[3]
<./images/task_1_maze_2.png, id=24, 80.3pt x 106.3975pt>
File: ./images/task_1_maze_2.png Graphic file (type png)
<use ./images/task_1_maze_2.png>
Package pdftex.def Info: ./images/task_1_maze_2.png used on input line 129.
Package pdftex.def Info: ./images/task_1_maze_2.png used on input line 166.
(pdftex.def) Requested size: 56.9055pt x 75.4015pt.
<./images/task_1_maze_4.png, id=25, 115.43124pt x 153.57375pt>
LaTeX Warning: `h' float specifier changed to `ht'.
[4 <./images/task_1_maze_1.png (PNG copy)>]
<./images/task_1_maze_4.png, id=29, 115.43124pt x 153.57375pt>
File: ./images/task_1_maze_4.png Graphic file (type png)
<use ./images/task_1_maze_4.png>
Package pdftex.def Info: ./images/task_1_maze_4.png used on input line 141.
Package pdftex.def Info: ./images/task_1_maze_4.png used on input line 178.
(pdftex.def) Requested size: 85.35826pt x 113.56311pt.
<./images/task_1_broken_solution.png, id=26, 115.43124pt x 150.5625pt>
<./images/task_1_broken_solution.png, id=30, 115.43124pt x 150.5625pt>
File: ./images/task_1_broken_solution.png Graphic file (type png)
<use ./images/task_1_broken_solution.png>
Package pdftex.def Info: ./images/task_1_broken_solution.png used on input line 150.
Package pdftex.def Info: ./images/task_1_broken_solution.png used on input line 187.
(pdftex.def) Requested size: 113.81102pt x 148.4485pt.
LaTeX Warning: `h' float specifier changed to `ht'.
[4 <./images/task_1_maze_1.png (PNG copy)> <./images/task_1_maze_2.png (PNG copy)> <./images/task_1_maze_4.png (PNG copy)>] [5 <./images/task_1_broken_solution.png (PNG copy)>] (./solution.aux) )
[5 <./images/task_1_maze_2.png (PNG copy)> <./images/task_1_maze_4.png (PNG copy)>] [6 <./images/task_1_broken_solution.png (PNG copy)>] [7] (./solution.aux) )
Here is how much of TeX's memory you used:
2440 strings out of 478238
37964 string characters out of 5850456
340329 words of memory out of 5000000
343329 words of memory out of 5000000
20682 multiletter control sequences out of 15000+600000
476294 words of font info for 53 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
55i,6n,62p,281b,316s stack positions out of 5000i,500n,10000p,200000b,80000s
{/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-ts1.enc}</usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr9.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt9.pfb></usr/share/texmf-dist/fonts/type1/public/cm-super/sfrm0900.pfb></usr/share/texmf-dist/fonts/type1/public/cm-super/sfrm1000.pfb>
Output written on solution.pdf (5 pages, 166458 bytes).
Output written on solution.pdf (7 pages, 172599 bytes).
PDF statistics:
85 PDF objects out of 1000 (max. 8388607)
49 compressed objects within 1 object stream
93 PDF objects out of 1000 (max. 8388607)
55 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
21 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@ -75,6 +75,43 @@ But still I was not satisfied with the results so I decided to add some more pun
so that it converges to the correct path.
\end{itemize}
The critical section evaluation in code is done as follows:
\begin{small}
\begin{verbatim}
def walk_through_maze(self, solution_matrix, critical_situation):
queue = [[self.start_pos]]
def add_to_queue(full_path, x, y):
if (x,y) not in full_path:
full_path.append((x, y))
queue.append(full_path)
while queue != []:
full_path = queue.pop()
x, y = full_path[-1]
if(self.maze[x][y] == 'E'):
return full_path
if x + 1 < len(self.maze) :
if solution_matrix[x+1, y] == 1 and
(critical_situation or (self.maze[x+1][y] == "." or self.maze[x+1][y] == "E")):
add_to_queue(full_path, x+1, y)
if x - 1 >= 0:
if solution_matrix[x-1, y] == 1 and
(critical_situation or (self.maze[x-1][y] == "." or self.maze[x-1][y] == "E")):
add_to_queue(full_path, x-1, y)
if y + 1 < len(self.maze) :
if solution_matrix[x, y+1] == 1 and
(critical_situation or(self.maze[x][y+1] == "." or self.maze[x][y+1] == "E")):
add_to_queue(full_path, x, y+1)
if y - 1 >= 0:
if solution_matrix[x, y-1] == 1 and
(critical_situation or (self.maze[x][y-1] == "." or self.maze[x][y-1] == "E")):
add_to_queue(full_path, x, y-1)
return []
\end{verbatim}
\end{small}
\subsubsection{Run the genetic algorithm with suitable settings}
I used the following settings wen running the algorithm:
\begin{small}
@ -155,5 +192,43 @@ Other mazes found also found some solutions, but they were not optimal. Or they
So I will try to improve them in the following sections.
\subsection{Task 2}
\subsubsection{Task description}
The default mutation and crossover functions in R are not well-suited for this task because they do not
necessarily return valid paths (for example, the mutation might introduce a move that goes through a
wall). To fix this, modify the mutation and selection functions so that they take the walls into account.
Additionally, try to create a starting population in a way that takes walls into account.
You can base your crossover and mutation functions on existing GA library functions.
Modify at least one crossover or mutation function in a way that makes them more suitable for this task.
\subsection{Task 3}
\subsubsection{Task description}
In Task 3, mazes also contain treasure (marked with T). For example:
\begin{center}
\begin{BVerbatim}
maze2 = c("####E######",
"##...#.####",
"#..#.#.####",
"#.##...####",
"#T##T#..S##",
"###########")
\end{BVerbatim}
\end{center}
Your task is to modify your approach so that the solution returns as short a path as possible that also
collects all the treasure.
\subsection{Task 4}
\subsubsection{Task description}
Present a report that describes your approach, shows highlights of your code, and presents the results.
The results have to include performance comparisons between different settings of the genetic algorithm
(different mutation, crossover and selection functions, different starting populations and so on). Make
sure to evaluate your approach on different mazes, the one in the instructions is just an example. The
mazes.r file on ucilnica contains several additional examples of various sizes and complexities. Find
the largest size of a maze that can still be solved with your approach - feel free to create your own
mazes if the example mazes are too small. Produce a graph to show how the maze size affects the
running time of the genetic algorithm
\end{document}