source: liacs/ccs/op4/report.tex@ 355

Last change on this file since 355 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 7.0 KB
Line 
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}
34The assignment given out during the seminar of Natural Computing
35Group of LIACS\footnote{http://natcomp.liacs.nl/} will have the
36following context:
37\begin{quote}
38You are required to implement an Evolutionary Algorithm for tacking the
39low-autocorrelation problem. Given your implementation, run your
40algorithm on strings of the lengths given the table, and report your
41results. A MATLAB code for the objective function is given to you in the
42following location:
43\texttt{http://www.liacs.nl/home/oshir/code/merit.m} (Backup at
44Appendix~\ref{file:merit.m})
45Its documentation:
46\texttt{http://www.liacs.nl/home/oshir/code/autocorr.pdf}
47\end{quote}
48
49\section{Problem}
50The given problem, the so-called \textsl{low-autocorrelation problem of
51binary sequences} is subject to actual research and is of big interest
52for industrial applications, e.g. communications and electrical
53engineering. 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
59f(\overrightarrow{y}) =
60 \frac{n^2}{2 \cdot E\overrightarrow{y}} \longrightarrow maximization
61\end{equation}
62s.t.
63\begin{equation}
64\displaystyle
65E(\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
71Find a way using genetic algorithm to get the optional solutions
72
73\section{Theory}
74A genetic algorithm will use 'evolution' to get the best possible
75results. 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
86There 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
96point 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}
104I have introduced one new mutation way, cross-flip. It will flip all
105values 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
111This will be my algorithm
112\begin{verbatim}
11301: Generate N random nodes on stack @A
11402: for n in 0 to size A
11503: exit loop if run for $round_size times
11604: check mutation(n) children are better and unshift to stack @A
11705: check cross-flip(n) children are better and unshift to stack @A
11806: check crossover(n) children are better and unshift to stack @A
11907: if n on end of the stack then remove all but A[0:5], add 5 random
12008: strings and do crossover on all variants.
12109: if improvement then set n to beginning
12210: add best result (@A[0]) to the @W array but keep the array sorted and
123 not longer then 10
12411: check if we have been here $maxround times, exit and give result
12512: 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;
12813: start putting 75 random strings into @A and go-to 02:
129\end{verbatim}
130
131\section{Implementation}
132I wrote my implementation in Perl code, with a stack
133implementation and used as much references as possible.
134
135\section{Experiments}
136I ran all tests 5 times and will display the best merit factor and
137corresponding string. Vectors are written in run-length notation: each
138figure indicates the number of consecutive elements with the same
139sign.
140
141\begin{table}[h]
142\caption{Experiment results}
143\begin{tabular}{l || l | l}
144Size & 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}
159The algorithm works pretty well on the small size numbers. The big
160numbers (n > 20) are not scoring good, cause the script/program is
161causing time problems.
162
163Writing the implementation in Perl is too slow. It's not generation
164the bigger rates at a decent speed\footnotemark, cause the Perl code is not optional
165yet. When looking at the profiler output (Appendix~\ref{text:profiler}), the merit
166function could be optimised to get a higher throughput.
167
168\footnotetext{one round of n = 100 takes at a dual
169core 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}
187Total Elapsed Time = 33.07120 Seconds
188 User+System Time = 32.94120 Seconds
189Exclusive 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}
Note: See TracBrowser for help on using the repository browser.