Index: liacs/nc/laser-pulse-shaping/Makefile
===================================================================
--- liacs/nc/laser-pulse-shaping/Makefile	(revision 47)
+++ liacs/nc/laser-pulse-shaping/Makefile	(revision 48)
@@ -1,2 +1,9 @@
+SOURCE=$(patsubst %.m,%.m.tex, $(shell ls *.m))
+
+include latex.mk
+
+foo:
+	echo $(SOURCE)
+
 pso.out: pso.m
 	@octave -q pso.m
Index: liacs/nc/laser-pulse-shaping/latex.mk
===================================================================
--- liacs/nc/laser-pulse-shaping/latex.mk	(revision 48)
+++ liacs/nc/laser-pulse-shaping/latex.mk	(revision 48)
@@ -0,0 +1,61 @@
+# Rick van der Zwet <rick@wzoeterwoude.net>
+# Licence: BSD
+# Descrip: LaTex file parser
+# $Id: latex.mk 571 2008-04-20 17:31:04Z rick $
+
+TARGET = report
+LATEX = latex
+XDVI = xdvi
+TEX = latex -halt-on-error
+DVIPDF = dvipdf
+ASPELL = aspell
+ASPELL_ARGS = -c --mode=tex -x
+
+#XXX: Make me dynamic
+VIEWPDF = evince
+.SUFFIXES: .pdf
+
+help:
+	@echo "Usage Makefile <option>"
+
+doc-all: doc-distclean buildpdf
+
+view: viewpdf
+
+viewdvi: builddvi
+	$(XDVI) $(TARGET)
+
+builddvi: $(SOURCE) $(TARGET).dvi
+
+doc-clean:
+	rm -vf *.aux *.log *toc *.out *.bak *.m.tex
+
+doc-distclean: doc-clean
+	rm -vf $(TARGET).dvi $(TARGET).pdf $(PROGRAM)
+
+buildpdf: $(SOURCE) $(TARGET).pdf
+
+viewpdf: buildpdf
+	$(VIEWPDF) $(TARGET).pdf
+
+spell: spell-en
+
+spell-nl: $(TARGET).tex
+	$(ASPELL) -l nl -p ~/aspell-n.dic $(ASPELL_ARGS) $<
+
+spell-en: $(TARGET).tex
+	$(ASPELL) -l en -p ~/aspell-en.dic $(ASPELL_ARGS) $<
+
+.dvi.pdf:
+	$(DVIPDF) $? $@
+
+.tex.dvi:
+	$(TEX) $? $@
+	$(TEX) $? $@
+
+.gs.png:
+	$(GNUPLOT) $?
+
+%.m.tex: %.m
+	highlight --include-style --linenumbers --no-doc \
+	  --latex --input $< --output $@
Index: liacs/nc/laser-pulse-shaping/report.tex
===================================================================
--- liacs/nc/laser-pulse-shaping/report.tex	(revision 48)
+++ liacs/nc/laser-pulse-shaping/report.tex	(revision 48)
@@ -0,0 +1,167 @@
+%
+% $Id: report.tex 571 2008-04-20 17:31:04Z rick $
+%
+
+\documentclass[12pt,a4paper]{article}
+
+\usepackage{listings}
+
+\frenchspacing
+\usepackage[english,dutch]{babel}
+\selectlanguage{dutch}
+\usepackage{graphicx}
+\usepackage{url}
+\usepackage{multicol}
+\usepackage{fancybox}
+\usepackage{amssymb,amsmath}
+\usepackage{float}
+\usepackage{color}
+\usepackage{subfig}
+\floatstyle{ruled}
+\newfloat{result}{thp}{lop}
+\floatname{result}{Result}
+
+\title{Laser Pulse Shaping problem\\
+\large{Practical Assignments Natural Computing, 2009}}
+\author{Rick van der Zwet\\
+  \texttt{<hvdzwet@liacs.nl>}}
+\date{\today}
+
+
+\begin{document}
+\newcommand{\wekacmd}[1]{\begin{quote}\small{\texttt{#1}}\end{quote}}
+\newcommand{\unixcmd}[1]{\begin{quote}\small{\texttt{#1}}\end{quote}}
+
+
+\maketitle
+
+\section{Introduction}
+The report is focused on the so-called \emph{laser pulse shaping problem}.
+Todays lasers are also used within the range of atoms or mulecule research.
+Using small pulses it is able to align and alter the movement of the atoms. 
+
+The problem lies in the fact the atoms cannot be controlled by any type of
+laser pulse. There are many parameters which could all be set to 'shape' the
+laser pulse the way it can move the atoms.
+
+\section{Problem description}
+To determine the best solution a fitness function is needed, which could be
+found in the shape of equation~\ref{eq:fitness}
+\begin{equation}
+\label{eg:fitness}
+SHG = \int_0^T E^4(t)dt \rightlongarrow maximization
+\end{equation}
+
+
+Due to the huge 'exploding' posibilities it is not possible to walk trough the
+whole list of posibities, so we need alternative approches to tackle this
+problem. First we will try the \emph{Monte Carlo Search algoritm [MCS]} and next try
+\emph{Simulated Annealing [SA]}.
+
+\emph{MCS} is all about random sequence generation and trying to find a good
+solution, do a small ajustment on the solution and compare the new solution
+again.
+
+\emph{SA} takes a more and less the same aproch, but it also accept small
+'losses' from time-to-time. But as time passes it get less likely to accept
+'bad solutions'.
+
+\section{Statistics}
+Of course many people have run numerous computer hours on finding the best
+possible fitness as shown in table~\ref{tab:best}. The algoritms used to find
+those numbers are not found.
+
+\begin{table}
+  \caption{Best known values of low-autocorrelation problem}
+  \begin{center}
+    \begin{tabular}{| l | c | r | }
+      \hline
+      $n$ & Best known $f$ \\
+      \hline \hline          
+      20  & 7.6923 \\ \hline 
+      50  & 8.1699 \\ \hline
+      100 & 8.6505 \\ \hline
+      200 & 7.4738 \\ \hline
+      222 & 7.0426 \\ \hline
+    \end{tabular}
+  \end{center}
+  \label{tab:best}
+\end{table}
+
+\section{Approach}
+The \emph{MCS} is implemented streight-forward from the wikipedia
+page\footnote{http://en.wikipedia.org/wiki/Monte\_Carlo\_method}. The mutation
+choosing is flipping one bit in the array.
+
+For the \emph{SA} implemented also comes streight from 'the book'
+\footnote{http://en.wikipedia.org/wiki/Simulated\_annealing}, the process
+choosing for the cooling-down sequence is taken from the dutch wikipedia page
+'Simulated annealing', which is nice indicator when to choose something when
+the solution is worse (logically, beter solutions will always be accepted).
+\footnote{http://nl.wikipedia.org/wiki/Simulated\_annealing}:
+\begin{math}
+p = e^{\frac{f(i)-f(j)}{c}}
+\end{math}
+
+\section{Implementation}
+The code is written in
+\emph{Octave}\footnote{http://www.gnu.org/software/octave/} which is the
+open-source 'variant' of \emph{MATLAB}\copyright 
+\footnote{http://www.mathworks.com/products/matlab/}. There are small minor
+differences between them, but all code is made compatible to to run on both
+systems. The code is to be found in Appendix~\ref{app:code}.
+
+As work is done remotely, the following commands are used:
+\unixcmd{matlab-bin -nojvm -nodesktop -nosplash -nodisplay < \%\%PROGRAM\%\%}
+\unixcmd{octave -q \%\%PROGRAM\%\%}
+
+\section{Results}
+All experiments are run 5 times the best solution is choosen and will be
+resented at table~\ref{tab:result}. Iteration size is set to 1000. For $n=20$
+the best fitness history is shown at figure~\ref{fig:fitness}.
+
+\begin{table}
+  \caption{Best known values of low-autocorrelation problem}
+  \begin{center}
+    \begin{tabular}{| r | r | r | r | }
+      \hline
+      $n$ & \multicolumn{3}{|c|}{Best fitness} \\
+          & known & MCS & SA \\
+      \hline \hline          
+      20  & 7.6923 & 4.3478 & 4.7619 \\ \hline 
+      50  & 8.1699 & 2.4752 & 2.6882 \\ \hline
+      100 & 8.6505 & 1.8342 & 1.7470 \\ \hline
+      200 & 7.4738 & 1.8678 & 1.5733 \\ \hline
+      222 & 7.0426 & 1.5657 & 1.4493 \\ \hline
+    \end{tabular}
+    \label{tab:result}
+  \end{center}
+\end{table}
+
+\begin{figure}[htp]
+  \begin{center}
+    \subfloat[SA]{\label{fig:edge-a}\includegraphics[scale=0.4]{sa-fitness.eps}}
+    \subfloat[MCS]{\label{fig:edge-b}\includegraphics[scale=0.4]{mcs-fitness.eps}}
+  \end{center}
+  \caption{Fitness throughout the iterations}
+  \label{fig:fitness}
+\end{figure}
+
+\section{Conclusions}
+Looking at the graphs the fitness was still increasing so a larger iteration
+size would make the fitness a better result. Secondly the \emph{SA} is
+preforming much worse on large number than the \emph{MCS} one. It seems to the
+temperature function is not working as expected. 
+
+Both algoritms are preforming much worse then the best found solutions.
+\section{Appendix 1}
+\label{app:code}
+\include{autocorrelation.m}
+\include{initseq.m}
+\include{mcs-call.m}
+\include{mcs.m}
+\include{mutation.m}
+\include{randint.m}
+\include{sa-call.m}
+\include{sa.m}
+\end{document}
