%----------------------------------------------------------------------
% COMPUTATIONAL PHYSICS - PROJECT 1
% SEMICLASSICAL QUANTIZATION OF MOLECULAR VIBRATIONS
%----------------------------------------------------------------------

\documentclass[a4paper]{IEEEtran}
\usepackage{amssymb}
\usepackage{moreverb}
\usepackage[cmex10]{amsmath}
\usepackage{cite}
\usepackage{graphicx}
\usepackage[colorlinks=false, hidelinks]{hyperref}

\usepackage{listings}
\usepackage{color}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{microtype}
\usepackage{inconsolata}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{alltt}
\usepackage{sverb}
\usepackage{verbatim}
\usepackage{pifont}
\usepackage{alltt}
\usepackage{helvet}

%----------------------------------------------------------------------
% CODE LISTING SETTINGS
%----------------------------------------------------------------------

\lstset{language=fortran,
        %basicstyle=\footnotesize\ttfamily,
        basicstyle=\small\ttfamily,
        columns=fullflexible,
        %title=\lstname,
        numbers=left, stringstyle=\texttt,
        numberstyle={\tiny\texttt},
        keywordstyle=\color{blue},
        commentstyle=\color{darkgreen},
        stringstyle=\color{purple} }

\mdfsetup{skipabove=\topskip, skipbelow=\topskip}

\definecolor{codebg}{rgb}{0.99,0.99,0.99}

\global\mdfdefinestyle{code}{%
    frametitlerule=true,%
    frametitlefont=\small\bfseries\ttfamily,%
    frametitlebackgroundcolor=lightgray,%
    backgroundcolor=codebg,%
    linecolor=gray, linewidth=0.5pt,%
    leftmargin=0.5cm, rightmargin=0.5cm,%
    roundcorner=2pt,%
    innerleftmargin=5pt
}

\global\mdfdefinestyle{code2}{%
    topline=false,%
    bottomline=false,%
    leftline=true,%
    rightline=false,%
    backgroundcolor=codebg,%
    linecolor=gray, linewidth=0.5pt,%
    leftmargin=0.0cm, rightmargin=0.0cm,%
    innerleftmargin=1pt
}

\newcommand{\showcode}[1]{\begin{mdframed}[style=code] %
                            \lstinputlisting{#1}%
                          \end{mdframed}%
}

\newcommand{\showsmallcode}[1]{\begin{mdframed}[style=code2] %
        \lstinputlisting[basicstyle=\ttfamily\tiny]{#1}%
                          \end{mdframed}%
}

%----------------------------------------------------------------------
% IEEE SETTINGS
%----------------------------------------------------------------------

\interdisplaylinepenalty=2500
\setlength{\IEEEilabelindent}{\IEEEilabelindentB}

%\markboth{630--364 Computational Physics}{}
\markboth{Semi-Classical Quantization of Molecular Vibrations. Michael Papasimeon. 1997}{}

%----------------------------------------------------------------------
% BEGIN DOCUMENT
%----------------------------------------------------------------------

\title{Semi-Classical Quantization of Molecular Vibrations}
\author{Michael Papasimeon\\ 12 August 1997} % \\
\date{August 12, 1997}

%----------------------------------------------------------------------
% BEGIN DOCUMENT
%----------------------------------------------------------------------

\begin{document}
\maketitle
%\thispagestyle{plain}

\begin{abstract}
This paper was written for an introductory undegraduate class in computational
physics in 1997. It focuses on basic computational/numerical techniques
for quadrature and root finding. It then applies these techniques to finding
the energy levels of molecular hydrogen $H_2$ using a semi-classical quantization
approach. The source code listings in \textsc{Fortran77} can be found in the appendices.
\end{abstract}

%----------------------------------------------------------------------
% QUADRATURE
%----------------------------------------------------------------------

\section{Quadrature}

\subsection{Aims}

      \IEEEPARstart{T}{he}
      main aim is to write a FORTRAN program to numerically integrate
      the integral:
      \begin{equation}
            \label{quadint}
            \int_{0}^{1} \frac{\ln(1+x)}{x} dx = \frac{\pi^{2}}{12}
      \end{equation}
      \begin{itemize}
            \item using the Trapezoidal rule,
            \item using Simpson's method,
            \item and to investigate the accuracy of both the
                  Trapezoidal rule and Simpson's method for different
                  step sizes.
      \end{itemize}

\subsection{Procedure}

    A FORTRAN program was written (\verb+quad.f+, source code in Appendix A),
    which implemented both the Trapezoidal and Simpson's rules for the
    quadrature of equation~\ref{quadint}. The program calls the
    functions to calculate the integral a number of times each with a
    diiferent number of divisions $n$, and hence step size $h$. Both
    the Trapezoidal and Simpson's rules are evaluated at number of
    divisions
    starting from $n=10$ to $n=10^6$, with each new evaluation
    increasing by a single order of magnitude. This allows the
    investigation of the accuracy of the different techniques as the
    number of divisions increases.

    The error is calculated is the absolute error:
        \[ Error = \mathrm{abs}(Result - Answer) \]
    where Result is the value produced by the numerical technique and
    $Answer$, is the analytic solution to the integral known to
    be $\frac{\pi^{2}}{12} \simeq 0.822467033$.

    Since the integrand is not defined at $x=0$, the FORTRAN function
    used to evaluate this returns a value of $1.0$ when $x=0$, this is
    because
        \[ \lim_{x \rightarrow 0} \frac{\ln(1+x)}{x} = 1 \].

\subsection{Results}

    \subsubsection{Trapezoidal Rule}
    The output from the program \verb+quad.f+ using the Trapezoidal
    rule is shown below in in Table~\ref{tbl:trapezoidal}

    \begin{table}[h]
      \caption{Results of using Trapezoidal rule.}
      \label{tbl:trapezoidal}
      \begin{center}
      \begin{tabular}{|r|r|r|r|} \hline
           $n$  &         $h$   &     $Result$ &   $Error$ \\
       \hline
       \hline
            10  & .1000000000   &.8227225585   &.255525E-03 \\
           100  & .0100000000   &.8224695905   &.255709E-05 \\
          1000  & .0010000000   &.8224670590   &.255711E-07 \\
         10000  & .0001000000   &.8224670337   &.255709E-09 \\
        100000  & .0000100000   &.8224670334   &.255251E-11 \\
       1000000  & .0000010000   &.8224670334   &.263123E-13 \\ \hline
       \end{tabular}
       \end{center}
    \end{table}

    \subsubsection{Simpson's Rule}
    The output from the program \verb+quad.f+ using Simpson's rule is
    shown below in Table~\ref{tbl:simpsons}.

    \begin{table}[h]
    \caption{Results using Simpson's rule.}
    \label{tbl:simpsons}
    \begin{center}
    \begin{tabular}{|r|r|r|r|} \hline
            $n$   &          $h$  &      $Result$ &        $Error$ \\
    \hline
    \hline
           10   &.1000000000   &.8224677660   &.732614E-06 \\
          100   &.0100000000   &.8224670335   &.744940E-10 \\
         1000   &.0010000000   &.8224670334   &.799361E-14 \\
        10000   &.0001000000   &.8224670334   &.310862E-14 \\
       100000   &.0000100000   &.8224670334   &.310862E-14 \\
      1000000   &.0000010000   &.8224670334   &.643929E-14 \\ \hline
    \end{tabular}
    \end{center}
    \end{table}

\subsection{Discussion}

    Looking at the results for the Trapezoidal rule calculations
    in Table 1, we see that as we increase the
    number of divisions $n$ by one order of magnitude, the error
    decreases by 2 orders. Therefore, we see that when using the
    Trapezoidal rule for quadrature, the error is of order $O(n^2)$, as
    expected.

    Making a comparison with the results for the Simpson's rule
    calculations shown in Table 2, we see that that as the number of
    divisions $n$ is increased by an order of magnitude, the error
    decreases by 4 orders. Therefore, when using Simpson's rule, the
    error is of order $O(n^4)$.
    The only problem is that the magnitude of the error stops decreasing
    after n = 10000. The most likely explanation for this is that we
    have reached the floating point limit on the number of decimal
    places which the computer which ran the program can handle.

    Therefore we see that that Simpson's rule is more accurate than the
    trapezoidal rule for quadrature.

%----------------------------------------------------------------------
% ROOT FINDING
%----------------------------------------------------------------------

\section{Root Finding}

\subsection{Aims}

    The main aim is to write a FORTRAN program which makes use of the
    false position method to calculate the non zero root of the
    equation
    \begin{equation}
        \label{false}
        \int_{0}^{x} t^2 dt = x
    \end{equation}
    and to compare with the analytic solution. The program will make use
    of the Simpson's rule to evaluate the integral.

\subsection*{Procedure}
    Firstly equation~\ref{false} must be solved analytically.
    \begin{eqnarray}
        \int_{0}^{x} t^2 dt         & = & x \nonumber \\
        \left[\frac{t^3}{2}\right]_{0}^{x} - x & = & 0 \nonumber \\
        \frac{x^3}{3} - x & = & 0 \nonumber \\
        x\left(\frac{x^2}{3} - 1\right) & = & 0 \nonumber
    \end{eqnarray}
    Therefore equation~\ref{false} has three roots
        \[ x = 0, \pm\sqrt{3} \]
    We are interested in finding the positive root,
    $x = +\sqrt{3} \simeq 1.732050808$, of equation~\ref{false} numerically.

    The procedure involved writing a FORTRAN program to find the roots
    of the equation
        \[ \int_{0}^{x} t^2 dt -x = 0 \].
    The algorithm used to find the root of this equation was the false
    position method. Simpson's rule was also used in the program to
    evaluate the integral in the equation.

    The program outputs a table of results, with varying number of
    divisions $n$ for the Simpson rule calculations and varying
    $Tolerance$ for the false position method. The values of $n$ range
    from $n = 10$ to $n = 10^7$ with each one being an order of
    magnitude of the previous value. The value for the tolerance of the
    false position algorithm is simply $1/n$.

    The source code for the program \verb+root.f+ can be found in
    Appendix B.

\subsection{Results}
    The results from the \verb+root.f+ program using the false position
    method is shown in Table~\ref{tbl:false-position}

    \begin{table}[h]
    \caption{Results using the False Position Method.}
    \label{tbl:false-position}
    \begin{center}
    \begin{tabular}{|r|r|r|r|} \hline
         $n$  & $Tolerance$ & $Result$  & $Error$ \\
    \hline
    \hline
         10   &.1000000000  &1.6831581899   &.488926E-01 \\
        100   &.0100000000  &1.7301619523   &.188886E-02 \\
       1000   &.0010000000  &1.7318112238   &.239584E-03 \\
      10000   &.0001000000  &1.7320371397   &.136679E-04 \\
     100000   &.0000100000  &1.7320476140   &.319354E-05 \\
    1000000   &.0000010000  &1.7320506340   &.173520E-06 \\
   10000000   &.0000001000  &1.7320507671   &.404475E-07 \\ \hline
    \end{tabular}
    \end{center}
    \end{table}

\subsection{Discussion}
    Looking at the results in Table 3, we see that as the number of
    divisions $n$ (for Simpson's rule) is increased in order of magnitude
    and the tolerance (for false position method) is made smaller, the
    error decreases by order $O(n)$.

%----------------------------------------------------------------------
% MOLECULAR VIBRATIONS
%----------------------------------------------------------------------

\section{Molecular Vibrations}

\subsection{Background}

      When two atoms are bound together in a molecular structure such as
      the two Hydrogen atoms in a $H_2$ molecule, they vibrate. Since
      the nuclei (protons in this case), are much heavier than the
      electrons the approximation that the protons are infinitely
      heavier than the electrons can be made. Therefore the potential
      between the protons depends only on the distance between them.

      At large distances, the potential is attractive to a van der Waals
      interaction and repulsive at short distances due to the Coulombic
      electrostatic repulsion of like charges, and because of the Pauli
      exclusion principle which states that no two fermions can occupy
      the same quantum state.

      The interaction of the potential for a diatomic molecule such as
      $H_2$ can be summarised in the graph below.

      \begin{center}
            \includegraphics[height=5cm]{potential.eps}
      \end{center}

      For a quantum system such as this one, Schrodinger's Equation is
      usually used to solve for the allowed energies $E_n$ of the molecular
      system.
      \begin{equation}
       \left[ \frac{\hbar}{2m}\frac{d^2}{dr^2} + V(r) \right] = E_n\psi_n
      \end{equation}

      Due to the fact that the mass of the protons is approximated to be
      infinite, the problem can be solved using classical mechanics and
      then applying quantisation rules of the ``old'' quantum theory.

      The total energy in classical mechanics is given by the sum of the kinetic and potential
      energies.
      \begin{equation}
            E = \frac{p^2}{2m} + V(r)
      \end{equation}
      Solving for the momentum $p$ we get:
      \begin{equation}
            p(r) = \pm\sqrt{2m(E-V(r)}
      \end{equation}
      To quantize this classical motion, we consider the potential in
      phase space. The area enclosed by the phase space trajectory is
      called the ``action'' is given by $S(E)$, where $E$ is the
      energy. According the ``old'' quantum theory quantisation rules,
      for a given energy $E_n$, the action must be only half integral
      multiples of $\pi$.

      \begin{equation}
      S(E_n) = \oint \frac{p(r)}{\hbar} dr
      \end{equation}

      \begin{equation}
      S(E_n) =
             2\sqrt{\frac{2m}{\hbar^2}}
             \int_{r_{in}}^{r_{out}} \sqrt{E_n - V(r)} dr
      \end{equation}

      \begin{equation}
      S(E_n) =
             \left(n + \frac{1}{2} \right)\pi
      \end{equation}

\subsection{Aims}

    The main aim is to solve the scaled action equation, to find the quantised
    scaled energy levels $\epsilon_n$ for the different quantum levels $n$.
    \begin{equation}
        \label{main}
        s(\epsilon_n) =
            \gamma\int_{x_{in}}^{x_{out}} [\epsilon_n - v(x)]^{1/2} dx =
            \left( n + \frac{1}{2} \right)\pi.
    \end{equation}
    The actual energy levels can then be calculated from $E = V\epsilon$.
    The aim is to solve the equation with a quadratic potential $v(x)$
    both analytically and numerically. Then the potential is to be
    replaced with the Morse potential which can only be solved
    numerically. The numerical results of the energy then need to be
    compared with the experimental results obtain for the quantised
    energy levels of the $\mathrm{H_2}$ molecule.

\subsection{Quadratic Potential Procedure}

    Using a quadratic potential $V(r)$, equation~\ref{main} needs to be solved.
    \[ V(r) = 4V_0 \left( \frac{r}{a} - 1 \right)
                   \left( \frac{r}{a} - 2\right) \]

    We need to find the roots of $\epsilon_n - v(x) = 0$,
    $x_{in}(\epsilon_n)$ and $x_{out}(\epsilon_n)$, where
    $x = r/a$, and $v(x) = V(x)/V_0$ and therefore $v(x) = 4(x-1)(x-2)$.
    \begin{eqnarray}
        \epsilon_n - v(x)   & = & 0 \nonumber \\
        \epsilon_n - 4(x-1)(x-2) & = & 0 \nonumber \\
        -4x^2 + 12x - 8 + \epsilon_n & = & 0 \nonumber
    \end{eqnarray}
    The roots of a quadratic are given by
    \[ x_\pm = \frac{-b \pm \sqrt{b^2 - 4ac} }{2a}\]
    \begin{eqnarray}
    x_{\pm} & = & \frac{-12 \pm \sqrt{144 + 16(\epsilon_n - 8)} }{-8} \nonumber \\
    x_{\pm} & = & \frac{-3 \pm \sqrt{\epsilon_n + 1}}{-2} \nonumber
    \end{eqnarray}
    Therefore the roots are given by:
    \[ x_- = x_{in}(\epsilon_n) = \frac{3 - \sqrt{\epsilon_n + 1} }{2} \]
    \[ x_+ = x_{out}(\epsilon_n) = \frac{3 + \sqrt{\epsilon_n + 1} }{2} \]

    With the roots of the $\epsilon_n - v(x) = 0$, know available,
    equation~\ref{main} can be solved analytically. Alternatively the
    a convenience equation can be used to solve equation~\ref{main}.
    \[ \int_{x_-}^{x_+} \sqrt{ax^2 + bx + c} dx = \frac{(4ac - b^2)\pi}{8a\sqrt{-a}} \]
    \begin{eqnarray}
        s(\epsilon_n) = \gamma\int_{x_{in}}^{x_{out}} [\epsilon_n - v(x)]^{1/2} dx & = &
                        \left( n + \frac{1}{2} \right)\pi \nonumber \\
        \gamma\int_{x_{in}}^{x_{out}} \sqrt{-4x^2 + 12x - 8 + \epsilon_n } dx & = &
                        \left( n + \frac{1}{2} \right)\pi \nonumber \\
        \gamma\left[ \frac{4(-4)(\epsilon_n - 8) - 144}{-64} \right] & = &
                        \left( n + \frac{1}{2} \right)\pi \nonumber \\
        \gamma\left[ \frac{\epsilon_n + 1}{4} \right] & = &
                        \left( n + \frac{1}{2} \right) \nonumber \\
        \epsilon_n & = & \frac{4\left(n + \frac{1}{2}\right)}{\gamma} - 1 \nonumber
    \end{eqnarray}

    Therefore the analytic solution for the energy $\epsilon_n$ is given
    by
    \begin{equation}
    \label{quadenergy}
    \epsilon_n = \frac{4\left(n + \frac{1}{2}\right)}{\gamma} - 1 \nonumber
    \end{equation}

    Using this information, a FORTRAN program was written, to solve
    equation~\ref{main} for the quadratic potential $v(x) = 4(x-1)(x-2)$.
    The source code for the program \verb+quadratic.f+ can be found in
    Appendix C. The program takes the quantum number n, and a value for the constant
    $\gamma$ as input.

    \begin{figure}
        \centering
        \includegraphics[width=0.8\columnwidth]{flow.eps}
        \caption{Flow chart of quadratic integration algorithm}
        \label{fig:flow-chart}
    \end{figure}

    Figure~\ref{fig:flow-chart} shows a very high level architectural design of
    the FORTRAN program \verb+quadratic.f+ shown in Appendix C.

\subsection{Quadratic Potential Results}
    The table below shows the results of the \verb+quad.f+ program for
    the values of $n = 0,1,2,3,4$, and with $\gamma = 1$. Since the
    accuracy of this method was investigated for different step sizes
    and tolerance values in the previous section, the results here all
    have $10^6$ divisions for Simpson's rule and a tolerance of
    $10^{-6}$ for the false position algorithm.

    The column labelled $\epsilon_n$ is the analytic solution to
    equation~\ref{main} for $v(x)$ given by equation~\ref{quadenergy},
    whereas the column labelled $\epsilon_n^{*}$ is the solution given
    by the FORTRAN program \verb+quadratic.f+.

    \begin{table}[h]
    \caption{Values of $\epsilon_n$ for a quadratic potential with $\gamma = 1$.}
    \label{tbl:epsilon}
    \begin{center}
    \begin{tabular}{|r|r|c|c|} \hline
    $n$ & $\epsilon_n$ & $\epsilon_n^{*}$ & $Error$ \\
    \hline
    \hline
    0   &   1   &   1.0000000008    &   .826897E-09 \\
    1   &   5   &   5.0000000025    &   .248070E-08 \\
    2   &   9   &   9.0000000041    &   .413422E-08 \\
    3   &  13   &  13.0000000058    &   .578873E-08 \\
    4   &  17   &  17.0000000074    &   .744295E-08 \\ \hline
    \end{tabular}
    \end{center}
    \end{table}

    To look at the numerical stability of the program, we vary the
    number of divisions $N$ in the Simpson quadrature algorithm, and the
    tolerance in the false position algorithm. Taking just one of the
    values of $n$, we have the following results for $n = 1$ and
    $\gamma = 1$, in the table below.

    \begin{table}[h]
    \caption{$\epsilon_n$ for $n=1$, $\gamma = 1$,
                    for varying tolerances for quadrature and root
                    finding algorithms.  }
    \label{tbl:epsilon-prime}
    \begin{center}
    \begin{tabular}{|r|r|c|c|} \hline
    $N$ & $Tolerance$ & $\epsilon_n$ & $Error$  \\
    \hline
    \hline
              10 &.1000000  &5.0801607150   &.801607E-01 \\
             100 &.0100000  &5.0024839897   &.248399E-02 \\
            1000 &.0010000  &5.0000784582   &.784582E-04 \\
           10000 &.0001000  &5.0000024808   &.248084E-05 \\
          100000 &.0000100  &5.0000000785   &.784505E-07 \\
         1000000 &.0000010  &5.0000000025   &.248070E-08 \\ \hline
    \end{tabular}
    \end{center}
    \end{table}

\subsection{Quadratic Potential Discussion}

    Looking at Table~\ref{tbl:epsilon}, we see good agreement with the values calculated
    analytically for $\epsilon_n$ and those calculated numerically, with
    an error of approximately $10^{-8}$ for all cases except for when
    the $n = 0$, when the error is approximately $10^{-9}$.
    The technique can then be used solve the problem of finding the
    quantized energy levels with more complicated and more physically
    realistic potentials such as the Morse potential, which there exists
    no analytic solution and must therefore be solved numberically.

    Looking at Table~\ref{tbl:epsilon-prime}, we see the results for varying tolerances for
    both the quadrature (Simpson's) algorithm, $N$, and the root finding
    algorithm (false position), $Tolerance$, for $n=1$ and $\gamma=1$.
    We see that the algorithms used result in numerically stable
    solutions by oberving that the error consistently decreases, as $N$
    is increased and as the $Tolerance$ is decreased.

\subsection{Morse Potential Procedure}

      The procedure was to modify the program used to calculate
      $\epsilon_n$ from using a quadratic potential, to a potential that
      was closer in shape to what had been observed in experiments.
      This is the Morse potential given by
      \begin{equation}
      V_{Morse}(r) = V_0\left[\left(1-e^{-(r-r_{min})/a}\right)^2 - 1\right]
      \end{equation}
      The Morse potential can be normalised ($x=r/a$ and $v(x)=V(r)/V_0$)
      to get
      \begin{equation}
            v(x) = \left( 1 - e^{-(x-x_{min})} \right)^2 - 1
      \end{equation}
      The next step is to analytically find the turning points
      $x_{in}(\epsilon_n)$ and $x_{out}(\epsilon_n)$ of the
      equation $\epsilon_n - v(x) = 0$.
      \[ \epsilon_n - \left[ \left( 1 - e^{-(x-x_{min})} \right)^2 - 1 \right]
                                                 =  0 \]
      Let $z = e^{-(x - x_{min})}$
      \begin{eqnarray}
            \epsilon_n - [ (1-z)^2 - 1] & = & 0\nonumber \\
            \epsilon_n - (z^2 - 2z) & = & 0 \nonumber \\
            z^2 - 2z - \epsilon_n & = & 0 \nonumber
      \end{eqnarray}
      Solve for z using
      \begin{eqnarray}
       z_\pm & = & \frac{-b \pm \sqrt{b^2 - 4ac} }{2a} \nonumber \\
       z_\pm & = & \frac{2 \pm \sqrt{4 - 4(1)(-\epsilon_n)} }{2} \nonumber \\
       z_\pm & = & 1 \pm \sqrt{1 + \epsilon_n} \nonumber
      \end{eqnarray}
      Now substitute $z$ back in to get
      \begin{eqnarray}
            e^{-(x_{\pm} - x_{min})} & = & 1 \pm \sqrt{1 + \epsilon_n} \nonumber \\
            -(x_{\pm} - x_{min}) & = &
                        \ln\left(1 \pm \sqrt{1 + \epsilon_n}\right) \nonumber\\
            x_{\pm} & = & x_{min} -
                  \ln \left( 1  \pm \sqrt{1+\epsilon_n} \right) \nonumber
      \end{eqnarray}
      Therefore $x_{in}(\epsilon_n) = x_{min} - \ln(1 + \sqrt{1-\epsilon_n})$ and
      $x_{out}(\epsilon_n) = x_{min} - \ln(1 + \sqrt{1+\epsilon_n})$.

      The following procedure was then followed:
      \begin{itemize}
            \item The \verb+quadratic.f+ program was modified to change
                  the potential from quadratic to Morse and to add the
                  new turning points calculated above.
            \item The source code for the new program \verb+morse.f+ can
                  be found in Appendix D.
            \item For the case of $n=0$, the program was run with a
                  number of different values of a, until a value was
                  found such that the value given for the energy
                  $E_n = V_0\epsilon_n$ was very close to value of
                  $E_0 = -4.477$ as given in Table 1.5 of Koonin
                  (experimental result).
            \item Using the final value of $a$, the first four quantised
                  energy levels were calculated with the program and
                  compared with the experimental results for the
                  $\mathrm{H_2}$ spectrum.
            \item The choice of starting values for $\epsilon_n$, is
                  restricted by the turning points, \\
                  $x_{\pm}  =  x_{min} -
                  \ln \left( 1  \pm \sqrt{1+\epsilon_n} \right)$.
                  We can see from this equation that
                  $-2 < \epsilon_n \le 1$.
      \end{itemize}

\subsection{Morse Potential Results}

      \subsubsection{Determining the parameter $\mathbf{a}$}
      The table below shows the results of inputing different values of
      $a$ into the \verb+morse.f+ program. We have the following values:
      \begin{itemize}
            \item $\gamma = 33.6567a$
            \item $r_{min} = 0.74166 \: \mathrm{\dot{A}}$,
                  $x_{min} = 0.74166a \: \mathrm{\dot{A}}$
            \item $V_0 = 4.747 \: \mathrm{eV}$, $(E_n = V_0\epsilon_n)$
            \item $n = 0$
            \item $N = 1000$ (Number of divisions in Simpson's Rule)
            \item $T = 10_{-3}$ (Tolerance in false position method)
      \end{itemize}
      From experimental results looking at the spectrum of the Hydrogen
      molecule, we know that for the lowest energy state (when $n=0$),
      we have $E_0 = -4.477 \: \mathrm{eV}$. Therefore, for a given
      value of $a$, we are looking for
      $\epsilon_0 = -4.477/4.747 \simeq -0.943121971$.

      \begin{table}[h]
      \caption{Values of $\epsilon_0$ for different values of the parameter $a$.}
      \label{tbl:epsilon-zero}
      \begin{center}
      \begin{tabular}{|c|c|} \hline
      $a$ & $\epsilon_0$ \\ \hline \hline
      0.50  &     -.9414586271  \\
      0.60  &     -.9510928378  \\
      0.55  &     -.9467075966  \\
      0.52  &     -.9436775546  \\
      0.51  &     -.9425895401  \\
      0.515 &     -.9431387536  \\ \hline
      \end{tabular}
      \end{center}
      \end{table}

      We see from Table~\ref{tbl:epsilon-zero} that we get closest to the value of
      $\epsilon_0$ when $a = 0.515$.

      Using this value of $a$, we can then run the program for the first
      4 values of $n = 0,1,2,3$ and compare to the experimental results.
      Since the experimental results are only available to 3 decimal
      places, it is meaningless to attempt to calculate solutions with
      more accuracy since we don't have more accurate experimental data
      to compare with. In all cases the calculations were done with 1000
      divisions in Simpson's rule and a tolerance of $10^{-3}$ for the
      root finding false position algorithm.

      The results of the running the program for the first four energy
      levels are shown in Table~\ref{tbl:first-four}, where $E_n^{*}$ is the
      numerical result calculated using the program and $E_n$ is the
      experimental result from Table 1.5 of Koonin.

      \begin{table}[h]
      \caption{First four quantized energy levels of
      the spectrum of the $H_2$ molecule.}
      \label{tbl:first-four}
      \begin{center}
      \begin{tabular}{|c|c|c|c|c|} \hline
      $n$   &   $\epsilon_n$  & $E_n^{*}$       &  $E_n$    & $Error$   \\\hline \hline
      0     &   -.9431387536  & -4.4770796631   & -4.477    & .796631E-04 \\
      1     &   -.8344090650  & -3.9609398314   & -3.962    & .106017E-02 \\
      2     &   -.7323362062  & -3.4763999710   & -3.475    & .139997E-02 \\
      3     &   -.6369210780  & -3.0234643571   & -3.017    & .646436E-02 \\ \hline
      \end{tabular}
      \end{center}
      \end{table}

\subsection{Morse Potential Discussion}

      As can be seen from Table 7, the values of the energy levels of
      the Hydrogen molecule for quantum levels $n = 0,1,2,3$, have a
      good agreement with the experimental results. The error was of
      magnitude $10_{-2}$ for $n = 1,2,3$ and of magnitude $10_{-4}$ for
      $n = 0$.

      The agreement between calculation and experiment is good,
      especially considering the use of the old quantum theory in the
      numerical calculations.

      More insight could have been gained into the accuracy of the
      numerical techniques used to do the calculations if the
      experimental data presented for the Hydrogen molecule spectrum was
      more accurate.

      With all the data now available we can make a plot of the equation
      \[ V_{Morse}(r) = V_0\left[\left(1-e^{-(r-r_{min})/a}\right)^2 - 1\right]. \]
      Using the values for $\gamma$, $a$, $r_{min}$, and $V_0$, shown in
      the previous section we can plot the Morse potential for the
      Hydrogren molecule in Figure~\ref{fig:morse}

        \begin{figure}
        \centering
        \includegraphics[width=0.8\columnwidth]{morse.eps}
        \caption{Morse Potential for Hydrogen Molecule}
        \label{fig:morse}
        \end{figure}

      Using the data for the first four quantized energy levels, we can
      plot these on top of the Morse potential plot, shown in
      Figure~\ref{fig:levels}.

        \begin{figure}[ht]
        \centering
        \includegraphics[width=0.8\columnwidth]{levels.eps}
        \caption{First Four Quantized Energy Levels}
        \label{fig:levels}
        \end{figure}

%----------------------------------------------------------------------
% APPENDICES
%----------------------------------------------------------------------

\onecolumn

\appendix[Code Listing: quad.f]
\showcode{quad.f}

\newpage
\appendix[Code Listing: root.f]
\showcode{root.f}

\newpage
\appendix[Code Listing: quadratic.f]
\showcode{quadratic.f}

\newpage
\appendix[Code Listing: morse.f]
\showcode{morse.f}

%----------------------------------------------------------------------
% END DOCUMENT
%----------------------------------------------------------------------

\end{document}

%----------------------------------------------------------------------


% !TeX root = ./report.tex
\maketitle
%\listoftodos
\begin{abstract}
The geometric independent set problem is a special case of the independent set problem where the graph is the intersection graph of a set of geometric objects. The challenge of the geometric independent set problem is to find the biggest set of non-intersecting objects, i.e. the maximum independent set  (MIS). In this report I will present polynomial time approximation schemes (PTAS) for the geometric independent set problem for unit disk graphs (UDG) and for unit height rectangles. The geometric independent set problem is in general $\NP$- hard and therefore intractable. The algorithms presented here use different approaches to guarantee a polynomial running time for a constant approximation quality.
\end{abstract}

\tableofcontents

\section{Introduction}
The geometric independent set problem, i.e. finding a (maximum) set of non-intersecting geometric shapes is a problem that can arise in many different fields. In this report I will introduce algorithms to give approximate solutions for the MIS of unit disk graphs as well as for the geometric independent set problem for unit height rectangles. Unit disks may correspond to the area of influence of radio towers where frequencies can only be assigned to radio towers where this areas do not intersect (i.e. an independent set) to prevent interference~\cite{chamaret}. The maximum independent set of unit height rectangles could correspond to a labelling of a two dimensional map with a uniform font~\cite{agarwallabel}.
\subsection{Maximum independent set problem for graphs}
An independent set of a graph is a set of vertices that are not adjacent (connected with an edge). Finding a maximum independent set of an arbitrary graph is known to be an \NP-complete problem~\cite{misnp}. The best known exact algorithms have a runtime \bigo{1.22^n} \cite{exacta,exactb} (already quite good compared to the \bigo{n^2 2^n} naive brute force approach resulting from checking every subset of vertices).

If the graph is an interval intersection graph (see \Fref{sec:ig}) the MIS can be found in polynomial time (similar to the algorithm described in~\Fref{sec:greedyalg}) though for many (most) other intersection graphs it is still \NP-complete but approximate solutions can be found efficiently.

\subsection{Polynomial time approximation scheme}
As finding exact solutions for \NP-hard problems is not feasible in most cases, algorithms that solve a given instance of an intractable problem in polynomial time with a bounded loss in solution quality are of interest. A so called polynomial time approximation scheme (PTAS) is a family of algorithms that find a solution with a solution quality that is bounded by a factor of $(1+\varepsilon)$ for any $\varepsilon > 0$. %\todo{PTAS subsection überarbeiten, ist recht konfus aktuell}
%\begin{align*}
%\frac{S_{\text{OPT}}}{\rho} \quad \text{or}
%\quad \frac{S_{\text{OPT}}}{1\pm \varepsilon} \qquad (S_{\text{OPT}} \ldots \text{quality of optimal solution})

That is, if the optimal solution is $S_\text{OPT}$, the algorithm finds a solution with a quality of at least $\nicefrac{S_\text{OPT}}{1+\varepsilon}$ for a maximization problem and a solution with a quality of at most $(1+\varepsilon)S_\text{OPT}$ for a minimization problem.
%\end{align*} in polynomial time. For maximization problems $\rho> 1$, for minimization problems $\rho < 1$  (or $(1+\varepsilon)$ respectively $(1 - \varepsilon)$ for some $\varepsilon > 0$).
In both cases the algorithm has runtime polynomial in input-size though the dependency on $\varepsilon$ is usually not polynomial.

The subset of problems in \NP\ (actually $\mathcal{NPO}$ -- \NP-\ Optimization) with a polynomial time approximation scheme with constant quality bound (with \bigo{1}-approximation) is also called $\mathcal{APX}$. If the problem admits $1\pm \varepsilon$- approximation schemes (for arbitrarily small $\varepsilon > 0$) it is in the subset $\mathcal{PTAS}$ of $\mathcal{APX}$.
\subsection{Intersection graphs}\label{sec:ig}
An intersection graph of a set of objects represents how these objects intersect each other. \Fref{fig:igex} shows an example of such an arrangement and its corresponding intersection graph.
  \begin{figure*}[!h]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering

 \begin{tikzpicture}[scale=0.6]
 \clip (-1.2,-1.2)rectangle(7.1,4.6);
 \newcommand{\centers}{(0,1),(0,0),(5,3),(2,1),(0.5,0.7),(4,3),(1.6,3.5),(6,0.5)}
 \foreach [count=\i] \coord in \centers{\draw[thick] \coord circle(1);}
 \end{tikzpicture}
      \caption{Geometric shapes (unit disks)}
\end{subfigure}%
  ~
 \begin{subfigure}[t]{0.5\textwidth}
      \centering
 \begin{tikzpicture}[scale=0.6]
 \clip (-1.2,-1.2)rectangle(7.1,4.6);
    % link centers if circles intersect
      \newcommand{\centers}{(0,1),(0,0),(5,3),(2,1),(0.5,0.7),(4,3),(1.6,3.5),(6,0.5)}
      \foreach [count=\i] \coord in \centers{\draw[gray!30,thick] \coord circle(1);}
        \foreach[count=\i] \a in \centers {
      \foreach[count=\j] \b in \centers {
        \ifnum \j < \i
          \draw[very thick] let \p1=\a, \p2=\b, \n1={veclen(\x1-\x2,\y1-\y2)} in
            {\ifdim \n1 < 2 cm \a -- \b \fi};
        \fi
      }
    }
    % draw circles
    \foreach \coord in \centers{\fill \coord circle(3pt);}
  \end{tikzpicture}
        \caption{Corresponding intersection graph}
    \end{subfigure}
    \caption{Arrangement of geometric shapes and corresponding intersection graph}\label{fig:igex}
\end{figure*}

It is also possible to reduce the edge set of the intersection graph to e.g.\ those edges where the corresponding objects intersect on an area bigger than a certain threshold (e.g. finding feasible locations for base stations where overlapping regions are inefficient). An example of this is in \Fref{fig:igex2} with a threshold of $20\%$ of the circle area.
\begin{figure}\centering

\end{figure}

  \begin{figure*}[!h]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering

\begin{tikzpicture}[scale=0.35,rotate=90]
\newcommand{\centers}{(0,0),(2,1),(1.6,3.5),(0,5),(5,3),(0.6,7),(4,6)}
{ \foreach \coord in \centers{\draw[thick] \coord circle(2);}}
\newcommand{\centerss}{(0,0),(1.6,3.5),(5,3),(0.6,7),(4,6)}
\end{tikzpicture}
   \caption{Geometric shapes (unit disks)}
\end{subfigure}%
  ~
 \begin{subfigure}[t]{0.5\textwidth}
      \centering
\begin{tikzpicture}[scale=0.35,rotate=90]
\newcommand{\centers}{(0,0),(2,1),(1.6,3.5),(0,5),(5,3),(0.6,7),(4,6)}
{ \foreach \coord in \centers{\draw[gray!40, thick] \coord circle(2);}}
{\draw[ultra thick] (0,0) -- (2,1) -- (1.6,3.5) -- (0,5)-- (0.6,7);}
{ \foreach \coord in \centers{\fill \coord circle(0.15);}}
\end{tikzpicture}
      \caption{Corresponding intersection graph}
    \end{subfigure}
    \caption{Edges in IG correspond to at least $20\%$ intersecting area of the circles.}\label{fig:igex2}
\end{figure*}

\subsubsection{Construction of intersection graphs from geometric objects}
Given an arrangement $\mathcal A$ of $n$ geometric objects its intersection graph $G=(V,E)$ can be obtained in the following way:
\begin{itemize}
\item The vertex set $V$ consists of $n$ vertices --- each of them uniquely represents one of the geometric shapes of $\mathcal A$
\item For every pair $s_i, s_j$ of vertices check whether they intersect each other and add the edge $\langle i, j\rangle$ to the edge set $E$ if this is the case.
\end{itemize}
Obviously the runtime of this scheme is \bigo{n^2}. The worst case performance of finding an intersection graph is always \bigo{n^2} as there can be a quadratic amount of intersections (if all objects intersect each other). If there are less intersection this can usually be improved to \bigo{n \log n + I} where $I$ is the amount of intersections (once again, with quadratic upper bound) and the other term is from sorting the objects according to some criterion, e.g. the leftmost point of the object on the x-axis. Sweepline algorithms are used for this, the best known is the Bentley--Ottman algorithm for line segments~\cite{bentleyott} with runtime \bigo{n \log n +n I}.

\subsubsection{Geometric representation of  intersection graph}
%Every graph can be interpreted as intersection graph (Erdös et al.~\cite{erdos1966representation} gave a constructive proof with  of some weirdly shaped geometric objects\todo{genauer erklären},
Finding a valid representation, i.e. a mapping  $f : V \to \mathbb R^d$, from the set of vertices to a vector representation of the geometric objects defined by $x_1, \ldots x_d \in \mathbb R$ (e.g. for disks in the plane $d=3$ ($x-,y-$ coordinates and radius), for rectangles $d=4$ (two points with two coordinates each)) is in many cases a $\NP$-hard problem \cite{nphard} and it is therefore not feasible to find a geometric representation of a given graph and use the additional information to simplify the general independent set problem.

\subsection{Robust algorithms}
An algorithm $\mathcal A$ computes a function $f: \mathcal G \to \mathcal H$. If the algorithm is only able to compute the correct result $f(i)$ for $i \in \mathcal U \subset G$ there are elements in $\mathcal G$ that are not in $\mathcal U$ and therefore the algorithm may not compute the correct result (or may not terminate at all).
\begin{definition}
 An algorithm $\mathcal A$ computes $f$ \textit{robustly on $\mathcal U$} if:
\begin{itemize}
\item for all instances $i\in\mathcal U$ it returns the correct result $f(i)$
\item for all instances $i\in\mathcal G\setminus \mathcal U$ the algorithm either returns $f(i)$ or a certificate showing that $i\notin \mathcal U$.
\end{itemize}
\end{definition}

\section{M(W)IS for unit disk graphs (UDG)}
In this section I will present a robust PTAS for both, the weighted and unweighted unit disk graph independent set problem as introduced by Nieberg et al.~\cite{nieberg}. The algorithm does not depend on the geometric representation, though the polynomial runtime is only guaranteed if such a representation exists because it uses the area $\pi$ of the unit disks to get an upper bound on the amount of disks in an independent set of a certain area.
\subsection{Preliminaries}
A unit disk graph $G=(V,E)$ is a graph where there exists a geometric representation $f:V \to \mathbb R^2$ i.e.\ a function that maps every vertex to a point to the center point on the real Cartesian plane of the disk in the geometric representation such that:
\begin{align}
(u,v) \in E \leftrightarrow ||f(u) - f(v)|| \leq 2.\label{eq:maxdist}
\end{align}
As finding this representation is \NP-hard it is not feasible to compute a valid representation of the given graph. Furthermore it is also \NP-hard to determine if a valid geometric representation even exists~\cite{nphard}.

Furthermore, let $\rho = 1+\varepsilon$ denote the desired approximation ratio where $\varepsilon > 0$.
\subsection{MIS for unweighted UDG}\label{sec:misudg}
The algorithm is given a UDG $G = (V,E)$ and the desired result is a set $I \subseteq V$ that has a cardinality that is at least $\alpha(G)\rho^{-1}$ where $\alpha(G)$ is the maximum size of an independent set in $G$.
The algorithm starts at an arbitrary node $v\in V$ and computes the sets
\begin{align*}
N_r = N_r(v) := \{w\in V|w \text{ has distance at most $r$ from $v$}\}
\end{align*} for $r = 0,1,\ldots$. Starting from $N_0$ the algorithm computes the maximum independent set $I_r \subset N_r$ of these $r$-neighborhoods until the condition
\begin{align}
|I_{r+1}| > \rho|I_r| \label{eq:udgcond}
\end{align}is no longer fulfilled - let $\bar r$ be the smallest $r$ where \fref{eq:udgcond} is violated. Such a $\bar r$ must exist and it has a constant upper bound.
\Fref{fig:udgalg} shows how these neighborhoods are selected on an example graph.
\input{img/NIn.tex}
\begin{theorem}[Nieberg et al.~\cite{nieberg}]
There exists a constant $c= c(\rho)$ such that $\bar r \leq c$
\end{theorem}
\begin{proof}
Due to \Fref{eq:maxdist} any vertex $w\in N_r$  satisfies
\begin{align*}
||f(w) - f(v)|| \leq 2r.
\end{align*}
it is therefore possible to draw a circle with radius $R = 2r+1$ that contains all disks representing the vertices in $N_r$. This circle also contains the disk representations of the vertices in $I_r$ which have a disjoint area of $\pi$ each (as their radius equals $1$). This leads to an upper bound on the size of each independent set:
\begin{align}
|I_r| \leq \pi R^2 /\pi = (2r+1)^2 = O(r^2).\label{eq:udupper}
\end{align}
From \Fref{eq:udgcond}follows:
\begin{align}
|I_r| > \rho|I_{r-1}| > \ldots  > \rho^r|I_0| = \rho^r.\label{eq:udglower}
\end{align}
Combining \eqref{eq:udupper} and \eqref{eq:udglower} yields
\begin{align}
\rho^r < |I_r| \leq O(r^2), \label{eq:upperboundlol}
\end{align}
an inequality (two of them actually) where the lower bound grows asymptotically faster then the upper bound with increasing $r$ -- therefore there exists a constant upper bound $c(\rho)$ for $r$.
\end{proof}
The fact that the size of the independent sets calculated for the various $N_r$ ($r\leq \bar r$) implies a polynomial runtime of $\bigo{n^{C^2}}$ (where $C = \bigo{r} = \bigo{1/\varepsilon^2 \log (1/\varepsilon}$).
The full algorithm proceeds as follows:
\begin{enumerate}
\item Calculate the independent set $I_{\bar r}$ starting from an arbitrary vertex $v$.
\item Remove the vertices in $N_{\bar r +1 }$ from the graph $G$ to get the graph $G' = (V',E') = G\setminus N_{\bar r +1}$ (including edges incident to any of the removed vertices).
\item Repeat the previous two steps for $G'$ until there is no vertex left i.e.\ $G' = (\varnothing,\varnothing)$.
\item Combine all $I_{\bar r}$ to get a $\rho$-approximate maximum independent set.
\end{enumerate}

\subsubsection{Proof of correctness \& approximation guarantee}

The correctness and approximation guarantee follows from the following two theorems by Nieberg et al.~\cite{nieberg}:
\begin{theorem}
Suppose that we can compute an independent set $I'\subset V\setminus N_{\bar r+1}$ of the graph $G'$. Then $I:=I_{\bar r} \cup I'$ is an independent set for $G$.
\end{theorem}
\begin{proof}
A vertex $v\in I'\subset V'$ has no neighbor $n\in N_{\bar r}$ as the distance between $v$ and any such $n$ is at least $\bar r +2$ (else it would have been in $N_{\bar r}$ and removed from the vertex set of $G'$). Therefore $I$ is an independent set.
\end{proof}

\begin{theorem}
Suppose inductively that we can compute a $\rho$-approximate independent set $I'\subset V\setminus N_{\bar r+1}$ of the graph $G'$. Then $I:=I_{\bar r} \cup I'$ is a  $\rho$-approximate independent set for $G$.
\end{theorem}
\begin{proof}
As $\bar r$ is chosen in such a way that the maximum independent set of $N_{\bar r}$ is a $\rho$-approximate independent set of $N_{\bar r +1}$  (ensured by \Fref{eq:udgcond}):
\begin{align*}
|I_{\bar r +1}| \leq \rho|I_{\bar r}|.
\end{align*}
Therefore the following holds:
\begin{align*}
\alpha(G[N_{\bar r +1}]) \leq \rho|I_{\bar r}|  = \rho\alpha(N_{\bar r}).
\end{align*}
Furthermore it is obvious that the size of an independent set of a graph is at most as large as the sum of the sizes of independent sets of subgraphs that form a partition of the initial graph. Applying this here yields
\begin{align*}
\alpha(G)& \leq \alpha(G[N_{\bar r +1 }]) + \alpha(V\setminus G[N_{\bar r +1}]) \leq \rho|I|\\
\alpha(G)& \leq  \rho|I|,
\end{align*} and thus proves that the desired approximation guarantee is fulfilled.
%\TODO[maybe make this proof a little easier to understand]
\end{proof}
\subsection{MWIS for weighted UDG}\label{sec:mwisudg}
If the given UDG has a vector $\vec w$ assigning positive values $w_i$ to every vertex $v_i$ and the objective is to find an independent set of maximum weight the algorithm described in \Fref{sec:misudg} can be easily adapted to yield an independent set that has a weight that is at least $\rho^{-1}$ the weight of the independent set with the maximum weight.
The following things have to be adapted:
\paragraph{Starting node $v_0$:} Don't start at an arbitrary node $v_0$ but at the node with the heighest weight.
\paragraph{Stopping criterion:} Modify the stopping criterion in \Fref{eq:udgcond} to consider the weight instead of only the size. The function $W: V^n\to \mathbb R$ maps vertices to their weight and sets of vertices to the sum of their weight.
\begin{align*}
W(I_{r+1}) > \rho W(I_r)
\end{align*}
Obtaining the bound to get a constant upper bound (as in \Fref{eq:upperboundlol}) is rather straightforward:\\
\begin{theorem}[Nieberg et al.~\cite{nieberg}]
There exists a constant $c= c(\rho)$ such that $\bar r \leq c$
\end{theorem}
\begin{proof}
The idea of the proof is the same as for the unweighted case. As the upper bound use:
\begin{align*}
W(I_r) &= \sum_{i\in I_r}W(v_i)\leq \sum_{i\in I_r}W(v_0) = |I_r|w_0
\intertext{where $w_0$ is the weight of $v_0$ -- the vertex with highest weight. And the lower bound use:}
W(I_r) &> \rho W(I_{r-1} > \ldots > \rho^r W(I_0) = \rho^r  w_0
\end{align*}As it still holds that $I_r$ is bounded by $\bigo{r^2}$ (using the area of the unit disks) we get the same upper and lower bounds but with an additional constant factor for the weight of the initial node.
\end{proof}

\subsection{Robustness}
The algorithms outlined in \Fref{sec:misudg} and \Fref{sec:mwisudg} are PTAS with the desired solution quality as long as the graph really is a unit disk graph. To get a robust PTAS for arbitrary graphs from this there are some minor modifications necessary. Observe, that in both cases the approximation quality as well as the overall correctness did not depend on any properties of a UDG. Only for getting the constant bound on the sizes of the independent sets $I_r$ the area of the disks was used. \\
The only necessary modification is therefore to look whether an independent set of size $|I_r^*| > (2r+1)^2$ can be found and if this is the case return it as certificate that the given graph is not a UDG. Finding this set is also possible in polynomial time as not the maximum independent set $I_r\subset N_r$ has to be found (the maximum size of this independent set would be unbounded and therefore impossible to determine in polynomial time) but only an independent subset with a size of at least $(2r+1)^2+1$ is necessary which is still possible in polynomial time.

\section{MIS for unit height rectangles}
The maximum independent set problem for unit height rectangle is a problem that arises when labelling maps. The goal is to find a maximum non-intersecting set of possible labels in the plane to ensure legibility. In this section I will present a $2$-approximation algorithm  with \bigo{n \log n} runtime for the unweighted MIS problem for unit height rectangles introduced by Agarwal et al.~\cite{agarwallabel} which can be improved upon with a dynamic programming approach to get a $(1+\nicefrac{1}{k})$-approximation algorithm with runtime \bigo{n \log n + n^{2k-1}} for $k\geq 1$. The idea of the improvement will be presented here, for the technical details the original paper has to be consulted. For this algorithms the arrangement of rectangles is required.
\subsection{A $2$-approximation algorithm}
The set of $n$ rectangles $R$ with unit height is given. The maximum independent set of rectangles is $I_\text{OPT}$. To get a $2$-approximate independent set, the algorithm partitions the $n$ rectangles into disjunct subsets, calculates the maximum independent set of those subsets and returns the conjunction of those independent sets. To divide the rectangles into sets horizontal lines $\ell_1, \ell_2,\ldots,\ell_m$ where $m\leq n$ are drawn such that the following three conditions hold:
\begin{itemize}
\item The distance between two adjacent lines is $>1$. i.e.\ bigger than the height of a rectangle
\item Each line intersects at least one rectangle
\item Each rectangle is intersected by exactly one line
\end{itemize}
To find the correct positions for the lines, first sort the rectangles according to their vertical coordinates and draw the first line at the top of the rectangle with smallest $y$-coordinate and the following lines at the top of the rectangle with the smallest $y$-coordinate that is not yet intersected by a line.  \Fref{fig:uhr1a} illustrates this. Now every rectangle has an intersecting line and the initial arrangement of rectangles is partitioned into sets $R_1,\ldots,R_m$ where for every $1\leq i \leq m$ the set $R_i$ contains those rectangles that are intersected by the line $\ell_i$.

Due to the fact that the distance between two lines is bigger than the height of the rectangles a rectangle in the set $R_i$ can only intersect with rectangles in the sets $R_i$ and $R_i\pm1$. Therefore the independent sets $I_i$ of the even sets $R_{2n}$ and the odd sets $R_{2n+1}$ ($0\geq n \geq \nicefrac{m}{2}$) can be combined to two independent sets $I_{\text{odd}} = \bigcup_{n> 0} I_{2n}$ and $I_{\text{even}} = \bigcup_{n\geq 0} I_{2n+1}$.

\subsubsection{Greedy algorithm for MIS of intervals}\label{sec:greedyalg}
The MIS of every subset $R_i$ can be found in polynomial time with a greedy algorithm. As can be seen in \Fref{fig:uhr1c} two rectangles that are intersected by a common horizontal line only intersect each other iff the intervals of their $x$-coordinates intersect each other. Therefore the problem of finding a MIS of the rectangles in one of the sets $R_i$ can be reduced to finding a MIS of the horizontal projection of these rectangles. For this a greedy algorithm with runtime \bigo{n\log n} exists. The idea of this algorithm is the following inductive argument: For every point $p$ on the $x$-axis at most one interval in the MIS can be \textit{active}, i.e.\ having a start point $s$ and an end point $e$ s.t.\ $s\leq p\leq e$. It follows that if two (or more) intervals intersect each other at one point at most one of these intervals can be added to an independent set. Choosing the interval with the lowest endpoint allows choosing more intervals after this interval (see \Fref{fig:uhr1d}).

\begin{figure*}[!h]
\centering
\begin{subfigure}[t]{0.5\textwidth}
\centering
\definecolor{cadmiumred}{rgb}{0.89, 0.0, 0.13}
\definecolor{cadmiumgreen}{rgb}{0.01, 0.75, 0.24}
\begin{tikzpicture}
\draw[very thick,cadmiumred] (1,0) rectangle+(1,1);
\draw[very thick,cadmiumred] (6,0) rectangle+(0.5,1);
\draw[very thick,cadmiumred] (3.5,0.2) rectangle+(1.5,1);
\draw[very thick,cadmiumred] (5.2,0.4) rectangle+(1,1);
\draw[very thick,cadmiumred] (3,0.8) rectangle+(0.9,1);

\draw[very thick,MidnightBlue] (2.2,1.3) rectangle+(1.5,1);
\draw[very thick,MidnightBlue] (1,1.4) rectangle+(1.9,1);
\draw[very thick,MidnightBlue] (3.5,1.6) rectangle+(2,1);

%\definecolor{darkpastelgreen}{rgb}
\draw[very thick,cadmiumgreen] (0.2,2.5) rectangle+(1.9,1);
\draw[very thick,cadmiumgreen] (6,2.5) rectangle+(1.2,1);
\draw[very thick,cadmiumgreen] (2.2,2.8) rectangle+(1.3,1);
\draw[very thick,cadmiumgreen] (1,2.9) rectangle+(0.7,1);
\draw[very thick,cadmiumgreen] (5.3,2.9) rectangle+(0.8,1);
\draw[very thick,cadmiumgreen] (3,3) rectangle+(1.5,1);
\draw[very thick,cadmiumgreen] (3.6,3.1) rectangle+(1,1);
\draw[very thick,cadmiumgreen] (4.7,3.3) rectangle+(0.5,1);

\draw[very thick,dashed] (0,1.0)--+(7.5,0) node[right] {$\ell_1$};
\draw[very thick,dashed] (0,2.3)--+(7.5,0)node[right] {$\ell_2$};
\draw[very thick,dashed] (0,3.5)--+(7.5,0)node[right] {$\ell_3$};
\end{tikzpicture}
\caption{Unit height rectangles partitioned into three sets $\color{cadmiumred}{R_1},\color{MidnightBlue}{R_2},\color{cadmiumgreen}{R_3}$ with intersecting lines $\ell_1,\ell_2,\ell_3$.}\label{fig:uhr1a}
\end{subfigure}%
  ~ \vline ~
 \begin{subfigure}[t]{0.5\textwidth}
      \centering
\begin{tikzpicture}[scale=1]
\draw[very thick,gray!50] (3.5,0.2) rectangle+(1.5,1);
\draw[very thick,gray!50] (6,0) rectangle+(0.5,1);

\draw[very thick,gray!50] (2.2,1.3) rectangle+(1.5,1);

\draw[ultra thick] (1,0) rectangle+(1,1);
\draw[ultra thick] (3,0.8) rectangle+(0.9,1);
\draw[ultra thick] (5.2,0.4) rectangle+(1,1);

\draw[ultra thick] (1,1.4) rectangle+(1.9,1);
\draw[ultra thick] (3.5,1.6) rectangle+(2,1);

\draw[very thick,gray!50] (3,3) rectangle+(1.5,1);
\draw[very thick,gray!50] (6,2.5) rectangle+(1.2,1);
\draw[very thick,gray!50] (0.2,2.5) rectangle+(1.9,1);
\draw[ultra thick] (1,2.9) rectangle+(0.7,1);
\draw[ultra thick] (2.2,2.8) rectangle+(1.3,1);
\draw[ultra thick] (3.6,3.1) rectangle+(1,1);
\draw[ultra thick] (4.7,3.3) rectangle+(0.5,1);
\draw[ultra thick] (5.3,2.9) rectangle+(0.8,1);

\draw[very thick,dashed] (0,1.0)--+(7.5,0) node[right] {$\ell_1$};
\draw[very thick,dashed] (0,2.3)--+(7.5,0)node[right] {$\ell_2$};
\draw[very thick,dashed] (0,3.5)--+(7.5,0)node[right] {$\ell_3$};
\end{tikzpicture}
\caption{MIS $I_1,I_2,I_3$ (black) for the sets $R_i$. Note that rectangles from IS of two adjacent sets ($I_i, I_{i\pm 1}$) may intersect each other.}
\end{subfigure}\\
 \begin{subfigure}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[scale=1]
\draw[very thick] (1,2.9) rectangle+(0.7,1);
\draw[very thick] (3,3) rectangle+(1.5,1);
\draw[very thick] (6,2.5) rectangle+(1.2,1);
\draw[very thick] (0.2,2.5) rectangle+(1.9,1);
\draw[very thick] (2.2,2.8) rectangle+(1.3,1);
\draw[very thick] (3.6,3.1) rectangle+(1,1);
\draw[very thick] (4.7,3.3) rectangle+(0.5,1);
\draw[very thick] (5.3,2.9) rectangle+(0.8,1);
\draw[very thick,dashed] (0,3.4)--+(7.5,0);
\begin{scope}[yshift=2.2cm]
\draw[very thick] (0.2,0) rectangle+(1.9,0);
\draw[very thick] (1,0.1) rectangle+(0.7,0);
\draw[very thick] (2.2,0) rectangle+(1.3,0);
\draw[very thick] (3,0.1) rectangle+(1.5,0);
\draw[very thick] (3.6,0.0) rectangle+(1,0);
\draw[very thick] (4.7,0.0) rectangle+(0.5,0);
\draw[very thick] (5.3,0.0) rectangle+(0.8,0);
\draw[very thick] (6,0.1) rectangle+(1.2,0);
%\draw[very thick,dashed] (0,1)--+(7.5,0);
\end{scope}
\end{tikzpicture}
\caption{To find a MIS of $R_3$ only the $x$-coordinates have to be considered. Two rectangles intersect iff their projection to a horizontal line (below) intersects.}
\label{fig:uhr1c}
\end{subfigure}%
  ~ \vline ~
 \begin{subfigure}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[scale=1]
\draw[ultra thick] (1,0) rectangle+(0.7,0);
\draw[ultra thick,gray!50] (0.2,0.1) rectangle+(1.9,0);
\draw[ultra thick] (2.2,0.2) rectangle+(1.3,0);
\draw[ultra thick,gray!50] (3,0.3) rectangle+(1.5,0);
\draw[ultra thick] (3.6,0.4) rectangle+(1,0);
\draw[ultra thick] (4.7,0.5) rectangle+(0.5,0);
\draw[ultra thick] (5.3,0.6) rectangle+(0.8,0);
\draw[ultra thick,gray!50] (6,0.7) rectangle+(1.2,0);
%\draw[very thick,dashed] (0,1)--+(7.5,0);
\end{tikzpicture}
\caption{Horizontal projection of rectangles in $R_3$ ordered (in vertical direction) by their endpoint. Greedy algorithm adds interval with nearest endpoint (bottom to top in this figure) that does not intersect rectangles already in the set.}
\label{fig:uhr1d}
\end{subfigure}

    \caption{Illustration of the $2$-approximation algorithm for the unit height rectangle MIS problem.}\label{fig:uhr1}
\end{figure*}

\subsubsection{Correctness and proof of approximation quality}
\begin{theorem}
The set $I_{\text{even}} = \bigcup_{n> 0} I_{2n}$ obtained by combining the maximum independent sets $I_{n}$ of the sets $R_{n}$ for even $n$ is also a maximum independent set of $R_{\text{even}} = \bigcup_{n>0}R_{2n}$.
\end{theorem}
\begin{proof}
 The rectangles in this set are independent because a rectangle $r$ from the set $I_x\subseteq R_x$ can't intersect any other rectangle in the set $I_x$ because if this were the case $I_x$ would not be an independent set. Furthermore the rectangle $r$ can't intersect any rectangle $r'\in I_\text{even}\setminus I_x$ as $r$ and $r'$ both are intersected by a horizontal line with a vertical distance $2+\varepsilon$ with $\varepsilon>0$ and therefore the vertical distance between $r$ and $r'$ is at least $\varepsilon$. As every independent set $I_x$ is the MIS of $R_x$ the combination $I_\text{even}$ is also the MIS of $R_\text{even}$. The same arguments apply to the set $I_\text{odd}\subseteq R_\text{odd}$.\\
\end{proof}
The approximation quality guarantee follows from the fact that the MIS $I_\text{OPT}$ of all the rectangles is at most $I_\text{even} + I_\text{odd}$. Therefore choosing the bigger of the sets $I_\text{even}$ and $I_\text{odd}$ leads to a $2$-approximation in the case that $|I_\text{even}| = |I_\text{odd}|$. If one of the sets has more elements than the other the approximation is even better.
\subsubsection{Runtime of $2$-approximation algorithm}
The runtime of the algorithm is dominated by the sorting of the rectangles which takes time \bigo{n \log n}. Partitioning the sorted rectangles with horizontal lines can be done in \bigo{n} by iteratively taking the first (i.e.\ having the smallest $y$-coordinate) not-yet-intersected rectangle and adding a line at it's upper $y$-coordinate. Finding the MIS of every set $R_i$ is also bounded by \bigo{n\log n} resulting from the sorting the rectangles in each of the sets of the partition. Selecting the rectangles for the independent sets $I_i$, combining the even and odd independent sets and comparing their sizes can all be done in \bigo{n}.

\subsection{Improving to a $(1+\nicefrac{1}{k})$-approximation algorithm}
The algorithm described before separates the rectangles into independent subproblems for which efficient algorithms exist. The idea from Agarwal et al. was to improve this method by increasing the size of these subproblems in a way that still ensures that they can be solved in polynomial time for some fixed $k$. In the $2$-approximation algorithm the MIS of $R_n$ for either even or odd $n$ were discarded completely. The idea of the improved algorithm is to partition the rectangles in the same way as before but to solve the MIS problem for sets of rectangles intersected by $k$ consecutive lines. Those sets are referred to as \textit{subgroups} and are defined in the following way:
\begin{equation*}
R_i^k = \bigcup_{n = i}^{i+k-1}R_n.
\end{equation*}
For some value $k$ there are $k+1$ \textit{groups} $G_1, \ldots, G_{k+1}$ that correspond to the sets $R_\text{odd}$ and $R_\text{even}$
\begin{equation*}
G_j = R_1^{j-1} \cup \bigcup_{i\geq 0}R_{i(k+1)+j}^k  = R \setminus \bigcup_{i\geq 0} R_{i(k+1)+j}.
\end{equation*}
The group $G_j$ is therefore the set of all rectangles $R$ except those intersected by every $(k+1)$-th line starting from the $j$-th line. Also all subgroups $R_i^k$ in $G_j$ are independent from each other, i.e.\ there are no two rectangles in two different subgroups that intersect each other.
Computing the MIS $I_i \subseteq G_i$ for all $i\in \{1,\ldots,k+1\}$ and picking the biggest of those independent sets leads to a $(1+\nicefrac{1}{k})$-approximate solution, %.
%The idea behind this technique is the \textit{shifting technique} introduced by Hochbaum and Maass~\cite{shifting}.
%\begin{theorem}
as for every $j$ the set $R\setminus G_j$ contains rectangles intersected by at most $\lceil \nicefrac{m}{k+1}\rceil$ lines %, computing the MIS for each $G_j$ and choosing the largest independent set yields a $(1+\nicefrac{1}{k})$-approximate solution as%
 and therefore at most $\nicefrac{|I_\text{OPT}|}{k+1}$ rectangles can be missed due to the pigeon hole principle. \\

 To get the maximum independent set for the groups $G_i$ a dynamic programming scheme is used that exceeds the scope of this report. In Agarwal et al.~\cite[Section 4.2]{agarwallabel} more details can be found.
%\end{theorem}
%\begin{proof}
%The method seperates the rectangles into disjunct $k+1$ sets and takes the MIS of $k$ sets. If the biggest MIS obtained by this method does not adhere to the approximation guarantee the independent set of $R \setminus G_j$ contains more than $\nicefrac{|I_\text{OPT}|}{k+1}$ rectangles.

%Assume that the MIS of $G_j$ is bigger than the MIS of $G_i$ for all $i\in \{1,\ldots,k+1\}\setminus j$. Furthermore assume that $I_i < I_\text{OPT} - \nicefrac{|I_\text{OPT}|}{k+1}$, i.e. the size of the MIS does not adhere to the $(1+\nicefrac{1}{k})$-approximation guarantee. If this is the case $I_j$ contains at least $ \nicefrac{|I_\text{OPT}|}{k+1}$ rectangles less than the optimal solution and the $k$ other $I_i$ omit even more. As all $I_i$ as well as $I_j$ omit rectangles from disjunct sets of rectangles
%\end{proof}

%\paragraph*{TEST}I'm citing stuff here
%\cite{chamaret}
%\cite{mcdiarmid}
%\cite{fonseca}
%\clearpage

2016-04-13 - Geometric Independent Set/Report/content.tex


% chap2.tex

\chapter{Network Structure}\label{chap:nwstruct}

This chapter discusses different type of networks in practice, their usage and prominent network architectures. We will discuss only few networks which have achieved significant success in recent times. Primarily we will discuss CNN(Convolutional Neural network) as that is the main network used through out this work.

\section{Networks}
The introduction to Neural network has started long ago with Frank Rosenblatt, famous MLP(Multi Layer Perceptron)\cite{Rosenblatt58theperceptron:}.Working of neural nets today are precisely captured by Rosenblatt.
It talks about pathways to connect to output so that for particular input associated pathway gets activated and produces corresponding output.
Following that several networks are suggested directed for specific tasks. For example for image to extract neighborhood relationship, convolution neural networks are suggested. For time series data Recurrent neural networks are suggested. LSTM is recent state of the art for handling time series tasks.

Auto Encoders are suggested as unsupervised nets, which generates low level representation of inputs using only input data.
Restricted boltzmann machines are another type of network which focuses on convergence by lowering the energy.
In Hopfield network every neuron connects to every other neuron in the network.

Other types of networks are Radial Basis Network(RBN), Gated Recurrent Unit(GRU), Deep belief network(DBN), Generative adversial network(GAN).

\subsection{Perceptron}
The perceptron has been introduced to handle perceptual recognition, generalization and hence the name Perceptron. In this landmark paper Rosenblatt nicely maps the neurons development in human being to perceptron.
For instance connection of nervous system are assumed as random and in neural nets at start mostly random initializations are used.
The original system has said to be capable of plasticity, which allows other neuron output to change over time seeing stimulus applied. And if same or similar stimuli is seen large number of times, will tend to form pathways to same sets of responding cells. This almost sums up the current neural nets, however the network construction, random initializations may differ a lot.
The perceptron is shown in fig \ref{fig:percep}
\begin{figure}[H]
	\centering
	\subfigure{
		\centering
		\includegraphics[scale=0.75]{Images/perceptron}
	}
	\caption{\label{fig:percep} Perceptron}
	\medskip
	\small
	\begin{flushleft}
		\textit{Regarded as starting point of neural network evolution perceptron is simplest of neural networks. It has  no hidden layers, just inputs with weights and bias term added together with non linear transformation or activation function produces output. Perceptron was limited in their power due to their non-ability to handle non linear target functions, such as XOR.}
	\end{flushleft}

\end{figure}

\subsection{CNN}
CNN famously known as Convolutional Neural Network are revolutionary architecture which has provided significant results in many image based learning tasks. CNN takes advantage of neighborhood relationships between data and so image data is natural choice for these networks. see figure \ref{fig:cnn}.

\begin{figure}[H]
	\centering
	\subfigure{
		\centering
		\includegraphics[scale=0.75]{Images/cnn}
	}
	\caption{\label{fig:cnn} CNN}
	\medskip
	\small
	\begin{flushleft}
		\textit{CNN composition is shown in figure \ref{fig:cnn}, This is most common network configuration, however there are many different variations suggested from time to time. CNN works well on data which is having neighborhood relationship such as image has spatial relationship between pixels. Input undergoes convolution to get low level representation with shared weights for the convolution. Generally convolution filter size is 3x3. Immediately after convolution layer there would be pooling layer, which reduces the data representation further. Deepness comes by repeating these layers. At last flatten layer reduces representation to number of classes which activates one of its neuron or provide the output probabilities of image belonging to output class vector.}
	\end{flushleft}

\end{figure}

\subsection{RNN}
Recurrent neural nets are having connections to same hidden layer neurons, and thus capable of storing time series data or feedback to be used with next set of input in sequence.

\begin{figure}[H]
\centering
\subfigure{
	\centering
	\includegraphics[scale=0.75]{Images/rnn}
}
\caption{\label{fig:rnn} RNN}
\medskip
\small
\begin{flushleft}
	\textit{Recurrent neural network are useful in case of sequential data, where data at current instance is dependent on previous data instances. Most popular RNN models are language models, where it generates probabilities of existence of any sentence based on underlying language it trained with. Another important application of RNNs are generative models, where in given one word it generates next word. This is possible by RNN having feedback to same neuron or hidden layers. The feedback give this network immense power as unfolding this network it will act as several deep layers which is dependent on RNN ability to store previous information.}
\end{flushleft}

\end{figure}

\subsection{LSTM}
Long Short Term Memory(LSTM) is one type of RNN network which uses LSTM cells.

\subsection{Auto Encoders}
Auto encoders helps in learning representation by using input as output and just keep encoded layers and grow network as deep as possible. Auto encoder has delivered significant results for various tasks including image classification tasks. Auto encoder LSTM is variant of LSTM with Auto encoding capabilities.

%\renewcommand{\baselinestretch}{\spacing}\normalsize
\doublespacing\normalsize


\subsection{Outlier Detection}
\label{sec:outlier-detection}

Models, once properly trained, are used for classification and detection of outliers -- either in incoming \texttt{INSERT} operations on a running system, or in existing rows (possibly but not necessarily the ones used during the model training phase). % LATER: Citation about databases sizes?

Given that databases can contain tables with tens or hundreds of columns, simply flagging a row as an outlier is insufficient: users cannot be expected to painstakingly analyze each outlying row. Instead, \dBoost/ automatically indicates which values in the row caused it to be flagged as an outlier.

The inter-column correlations are also taken into account during modeling: if the statistical analysis phase detected a correlation between two columns $a$ and $b$, each tuple $t$ will be augmented by an additional field that contains the corresponding pair $(t_a, t_b)$. This field is treated as a single, multidimensional value, and is analyzed similarly to the other values by the models.

As for statistical modeling, the heuristics that we employ for simple Gaussian and mixture modeling are not new; our contribution rests in the heuristics that we use for histograms (\ref{sec:outlier-detection-histograms}), and in the description of \emph{meta-modeling}.

\subsubsection{Histogram Modeling}
\label{sec:outlier-detection-histograms}
The histogram-based modeling strategy proceeds in two phases to detect outliers.

First, after running through the learning phase, it decides for each histogram whether that histogram is ``peaked'' (i.e.\ showing a few strong modes) enough to be used to detect outliers. The aim of this phase is to discard histograms where most bins have a similar number of values, and are thus not useful for outlier detection. In practice, we use a simple statistical test to determine whether a histogram is sufficiently modal: if the number of elements that fall into the most populated (``top'') bins is less than some user-specified proportion, the histogram is discarded. Finding how many bins to include in the set of top bins is the most challenging part, and for this paper we explored two thresholding strategies (Figure~\ref{fig:peakiness}):

\begin{figure*}
  \centering
  \paddedgraphics{../../graphics/peakiness.pdf}
  \caption{Sample histograms, and corresponding decisions with distribution-dependent (\(D\)-independent) and distribution-independent (\(D\)-independent) thresholds. Each figure shows a sorted histogram, with the top bins hatched (in dotted green in the distribution-independent case, and in solid orange in the distribution-dependent case). The vertical arrows show the small value \(r=3\) in the distribution-dependent case. The weaknesses of the distribution-independent-model show in the third and fourth plots: in the third one the distribution-dependent strategy correctly rejects because of the small \(r\); in the fourth the distribution-independent strategy yields an incorrect threshold.}
  \label{fig:peakiness}
\end{figure*}

\begin{itemize}
\item \emph{Distribution-independent} -- Given a histogram with $N$ bins, we count only the values in the top bin if $1 \leq N \leq 3$, in the top $2$ bins if $4 \leq N \leq 5$, and in the top $3$ bins for $3 \leq N \leq 16$ (histograms with $N > 16$ bins were previously discarded). This method is stable when the set of bins is static (week days, booleans, \ldots), but it is sensitive to the addition of removal of bins.
\item \emph{Distribution-dependent} -- We sort the bins in increasing order of bin size $b_i$, and find the index $i_{\max}$ such that the ratio $r = \sfrac{b_{i+1}}{b_{i}}$ is maximal (this calculation is safe, because the bin sizes are non-zero integers). If that ratio is under a user-defined threshold, we reject the histogram; otherwise, we consider bins $i_{\max} .. \texttt{end}$ to be ``top'' bins.
\end{itemize}

Figure~\ref{fig:peakiness} shows various types of histograms, and lists the conclusions that each of these two approaches yield.

After identifying a relevant set of histograms (this operation only needs to run once, at the very beginning of the last pass), we proceed to the actual detection phase. We classify an expanded tuple $X$ as an outlier if any of its values (or set of values, as grouped according to the correlation hints previously obtained) $x_a$ verifies:
\begin{align}
h_a(x_a) \le \epsilon \sum_k h_a(k)
\label{eqn:hist-outlier}
\end{align}
where $h_a(x)$ designates the number of tuples with value $x$ for field $a$, and $\epsilon$ is a user-chosen sensitivity parameter.

In this model, identifying and reporting the outlying attributes is simply a matter of remembering which values $x_a$ failed test \eqref{eqn:hist-outlier}.

\subsubsection{Simple Gaussian Modeling}
The simple Gaussian model measures how much each value differs from the mean computed in the preceding pass. Given a tolerance parameter $\theta$, a row is deemed an outlier if at least one of its attributes $a$ has a value $v_a$ such that
\begin{align}
  |v_a - \mu_a| \ge \theta \cdot \sigma_a
  \label{eqn:gaussian-outlier}
\end{align}
where $\mu_a$ and $\sigma_a$ are the model's parameters for column $a$, as described in Section~\ref{sec:gaus_model}.

In this model, detecting which values are responsible for the outlier flag is simply a matter of keeping track of which attributes satisfy Equation~\eqref{eqn:gaussian-outlier}. The simple Gaussian model does not take correlation hints into account, and thus reports only single-attribute outliers.

\subsubsection{Mixture Modeling}
In the Mixture model, the likelihood of each (possibly multidimensional) field is evaluated using the corresponding GMM\. This model operates under the assumption that data is accurately modeled by the chosen number of components in the GMM, and in particular that each non-outlying data point is well modeled by one of the Gaussians of the GMM.

This makes it possible to assign a Gaussian component to each tuple, and then flag as outliers the tuples that are not sufficiently well explained by their corresponding Gaussian (see~\cite{Roberts1999}). Given a tuple $t$ and its corresponding Gaussian $c$, this means rejecting $t$ if

\begin{align}
  \pi_c \cdot \Pr(\textbf{dist}(t, \mu_c) > d_0)  \leq \theta
  \label{eqn:mixture-outlier}
\end{align}
where $\theta$ is a user-defined parameter between 0 and 1, and $d_0$ is the Mahalanobis distance of $t$ to the Gaussian.

As in the Gaussian Model, providing the user with a list of attributes that caused the row to be flagged as an outlier is simply a matter of tracking correlations that satisfied equation~\eqref{eqn:mixture-outlier}.

\subsubsection{Partition-based modeling}
In the partition-based case, outliers are detected by the underlying models. To classify a given expanded tuple, each group of correlated attributes is divided between a one-attribute key and a group sub-population attributes. This group of attributes is then passed to the underlying model corresponding to the given value of the key, and the whole original tuple is reported as an outlier if any of its groups of sub-population attributes is marked as such by the underlying models.


\documentclass[a4paper,11pt]{article}

\usepackage{physics}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm, mathtools}
%\usepackage{hyperref}
\usepackage{color}
\usepackage{jheppub}
\usepackage[T1]{fontenc} % if needed

% My Documents
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\bes}{\begin{equation*}}
\newcommand{\ees}{\end{equation*}}
\newcommand{\bea}{\begin{flalign*}}
\newcommand{\eea}{\end{flalign*}}

%\linespread{1.0}
%\setlength{\parindent}{0em}
%\setlength{\parskip}{0.8em}

\title{\textbf{Notes for BH Mimickers Project}}
\author{Aditya Vijaykumar}
\affiliation{International Centre for Theoretical Sciences, Bengaluru, India.}
\emailAdd{aditya.vijaykumar@icts.res.in}

\begin{document}
\maketitle

The basic aim is to ascertain whether the GWs detected by LIGO were really due to the coalescence of binary black holes. Put another way - we want to assume some simple models of these alternative objects, and constrain what the parameters of these models might be.

\section{Reviews}

\subsection{Notes on arXiv:1804.08026 - Constraining black hole mimickers with gravitational wave observations}

\begin{itemize}
	\item A commonly considered alternative to Black Holes are Boson Stars (hereforth abbreviated as BS; no pun intended). BS are solutions of Einstein equations with the matter term containing a complex scalar field coupled to the metric. One can write the Einstein-Hilbert action describing the BS as follows,
	\begin{equation*}
	S = \int \dd^4{x} \sqrt{-g}\qty[R - \dfrac{1}{2} \qty(g^{ab} \partial_a \phi \partial_b \phi   + V(\abs{\phi}^2))]
	\end{equation*}
	The scalar field gives the BS energy to gravitate. It is not exactly very straightforward why the BS should be stable, and what should balance the gravitation. The bottom line, though, is that one can think of scenarios where BS might be stable against gravitational collapse. \textit{Living Reviews in Relativity} has what seems like a good summary of BS. \footnote{\text{https://link.springer.com/article/10.1007\%2Fs41114-017-0007-y}} \textit{Gravastars} are another proposed model for such compact objects.

	\item One is not sure about what electromagnetic signatures such models can have, but one can have hope of detecting (or not detecting) these objects through Gravitational Waves. Such non-BH models will have tidal deformation due to the companion object, as well as deformations due to their own spin. These deformations would change the gravity around these objects, and hence the gravitational waves that are emitted from them. We can hope of detecting these deviations from Black Holes in the inspiral waveform.

	We choose the inspiral because we think we understand the PN expansion very well. We essentially cut off our analysis before PN starts losing significance. One can't deal with the merger phase very well as full numerical simulations of these models are still at a very nascent stage. \textcolor{red}{But can one deal with such objects in perturbation theory and obtain ringdown modes for such models?} \footnote{https://journals.aps.org/prd/pdf/10.1103/PhysRevD.50.6235}

	\item As opposed to the Fisher Matrix analysis used in other papers, this paper makes use of a full Bayesian method using the best GW waveforms. \textcolor{red}{What are the problems with the Fisher Matrix analysis and why is this method better?}

	\item The objects considered in this paper are nonspinning, perfect fluid stars described by a polytropic equation of state. We have,
	\begin{equation*}
	p = K \rho^{1 + 1/n} \qq{and} \rho = \epsilon - n p
	\end{equation*}
	where $ p $ is the pressure, $ \rho $ is the rest mass density, $ n $ is the polytropic index, $ \epsilon $ is the energy density. For this analysis, we require the mass-radius relationship and the mass-tidal deformability relationship - these are the quantities that determine the contact frequency for such systems. \textcolor{red}{Read up why this is so.} The waveforms can be modelled using the quadrupolar tidal deformability, but ascertaining the contact frequency requires higher multipolar moments. The stellar structure is computed by solving TOV and using existing expressions to find tidal deformabilities.

	\item At the start of the inspiral, we can approximate the system as two-body point particle motion, but as we proceed towards the late inspiral, the tidal effects will become important and the PN expansion will be rendered untrustworthy. To account for the tidal effects, we add tidal corrections to the IMRPhenomD waveforms \textcolor{red}{How do I access the IMRPhenomD waveforms? Also, what is the idea behind phenomenological waveforms, and what are its shortcomings?} at some order in the expansion. \textcolor{red}{How do we figure out the order? Naive guess would be that doing a PN-like expansion for these tidally deformed systems would give us valid corrections only at some specific order, and hence we take that.} Even after this, due to the approximations that we have made, we cannot expect the waveform to be valid when the objects come into contact. Hence, we cut off our analysis at that point. We take this point to be the frequency at the first instance when one of the stars has $ \lambda = 0.2 $ \textcolor{red}{Why this number and not any number? Is there any calculation which shows that this is a reasonable approximation to make?}, and call it the \textit{contact frequency}.

	\item The rest of the paper is mostly technicalities of the data analysis. Plots are drawn of the combined posteriors $ \Lambda $ and $ n $. \textcolor{red}{The nitty gritties of the data analysis is something that I don't understand well, and something I need to figure out soon.} And a certain class of models with $ K, n $ are ruled out. The interesting thing is that the authors claim that \textit{boson stars can approximately thought to be like polytropic stars} by looking at the $ \Lambda $ vs $ n $ curves, and hence we can constrain the potentials of these boson stars. \textcolor{red}{But really, is that a fair enough argument? Isn't there a way to be more precise?} We then assume of $ \phi^4 $ potential and translate the constraints obtained from polytropic stars to constraints on $ m_B, \lambda_B $ in the $ \phi^4 $ potential.

	\item The authors say they want to extend the current work to include gravastar models as also to the spinning case. \textcolor{red}{What exactly are the complications in doing the same?}
\end{itemize}
\end{document}


\begin{table*}[!htb]
\small
\centering
 \begin{tabular}{|p{7cm}|p{3cm}|p{1.5cm}|p{1.5cm}|}
 \hline
Model weights & Decay type & Top-1 Acc & Top-5 Acc\\\hline\hline
alexnet: 1.0,
inception: 1.0
resnet: 1.0 & exponential & 0.5323 & 0.8203 \\\hline
alexnet: 0.7,
inception: 1.0,
resnet: 1.0 & exponential & 0.5318 & 0.8177 \\\hline
alexnet: 0.7,
inception: 0.7,
resnet: 1.0 & exponential & 0.531 & 0.8177 \\\hline
alexnet: 0.7,
inception: 1.0,
resnet: 0.7 & exponential & 0.5268 & 0.8169 \\\hline
alexnet: 0.7,
inception: 1.0,
resnet: 1.0 & linear & 0.5202 & 0.8165 \\\hline
alexnet: 1.0,
inception: 1.0,
resnet: 0.7 & exponential & 0.5282 & 0.8151 \\\hline
alexnet: 0.7,
inception: 1.0,
resnet: 0.7 & linear & 0.5191 & 0.8142 \\\hline
alexnet: 1.0,
inception: 0.7,
resnet: 1.0 & exponential & 0.5199 & 0.8141 \\\hline
alexnet: 1.0,
inception: 1.0,
resnet: 1.0 & linear & 0.5218 & 0.8140 \\\hline
alexnet: 1.0,
inception: 0.7,
resnet: 0.7 & linear & 0.5279 & 0.8136 \\\hline
\end{tabular}
\caption{Top 10 bagging ensemble configurations, as ranked by top-5 accuracy over validation set.}
\label{tab:top10_configs}
\end{table*}

\subsection{Grid Search Hyperparameters}

We use grid search to explore the space of hyperparameter values that yield the best top-5 accuracy over validation set. Hyperparameters on the search space are:\\

\noindent {\bf Model weights.} We define a 'model weight' as the weight for each model in the weighted majority bagging ensemble prediction. This value ranges from 0.0 to 1.0 for each model.  After initially experimenting with varying model contributions in increments of 0.25, we found no gains in validation accuracy for any configuration where weight was less than 0.7.  Therefore, for our final grid search we use either 0.0, 0.7 or 1.0 as the weight for each model in the bagging ensemble.\\

\noindent {\bf Decay function.} We define 'decay function' as the function over the prediction ranks of each model. We consider three different decay functions:

$$\text{Constant: } D(r,k) \begin{cases}
               1.0 \text{ if } r < k\\
               0.0 \text{ otherwise}
            \end{cases}$$

$$\text{Linear: } D(r) = |\text{prediction\_classes}| - r$$

$$\text{Exponential: } D(r) = e^{\frac{-r}{5}}$$

where $r$ is the prediction rank and in the case of ``Constant'', $k$ is a rank cutoff, e.g., $k = 5$ if only the first 5 predictions of that model are considered for the weighted majority vote.  We use two variations of constant decay function, one where $k = 5$, and another where $k = 10$. In our experiments, we find that the best results are obtained when the decay function is either exponential, or constant with $k = 5$.\\

\noindent {\bf Class-wise confidence.} As described in Section~\ref{ss:ensembling}, we also consider an heuristic that takes into account the class-wise confidence as calculated over the training set.  This adds a total of four permutations per configuration, as both top-1 and top-5 class-wise confidence is considered.\\

\noindent {\bf Class-wise accuracy.} The final heuristic we include as part of the grid search space is class-wise accuracy, defined in Section~\ref{ss:ensembling}.  Similar to class-wise confidence, this hyperparameter too adds four permutations per configuration to the total search space we explore with grid search.\\

An example configuration for the grid search space, together with its top-1 and top-5 accuracy over validation set is given in Figure ~\ref{fig:gs_config}.  In Table~\ref{tab:top10_configs} we display the 10 best configurations found by our grid search over the hyperparameters described above. Other configurations and their accuracies over validation set are included in the accompanying source code, under \texttt{weighted\_majority/grid\_search\_results.txt}.

\subsection{Ensemble Weight}

The ensemble value of a single class prediction for an image is given by the formula:

$$E(p,r) = \sum_{n=1}^{|models|} w_n * c_p * a_p * d(r)$$

where $p$ is the prediction class, $r$ is the rank of that class as given by CNN model $n$, $w_n$ is the weight (for majority vote) assigned to that model, $c_p$ is the class-wise confidence score for prediction class $p$, $a_p$ is the class-wise accuracy for prediction class $p$, and $d$ is the contribution of rank $r$ after decay function is applied.

For example, given the grid search configuration in Figure~\ref{fig:gs_config}, $c_p$ would be set to 1.0 since class-wise confidence scores are disabled, and $a_p$ would also be set to 1.0 for a similar reason. Further, $d(r)$ would be the result of applying the ``Constant'' decay function with $k = 5$, yielding 0.0 if $r > 5$, and $w_n$ would be 1.0 regardless of model (AlexNet, ResNet, or Inception).  So in this case, the final ensemble value for class $p$ is equal to the weighted majority of the three different CNNs, with equal weight assigned to each.

\begin{figure}[!ht]
\verbatiminput{grid_search_config.txt}
\caption{Example configuration explored by grid search, together with resulting top-1 and top-5 accuracy over validation set.}
\label{fig:gs_config}
\end{figure}

\subsection{Best Performing CNN Ensembles}

Table~\ref{tab:top10_configs} shows the top 10 configurations, as ranked by top-5 accuracy over validation set.  Our grid search also explores configurations where class accuracies and class confidence scores for both top-1 and top-5 -- as defined in Section~\ref{ss:ensembling} -- are considered.  We find, however, that the configurations with highest top-5 accuracy over validation set are obtained when neither of these heuristics are considered.  In addition, our experimental results indicate highest top-5 accuracy over validation set is obtained when all models have similar weights, i.e., the simple weighted majority case.