1 | \documentclass[a4paper,12pt]{article}
|
---|
2 | \usepackage{hyperref}
|
---|
3 | \usepackage{a4wide}
|
---|
4 | %\usepackage{indentfirst}
|
---|
5 | \usepackage[english]{babel}
|
---|
6 | \usepackage{graphics}
|
---|
7 | %\usepackage[pdftex]{graphicx}
|
---|
8 | \usepackage{latexsym}
|
---|
9 | \usepackage{fancyhdr}
|
---|
10 | \usepackage{fancyvrb}
|
---|
11 |
|
---|
12 | \pagestyle{fancyplain}
|
---|
13 | \newcommand{\tstamp}{\today}
|
---|
14 | \newcommand{\id}{$ $Id: report.tex 195 2007-05-30 01:04:25Z rick $ $}
|
---|
15 | \lfoot[\fancyplain{\tstamp}{\tstamp}] {\fancyplain{\tstamp}{\tstamp}}
|
---|
16 | \cfoot[\fancyplain{\id}{\id}] {\fancyplain{\id}{\id}}
|
---|
17 | \rfoot[\fancyplain{\thepage}{\thepage}] {\fancyplain{\thepage}{\thepage}}
|
---|
18 |
|
---|
19 |
|
---|
20 | \title{ Challenges in Computer Science \\
|
---|
21 | \large{Assignment 4 - genetic search algorithm}}
|
---|
22 | \author{Rick van der Zwet\\
|
---|
23 | \texttt{<hvdzwet@liacs.nl>}\\
|
---|
24 | \\
|
---|
25 | LIACS\\
|
---|
26 | Leiden Universiteit\\
|
---|
27 | Niels Bohrweg 1\\
|
---|
28 | 2333 CA Leiden\\
|
---|
29 | The Netherlands}
|
---|
30 | \date{\today}
|
---|
31 | \begin{document}
|
---|
32 | \maketitle
|
---|
33 | \section{Introduction}
|
---|
34 | The assignment given out during the seminar of Natural Computing
|
---|
35 | Group of LIACS\footnote{http://natcomp.liacs.nl/} will have the
|
---|
36 | following context:
|
---|
37 | \begin{quote}
|
---|
38 | You are required to implement an Evolutionary Algorithm for tacking the
|
---|
39 | low-autocorrelation problem. Given your implementation, run your
|
---|
40 | algorithm on strings of the lengths given the table, and report your
|
---|
41 | results. A MATLAB code for the objective function is given to you in the
|
---|
42 | following location:
|
---|
43 | \texttt{http://www.liacs.nl/home/oshir/code/merit.m} (Backup at
|
---|
44 | Appendix~\ref{file:merit.m})
|
---|
45 | Its documentation:
|
---|
46 | \texttt{http://www.liacs.nl/home/oshir/code/autocorr.pdf}
|
---|
47 | \end{quote}
|
---|
48 |
|
---|
49 | \section{Problem}
|
---|
50 | The given problem, the so-called \textsl{low-autocorrelation problem of
|
---|
51 | binary sequences} is subject to actual research and is of big interest
|
---|
52 | for industrial applications, e.g. communications and electrical
|
---|
53 | engineering. Its description follows.\\
|
---|
54 | \textbf{Feasible Solutions:} Binary Sequences
|
---|
55 | $\overrightarrow{y} \in \{-1,+1\}^n$ \\
|
---|
56 | \textbf{Objective Function:}
|
---|
57 | \begin{equation}
|
---|
58 | \displaystyle
|
---|
59 | f(\overrightarrow{y}) =
|
---|
60 | \frac{n^2}{2 \cdot E\overrightarrow{y}} \longrightarrow maximization
|
---|
61 | \end{equation}
|
---|
62 | s.t.
|
---|
63 | \begin{equation}
|
---|
64 | \displaystyle
|
---|
65 | E(\overrightarrow{y}) = \sum_{k=1}^{n-1}
|
---|
66 | \left(
|
---|
67 | \sum_{i=1}^{n-k} y_i \cdot y_{i+k}
|
---|
68 | \right) ^2
|
---|
69 | \end{equation}
|
---|
70 |
|
---|
71 | Find a way using genetic algorithm to get the optional solutions
|
---|
72 |
|
---|
73 | \section{Theory}
|
---|
74 | A genetic algorithm will use 'evolution' to get the best possible
|
---|
75 | results. It will normally be executed in the following order
|
---|
76 |
|
---|
77 | \begin{enumerate}
|
---|
78 | \item Generate N number of random parents
|
---|
79 | \item Determine best parents
|
---|
80 | \item start generating offspring \label{again}
|
---|
81 | \item Determine best offspring
|
---|
82 | \item Combine the best parents and offspring to number of N new parents
|
---|
83 | \item Check if end condition is matched else go-to \ref{again} again
|
---|
84 | \end{enumerate}
|
---|
85 |
|
---|
86 | There are a few well known mutations to generate new nodes
|
---|
87 | \begin{itemize}
|
---|
88 | \item Crossover: Combine 2 parts of 2 nodes to a new node. Example (using crossover point 3):
|
---|
89 | \begin{verbatim}
|
---|
90 | A = 0 1 0 | 1 1 0
|
---|
91 | B = 1 1 1 | 0 0 0
|
---|
92 | A' = 0 1 0 0 0 0
|
---|
93 | B' = 1 1 1 1 1 0
|
---|
94 | \end{verbatim}
|
---|
95 | \item Mutation: Change a few values in a node. Example using mutation
|
---|
96 | point 3.
|
---|
97 | \begin{verbatim}
|
---|
98 | A = 0 1 0 1 1 0
|
---|
99 | A' = 0 1 1 1 1 0
|
---|
100 | \end{verbatim}
|
---|
101 | \end{itemize}
|
---|
102 |
|
---|
103 | \subsection{Algorithm}
|
---|
104 | I have introduced one new mutation way, cross-flip. It will flip all
|
---|
105 | values starting from a certain point. Example, using point 3
|
---|
106 | \begin{verbatim}
|
---|
107 | A = 0 1 0 1 1 0
|
---|
108 | A' = 0 1 1 0 0 1
|
---|
109 | \end{verbatim}
|
---|
110 |
|
---|
111 | This will be my algorithm
|
---|
112 | \begin{verbatim}
|
---|
113 | 01: Generate N random nodes on stack @A
|
---|
114 | 02: for n in 0 to size A
|
---|
115 | 03: exit loop if run for $round_size times
|
---|
116 | 04: check mutation(n) children are better and unshift to stack @A
|
---|
117 | 05: check cross-flip(n) children are better and unshift to stack @A
|
---|
118 | 06: check crossover(n) children are better and unshift to stack @A
|
---|
119 | 07: if n on end of the stack then remove all but A[0:5], add 5 random
|
---|
120 | 08: strings and do crossover on all variants.
|
---|
121 | 09: if improvement then set n to beginning
|
---|
122 | 10: add best result (@A[0]) to the @W array but keep the array sorted and
|
---|
123 | not longer then 10
|
---|
124 | 11: check if we have been here $maxround times, exit and give result
|
---|
125 | 12: check if we have been here such that ($times % $winnercompare) == 0
|
---|
126 | start generating special results by combining the best results of @W
|
---|
127 | into @A and go-to 02;
|
---|
128 | 13: start putting 75 random strings into @A and go-to 02:
|
---|
129 | \end{verbatim}
|
---|
130 |
|
---|
131 | \section{Implementation}
|
---|
132 | I wrote my implementation in Perl code, with a stack
|
---|
133 | implementation and used as much references as possible.
|
---|
134 |
|
---|
135 | \section{Experiments}
|
---|
136 | I ran all tests 5 times and will display the best merit factor and
|
---|
137 | corresponding string. Vectors are written in run-length notation: each
|
---|
138 | figure indicates the number of consecutive elements with the same
|
---|
139 | sign.
|
---|
140 |
|
---|
141 | \begin{table}[h]
|
---|
142 | \caption{Experiment results}
|
---|
143 | \begin{tabular}{l || l | l}
|
---|
144 | Size & m-factor & vector \\
|
---|
145 | \hline
|
---|
146 | 3 & 4.5 & 2,1\\
|
---|
147 | 4 & 4.0 & 1,3\\
|
---|
148 | 5 & 6.5 & 3,1,1\\
|
---|
149 | 10 & 10.0 & 3,3,1,2,1,1\\
|
---|
150 | 15 & 7.5 & 3,3,1,3,1,2,1,1\\
|
---|
151 | 20 & 7.7 & 5,1,1,3,1,1,2,3,2,1\\
|
---|
152 | 30 & 6.7 & 4,2,5,1,2,3,1,2,1,1,1,1,3,1,1,1\\
|
---|
153 | 50 & 5.0 & 1,1,1,1,1,1,1,2,2,3,4,1,7,2,2,2,1,2,1,1,5,4,1,1,2\\
|
---|
154 | 75 & 4.7 & 1,1,4,5,2,1,1,2,4,4,1,3,3,2,1,1,1,1,1,2,2,3,1,4,2,2,1,3,1,1,2,1,4,1,3,1,2\\
|
---|
155 | \end{tabular}
|
---|
156 | \end{table}
|
---|
157 |
|
---|
158 | \section{Conclusion}
|
---|
159 | The algorithm works pretty well on the small size numbers. The big
|
---|
160 | numbers (n > 20) are not scoring good, cause the script/program is
|
---|
161 | causing time problems.
|
---|
162 |
|
---|
163 | Writing the implementation in Perl is too slow. It's not generation
|
---|
164 | the bigger rates at a decent speed\footnotemark, cause the Perl code is not optional
|
---|
165 | yet. When looking at the profiler output (Appendix~\ref{text:profiler}), the merit
|
---|
166 | function could be optimised to get a higher throughput.
|
---|
167 |
|
---|
168 | \footnotetext{one round of n = 100 takes at a dual
|
---|
169 | core Pentium 4 3Ghz and 2GB RAM about 2 minutes}
|
---|
170 | %\begin{thebibliography}{XX}
|
---|
171 | %
|
---|
172 | %\end{thebibliography}
|
---|
173 |
|
---|
174 | \section{Appendix}
|
---|
175 |
|
---|
176 | \subsection{merit.m}
|
---|
177 | \label{file:merit.m}
|
---|
178 | \VerbatimInput{merit.m}
|
---|
179 | %\newpage
|
---|
180 | \subsection{merit.pl}
|
---|
181 | \label{file:merit.pl}
|
---|
182 | \VerbatimInput{merit.pl}
|
---|
183 | %\newpage
|
---|
184 | \subsection{profiler output}
|
---|
185 | \label{text:profiler}
|
---|
186 | \begin{verbatim}
|
---|
187 | Total Elapsed Time = 33.07120 Seconds
|
---|
188 | User+System Time = 32.94120 Seconds
|
---|
189 | Exclusive Times
|
---|
190 | %Time ExclSec CumulS #Calls sec/call Csec/c Name
|
---|
191 | 85.9 28.31 28.312 99474 0.0003 0.0003 main::merit
|
---|
192 | 6.00 1.975 1.975 990000 0.0000 0.0000 main::flip
|
---|
193 | 5.22 1.718 17.022 2000 0.0009 0.0085 main::crossovers
|
---|
194 | 3.26 1.073 15.030 2000 0.0005 0.0075 main::mutations
|
---|
195 | 2.84 0.935 28.587 126000 0.0000 0.0002 main::try_merit
|
---|
196 | 0.50 0.166 0.163 2529 0.0001 0.0001 main::combine
|
---|
197 | 0.25 0.083 0.164 20 0.0042 0.0082 main::reinit
|
---|
198 | 0.22 0.074 34.493 1 0.0736 34.492 main::main
|
---|
199 | 0.16 0.054 1.075 2000 0.0000 0.0005 main::crossover
|
---|
200 | 0.15 0.048 0.042 1365 0.0000 0.0000 main::randarray
|
---|
201 | 0.08 0.027 0.027 18532 0.0000 0.0000 main::message
|
---|
202 | 0.06 0.019 0.019 134 0.0001 0.0001 main::array2string
|
---|
203 | 0.03 0.009 0.028 134 0.0001 0.0002 main::printer
|
---|
204 | 0.00 - -0.000 1 - - strict::bits
|
---|
205 | 0.00 - -0.000 1 - - strict::import
|
---|
206 | \end{verbatim}
|
---|
207 |
|
---|
208 | \end{document}
|
---|