%!TEX root = ../thesis.tex
%*******************************************************************************
%*********************************** First Chapter *****************************
%*******************************************************************************

\chapter{Introduction}  %Title of the First Chapter

\ifpdf
    \graphicspath{{Chapter1/Figs/Raster/}{Chapter1/Figs/PDF/}{Chapter1/Figs/}}
\else
    \graphicspath{{Chapter1/Figs/Vector/}{Chapter1/Figs/}}
\fi

%**********************************

%********************************** %First Section  **************************************

\nomenclature[x]{$F$}{Boolean Formula}
\nomenclature[z-CNF]{CNF}{Conjunctive Normal Form}
\nomenclature[z-DNF]{DNF}{Disjunctive Normal Form}
\nomenclature[z-SAT]{SAT}{Boolean Satisfiability Problem}
\nomenclature[z-kSAT]{$k$-SAT}{Boolean Satisfiability Problem with each clause
                               restricted to have size $k$ or less}

\begin{figure}
    \centering
    \begin{tikzpicture}
        \begin{scope}[auto,every node/.style={draw,circle,minimum size=2.5em}]
            % Clause 1
            \node (c1!x) at (-2, 0) {$\neg x$};
            \node (c1y) at (-2.5, -1) {$y$};
            \node (c1!z) at (-3, -2) {$\neg z$};
            \draw[rotate around={63:(-2.5,-1)}] (-2.5,-1) ellipse (2 and 0.7);

            % Clause 2
            \node (c2x) at (2, 0) {$x$};
            \node (c2y) at (2.5, -1) {$y$};
            \node (c2!z) at (3, -2) {$\neg z$};
            \draw[rotate around={-63:(2.5,-1)}] (2.5,-1) ellipse (2 and 0.7);

            % Clause 2
            \node (c3!x) at (-1.1, -5) {$\neg x$};
            \node (c3!y) at (0, -5) {$\neg y$};
            \node (c3!z) at (1.1, -5) {$\neg z$};
            \draw[] (0,-5) ellipse (2 and 0.7);
        \end{scope}

        \path (c1!x) edge (c2y);
        \path (c1!x) edge (c2!z);
        \path (c1!x) edge (c3!x);
        \path (c1!x) edge (c3!y);
        \path (c1!x) edge (c3!z);
        \path (c1y) edge (c2x);
        \path (c1y) edge (c2y);
        \path (c1y) edge (c2!z);
        \path (c1y) edge (c3!x);
        \path (c1y) edge (c3!z);
        \path (c1!z) edge (c2x);
        \path (c1!z) edge (c2y);
        \path (c1!z) edge (c2!z);
        \path (c1!z) edge (c3!x);
        \path (c1!z) edge (c3!y);
        \path (c1!z) edge (c3!z);

        \path (c2x) edge (c3!y);
        \path (c2x) edge (c3!z);
        \path (c2y) edge (c3!x);
        \path (c2y) edge (c3!z);
        \path (c2!z) edge (c3!x);
        \path (c2!z) edge (c3!y);
        \path (c2!z) edge (c3!z);
    \end{tikzpicture}
    \caption[Graph Representation of a 3SAT Formula]{Illustration of the 3SAT in Equation \ref{eq:formula_sat}. Vertices are grouped
    by their clauses and the edges
    represent literals that do not contradict. This establishes a reduction
    from 3SAT to clique}
    \label{fig:sat}
\end{figure}

\section{Boolean Satisfiability Problem} %Section - 1.1
The boolean satisfiability problem, abbreviated as SAT, is the problem of finding
a satisfying assignment to the variables to make a boolean formula evaluate to true.
CNF-SAT is the same problem, but with formulas restricted to Conjunctive Normal Form
(CNF). A boolean formula in CNF is composed of a conjunction of clauses where
each clause is a disjunction of literals. For example consider the following
boolean formula in CNF:
\begin{equation} \label{eq:formula_sat}
    (\neg x \lor y \lor \neg z) \land (x \lor y \lor \neg z) \land (\neg x \lor \neg y \lor \neg z)
\end{equation}
This boolean formula has
a satisfying assignment $x = \text{false}, y = \text{true}, z = \text{false}$. Therefore the boolean formula is satisfiable.
However, if we consider the boolean formula
\begin{align}
(x \lor y \lor z)\land(x \lor y \lor \neg z)\land(x \lor \neg y \lor z) \nonumber\\
\land(x \lor \neg y \lor \neg z)\land(\neg x \lor y \lor z)\land(\neg x \lor y \lor \neg z) \\
\land(\neg x \lor \neg y \lor z)\land(\neg x \lor \neg y \lor \neg z) \nonumber
\end{align}
It's clear to see that this boolean formula can have no
satisfying assignment, since each assignment to the variables
will at least leave one clause unsatisfied.

%********************************** %Second Section  *************************************
\section{Uses of Boolean Satisfiability} %Section - 1.2
\subsection{Theoretical Significance}
SAT is a widely studied problem and has had a significant impact on
our understanding of computational complexity. For instance, SAT
was the first problem shown to be NP-HARD.
This then forms the basis of the NP-COMPLETE complexity class \cite{cook1971complexity, karp1972reducibility}.
This then means that a large class of problems all can be reduced to each other \cite{garey1974some}.
SAT has then in some sense become the defacto NP-COMPLETE problem and
our understanding of NP-COMPLETEness is driven by our understanding of SAT.

Furthermore, study of SAT has lead to new conjectures about
the complexity of SAT that are stronger than
the $P \neq NP$ conjecture, roughly stating that SAT requires exponential time \cite{impagliazzo2001complexity}. These conjectures allow for new conditional lower
bounds on a wide variety of other problems, not strictly limited to
NP-COMPLETE problems \cite{vassilevska2015hardness, lokshtanov2013lower}.
This gives us an understanding of the relative difficulty of finding
improved algorithms for many computational problems. For instance,
we know that finding a $\mathcal{O}(n^{2 - \epsilon})$ time algorithm
for string edit distance would violate some of these conjectures \cite{vassilevska2015hardness, levenshtein1966binary}. Hence making an improvement over an $\mathcal{O}(n^2)$ algorithm
should be seen as being as hard as discovering an improved SAT algorithm.

\subsection[Practical Applications]{Practical Applications of Boolean Satisfiability}
Although, even with these conjectures about the hardness of SAT,
as SAT solvers have become more efficient, SAT solving has found numerous applications \cite{marques2008practical, sat2009theory}.
One of these applications is model checking, where
the use SAT allows for better memory usage than traditional methods and hence larger models \cite{biere1999symbolic}.
Others include, but are not limited to, crosstalk noise prediction in integrated circuits \cite{chen1999towards},
termination analysis \cite{fuhs2007sat}, design debugging \cite{smith2005fault}, AI planning \cite{kautz1992planning},
haplotype  inference  in  bioinformatics \cite{lynce2006efficient}, knowledge-compilation \cite{darwiche2004new},
software testing \cite{khurshid2004testera}, package management in software distributions \cite{tucker2007opium},
checking of pedigree consistency \cite{10.1007/978-3-540-71209-1_26}, Test-pattern generation in digital systems
\cite{larrabee1992test} and circuit delay computation \cite{mcgeer1991timing}.

Naturally, as the computational power available to SAT solvers grows and as the
solvers become more efficient, SAT solving will find more
practical applications.

%********************************** % Third Section  *************************************
\section{Organisation and Motivation For This Report}  %Section - 1.3
%NP-COMPLETE decision problems such as SAT and variants such as 3SAT,
%do not have any polynomial time algorithms unless $P=NP$ \cite{schaefer1978complexity}.
%However, SAT is a useful problem in practice \cite{marques2008practical}.
%Therefore, algorithms for solving SAT such as the
%Davis Putnam Logemann Loveland algorithm (DPLL) and
%Conflict Driven Clause Learning (CDCL) have been developed \cite{Quest_for_efficient_solvers, CDCL}.
%Solvers based on these algorithms appear to be ``fast'' in practice \cite{SAT_Comp2017}.
%At the same time, there are popular conjectures about the complexity
%of SAT that are stronger than assuming $P=NP$ \cite{impagliazzo2001complexity}. These conjectures
%allow theoreticians to prove conditional lower bounds on a wide
%array of problems \cite{lokshtanov2013lower, vassilevska2015hardness}.
There is a juxtaposition of theory and practice where conjectures about the computational complexity of
SAT suggest that we should not expect it to be solvable in subexponential time \cite{impagliazzo2001complexity},
and yet there are highly optimised SAT solvers that are ``fast'' in practice. Some
of these solvers are able to handle SAT instances having on the order of $10^5$ variables
and $10^6$ clauses \cite{SAT_Comp2017, sat2018descriptions}.
This report will attempt to provide an exposition on this
gap between theory and practice.

First this will be done by providing an overview of how modern SAT solvers work,
by both covering the algorithms that these solvers are based on and also some
of the implemented solvers that use these algorithms.

To contrast this, the next two chapters will cover the complexity conjectures
that are based on the hardness of SAT and will go over some conditional lower bounds that can be
proven using these conjectures. This report also decides to dedicate a chapter to a commonly used lemma
in these proofs called the sparsification lemma. This lemma is instrumental in many
conditional lower bounds that apply to polynomial time algorithms such as string edit distance, hence
this chapter will explain and go over the proof of the lemma, providing some new intuitions along the way.

Finally, the last chapter will cover some research into structures in SAT instances
that can be used to either explain why some SAT instances are easy to solve compared to what
the worst case complexity of SAT solving would suggest, or provide motivation for currently employed
heuristics in modern SAT solvers.

Taken as a whole this report will provide the reader with a foundational understanding
of both how practical SAT solvers work and how they are able
to solve SAT instances that are significantly larger than what we might expect were possible
given what worst case complexity suggests. This report attempts to be accessible
to anyone with an undergraduate level understanding of computational complexity and algorithms
who is interesting in both the practical and theoretical side of SAT.

%To understand the apparent gap between worst case complexity and practical performance
%a number of empirical studies have been made to illustrate the existence of structure
%within most SAT instances which modern SAT solvers can exploit \cite{DBLP:journals/corr/ZulkoskiMWRLCG17, backdoor_typical, SAT_Comp2017, understanding_sat_structure}.
%Two key realisations
%support the notion that SAT can be solved faster than what worst case complexity would
%suggest. The first being the existence of a ``phase transition'' in the difficulty of instances
%of SAT. That being that as the ratio of clauses to the number of variables in the SAT
%formula increases, the probability of the SAT formula being satisfiable decreases (as
%there are now more constraints). The apparent ``hardness'' in practice peaks when this
%ratio approaches approximately $0.42$ and SAT instances can be solved significantly quicker
%when the ratio is larger or smaller than $0.42$ \cite{phase_transition, hard_and_easy_distributions}.
%The second discovery, is the existence of strong and weak backdoors in SAT instances \cite{10.1007/978-3-642-21043-3_33, backdoor_typical}.
%A backdoor in a SAT instance is a small subset of literals in the SAT formula such that
%when these literals are satisfied, the remaining subproblem can be solved in polynomial time. Current literature suggest that most SAT instances have backdoors significantly
%smaller than the size of the SAT formula.

\section{Notation}

A brief mention of notation before moving on, unless otherwise specified
a SAT instance will be in Conjunctive Normal Form (CNF), hence
we use the term SAT informally to refer to CNF-SAT. This means that
a formula is a conjunction of clauses where each clause is a disjunction of literals.
In terms of representation, it will often be convenient to represent a clause
$C$ as a set of literals and a formula $F$ as a set of clauses.
Therefore a formula
\begin{equation*}
    F = (a \lor b) \land (\neg a \lor b \lor \neg c) \land (b \lor c)
\end{equation*}
will be represented as
\begin{equation*}
    \{\{a, b\},\{\neg a, b, \neg c\}, \{b, c\}\}
\end{equation*}
Thus we can denote the number of clauses as $|F|$ and we could
express the set of literals as $\bigcup_{C \in F}C$.

Throughout this report, the letters $n$ and $m$ will always denote the
number of variables and the number of clauses respectively. These
parameters of the formula have notable significance on the running time
of algorithms for SAT and variants of SAT. Hence it is often natural
to express the complexity of these algorithms as a parameterized complexity
with often $n$ as the parameter (Although this is not always the case, see \cite{hirsch2000new}).
Often this will give expressions of the
form $2^n \cdot (n + m)^{\mathcal{O}(1)}$. However, the polynomial
factor is not of much interest and hence we will use the notation
$\mathcal{O}^{\ast}(\cdot)$ to suppress any polynomial factors.
$k$-SAT is CNF-SAT with the additional restriction that $\forall C \in F : |C| \leq k$.
For boolean formulas $F$ and $G$, we use the notation $F \approx G$ to mean
that $F$ and $G$ are equisatisfiable.
Let $vars()$ be a function that returns the set of variables that are used
in its argument. So for a formula $F$, then $vars(F)$ is the set of $n$ variables,
for a clause $C$, then $vars(C)$ is the set of variables that appear in the clause
and for a literal $l$, then $vars(l)$ is simply the variable that corresponds to
that literal.


%
% @author   Shmish  "shmish90@gmail.com"
% @legal    MIT     "(c) Christopher Schmitt"
%

\documentclass{article}

%
% Document Imports
%

\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{color}
\usepackage{tikz}

%
% Document Configuation
%

\newcommand{\hwAuthor}{Christopher Schmitt}
\newcommand{\hwSubject}{Math 218}
\newcommand{\hwSection}{Section 81}
\newcommand{\hwSemester}{Summer 2019}
\newcommand{\hwAssignment}{Assignment 5}

%
% Document Enviornments
%

\setlength{\headheight}{65pt}
\pagestyle{fancy}
\lhead{\hwAuthor}
\rhead{
  \hwSubject \\
  \hwSection \\
  \hwSemester \\
  \hwAssignment
}

\newenvironment{problem}[1]{
  \nobreak\section*{Problem #1}
}{}

%
% Document Start
%

\begin{document}
  \begin{problem}{1}
    \begin{center}
      \textbf{(a)} Prove that the set $12\mathbf{Z}$ of all multiples of $12$ is countably infinite.
    \end{center}
    \begin{center}
      \begin{tikzpicture}[scale=1]
        \node (1) at (0, 1) {$1$};
        \node (2) at (1, 1) {$2$};
        \node (3) at (2, 1) {$3$};
        \node (4) at (3, 1) {$4$};
        \node (5) at (4, 1) {$5$};
        \node (6) at (5, 1) {$6$};
        \node (7) at (6, 1) {$\dots$};
        \node (0) at (0, 0) {$0$};
        \node (12) at (1, 0) {$12$};
        \node (-12) at (2, 0) {$-12$};
        \node (24) at (3, 0) {$24$};
        \node (-24) at (4, 0) {$-24$};
        \node (36) at (5, 0) {$36$};
        \node (-36) at (6, 0) {$\dots$};

        \draw (1) -- (0);
        \draw (2) -- (12);
        \draw (3) -- (-12);
        \draw (4) -- (24);
        \draw (5) -- (-24);
        \draw (6) -- (36);
      \end{tikzpicture}
    \end{center}

    \begin{center}
      \textbf{(b)} Prove that the set $\mathbf{Z}^{+} \times \mathbf{Z}^{+}$ is countably infinite.
    \end{center}
    \begin{center}
      \begin{tikzpicture}[scale=1.5]
        \node (1) at (1, 1) {$(1, 1)$};
        \node (2) at (1, 2) {$(1, 2)$};
        \node (3) at (2, 1) {$(2, 1)$};
        \node (4) at (3, 1) {$(3, 1)$};
        \node (5) at (2, 2) {$(2, 2)$};
        \node (6) at (1, 3) {$(1, 3)$};
        \node (7) at (1, 4) {$(1, 4)$};
        \node (8) at (2, 3) {$(2, 3)$};
        \node (9) at (3, 2) {$(3, 2)$};
        \node (10) at (4, 1) {$(4, 1)$};

        \draw (1) -- (2) -- (3) -- (4) -- (5) -- (6) -- (7) -- (8) -- (9) --(10);
      \end{tikzpicture}
    \end{center}
  \end{problem}

  \begin{problem}{2}
    \begin{center}
      \textbf{(a)} Prove that the set ${x \in \mathbf{R} | 0.53 < x < 0.54}$ (in other words, the interval (0.53, 0.54) is uncountable.
    \end{center}
    \begin{center}
      $f : \mathbf{R} \rightarrow (0.53, 0.54)$\\
      $f(x) = tan(50\pi(x - 0.535))$\\
      Since a bijection exists between $\mathbf{R}$ and $(0.53, 0.54)$, $(0.53, 0.54)$ is uncountable.
    \end{center}

    \begin{center}
      \textbf{(b)} Let $A$ be the set of all infinite sequences of positive integers. For example, one of the elements of $A$ is the sequence $1, 2, 3, 4, 5, 6, \dots$ Another element of $A$ is the sequence $1, 2, 4, 8, 16, 32, \dots$ Prove that $A$ is uncountable.
    \end{center}
    \begin{proof}
      Suppose that the set $A$ is countably infinite.\\
      $\implies$ A bijection exists between $A$ and $\mathbf{Z^{+}}$\\
      $\implies$ Some function, $f : \mathbf{Z^{+}} \rightarrow A$ is onto\\
      $\implies$ A list can be created matching every member of $A$ to $\mathbf{Z^{+}}$\\
      However, an element can be constructed that is not in $A$: $x_1, x_2, x_3, ...$, where $x_n$ is any random integer such that $x_n$ is not equal to $k$, where $k$ is the $n$'th element of $n$'th element of the list.  So $f$ cannot be onto.
    \end{proof}
  \end{problem}

  \begin{problem}{3}
    Find the quotient and the remainder when $a$ is divided by $b$, for the following values of $a$ and $b$:
    \begin{enumerate}
      \item[\textbf{(a)}] $a = 148$, $b = 9$, $q = 16$, $r = 4$
      \item[\textbf{(b)}] $a = -148$, $b = 9$, $q = -17$, $r = 5$
      \item[\textbf{(c)}] $a = 148$, $b = -9$, $q = -17$, $r = 5$
      \item[\textbf{(d)}] $a = -148$, $b = -9$, $q = 16$, $r = 4$
    \end{enumerate}
  \end{problem}

  \begin{problem}{4}
    Find the binary and hexadecimal representations of the decimal number 2775.
    \begin{center}
      $101011010111_{2}$\\
      $AD7_{16}$
    \end{center}
  \end{problem}

  \begin{problem}{5}
    Use the Extended Euclidean Algorithm to compute the greatest common divisor of the integers $768$ and $46$, and to express that greatest common divisor in the form $768x + 46y$, where $x, y \in Z$.
    \begin{center}
      $2 = 10(768) + 167(46)$
    \end{center}
  \end{problem}

  \begin{problem}{6}
    Factor the integer 155,540 into a product of primes.
    \begin{center}
      $2^{2} \times 5 \times 7 \times 11 \times 101$
    \end{center}
  \end{problem}
\end{document}


\chapter{Methods}

Methods, or class functions, can be added to a class. Mostly, methods should be the way to interact with your class. Instead of changing member variables directly, a class should provide methods to access and alter them. Appart from providing accessors to variables, methods should also be used for any kind of action your class might perform.

\section{Methods without arguments or result}

A plain method does exactly the same thing, every time you call it. When you think back the the class \eeClass{movingCircle}, you might want to add a method to put the circle back in the middle of the screen:

\begin{code}
class movingCircle {
  Circle c;
  Vec2 speed;

  void reset() {
    c.pos = Vec2(0);
  }
}

// somewhere in your application
movingCircle mc;
mc.reset();

\end{code}

In this example, the circle's position will be set to zero when the \eeFunc{reset()} method is called. This method consists of three parts:

\begin{description}
\item[void] Indicates the method has no result. (More about results in a moment.)
\item[reset] The name of the method. You can pick your own name, but of course the restrictions for variable names also apply here. (Some characters are not allowed, don't start with a number, \ldots)
\item[()] End with a couple of braces. Later on, arguments will be put between them.
\end{description}

\begin{exercise}
Add the \eeFunc{reset()} method above to the previous exercise. In the \eeFunc{Update()} function of your program, replace the code to reset the circle's position with your method.

Add a method \eeFunc{draw()} to the same class. This method will draw the circle with a certain color. Again, replace the code in your app with this method.
\end{exercise}

\section{Methods with Arguments}
A method can have one or more arguments. Arguments are used to pass values to a method. In the previous example, the \eeFunc{reset()} method didn't need an argument. We know what has to be done to put a circle back in the middle of the screen. But should you write a method to place a circle on any position, you'ld have to pass the desired position as an argument. Like so:

\begin{code}
class movingCircle {
  Circle c;
  Vec2 speed;

  void setPos(Vec2 pos) {
    c.pos = pos;
  }
}

// somewhere in your application
movingCircle mc;
Vec2 p(0.1, 0.4);
mc.setPos(p);
\end{code}

This method has an argument of the type \eeClass{Vec2}. The argument is used internally to alter the circle's position. It is important to remember you only pass the value of the argument, not its name or the variable itself. There is no established relationship between an method and the variables passed into it.

\begin{code}
movingCircle mc;
Vec2 p(0.1, 0.4);
mc.setPos(p);     // pass contents of p to mc
p.x += 0.1;       // altering p does not alter the position in mc!!!
mc.setPos(p);     // call setPos again to pass the new contents to mc
\end{code}

\begin{exercise}
Add the method \eeFunc{setPos} to your exercise. With it, try something new in the application: every time you press F1, a new random position should be assigned to every circle.

Add a method \eeFunc{setRadius} with a float argument. This method should change the radius of the circle. Change the radius along with the the position when you press F1. (Remember to use only small values, like a 0.01 to 0.2 range.)
\end{exercise}

\section{More arguments}
Methods are not limited to a single argument. You can add more as long as they're separated with comma's.

\begin{code}
class movingCircle {
  Circle c    ;
  Vec2   speed;

  void init(float r, Vec2 pos, Vec2 speed) {
    c.r     = r    ;
    c.pos   = pos  ;
    T.speed = speed;
  }
}

// somewhere in your application
movingCircle mc;
Vec2 p(0.1, 0.4);
mc.init(0.1, p, Vec2(0.3, -0.5));
\end{code}

Again, the example introduces a few new concepts:
\begin{description}
\item[T] What if the name of an argument is the same as the name of a class variable? In the example above there is an argument called 'speed', but also a variable called speed. How will the compiler know which is which, when you just type speed. Well, as a rule the most local declaration is used, which in this case is the argument. To indicate you want to use the class variable, you can use \eeClass{T}. Again in the example, the value of the argument 'speed' is passed to the class variable 'speed'.
\item[Passing arguments] When the init method is used, a predefined \eeClass{Vec2} is used to pass the position. But speed also needs a \eeClass{Vec2}. In this case, a new Vec2 is created directly inside the braces and passed as an argument. Both options are valid, but the first one is generally used when you still need the object p after passing it to the function. This would not be possible with the second \eeClass{ Vec2} because it does not have a name.
\end{description}

\begin{exercise}
And in init method to your class and use it.
\end{exercise}

\section{Methods with a Result}
In the beginning of this chapter, I mentioned you should never use class variables directly, outside a class. You've just learned how to alter a variable through a method with an argument, but what if you wanted to retrieve the value of the variable? The answer is simple. Use the method result:

\begin{code}
class movingCircle {
  Circle c;
  Vec2 speed;

  void init(float r, Vec2 pos, Vec2 speed) {
    c.r         = r    ;
    c.pos       = pos  ;
    this->speed = speed;
  }

  float getRadius() {
    return c.r;
  }
}

// somewhere in your application
movingCircle mc;
mc.init(0.1, p, Vec2(0.3, -0.5));
float radius = mc.getRadius();

\end{code}

At the end of this example, the float radius will have a value of 0.1. This is how you create a method with a result:

\begin{itemize}
\item Use the result type instead of the keyword void. In this case we want to retrieve a radius from the circle. A radius is a float, which means the result type will also be a float.
\item The method contents should end with the keyword \texttt{return}, followed by the value that should be returned. This value will be passed to the caller.
\end{itemize}

\begin{exercise}
Add this method to your class. Add code to your application to show the radius of a circle on the screen.
\end{exercise}

\section{Methods with Arguments and Result}
One last possibility is the combination of arguments with a result. One common pitfall: although a method can have many arguments, it can only have one result.

The next example implements a \eeFunc{move} method. This method will move a circle by passing a value as an argument. This value will be added to the currrent position, but only as long as the result would not be outside of the screen. By returning a bool as a result, we can let the application know if movement succeeded.

\begin{code}
class movingCircle {
  Circle c    ;
  Vec2   speed;

  void init(float r, Vec2 pos, Vec2 speed) {
    c.r         = r    ;
    c.pos       = pos  ;
    this->speed = speed;
  }

  float getRadius() {
    return c.r;
  }

  bool move(Vec2 pos) {
    if(Cuts(c.pos + pos, D.viewRect())) {
      c.pos += pos;
      return true;
    } else {
      return false;
    }
  }
}

// somewhere in your application
movingCircle mc;
Vec2 p(0, 0);
mc.init(0.1, p, Vec2(0.3, -0.5));
if( !mc.move(mc.speed * Time.d()) ) {
  // do something when failed
}
\end{code}

\begin{exercise}
Add the move method to your class. The application must use this method to move the circle. This method indicates wether or not the movement was a success, so you can remove the application code to keep the circle within the screen boundaries. If the method returns false, simple call the \eeClass{reset} method to put the circle back in the middle.

It is still possible to simplify move even further. We already know movement will always be the same. So we don't actually need an argument at all! The movement can be done with the information available in the class itself. (speed and the time delta)
\end{exercise}

\section{The solution}
The complete class and app for this chapter is listed below for reference. Please compare this with your own result.

De class movingCircle:
\begin{code}
class movingCircle
{
   Circle c    ;
   Vec2   speed;
   Color  color;

   void create(float radius, Vec2 pos, Vec2 speed, Color color)
   {
      c.r     = radius;
      c.pos   = pos   ;
      T.speed = speed ;
      T.color = color ;
   }

   bool move()
   {
      Vec2 newPos = c.pos + speed * Time.d();
      if(Cuts(newPos, D.viewRect()))
      {
         c.pos = newPos;
         return true;
      } else return false;
   }

   Vec2 getPos()
   {
      return c.pos;
   }

   void setPos(Vec2 pos)
   {
      c.pos = pos;
   }

   void reset()
   {
      c.pos = 0;
   }

   void draw()
   {
      c.draw(color);
   }
}
\end{code}

The application:

\begin{code}
Memc<movingCircle> circles;

void InitPre()
{
   EE_INIT();
}

bool Init()
{
   return true;
}

void Shut() {}

bool Update()
{
   if(Kb.bp(KB_ESC)) return false;

   if(Kb.bp(KB_SPACE))
   {
      circles.New().create(RandomF(0.05, 0.1),
                           Vec2(0),
                           Vec2(RandomF(-1, 1), RandomF(-1, 1)),
                           Color(Random(255), Random(255), Random(255))
                           );
   }

   if(Kb.bp(KB_F1))
   {
      REPA(circles)
      {
         circles[i].setPos(Vec2(RandomF(-D.w(), D.w()), RandomF(-D.h(), D.h())));
      }
   }

   REPA(circles)
   {
      if(!circles[i].move()) circles[i].reset();
   }

   return true;
}

void Draw()
{
   D.clear(BLACK);

   REPA(circles)
   {
      circles[i].draw();
   }
}
\end{code}


%% Template for MLP Coursework 1 / 19 October 2021

%% Based on  LaTeX template for ICML 2017 - example_paper.tex at
%%  https://2017.icml.cc/Conferences/2017/StyleAuthorInstructions

\documentclass{article}
\input{mlp2021_includes}

\definecolor{red}{rgb}{0.95,0.4,0.4}
\definecolor{blue}{rgb}{0.4,0.4,0.95}
\definecolor{orange}{rgb}{1, 0.65, 0}

\newcommand{\youranswer}[1]{{\color{red} \bf[#1]}} %your answer:

%% START of YOUR ANSWERS
\input{mlp-cw1-questions}
%% END of YOUR ANSWERS

%% Do not change anything in this file. Add your answers to mlp-cw1-questions.tex

\begin{document}

\twocolumn[
\mlptitle{MLP Coursework 1}
\centerline{\studentNumber}
\vskip 7mm
]

\begin{abstract}
In this report we study the problem of overfitting, which is \questionOne.
We first analyse the given example and discuss the probable causes of the underlying problem.
Then we investigate how the depth and width of a neural network
can affect overfitting in a feedforward architecture and observe that increasing width and depth \questionTwo.
Next we discuss why two standard methods, Dropout and Weight Penalty, can
mitigate overfitting, then describe their implementation and use them in our experiments
to reduce the overfitting on the EMNIST dataset.
Based on our results, we ultimately find that \questionThree.
Finally, we briefly review another method, Maxout, discuss its strengths and weaknesses, and conclude the report with our observations and future work. Our main findings indicate that \questionFour.
\end{abstract}

\section{Introduction}
\label{sec:intro}
In this report we focus on a common and important problem while training machine learning models known as overfitting, or overtraining, which is \questionOne.
We first start with analyzing the given problem in Fig.~\ref{fig:example}, study it in different architectures and then investigate different strategies to mitigate the problem.
In particular, Section \ref{sec:task1} identifies and discusses the given problem, and investigates the effect of network width and depth in terms of generalization gap (see Ch.~5 in \citealt{Goodfellow-et-al-2016}) and generalization performance.
Section \ref{sec:task2.1} introduces two regularization techniques to alleviate overfitting: Dropout \cite{srivastava2014dropout} and L1/L2 Weight Penalties (see Section~7.1 in \citealt{Goodfellow-et-al-2016}).
We first explain them in detail and discuss why they are used for alleviating overfitting.
In Section~\ref{sec:task2.2} we incorporate each of them and their various combinations to a three hidden layer neural network, train it on the EMNIST dataset, which contains 131,600 images of characters and digits, each of size 28x28 which are split into 47 classes, grouping together some difficult to distinguish characters.
We evaluate them in terms of generalization gap and performance, and discuss the results and effectiveness of the tested regularization strategies.
Our results show that \questionThree.
In Section~\ref{sec:task3}, we discuss a related work on Maxout Networks and highlight its pros and cons.\footnote{Instructor note: Omitting this for this coursework, but normally you would be more specific and summarise your conclusions about that review here as well.}
Finally, we conclude our study in section \ref{sec:concl}, noting that \questionFour.

\section{Problem identification}
\label{sec:task1}

\begin{figure}[t]
    \centering
    \begin{subfigure}{\linewidth}
        \includegraphics[width=\linewidth]{figures/accuracy_IHO_withrelu.png}
        \caption{accuracy by epoch}
        \label{fig:example_acccurves}
    \end{subfigure}
    \begin{subfigure}{\linewidth}
        \centering
        \includegraphics[width=\linewidth]{figures/error_IHO_withrelu.png}
        \caption{error by epoch}
        \label{fig:example_errorcurves}
    \end{subfigure}
    \caption{Training and validation curves in terms of classification accuracy (a) and cross-entropy error (b) on the EMNIST dataset for the baseline model.}
    \label{fig:example}
\end{figure}

Overfitting to training data is a very common and important issue that needs to be dealt with when training neural networks or other machine learning models in general (see Ch.~5 in \citealt{Goodfellow-et-al-2016}).
A model is said to be overfitting when \questionFive.

\questionSix.

Fig.~\ref{fig:example_acccurves} and \ref{fig:example_errorcurves} show a prototypical example of overfitting.
We see in Figure~\ref{fig:example_acccurves} that \questionSeven.

The extent to which our model overfits depends on many factors.
For example, the quality and quantity of the training set and
the complexity of the model. If we have a lot of varied training samples,
or if our model is relatively shallow, it will in general
be less prone to overfitting. Any form of regularisation
will also limit the extent to which the model overfits.

\subsection{Network width}

\questionTableOne
\questionFigureTwo

First we investigate the effect of increasing the number of
hidden units in a single hidden layer network when training
on the EMNIST dataset.
The network is trained using the Adam optimizer
with a learning rate of $10^{-3}$ and a batch size of 100, for a total of 100 epochs.

The input layer is of size 784, and output layer consists
of 47 units.
Three different models were trained, with a
single hidden layer of 32, 64 and 128 ReLU hidden units
respectively.
Figure~\ref{fig:width} depicts the error and accuracy curves over 100 epochs for the model with varying number of hidden units.
Table~\ref{tab:width_exp} reports the final accuracy and generalization gap.
We observe that \questionEight.

\questionNine.

\subsection{Network depth}

\questionTableTwo
\questionFigureThree

Next we investigate the effect of varying the number of hidden
layers in the network.
Table~\ref{tab:depth_exps} and Fig.~\ref{fig:depth} shows the results from
training three models with one, two and three hidden layers respectively,
each with 128 ReLU hidden units.
As with previous experiments, they are
trained with the Adam optimizer with a learning rate of  $10^{-3}$ and
a batch size of 100.

We observe that \questionTen.

\questionEleven.

\questionTwelve.

\section{Dropout and Weight Penalty}
\label{sec:task2.1}

In this section, we investigate three regularization methods to
alleviate the overfitting problem, specifically dropout layers
and the L1 and L2 weight penalties.

\subsection{Dropout}

Dropout~\cite{srivastava2014dropout}
is a stochastic method that randomly inactivates
neurons in a neural network according to an hyperparameter, the
dropout rate. Dropout is commonly represented by an
additional layer inserted between the linear layer and
activation function.
Its forward propagation during training is defined as follows:

\begin{align}
    mask &\sim bernoulli(p)\\
    y' &= mask \odot y\
\end{align}

where $y, y' \in \mathbb{R}^d$ are the output of the linear layer
before and after applying dropout,
respectively. $mask \in \mathbb{R}^d$ is a mask vector randomly sampled from the
Bernoulli distribution with parameter of inclusion probability
$p$, and $\odot$ denotes the element-wise multiplication.

At inference time, stochasticity is not desired, so no neurons
are dropped. To account for the change in expectations of the
output values, we scale them by the inverse of the dropout rate
$p$:

\begin{align}
    y' &= y/p\
\end{align}

As there is no nonlinear calculation involved, the backward
propagation is just the element-wise product of the gradients
with respect to the layer outputs and mask created
in the forward calculation. The backward propagation for
dropout is therefore formulated as follows:

\begin{align}
    \frac{\partial y'}{\partial y} = mask
\end{align}

Dropout is an easy to implement and highly scalable
method. It can be implemented as a layer-based calculation
unit, and be placed on any layer of the neural network at
will. Dropout can reduce the dependence of hidden features
between layers so that the neurons of the next layer will not
specifically depend on some features from of the previous layer.
Instead, it force the network to evenly distribute information
among all features. By randomly dropping some neurons in training,
dropout makes use of a subset of the whole architecture, so it can
also be viewed as bagging different sub networks and averaging their
outputs.

\subsection{Weight penalty}

L1 and L2 regularization~\cite{ng2004feature} are simple but effective
methods to mitigate overfitting to training data.
\questionThirteen.

\questionFourteen.

\section{Balanced EMNIST Experiments}

\questionTableThree

\questionFigureFour

\label{sec:task2.2}

Here we evaluate the effectiveness of the given regularization methods for reducing the overfitting on the EMNIST dataset.
We build a baseline architecture with three hidden layers, each with 128 neurons, which suffers from overfitting in EMNIST as shown in section \ref{sec:task1}.
We follow the previous training settings where we deliberately let the baseline overfit
on the training set as in previous experiments.
These settings ensure the fairness of the evaluation of three methods to alleviate overfitting.
Then, we apply the L1 or L2 regularization with dropout to our baseline and search for good hyperparameters on the validation set.
We summarize all
the experimental results in Table~\ref{tab:hp_search}. For each method, we
plot the relationship between generalisation gap and validation accuracy in Figure~\ref{fig:hp_search}.

First we analyze three methods separately, train each over a set of hyperparameters and compare their best performing results.

\questionFifteen.

\section{Literature Review: Maxout Networks}
\label{sec:task3}

\paragraph{Summary of Maxout Networks} In this section, we
briefly discuss another generalization method: Maxout net-
works \cite{goodfellow2013maxout}. This paper further ex-
plores the dropout method and proposes a new "maxout" layer
 which can complement dropout.
The authors evaluate the performance of Maxout Networks
in four standard datasets, namely MNIST, CIFAR-10
and 100, and SVHN. They point out that although
dropout has been widely applied in deep models, \questionSixteen. Following this
motivation, they propose the Maxout activation layers. These can be considered learnable activations that work as a universal convex function approximator. The Maxout layer first
maps the hidden space to $k$ subspaces through independent
affine transformations, then, for each element in output
vectors, it takes the maximum value across all subspaces.

\questionSeventeen.

\paragraph{Strengths and limitations} The author proposed a novel
neural activation unit that further exploits the dropout technique.
\questionEighteen.

Although the Maxout activation units can maximize
the averaging effect of dropout in a deep architecture,
we can argue that the Maxout computation
is expensive. The advantage of dropout lies in its high
scalability and computational advantages. It can be arbitrarily
applied to various network structures, and the calculation
speed is fast, which is very suitable for heavy computing
algorithms such as training and inference of neural networks.
In comparison, the design of the Maxout network needs to project the
hidden vector into $k$ subspaces. Both the forward algorithm and the
backward algorithm of dropout can be calculated in $\mathcal{O}(D)$
complexity, but the complexity of Maxout is $\mathcal{O}(kD)$.
This can lead to increasing the number of training epochs needed
to reach convergence.
Furthermore, the universal approximation property of Maxout seems
powerful, but it would be interesting to verify that it is useful
in practice. Specifically, we can design an experiment where we
increase the number of subspaces $k$ and see where performances stop
improving. In extreme cases, it is even possible that the
function learned is too specific to the training data, effectively
causing overfitting.

\section{Conclusion}
\label{sec:concl}

\questionNineteen.

\bibliography{refs}

\end{document}


\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{color}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{gensymb}
\usepackage{framed}
\usepackage[dvipsnames]{xcolor}
\usepackage{xcolor}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{verbatim}
\pagestyle{fancy}
\lfoot{\textbf{Open Source Rover Software Controls}}
\rfoot{Page \thepage}
\lhead{\textbf{\leftmark}}
\rhead{\textbf{\rightmark}}
\cfoot{}
\renewcommand{\footrulewidth}{1.8pt}
\renewcommand{\headrulewidth}{1.8pt}
\doublespacing
\setlength{\parindent}{1cm}

\begin{document}

\title{Open Source Rover: Software Controls}
\author{Authors: Michael Cox, Eric Junkins, Olivia Lofaro}

\makeatletter
\def\@maketitle{
\begin{center}
	\makebox[\textwidth][c]{ \includegraphics[width=0.8\paperwidth]{"Pictures/software title".png}}
	{\Huge \bfseries \sffamily \@title }\\[3ex]
	{\Large \sffamily \@author}\\[3ex]
	\includegraphics[width=.85\linewidth]{"Pictures/JPL logo".png}
\end{center}}
\makeatother

\maketitle

\noindent {\footnotesize Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise, does not constitute or imply its endorsement by the United States Government or the Jet Propulsion Laboratory, California Institute of Technology. \textcopyright  2018 California Institute of Technology. Government sponsorship acknowledged.}

% Introduction
\newpage

\tableofcontents

\newpage

\section{Control System}

There are two main issues we need to address when designing the control mechanics for the rover. One is the direction that each of the corner wheels needs to point in order for the rover to be able to turn correctly. The other is how fast each of the individual drive motors needs to spin (it's not the same speed at each wheel when the rover is turning!).

\subsection{Drive Motor calculations}
The 6 wheel rover design employs Ackerman steering, which can be seen in Figure \ref{Ackerman}. The rover steers about a point which lies on the line that passes through the two center wheels. All 6 wheels need to align their center axis towards the point around which the rover will turn. Notice that we observe a more drastic steering angle for the wheels closer to that point than for the wheels that are further away.

\begin{figure}[H]
 	\centering
	\includegraphics[width=.35\textwidth]{"Pictures/Ackerman".PNG}
 	\caption{Ackerman Steering}
	\label{Ackerman}
\end{figure}

Let's go step-by-step though how to calculate the speed of each of the drive wheels. To start, we will look at the rover which will be turning about a point P at radius r, shown in Figure \ref{r1}

\begin{figure}[H]
 	\centering
  	\begin{minipage}[b]{0.45\textwidth}
		\includegraphics[width=\textwidth]{"Pictures/rover1".PNG}
  	\end{minipage}
  	\hfill
  	\begin{minipage}[b]{0.45\textwidth}
    		\includegraphics[width=\textwidth]{"Pictures/rover2".png}
  	\end{minipage}
  	\caption{Rover turning about point P}
	\label{r1}
\end{figure}

\noindent We start by sending a signal from the controller for the rover to drive forward. Let's call the speed at which it drives X (for now, we set X to its maximum value of 100). By convention, this will tell the middle of the rover that it should move forwards at the max speed of 100. However, if the rover is turning, each wheel will need to spin at a slightly different rate to avoid slipping or "scrubbing". Because no wheel can spin faster than speed 100 and because the wheels have differing distances they must travel along their arcs during the turn, we send the max speed of 100 to the wheel furthest away from the point we are turning around. In the case above, this is wheel \#2. Therefore, we now set wheel \#2 to spin at speed 100 as shown in Figure \ref{r2}.

\begin{figure}[H]
 	\centering
  	\begin{minipage}[b]{0.45\textwidth}
		\includegraphics[width=\textwidth]{"Pictures/rover3".PNG}
  	\end{minipage}
  	\hfill
  	\begin{minipage}[b]{0.45\textwidth}
    		\includegraphics[width=\textwidth]{"Pictures/rover4".png}
  	\end{minipage}
  	\caption{Rover distributing speed to fastest/furthest wheel}
	\label{r2}
\end{figure}

\noindent Next, we examine how to distribute speed to the other wheels. We will make use of arc lengths of the circles the wheels turn about which is given by the relation in Equation \ref{eq1}:

\begin{equation}
	S = R  \theta
	\label{eq1}
\end{equation}

\begin{figure}[H]
 	\centering
	\includegraphics[width=.55\textwidth]{"Pictures/rover5".PNG}
 	\caption{Arc lengths of driving curves}
	\label{r3}
\end{figure}

\noindent In order for the entire rover to drive cohesively each wheel must travel the same number of degrees from Equation \ref{eq1} in the same time, so we can solve for the relation between each of the wheels now. (In the equations below, $\theta$ is the angle that the wheel traverses, S is the arc length that the wheel travels, and R is the radius or distance from the wheel to the turning point)

\begin{equation}
	\textcolor{ForestGreen}{\theta_1 = \frac{S_1}{R_1}} \qquad \textcolor{red}{\theta_2 = \frac{S_2}{R_2}}
\end{equation}

\begin{equation}
	\textcolor{ForestGreen}{\theta_1} = \textcolor{red}{\theta_2} \qquad \textcolor{ForestGreen}{S_1}=\textcolor{red}{S_2} \frac{\textcolor{ForestGreen}{R_1}}{\textcolor{red}{R_2}}
	\label{eq2}
\end{equation}

\noindent From Equation \ref{eq2} we can see that the ratio of the distance traveled (and thus the speed) of each of the wheels is going to be given by the ratio of the radius of the arc that each wheel is turning about. The last step is to figure out the radius of that arc for each wheel.

\begin{figure}[H]
 	\centering
  	\begin{minipage}[b]{0.45\textwidth}
		\includegraphics[width=\textwidth]{"Pictures/rover7".PNG}
  	\end{minipage}
  	\hfill
  	\begin{minipage}[b]{0.45\textwidth}
    		\includegraphics[width=\textwidth]{"Pictures/rover6".png}
  	\end{minipage}
  	\caption{Radius of arc for turning}
	\label{r4}
\end{figure}

\begin{equation}
	\textcolor{ForestGreen}{R_1} = \sqrt{\textcolor{Plum}{d_3}^2 + (\textcolor{orange}{d_1} + r)^2}            \qquad \textcolor{red}{R_2} = \textcolor{blue}{d_4} + r
	\label{eq3}
\end{equation}

\noindent The distances $d_1$, and $d_3$ are geometric relations based on the mechanical lengths of the robot itself. Putting this all together, let's look at an example of calculating speed and turning distance.
\begin{centering}
\begin{tabular}[2]{|c|c|}
	\hline
	\textbf{Variable} & \textbf{Physical description} \\ \hline
	$d_1$ & Horizontal distance between middle of rover and the corner wheels \\ \hline
	$d_2$ & Vertical distance between the middle of rover and back corner wheels \\ \hline
	$d_3$ & Vertical distance between the middle of the rover and the front corner wheels \\ \hline
	$d_4$ & Horizontal distance between the middle of the rover and the center wheels \\ \hline
\end{tabular}

\begin{figure}[H]
 	\centering
	\includegraphics[width=.55\textwidth]{"Pictures/rover8".PNG}
 	\caption{Physical distance of wheel geometry}
	\label{r5}
\end{figure}

\end{centering}
\noindent For the version of the rover described in the build documents, the distances are as follows\footnote{If you change the rover's geometry (such as distances between wheels) you will need to update these values in the code as well!}:
\begin{equation}
	d_1 = 7.254 in \qquad d_2 = d_3 = 10.5 in \qquad d_4 = 10.073 in
\end{equation}

\noindent For this example, we will have a controller signal of max speed (100), and a turning radius of 30 inches (by convention the positive turning radius is turning to the right and negative is turning to the left), as shown in Figure \ref{r6}:

\begin{equation}
	r = 30 in \qquad X = 100
\end{equation}

\begin{figure}[H]
 	\centering
	\includegraphics[width=.55\textwidth]{"Pictures/rover9".PNG}
 	\caption{30 Inch Turning radius}
	\label{r6}
\end{figure}

\noindent Using Equations \ref{eq2} and  \ref{eq3} we get the following relations for the speed distribution. We substitute Equation \ref{eq3} into \ref{eq2}, which solves for the arc length distance. This is analogous to the speed of each wheel, as speed is just $speed = \frac{distance}{time}$.  We denote speed with V (for velocity), and we now have:

\begin{equation}
	\textcolor{ForestGreen}{V_1} = X \frac{\textcolor{ForestGreen}{R_1}}{\textcolor{red}{R_2}} \qquad = X \frac{\textcolor{ForestGreen}{\sqrt{d_3^2 + (d_1 + r)^2}}}{\textcolor{red}{r + d_4}}
\end{equation}

\begin{equation}
	\textcolor{red}{V_2} = X
\end{equation}

\begin{equation}
	\textcolor{blue}{V_3} = X \frac{\textcolor{blue}{R_3}}{\textcolor{red}{R_2}} \qquad  = X \frac{\textcolor{Blue}{\sqrt{d_2^2 + (d_1 + r)^2}}}{\textcolor{red}{r + d_4}}
\end{equation}

\begin{equation}
	\textcolor{orange}{V_4} = X \frac{\textcolor{orange}{R_4}}{\textcolor{red}{R_2}} \qquad =  X \frac{\textcolor{orange}{\sqrt{d_3^2 + ( r - d_1)^2}}}{\textcolor{red}{r + d_4}}
\end{equation}

\begin{equation}
	\textcolor{cyan}{V_5} = X \frac{\textcolor{cyan}{R_5}}{\textcolor{red}{R_2}} \qquad =  X \frac{\textcolor{cyan}{r - d_4}}{\textcolor{red}{r + d_4}}
\end{equation}

\begin{equation}
	\textcolor{Plum}{V_6} = X \frac{\textcolor{Plum}{R_6}}{\textcolor{red}{R_2}} \qquad = X \frac{\textcolor{Plum}{\sqrt{d_2^2 + (r-d_1)^2}}}{\textcolor{red}{r + d_4}}
\end{equation}

\noindent Substituting in the values for the speed X and the various distances, we obtain the following values for the motor speeds:

\bigskip

\begin{centering}

\begin{tabular}[2]{|c|c|}

	\hline
	\textbf{Motor} & \textbf{Motor speed \% of max (100)} \\ \hline
	\textcolor{ForestGreen}{1} & 96.59 \\ \hline
	\textcolor{red}{2} & 100 \\ \hline
	\textcolor{blue}{3} & 96.59\\ \hline
	\textcolor{orange}{4} & 62.52 \\ \hline
	\textcolor{cyan}{5} & 49.73\\ \hline
	\textcolor{Plum}{6} & 62.52\\ \hline

\end{tabular}

\end{centering}
\bigskip
\noindent We can see that at a small turning radius like 30 inches, we will see a drastic difference between the motor speeds. As the turning radius increases, we will see less and less difference between the speeds.  This is the case up until the point where the calculated turning radius is 250 inches or greater; 250 inches is the point at which the encoders on the corners no longer have the resolution to differentiate between 1\degree\ and 0\degree\ and thus we say that anything above a turning radius of 250 inches is not turning at all and we give all motors the same speed.

\subsection{Corner Motor Positions}

To signal turning, the rover will take values from the controller from -100 to 100. This value represents the percentage of the minimum (tightest) turning radius that the wheels can handle, with negative numbers turning to the left and positive numbers to the right. The higher the magnitude of the number, the tighter turning radius, i.e. -100 means the tightest turn possible to the left, 0 means straight ahead, and 100 means the tightest turn possible to the right. This "tightest" turning radius is determined by a combination of the geometric distances of the rover as well as the physical hard stop limitations of the corner motors. In our system, each of the corner motor is allowed to turn up to 45 degrees before hitting a physical hard stop, as shown in Figure \ref{r7}.

\begin{figure}[H]
 	\centering
  	\begin{minipage}[b]{0.45\textwidth}
		\includegraphics[width=\textwidth]{"Pictures/rover11".PNG}
  	\end{minipage}
  	\hfill
  	\begin{minipage}[b]{0.45\textwidth}
    		\includegraphics[width=\textwidth]{"Pictures/rover10".png}
  	\end{minipage}
  	\caption{Corner angle limitations}
	\label{r7}
\end{figure}

\noindent In order to figure out the tightest turning radius, we need to solve for the closest place along the rover's center axis that the corner wheel can point given its 45\degree\ limitation. This is shown in Figure \ref{r8}:

\begin{figure}[H]
 	\centering
  	\begin{minipage}[b]{0.45\textwidth}
		\includegraphics[width=\textwidth]{"Pictures/rover12".PNG}
  	\end{minipage}
  	\hfill
  	\begin{minipage}[b]{0.45\textwidth}
    		\includegraphics[width=\textwidth]{"Pictures/rover13".png}
  	\end{minipage}
  	\caption{Minimum Turning Radius calculations}
	\label{r8}
\end{figure}

\begin{equation}
	tan(\textcolor{blue}{\theta}) = \frac{\textcolor{orange}{d_3}}{\textcolor{ForestGreen}{x}} \qquad  r_{min} = \textcolor{red}{d_1} + \textcolor{ForestGreen}{x}
	\label{eq4}
\end{equation}

\begin{equation}
	r_{min} = \textcolor{red}{d_1} + \frac{\textcolor{orange}{d_3}}{tan(\textcolor{blue}{\theta})} \qquad   r_{min} = \textcolor{red}{7.254} + \frac{\textcolor{orange}{10.5}}{tan(\textcolor{blue}{45\degree})}
\end{equation}

\begin{equation}
	r_{min} = 17.754 inches
\end{equation}

\noindent Plugging in the distance values from our physical robot, we see that the minimum turning radius to each side will be at 17.754 inches. In order to not push the system to the physical hard stops when it turns, we therefore set the minimum radius to be at 20 inches to either side. As mentioned before, the "maximum" turning radius is at 250 inches to either side, as this is the location in which the encoder no longer can differentiate between it being at 0\degree\ and 1\degree . In order to calculate what target angle each corner should be at given the turning radius input from the controller, we take Equation \ref{eq4} and solve for $\theta$:
\begin{equation}
	tan(\textcolor{blue}{\theta}) = \frac{\textcolor{orange}{d_3}}{\textcolor{ForestGreen}{x}} \qquad \textcolor{blue}{\theta} = tan^{-1}(\frac{\textcolor{orange}{d_3}}{R - \textcolor{red}{d_1}})
\end{equation}

\noindent Where R is the physical turning radius of the rover (but remember that the values from the controller are given as a percentage of the range of the possible turning radii for the rover).

\end{document}

Software/Latex Docs/Software Controls/Software Controls.tex


\documentclass{beamer}
%
% Choose how your presentation looks.
%
% For more themes, color themes and font themes, see:
% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%
\mode<presentation>
{
    \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
    \usecolortheme{default} % or try albatross, beaver, crane, ...
    \usefonttheme{default}  % or try serif, structurebold, ...
    \setbeamertemplate{navigation symbols}{}
    \setbeamertemplate{caption}[numbered]
    \setbeamertemplate{footline}[frame number]
    \setbeamertemplate{itemize items}[circle]
    \setbeamertemplate{theorems}[]
    \setbeamercolor*{structure}{bg=white,fg=blue}
    \setbeamerfont{block title}{size=\normalsize}
    \setbeamertemplate{frametitle continuation}{}
}

\newtheorem{proposition}[theorem]{Proposition}
\theoremstyle{definition}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{idea}[theorem]{Idea}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{aligned-overset}
\usepackage{alltt}
\usepackage{amsmath}
\usepackage{csquotes}
\usepackage{multicol}
\usepackage{stmaryrd}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{nicefrac}
\usepackage{tikz}
\usepackage{pgf-pie}
\usepackage{appendixnumberbeamer}

\captionsetup{labelformat=empty}

\renewcommand\tabularxcolumn[1]{m{#1}}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}

\def\code#1{\texttt{\frenchspacing#1}}
\def\padding{\vspace{0.5cm}}
\def\spadding{\vspace{0.25cm}}
\def\b{\textcolor{blue}}
\def\r{\textcolor{red}}
\def\o{\textcolor{gray}}
\def\g#1{{\usebeamercolor[fg]{block title example}{#1}}}

% fix for \pause in align
\makeatletter
\let\save@measuring@true\measuring@true
\def\measuring@true{%
    \save@measuring@true
    \def\beamer@sortzero##1{\beamer@ifnextcharospec{\beamer@sortzeroread{##1}}{}}%
    \def\beamer@sortzeroread##1<##2>{}%
    \def\beamer@finalnospec{}%
}
\makeatother

\usepackage[sorting=ynt,style=authoryear]{biblatex}
\addbibresource{sources.bib}

\title[Probabilistic Social Choice]{Probabilistic Social Choice \\ \small{(\cite{Brandl2015})}}
\author{Jonas Hübotter}
\date{November 23, 2021}

\begin{document}

\begin{frame}
    \titlepage
\end{frame}

% Uncomment these lines for an automatically generated outline.
% \begin{frame}[allowframebreaks]{Outline}
%     \tableofcontents[subsubsectionstyle=hide]
% \end{frame}
% \AtBeginSection[]
%   {
%      \begin{frame}
%      \frametitle{Plan}
%      \tableofcontents[currentsection, sectionstyle=show/hide, hideothersubsections]
%      \end{frame}
%   }

\section{Introduction}

\begin{frame}
\begin{center}
Ava, Ben, and Chloe want to go for lunch.\pause \\[10pt]

Ava wants to go to Klara's Kitchen $\succ$ Mensa $\succ$ foodLAB.\par
Ben wants to go to Mensa $\succ$ foodLAB $\succ$ Klara's Kitchen.\par
Chloe wants to go to foodLAB $\succ$ Klara's Kitchen $\succ$ Mensa.\pause \\[10pt]

So where to go?\pause \\[25pt]

\large{Aggregating the preferences of individuals\par is the \b{problem of social choice}.}
\end{center}
\end{frame}

\section{Deterministic Social Choice}

\begin{frame}{Framework of Social Choice}
Given \begin{itemize}
    \item an \b{electorate} \g{(Ava, Ben, and Chloe)}\pause,
    \item a set of \b{alternatives} $A\ \g{= \{\text{foodLAB}, \text{Klara's Kitchen}, \text{Mensa}\}}$\pause,
    \item a \b{preference profile} $R$ over $A$\pause \\[8pt]
        \begin{center}\begin{tabular}{ c|c|c }
         $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
         \hline\hline
         K & M & F \\
         M & F & K \\
         F & K & M \\
        \end{tabular}\end{center}
\end{itemize}\vspace{8pt}\pause

find a \b{social choice function} $f : \mathcal{R}_A\only<5->{\footnote{$\mathcal{R}_A = \Delta(\mathcal{L}(A))$ is the set of all preference profiles over $A$. Here, $\mathcal{L}(A)$ is the set of all linear preference relations over $A$ and $\Delta(S)$ is the set of all probability distributions over $S$.}} \to A$ that returns a single alternative\pause,

\g{i.e., identifies a place for lunch that is in $A$.}
\end{frame}

\begin{frame}{Framework of Social Choice}
$R(a \succ b)$ is the fraction of the electorate that prefers $a$ to $b$.\pause \\[15pt]

\begin{example}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{center}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & M & F \\
 M & F & K \\
 F & K & M \\
\end{tabular}\end{center}
\end{column}
\begin{column}{0.5\textwidth}
\begin{flalign*}
    \g{R(K \succ M)}\ &\g{=\pause \nicefrac{2}{3}} &\\
    \g{R(M \succ F)}\ &\g{=\pause \nicefrac{2}{3}} &\\
    \g{R(F \succ K)}\ &\g{=\pause \nicefrac{2}{3}} &
\end{flalign*}
\end{column}
\end{columns}
\end{example}
\end{frame}

\subsection{Condorcet Consistency}

\begin{frame}{Framework of Social Choice}
\begin{center}
We do not just want \emph{some} social choice function,\par
we want a \emph{good} social choice function.\pause \\[10pt]
We need an \emph{axiomatic characterization}.
\end{center}\pause

\begin{block}{Condorcet consistency}
If $R(a \succ b) > \nicefrac{1}{2}$ for any $b \in A \setminus \{a\}$\pause, then $a$ is called the \b{Condorcet~winner}.\par\pause
$f$ is \b{Condorcet consistent} if it always chooses the Condorcet winner provided one exists.
\end{block}\pause

\begin{example}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{center}\begin{tabular}{ c|c }
 $\nicefrac{2}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & F \\
 M & K \\
 F & M \\
\end{tabular}\end{center}
\end{column}\pause
\begin{column}{0.5\textwidth}
\begin{align*}
    \g{R(K \succ M)}\ &\g{= 1} \\
    \g{R(K \succ F)}\ &\g{= \nicefrac{2}{3}}
\end{align*}
$\rightsquigarrow K$ is the Condorcet winner
\end{column}
\end{columns}
\end{example}

% \begin{block}{Weak Pareto Efficiency}
% If $R(\text{Klara's Kitchen} \succ \text{Mensa})\only<4->{\footnote{$R(a \succ b)$ is the fraction of the electorate that prefers $a$ to $b$.}} = 1$,\pause\ then $f(R) \neq \text{Mensa}$.\par\pause
% \g{We would be better off collectively by going to Klara's Kitchen.}
% \end{block}\pause

% \begin{block}{Monotonicty}
% If $R(\text{Klara's Kitchen} \succ b) \leq R'(\text{Klara's Kitchen} \succ b)$,\pause\par
% then $f(R) = \text{Klara's Kitchen}$ implies $f(R') = \text{Klara's Kitchen}$.\par\pause
% \g{When we decide to go to Klara's Kitchen and the support for going there is increased, we should still go there.}
% \end{block}
\end{frame}

\begin{frame}{Framework of Social Choice}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{center}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & M & F \\
 M & F & K \\
 F & K & M \\
\end{tabular}\end{center}
\end{column}
\begin{column}{0.5\textwidth}
\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300

%Straight Lines [id:da006979237897732471]
\onslide<1->{\draw [color=red  ,draw opacity=1 ]   (186.52,146.05) -- (231.52,146.05) ;}
%Straight Lines [id:da015439588280161676]
\onslide<3->{\draw [color=blue  ,draw opacity=1 ]   (181.52,95.05) -- (150.52,133.05) ;}
%Straight Lines [id:da9956392230048516]
\onslide<2->{\draw [color=green  ,draw opacity=1 ]   (234.52,95.05) -- (267.52,134.05) ;}

% Text Node
\onslide<1->{\draw (127,138) node [anchor=north west][inner sep=0.75pt]  [color=red  ,opacity=1 ]  {$K\succ M$};}
% Text Node
\onslide<2->{\draw (242,138) node [anchor=north west][inner sep=0.75pt]  [color=green  ,opacity=1 ]  {$M\succ F$};}
% Text Node
\onslide<3->{\draw (186,75) node [anchor=north west][inner sep=0.75pt]  [color=blue  ,opacity=1 ]  {$F\succ K$};}

\end{tikzpicture}
\end{column}
\end{columns}\pause\pause\pause\vspace{10pt}

The preferences of Ava, Ben, and Chloe do not yield a Condorcet~winner (known as the Condorcet paradox).\pause \\[20pt]

\begin{center}
\r{Many commonly used social choice functions are Condorcet~inconsistent.}\par\pause
\small{(plurality, two-round runoff, instant runoff, Borda count)}
\end{center}\pause\vspace{10pt}

$\rightsquigarrow$ deterministic social choice functions are problematic
\end{frame}

\section{Probabilistic Social Choice}

\begin{frame}{Probabilistic Social Choice}
Instead of returning a single alternative, a \b{probabilistic social choice function} returns probability distributions (\b{lotteries}) over alternatives.\pause \\[10pt]

Formally, $f : \mathcal{R}_A \to \mathcal{P}(\Delta(A))$ where $\Delta(A)$ is the set of lotteries over $A$.\pause

\begin{example}[random dictatorship]
Choose a preference relation among all preference relations uniformly at random, and choose its most-preferred alternative.

\begin{center}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 \r{K} & \r{M} & \r{F} \\
 \o{M} & \o{F} & \o{K} \\
 \o{F} & \o{K} & \o{M} \\
\end{tabular}\end{center}\pause
$\rightsquigarrow RD(R) = \{\nicefrac{1}{3} F + \nicefrac{1}{3} K + \nicefrac{1}{3} M\}$
\end{example}
\end{frame}

\begin{frame}{Probabilistic Social Choice}
\begin{block}{Requirements}
\begin{itemize}\pause
    \item when Ava goes to lunch on her own, she should choose Klara's~Kitchen with probability $1$ (\b{unanimity})\pause
    \item when $f$ returns multiple lotteries for a preference profile, there is an "arbitrarily close" preference profile that only yields a single lottery (\b{decisiveness})
\end{itemize}
\end{block}\pause
$\rightsquigarrow$ deterministic social choice functions are a special case of probabilistic social choice functions which only return \emph{degenerate} lotteries (i.e., lotteries that put all probability mass on a single alternative).
\end{frame}

\subsection{Population Consistency}

\begin{frame}{Consistency Axioms}
\begin{columns}
\begin{column}{0.25\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c }
 $\nicefrac{1}{2}$ & $\nicefrac{1}{2}$ \\
 \hline\hline
 K & M \\
 M & F \\
 F & K \\
\end{tabular}\caption{$R'$}\end{table}\end{center}
\end{column}
\begin{column}{0.25\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c }
 $\nicefrac{1}{2}$ & $\nicefrac{1}{2}$ \\
 \hline\hline
 K & M \\
 F & F \\
 M & K \\
\end{tabular}\caption{$R''$}\end{table}\end{center}
\end{column}
\onslide<2->{\begin{column}{0.5\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{4}$ & $\nicefrac{1}{4}$ & $\nicefrac{1}{2}$ \\
 \hline\hline
 K & K & M \\
 M & F & F \\
 F & M & K \\
\end{tabular}\caption{$\nicefrac{1}{2} R' + \nicefrac{1}{2} R'' = R$}\end{table}\end{center}
\end{column}}
\end{columns}

\g{\onslide<1->{When $\nicefrac{1}{2}K + \nicefrac{1}{2}M$ is chosen by $R'$ and $R''$}\onslide<2->{, then it must also be chosen by $R$.}}\pause\pause

\begin{block}{Population Consistency}
When two separate electorates $R'$ and $R''$ agree on a lottery, this lottery must also be chosen by a combination of the electorates.

$\rightsquigarrow$ consistency with respect to a variable electorate
\end{block}
\end{frame}

\subsection{Cloning Consistency}

\begin{frame}{Consistency Axioms}
Ben \emph{really} wants to go to Mensa so he devises an evil plan to confuse his friends.\pause\par
Instead of proposing to go to Mensa, he introduces separate \b{clones} $B = \{M1, M2, \dots\}$ for table 1 at Mensa, table 2 at Mensa, ...\pause

\begin{columns}
\begin{column}{0.33\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & M1 & F \\
 M1 & M2 & K \\
 M2 & F & M2 \\
 F & K & M1 \\
\end{tabular}\caption{$R$}\end{table}\end{center}
\end{column}\pause
\begin{column}{0.33\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & M1 & F \\
 M1 & F & K \\
 F & K & M1 \\
\end{tabular}\caption{$R|_{A'}$ \\ $A' = \{F, M1, K\}$}\end{table}\end{center}
\end{column}
\begin{column}{0.33\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c }
 $\nicefrac{2}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 M1 & M2 \\
 M2 & M1 \\
\end{tabular}\caption{$R|_B$ \\ $B = \{M1, M2\}$}\end{table}\end{center}
\end{column}
\end{columns}\pause

\begin{block}{Cloning Consistency}
We should assign the same probability to $M$ independently of the number of clones and the internal relationship between these clones.

$\rightsquigarrow$ consistency with respect to components of \emph{similar} alternatives
\end{block}
\end{frame}

\subsection{Composition Consistency}

\begin{frame}{Consistency Axioms}
\begin{columns}
\begin{column}{0.33\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & M1 & F \\
 M1 & M2 & K \\
 M2 & F & M2 \\
 F & K & M1 \\
\end{tabular}\caption{$R$}\end{table}\end{center}
\end{column}
\begin{column}{0.33\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 K & M1 & F \\
 M1 & F & K \\
 F & K & M1 \\
\end{tabular}\caption{$R|_{A'}$ \\ $A' = \{F, M1, K\}$}\end{table}\end{center}
\end{column}
\begin{column}{0.33\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c }
 $\nicefrac{2}{3}$ & $\nicefrac{1}{3}$ \\
 \hline\hline
 M1 & M2 \\
 M2 & M1 \\
\end{tabular}\caption{$R|_B$ \\ $B = \{M1, M2\}$}\end{table}\end{center}
\end{column}
\end{columns}

\g{$f$ should assign more probability to $M1$ than to $M2$.}\pause

\begin{block}{Composition Consistency (extending cloning consistency)}
The probability of clones must be directly proportional to the probabilities that $f$ assigns to these alternatives for $R|_B$.
\end{block}
\end{frame}

\section{Results}

\begin{frame}
We have seen that \emph{Condorcet consistency}, \emph{population consistency}, and \emph{composition consistency} arise as natural axioms.\pause \\[15pt]

Deterministic social choice functions \r{cannot} satisfy \begin{itemize}
    \item Condorcet consistency and population consistency\pause
    \item population consistency and composition consistency
\end{itemize}\pause\vspace{10pt}

What about probabilistic social choice functions?
\begin{itemize}
    \item random dictatorships satisfy population consistency and cloning consistency\pause
    \item \emph{maximal lotteries} satisfy population consistency and composition consistency (and Condorcet consistency)\par(\cite{Brandl2015})
\end{itemize}\pause

$\rightsquigarrow$ maximal lotteries settle a dispute between the founding fathers of social choice theory, Chevalier~de~Borda and Marquis~de~Condorcet.
\end{frame}

\section{Interpretation}

\begin{frame}
\begin{center}
    \Large{Random aggregation does not entail decisions must lack rationale, but rather that results may be random in the absence of a clear winner and as such the procedure is harder to exploit.} \\[20pt]

    \normalsize{\blockquote{Sometimes, in fact, we want to exclude reasons from decision‐making entirely. This is what lotteries can do.}\par(\cite{Stone2011})}
\end{center}
\end{frame}

\begin{frame}{Acceptability of Lotteries}
Amidst which circumstances are random choices useful?\pause
\begin{itemize}
    \item depending on the risk aversion of voters, and
    \item the effective degree of randomness.
\end{itemize}
\end{frame}

\begin{frame}{Acceptability of Lotteries}
\begin{block}{Risk Aversion}
Typically, the risk aversion depends on
\begin{itemize}
    \item the stakes of the decision\pause, and
    \item the frequency of preference aggregation.
\end{itemize}\pause

If preferences are aggregated rarely the law of large numbers does not apply and a risk-averse voter might prefer a sure outcome to a random outcome even if in expectation she prefers the random outcome.
\end{block}\pause\vspace{10pt}

In the Athenian democracy, lotteries were a principal component.\only<4->{\footnote{Special allotment machines (\emph{kleroteria}) were used to select candidates.}} The process of selecting candidates by a lottery for a political office is also known as \emph{sortition} or \emph{selection by lot}.
\end{frame}

\begin{frame}{Acceptability of Lotteries}
\begin{block}{Effective Degree of Randomness}
What to do about ties? Are ties rare or common?\pause \\[15pt]

\g{Condorcet view:} we encounter a tie iff there is no Condorcet~winner, i.e., no unequivocal winner.\pause \\[5pt]
It can be shown that Condorcet's view of equivocality and the randomness of maximal lotteries coincide.\only<3->{\footnote{Maximal lotteries are degenerate iff there is a Condercet winner.}}\pause \\[15pt]

Empirically, there often exists a Condorcet winner. If there exists no Condorcet winner, the support of maximal lotteries is typically small compared to the number of alternatives.
\end{block}
\end{frame}

\begin{frame}{An Alternative Interpretation}
We have been thinking about lotteries as probability distributions over alternatives, used to obtain a single (or multiple) choices.\pause

\begin{example}
Consider a firm that asks its employees to spend a fixed budget on non-profits of their choice. How can we come up with a fair allocation of the budget?\pause\vspace{-20pt}
\begin{columns}
\begin{column}{3cm}
\begin{align*}
    0.4 a + 0.25 b + 0.35 c
\end{align*}
\end{column}
\begin{column}{1cm}
\begin{align*}
    \Large{\rightsquigarrow}
\end{align*}
\end{column}
\begin{column}{2.5cm}
\begin{figure}
\centering
\resizebox{2.5cm}{!}{%
\begin{tikzpicture}
\pie{40/a,
    25/b,
    35/c}
\end{tikzpicture}%
}
\end{figure}
\end{column}
\end{columns}
\end{example}\pause

\begin{center}
    \large{Probabilities can equivalently be interpreted as fractions of a divisible resource such as money or time.}
\end{center}
\end{frame}

\section{Discussion}

\begin{frame}
\large{\begin{center}
\g{Thank you for your attention} \\ [25pt]

How often do preferences have to be (repeatedly) aggregated until lotteries become acceptable? \\[10pt]

Is randomness in decision making at all acceptable?\par Is it desirable?
\end{center}}
\end{frame}

\appendix

\begin{frame}[allowframebreaks]{References}
\nocite{*}
\printbibliography
\end{frame}

\begin{frame}{The Inefficiency of Majority Rule without Lotteries}
\blockquote{The 101 Club must choose a single form of entertainment for
 all club members. The membership rolls contain fifty football
 fanatics, fifty ballet aficionados, and a single lover of musical
 comedy. For the footballers the musical is almost as bad as the
 ballet. For the ballet enthusiasts the musical is little better than
 football. By majority rule, using pairwise comparisons without
 lotteries, the musical will be chosen. If lotteries were permitted, a
 fifty-fifty football-ballet lottery would defeat the musical by any
 required plurality up to 100 out of 101. (\cite{Zeckhauser1969})}
\end{frame}

\begin{frame}{The Inefficiency of Majority Rule without Lotteries}
\blockquote{A political system, such as the one in the United States, which
 rules out lotteries might lead to dominance by the center, even if
 the right and left could put together a majority coalition that would
 prefer a lottery on the extremes to a middle outcome. (\cite{Zeckhauser1969})}\pause

In general, majority rule without lotteries corrects towards the median choice.\par
This can be considered inefficient or desirable. The judgement may depend on the setting.
\end{frame}

\begin{frame}{Maximal Lotteries}
For a set of alternatives $A$ and preference profile $R \in \mathcal{R}_A$, let $M_R$ be the \b{majority margin matrix} defined by \begin{align*}
    M_R(x,y) = R(x \succ y) - R(y \succ x).
\end{align*}\pause \g{$M_R(x,y)$ denotes the difference between the fraction of voters preferring $x$ to $y$ and the fraction of voters preferring $y$ to $x$.}\pause\par\g{$\rightsquigarrow M_R$ is skew-symmetric}\pause \\[10pt]
Any $x \in A$ such that $M_R(x,y) \geq 0$ for all $y \in A$ is a \emph{(weak)~Condorcet~winner}.\pause\par
Any $x \in A$ such that $M_R(x,y) > 0$ for all $y \in A \setminus \{x\}$ is a \emph{strict~Condorcet~winner}.
\end{frame}

\begin{frame}{Maximal Lotteries}
We fix two lotteries $p, q \in \Delta(A)$.\pause\par
For $p$ and $q$, the majority margin $M_R$ can be extended to the \b{expected majority margin} $p^T M_R q$.\pause\par
The set of maximal lotteries is then the set of \emph{probabilistic Condorcet winners}\pause: \begin{align*}
    ML(R) = \{p \in \Delta(A)\pause \mid \forall q \in \Delta(A)\pause.\ p^T M_R q \geq 0\}.
\end{align*}\pause

\begin{block}{Interpretation in the Context of Game Theory}\pause
Let $M_R$ be the payoff matrix of a symmetric zero-sum game.\pause\ Lotteries in social choice theory correspond to mixed strategies in game theory.\pause\par
Then, maximal lotteries correspond to the mixed Nash equilibria (i.e., maximin strategies).\pause\par
$\rightsquigarrow$ efficient computation using linear programming.
\end{block}
\end{frame}

\begin{frame}{Maximal Lotteries}
\begin{example}
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{center}\begin{table}\begin{tabular}{ c|c|c }
 $\nicefrac{1}{2}$ & $\nicefrac{1}{3}$ & $\nicefrac{1}{6}$ \\
 \hline\hline
 $a$ & $a$ & $b$ \\
 $b$ & $c$ & $c$ \\
 $c$ & $b$ & $a$ \\
\end{tabular}\caption{$R$}\end{table}\end{center}
\end{column}\pause
\begin{column}{0.5\textwidth}
\begin{align*}
    M_R = \bordermatrix{ & \g{a} & \g{b} & \g{c} \cr
      \g{a} & 0 & \nicefrac{1}{3} & \nicefrac{1}{3} \cr
      \g{b} & -\nicefrac{1}{3} & 0 & \nicefrac{1}{3} \cr
      \g{c} & -\nicefrac{1}{3} & -\nicefrac{1}{3} & 0 } \qquad \\
\end{align*}
\end{column}
\end{columns}\pause

Clearly, $a$ is the only Nash equilibrium of the symmetric zero-sum game, so $ML(R) = \{a\}$ \g{($a$ is also the Condorcet winner)}.\pause\par
Note that a random dictatorship returns the lottery $\nicefrac{5}{6} a + \nicefrac{1}{6} b$.
\end{example}
\end{frame}

\begin{frame}{Randomness of Maximal Lotteries for Two Alternatives}
Let $A = \{x, y\}$ and $R \in \mathcal{R}_A$.\pause

\begin{align*}
    ML(R) = \begin{cases}
        \{x\} & \text{if } R(x \succ y) > \nicefrac{1}{2} \\
        \{y\} & \text{if } R(x \succ y) < \nicefrac{1}{2} \\
        \Delta(A) & \text{otherwise}
    \end{cases}
\end{align*}\pause

In contrast, a random dictatorship returns the lottery $R(x \succ y) x + R(y \succ x) y$.\pause \\ [10pt]

$\rightsquigarrow$ in a way, maximal lotteries have the smallest reasonable degree of randomness while random dictatorships are the most random.
\end{frame}

\end{document}