\chapter{Impedance and Sliding Mode Control of a One Degree of Freedom Exoskeleton}

\section{Exoskeleton Model}

\subsection{Exoskeleton}

In this study, we will use the upper limb exoskeleton described at chapter \ref{ch:ulexo}. It has one degree of freedom on the elbow joint, actuated by a DC motor with a Power Window Lifter gear transmission. The motor used is a 12V Mabuchi 578VA. The transmission has a 10:1 reduction ratio. The structure of the exoskeleton is constructed on aluminum.

The exoskeleton is illustrated in figure \ref{exoskeleton system}. When the user tries to flex his arm, an electrical voltage can be recorded from the electrodes placed on the skin next to the biceps brachii. The SparkFun Muscle Sensor V3 was used to measure the EMG. It acquires the biceps muscle voltage, rectifies, low-pass filters  and amplifies the signal. This signal is sent to a microprocessor (in this case the ATmega328P), that makes the analog-to-digital conversion and applies a moving average filter. Finally the voltage signal is transformed into a desired joint angle. Equation \ref{eq:voltage_angle} shows the equation that gives the desired joint angle as a function of the EMG sensor voltage. A linear relationship between the angular position and the measured voltage was chosen. The equation was defined by measuring the lowest and highest voltage level acquired from the biceps muscle and linearly scaling it to the minimum angle of 0 and maximum angle of \(\frac{\pi}{2}\). It is important to note that the voltage from the EMG sensor is never zero. Even at a relaxed position, the sensor measures a residual voltage level.

\begin{equation}
\label{eq:voltage_angle}
\theta_d = -0.29 + 0.582 * V_{emg}
\end{equation}

\begin{figure}[thpb]
      \centering
      \includegraphics[scale=0.5]{Images/Exoskeleton_System.jpg}
      \caption{Diagram showing the exoskeleton block diagram control}
      \label{exoskeleton system}
   \end{figure}

   With the desired joint angle the PWM magnitude sent to the motor driver is calculated with a control logic in order to control the motor that actuates the exoskeleton. This control logic will be further studied in the next section. The motor driver input is the PWM voltage and its output is an electrical current. Equation \ref{eq:current} shows the relationship between PWM voltage and motor current:

   \begin{equation}
\label{eq:current}
I = K_v*V
\end{equation}

Where \(K_v = 1.42\) is the driver gain, V is the voltage applied to the driver and I is the output current of the driver.

The output electrical current from the driver goes to the motor, actuating the exoskeleton and consequently moving the user’s forearm.

\subsection{Modeling}

Even though the exoskeleton has only one degree of freedom on the elbow joint, the user's shoulder angle should be considered because it influences the forces applied to the exoskeleton and the arm. The exoskeleton can be modeled as two segments: the upper arm (between shoulder and elbow) and the forearm (between elbow and wrist).

\begin{figure}[thpb]
      \centering
      \includegraphics[scale=0.5]{Images/DCL_exoesqueleto.jpg}
      \caption{Free body diagram of the exoskeleton}
      \label{exoskeleton fbd}
   \end{figure}

Figure \ref{exoskeleton fbd} shows the exoskeleton free body diagram, where the upper arm is considered to be fixed at a given angle \(\theta_1\), \(\theta_2\) is the angle between the upper arm and the forearm with a motion range between 0 and \(\frac{\pi}{2}\) rad, \(\tau\) is the torque applied by the motor, the Load has a range between 0 and 100N, M is the sum of the human forearm and exoskeleton forearm masses that equals 2.14 kg, \(L_1\) is the distance between the elbow center and the forearm center of mass (0.12m), \(L_2\) is the length of the forearm (0.22m), \(J_e\) is the forearm moment of inertia \(5.6 \cdot 10^{-3}  kg\cdot m^2\).

Equation \ref{eq:coupled exo motor} shows the dynamics of the exoskeleton:

\begin{equation}
\label{eq:coupled exo motor}
\left(\frac{J_e}{n}+J_m\right)\cdot \ddot{\theta}_m+B \cdot \dot{\theta}_m = \tau + \frac{-L_2 \cdot Load - L_1 \cdot M \cdot g \cdot sin\left(\frac{\theta_m}{n}+\theta_1\right)}{n}
\end{equation}

   Equation \ref{eq:motor torque} gives the relation between motor input current and output torque:

   \begin{equation}
\label{eq:motor torque}
\tau = k_m \cdot I
\end{equation}

Using equations \ref{eq:current}, \ref{eq:coupled exo motor} and \ref{eq:motor torque} gives the exoskeleton and human dynamics:

\begin{equation}
\label{eq:plant dynamics}
\left(\frac{J_e}{n}+J_m\right)\cdot \ddot{\theta}_m+B \cdot \dot{\theta}_m = K_m \cdot K_v \cdot V +\frac{-L_2 \cdot Load - L_1 \cdot M \cdot g \cdot sin\left(\frac{\theta_m}{n}+\theta_1\right)}{n}
\end{equation}

Where \(\theta_m\) is the angle of the shaft of the motor, \(J_m = 6 \cdot 10^{-5} kg \cdot m^2\) is the inertia of the motor, B = 1.2732 is the damping coefficient of the motor, n = 10 is the reduction factor and \(K_m = 0.533\) is the electrical current gain of the motor.

\section{Control}

\subsection{General Characteristics}

The action control will be the voltage V applied to the driver of the motor.
The load applied to the exoskeleton can vary from 0N to 100N. In this way the user will be able to manipulate different objects without changing the control parameters in a short time span. The controller goal is to control the exoskeleton position while maintaining safety and confort. The range of motion of the elbow joint is from 0 to \(\frac{\pi}{2}\) rad while the maximum angular velocity must be around \(\frac{\pi}{4}\) rad/s. There must be no overshoot on the movement.

\subsection{Impedance Control}

The first law will be based on impedance control. Impedance control imposes a dynamic behavior to the interaction between the target system and the environment, usually a mass-spring-damper system.
Impedance control is suited for tasks that require contact forces without an accurate control of the end-effector position (e.g. grabing an object). That is especially important in biomechanical applications since the human arm is capable of doing delicate tasks without a profound knowledge of necessary forces to be applied to the target objects.
One drawback is that whenever an external force is applied on the system the final position of the end-effector will not necessarily be the desired one, instead it controls a combination of force and position. The chosen stiffness for the dynamic system will regulate this trade-off between contact force and position accuracy.

\subsection{Impedance Control Design}

The system dynamics, (equation \ref{eq:plant dynamics}), can be rewritten as follows:

\begin{equation}
\begin{split}
\label{eq:rewritten plant}
\ddot{\theta}_m = \frac{-B \cdot \dot{\theta}_m + \frac{-L_2 \cdot Load - L_1 \cdot M \cdot g \cdot sin (\frac{\theta_m}{n}+\theta_1 )}{n} + K_v \cdot K_m \cdot V }{\frac{J_e}{n}+J_m}
\end{split}
\end{equation}

Equation \ref{eq:rewritten plant} can be organized in the form:

\begin{equation}
\label{eq:reorg}
\ddot{\theta}_m = f + bu
\end{equation}

Where:

\begin{equation}
\label{eq:f}
f = \frac{-B \cdot \dot{\theta}_m + \frac{-L_2 \cdot Load - L_1 \cdot M \cdot g \cdot sin \left(\frac{\theta_m}{n}+\theta_1 \right)}{n}}{\frac{J_e}{n}+J_m}
\end{equation}

\begin{equation}
\label{eq:b}
b = \frac{K_v \cdot K_m}{\frac{J_e}{n}+J_m}
\end{equation}

\begin{equation}
\label{eq:u}
u = V
\end{equation}

The desired closed loop dynamics are:

\begin{equation}
\label{eq:desired}
M_d \cdot (\ddot{\theta}_m-\ddot{\theta}_d) + B_d \cdot (\dot{\theta}_m - \dot{\theta}_d) + K_d \cdot (\theta_m - \theta_d) = -F
\end{equation}

Where \(M_d\) is the desired inertia, \(B_d\) is the desired damping, \(K_d\) is the desired stiffness, \(\theta_d\) is desired position and

\begin{equation}
\label{eq:F}
F = \frac{L_2 \cdot Load}{n}
\end{equation}

This characterizes a mass-spring-damper dynamics that will be imposed to the system by the controller.

By substituting equation \ref{eq:desired} in equation \ref{eq:reorg} and rearranging, one gets:

\begin{equation}
\label{eq:subs1}
u = b^{-1} \left(-f+ \frac{M_d \cdot \ddot{\theta}_d-B_d \cdot (\dot{\theta}_m-\dot{\theta}_d)-K_d \cdot (\theta_m-\theta_d)-F}{M_d}\right)
\end{equation}

Equation \ref{eq:subs1} gives the control law for the system, that can be expressed as (using \ref{eq:rewritten plant} - \ref{eq:F})

\begin{equation}
\begin{split}
\label{eq:inpedance law}
V = {} & \frac{1}{K_v \cdot K_m} (B \cdot \dot{\theta}_m + \frac{L_2 \cdot Load}{n} + \frac{L_1 \cdot M \cdot g \cdot sin(\frac{\theta_m}{n}+\theta_1)}{n} + \\
& (\frac{J_e}{n}+J_m)(M_d \cdot \ddot{\theta}_d - B_d(\dot{\theta}_m-\dot{\theta}_d)-K_d(\theta_m-\theta_d)-\frac{L_2 \cdot Load}{n})\cdot \frac{1}{M_d})
\end{split}
\end{equation}

This control law, as it is presented, cancels the nonlinearities of the system and imposes the desired dynamic  system behavior to the exoskeleton.

\subsection{Sliding Mode Control Design}

The second applied control law will be the Sliding Mode control. The system dynamics are the same as shown in equation \ref{eq:coupled exo motor}

The desired sliding surface is:

\begin{equation}
\label{eq:SM}
s = \dot{\theta}_m - \dot{\theta}_{d} + \lambda \cdot (\theta_m-\theta_{d})
\end{equation}

The control signal is u and, to achieve the desired controlled dynamics of the system, its value is as follows:

\begin{equation}
\label{eq:uSM}
u = \hat{b}^{-1}\left(-\hat{f}+\ddot{\theta}_{d} -\lambda \cdot (\theta_m-\theta_{d})-K\cdot sat\left(\frac{s}{\phi}\right)\right)
\end{equation}

Where:

\begin{equation}
\label{eq:bSM}
\hat{b} = \frac{K_v \cdot K_m}{\frac{J_e}{n}+\hat{J}_m}
\end{equation}

\begin{equation}
\label{eq:fSM}
\hat{f} = \frac{-B \cdot \dot{\theta}_m + \frac{-L_2 \cdot \hat{Load} - L_1 \cdot M \cdot g \cdot sin(\frac{\theta_m}{n}+\theta_1)}{n}}{\frac{J_e}{n}+\hat{J}_m}
\end{equation}

\(\hat{J_m}\) is the motor inertia with measuring error and \(\hat{Load}\) is the external load applied to the exoskeleton with measuring error.

This way, when in closed loop, the system acquires the following dynamics:

\begin{equation}
\label{eq:CLSM}
\frac{ds}{dt} = (\ddot{\theta}_m-\ddot{\theta}_{d})+\lambda \cdot (\dot{\theta}_m-\dot{\theta}_{d})
\end{equation}

That is,

\begin{equation}
\begin{split}
\label{eq:CLSM}
\frac{ds}{dt} = {} & f + b \cdot \hat{b}^{-1} \cdot (-\hat{f}) + b \cdot \hat{b}^{-1} \cdot (\ddot{\theta}_{d} - \lambda \cdot (\theta_m - \theta_{d}) +  \\
& - b \cdot \hat{b}^{-1} \cdot K \cdot sat(\frac{s}{\phi})-\ddot{\theta_m} + \lambda \cdot (\dot{\theta}_m-\dot{\theta}_{d}))
\end{split}
\end{equation}

To guarantee convergence the control must satisfy a sliding condition:

\begin{equation}
\label{eq:condition}
\frac{1}{2}\frac{ds^2}{dt} \leq -\eta \cdot |s|
\end{equation}

Equation \ref{eq:condition}, using \ref{eq:CLSM}:

\begin{equation}
\label{eq:K}
K \leq \beta \cdot (\eta + F) + (\beta -1) \cdot |\hat{u}|
\end{equation}

Where,
\begin{equation}
\label{eq:beta}
\beta = \sqrt{\frac{b_{max}}{b_{min}}}
\end{equation}

\begin{equation}
\label{eq:Fsm}
F > |f-\hat{f}|
\end{equation}

\begin{equation}
\label{eq:uhat}
\hat{u} = -\hat{f} + \ddot{\theta}_{d}-\lambda \cdot (\theta_m - \theta_{d})
\end{equation}

\section{Results}

\subsection{Impedance Control}

Choosing \(M_d = 1 kg \cdot m^2, B_d = 4 N \cdot m \cdot s, K = 4.5 N \cdot m\) and \(\theta_d = 1 rad\) gives \(\omega_n = \frac{2\pi}{8}\) rad/s the natural frequency of the system, \(t_{0-90\%} = 2.4 s\) the time the system takes to reach 90\% of the final position and \(\zeta > 1\) the damping factor, since there must be no overshoot.

Figures \ref{posicao0} and \ref{posicao100} show the results of a simulation where \(\theta_d = 1 rad\) and external load = 0 and 100N, respectively.

\begin{figure}[thpb]
      \centering
      \includegraphics[scale=0.5]{Images/posicao_load_0_paper.jpg}
      \caption{Position \(\theta_2\) versus time for an external load = 0}
      \label{posicao0}
   \end{figure}

   \begin{figure}[thpb]
      \centering
      \includegraphics[scale=0.5]{Images/posicao_load_100_paper.jpg}
      \caption{Position \(\theta_2\) versus time for an external load = 100 N}
      \label{posicao100}
   \end{figure}

\subsection{Sliding Mode Control}

Considering the measured load with 30\% error and the measured motor inertia with 20\% error, that is, \(\hat{Load} = 130N\) and \(\hat{J}_m = 7.2 \cdot 10^{-5} kg \cdot m^2\), resulting in \(\beta = 1.04\), the system was simulated with the following parameters: \(\eta = 5, \lambda = 1\) and \(\phi = 10\) and the results for the position and the sliding surface can be found in figures \ref{posicaoSliding} and \ref{slidingSurface}, respectively.

\begin{figure}[thpb]
      \centering
      \includegraphics[scale=0.5]{Images/Sliding_mode_position.jpg}
      \caption{Position \(\theta_2\) versus time}
      \label{posicaoSliding}
   \end{figure}

   \begin{figure}[thpb]
      \centering
      \includegraphics[scale=0.5]{Images/Sliding_mode_S.jpg}
      \caption{Sliding surface versus time}
      \label{slidingSurface}
   \end{figure}

\section{Conclusions}

Both control approaches has advantages and drawbacks. The impedance control cannot reach a desired position with utmost accuracy since the external load, by definition, will take the system out of its desired final position and the system parameters must be precisely measured in order to guarantee accurate desired dynamics. On the other hand, precise activities can be achieved without a deep knowledge of the environment, the system acquires familiar characteristics in the form of a mass-spring-dampener system and it is safer for the user since the controller changes the position of the system when an excessive external load is detected. The sliding mode control can achieve great precision and accuracy of desired position and trajectory and does not require a precise measurement of the system characteristics.

Depending on the application each one of these control methods is more appropriated. In the case of a wearable exoskeleton, the impedance control is a more suitable control method, since it offers a dynamic behavior close to that of a human limb and is safer for the user. To control an external robotic arm, the sliding mode control can be used since it will cause no harm to the user and is capable of performing actions with higher accuracy.


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

\chapter{Previous Work}
\label{ch:2}

\graphicspath{{Chapter2/Figs/Vector/}{Chapter2/Figs/Raster/}}

% **************************** Nomenclature **********************************
\nomenclature[c-1-x]{$x$}{Data points where $x=\{x_0, x_1, ..., x_{N-1}\}$}
\nomenclature[c-1-y]{$y$}{Labels for the dataset where $y=\{y_0, y_1, ..., y_{N-1}\}$}
\nomenclature[c-1-N]{$N$}{Number of features (dimensions) of $x$}
\nomenclature[c-1-n]{$N$}{Number of data points $x$}

\nomenclature[c-1-s]{$s_g$}{Sample standard deviation of the predictions}

\nomenclature[c-2-IC50]{$\mathrm{IC_{50}}$}{Half maximal inhibitory molar concentration}
\nomenclature[c-2-XC50]{$\mathrm{XC_{50}}$}{Half maximal effective or inhibitory molar concentration}
\nomenclature[c-2-EC50]{$\mathrm{EC_{50}}$}{Half maximal effective molar concentration}
\nomenclature[c-2-AC50]{$\mathrm{AC_{50}}$}{Half maximal effective molar concentration}
\nomenclature[c-2-Ki]{$\mathrm{Ki}$}{Half maximal molar concentration for half receptor occupancy}
\nomenclature[c-2-LD50]{$\mathrm{LD_{50}}$}{Median lethal dose}

%*****************************************************************************
\section{Active Learning}
\label{ch:Active Learning}

In order to assist the understanding of the methodologies used by others within the field of active learning, a toy dataset has been created. It is based upon~(\ref{eq:phantom}) and has been shown in Figure~\ref{fig:phantom}. The $y$ values used within the algorithms have been combined with errors, $\epsilon{}\sim{}\mathcal{N}(0, 0.01)$.

\begin{equation}
    y = \sin{(x_0)}^{10} + \cos{(10 + x_0 x_1)}\cos{(x_0)}
    \label{eq:phantom}
\end{equation}

\begin{figure}[h]
    \begin{center}
        \includegraphics{phantomOverview.pdf}
        \caption[Toy Dataset]{Contour plot of the function used to demonstrate the algorithms presented in previous work. The crosses have been used to show the location of the 200 test data points used within this example.}
        \label{fig:phantom}
    \end{center}
\end{figure}

In order to assess the algorithms, the mean squared error (mse) has been used. Comparisons are made to the na\"ive approach of Monte Carlo (random sampling). Each algorithm will be given five random starting points from which they will then attenuate to the data set.

There are several schools of thought regarding active learning. These can be separated into two distinct categories: current data and future predictions. The former of these is computationally cheaper, more complex to implement, and less adaptable to model changes.

\subsection{Current Data}
\subsubsection{Uncertainty Sampling and Regions of Disagreements}
\label{sec:UncertaintySampling}

When using probabilistic models, the data points with the highest uncertainty may be sampled first, as described by \textcite{Set09}. According to this strategy, (\ref{eq:info_uncertainty}) gives the next point to sample. This, in principle appears to be simple to implement, but upon closer inspection raises some concerns. Most noticeable is the limitation it places upon the model used.

\begin{equation}
    \label{eq:info_uncertainty}
    {x_\mathrm{next}=\argmin_X{\left[P(y^{*}|x;\theta{})\right]}}
\end{equation}

\textcite{Set09} also notes the use of information theory for probabilistic models (\ref{eq:info_uncertainty}), where \mbox{${y^{*}=\argmax_y{}P(y|x;\theta{})}$} is the most likely $y$ for $x$. This derives from the principle that the greatest entropy requires the most information to encode, and thus the least certain. However, \textcite{Set09} fails to address non-probabilistic models in this instance, instead converting such models into probabilistic ones.

\textcite{Set09} suggests another interpretation for uncertainty. By taking another approach from information theory, (\ref{eq:infoUncert}) is reached. This directly gives the point of the highest entropy, suggesting by knowing the point provides the largest information gain. Again however, this is difficult to implement with most models, as a probability distribution is required. This could be made simpler by approximating to a normal distribution.

\begin{equation}
    \label{eq:infoUncert}
    x_\mathrm{next}=\argmax_x{\left[-\sum_i{P(y_i|x;\theta)\log{P(y_i|x;\theta)}}\right]}
\end{equation}

In order to adapt non-probabilistic models into probabilistic ones, composite models may be used. These are an amalgamation of other models where the standard deviation of the individual models can be taken as the degree of certainty for a given point. This is commonly referred to minimising the region of disagreement, referring to the areas of discord within the hypothesis space. By minimising the region of disagreement between various models, a more coherent hypothesis space is sought leading to a more accurate model. This is the method used in Figure \ref{fig:rodPhantom}. This is shown in (\ref{eq:x_next1}).

\begin{equation}
    \label{eq:x_next1}
    x_\mathrm{next}=\argmax_X{\left[s_{g(X)}\right]}
\end{equation}

\begin{figure}[H]
    \begin{center}
        \includegraphics{rodPhantom.pdf}
        \caption[Uncertainty Sampling Demonstration]{The outcome of the investigating the areas of the highest uncertainty. An initial set of 5 random points (displayed as blue stars in A)) was provided, and 50 further iterations were then carried out of sample size 1. A) demonstrates the final set of points tested by the algorithm and B) shows the mean squared error for the algorithm after each iteration.}
        \label{fig:rodPhantom}
    \end{center}
\end{figure}

Interestingly, Figure~\ref{fig:rodPhantom}B shows how the mean squared error for the random sampling method performed to worse within the iterations tested. This is likely due to a bias in the use of linear models in fitting leading to large uncertainties surrounding areas with high curvature. Evidence to this is provided in Figure~\ref{fig:rodPhantom}A with a large proportion of the sampled points at areas of high curvature.

% \subsubsection{Broad Knowledge Base}
% A second form stems from information theory. Here, the aim is to produce an evenly dispersed $x$ allowing a well-informed knowledge base. This prevents poor model choice from influencing the algorithm as was seen in \ref{fig:rodPhantom}. There are two paths to proceed: density and nearest neighbours.

% The former of these requires a definition of density in a sparsely populated space. As an analogy, although the density of a gas appears well-defined, it becomes non-smooth once the volume defined over is comparable to the distance between particles. Thus, a new definition is required.

% Alternatively, nearest neighbour requires little explanation. $x_\mathrm{next}$ is the unlabelled data point furthest from any labelled data point. The results of \ref{eq:inverseSim} can be seen in Figure~\ref{fig:b}.

% \begin{equation}
%   \label{eq:inverseSim}
%   x_\mathrm{next}=\argmax_x{\left(\sum{\frac{1}{\simm{(x, x_i)}}}\right)}
% \end{equation}

% \begin{figure}[h]
%   \begin{center}
%     \includegraphics{broadPhantom.pdf}
%     \caption[Broad-Base Sampling Illustration]{The outcome of the investigating the areas of using a broad base. An initial set of 5 random points was provided, and 50 further iterations were then carried out of sample size 1. A) Demonstrates the final set of points tested by the algorithm and B) shows the change in the mean squared error for the algorithm after each iteration.}
%     \label{fig:b}
%   \end{center}
% \end{figure}

\subsubsection{Density Hotspots}
\label{sec:litRevDH}
Conversely, a density weighted model has been suggested, as it escapes the introduction of error from outliers (i.e.\ data points far away from alternative data points) and artificially reduces the available number of data points. \textcite{Set08} suggest (\ref{eq:Settles_density}) which can be broken down into two parts: a function for selection, $\phi_A$, and a function for similarity, $\simm$. The former represent another function for determining which point to sample next. The latter requires a function to describe the similarity between data points. $\beta$ is simply a parameter within this algorithm.

\begin{equation}
    \label{eq:Settles_density}
    x_\mathrm{next}=\argmax_x{\left[\phi_A(x)\times{\left(\frac{1}{n}\sum{\simm{(x, x_i)}}\right)}^\beta\right]}
\end{equation}

\textcite{Set08} admit that $\simm$ is open for interpretation. It must also be recognised that this lays the foundation of a clusterisation algorithm. There exist many forms of these algorithms, with the results of several of these algorithms on toy data sets presented in Figure~\ref{fig:ClusterResults} \cite{SciClus}.

\begin{figure}[H]
    \begin{center}
        \includegraphics[width=\textwidth]{clusters.png}
        \caption[Comparison of Clusterisation Algorithms]{Clusterisation algorithms used on sample two-dimensional data sets to demonstrate resultant clusters.}
        \label{fig:ClusterResults}
    \end{center}
\end{figure}

As Figure~\ref{fig:ClusterResults} demonstrates, there are multiple different interpretations of the solution to the problem of clustering. The makers of the Scikit learn package also discuss the scalability of each algorithm \cite{SciClus}. In order to prepare a high number of features (beyond the two used within this section for demonstration) and large number of data points, it is required that the algorithm scales accordingly. Further, for an adaptive process, it is more suitable for an algorithm to be adaptive to differing distribution. This limits the suitable algorithms to K-Means, Ward and Birch - columns one, five, and nine of Figure~\ref{fig:ClusterResults} respectively. Results for Birch can be seen in Figure~\ref{fig:clusterPhantom}. This appears do well, although it must be noted that this is likely due to the similarity between Monte Carlo (random) sampling, and clusterisation. I.e. areas distant from previously gathered points face a high chance of sampling.

\begin{figure}[H]
    \begin{center}
        \includegraphics{clusterPhantom.pdf}
        \caption[Cluster Hotspot Sampling Illustration]{The outcome of the investigating the areas of using a cluster hotspot sampling methodology. An initial set of 5 random points (displayed as blue stars in A)) was provided, and 50 further iterations were then carried out of sample size 1. A) demonstrates the final set of points tested by the algorithm and B) shows the mean squared error for the algorithm after each iteration.}
        \label{fig:clusterPhantom}
    \end{center}
\end{figure}

\subsection{Estimated Future}
These methods attempt to minimise a future attribute of the model. This works by predicting changes given with the inclusion of more data with a higher degree f theoretical underpinning that the sampling methods discussed thus far.

\subsubsection{Expected Model Change}
As the name implies, this method chooses points which are likely to have the largest impact on the final model. By instigating each potential point, the impact on the eventual model can be found. However, this requires a method for quantifying the model change.

\textcite{Set08,Set09} investigate models which can be trained "online": i.e. models which can use the previous iteration to reduce the time taken for convergence. They present a method called "Expected Gradient Length" (EGL) which has a couple of prerequisites: \textbf{1)} A probabilistic model is used \textbf{2)} Linear gradient based optimisation is used \textbf{3)} The model can be improved from previous iterations. Given these prerequisites, the problem becomes less computationally inexpensive given a small dataset or extensive parallelisation, and scales as $\mathcal{O}(n)$. However, it does have the distinct drawback of requiring close control of the data models used. Here, the length of the training gradient (the gradient used in re-fitting the parameters with gradient based optimisation) can be used as a measure of model change. In the case of a small model change, as is expected, the length of the training gradient can be written as ${\left\|\nabla{}l(\langle{}x, y_i\rangle{};\theta{})\right\|}$. Combining this with the probability distribution of $y$, the next sample to undergo labelling is given by (\ref{eq:EGL}).

\begin{equation}
    \label{eq:EGL}
    x_{EGL}^*=\argmax_x{\sum_i{P(y_i|x;\theta{})\left\|\nabla{}l(\langle{}x, y_i\rangle{};\theta{})\right\|}}
\end{equation}

\section{Batch Active Learning}
Little literature exists with respect to batch active learning. Naïve implementation exist whereby the methods explored earlier present a stack of data points to be chosen, and the top $N$ are used. However, this method does not take into account the equivalence of the data points. This can be seen by the formation of clusters within the uncertainty sampling method in Figure~\ref{fig:broadrod}, although it is not present within the clusterisation algorithm shown in Figure~\ref{fig:batchCluster}.

\begin{figure}[H]
    \begin{center}
        \includegraphics{batchrodPhantom.pdf}
        \caption[Batch Uncertainty Sampling]{The outcome of the investigating the areas of using uncertainty sampling. An initial set of 5 random points (displayed as blue stars in A)) was provided, and 5 further iterations were then carried out of sample size 10. A) Demonstrates the final set of points tested by the algorithm and B) shows the mean squared error for the algorithm after each iteration.}
        \label{fig:broadrod}
    \end{center}
\end{figure}

% \begin{figure}[H]
%   \begin{center}
%     \includegraphics{batchbroadPhantom.pdf}
%     \caption[Batch Broad-Base Sampling]{The outcome of the investigating the areas of using broad-base sampling. An initial set of 5 random points was provided, and 5 further iterations were then carried out of sample size 10. A) Demonstrates the final set of points tested by the algorithm and B) shows the change in the mean squared error for the algorithm after each iteration.}
%   \end{center}
% \end{figure}

\begin{figure}[H]
    \begin{center}
        \includegraphics{broadClusterPhantom.pdf}
        \caption[Batch Cluster Sampling]{The outcome of the investigating the areas of using cluster sampling. An initial set of 5 random points (displayed as blue stars in A)) was provided, and 5 further iterations were then carried out of sample size 10. A) Demonstrates the final set of points tested by the algorithm and B) shows the mean squared error for the algorithm after each iteration.}
        \label{fig:batchCluster}
    \end{center}
\end{figure}

It is to be expected that regions of high uncertainty will exist. Within these regions, multiple points will have similar uncertainties. Thus, it is likely in batch querying areas of high uncertainty multiple points from the same area of feature space will be chosen, reducing the information gain by the model. Perhaps the consequences will be even worse due to overfitting. A simple fix would be to simulate the model after 1 iteration, and select the next point from there. By doing this $n-1$ times, a better solution may be found, although this may prove to be computationally expensive.

\subsection{BatchBALD}
\textcite{BatchBALD} propose an algorithm named BatchBALD (Batch Bayesian Active Learning by Disagreement). Demonstrating for sample size of 10 an improvement compared to random sampling in optical character recognition. In doing so, they use complex Bayesian Neural Networks and apply the problem to categorical data. They also note it does not work well in the event of noisy data: a common feature of laboratory based labelling.

\section{Drug Data for Machine Learning}
There are numerous data categories that can be used to represent a chemical in a suitable form for machine learning. Indeed, the field of chemoinformatics is dedicated to the pursuit of describing chemicals for computational models. Each of these methods have various strengths and weaknesses. Some are directly based upon the chemical structure whereas others are based upon physical properties. These can be combined to produce models with high predictive capabilities.

\subsection{Physical Properties}
A selection of physical properties from chemicals are known, from melting points to solubility. Many of these provide important aspects for consideration and allow human scientists to predict interactions, especially when determining new drugs. These data are often reported in tables within textbooks such as Perry's Chemical Engineering Handbook or provided through software \cite{CHEMBL,Perrys}.

Several of these data can be predicted through theoretical models, although the difficulty increases for larger molecules. For example, models exist for density predictions, but predicting the $\mathrm{LD_{50}}$ of a drug is  far more challenging task. Indeed, even with animal testing, this property is deemed difficult to truly assess.

Within drug discovery, physical and biological properties are usually the sought after labels. An example of this is supplied by \textcite{CHEMBL} with a custom property named pChEMBL, as defined by (\ref{eq:pChEMBL}) where "|" is synonymous with "or". This provides a measure for a drug against a specific molecular structure, such as proteins. Values are expected to be between 2 and 12, although these are not limited. Indeed, values even be negative, although this is rare and unlikely. The larger the value, the greater the chemical interaction.

\begin{equation}
    \label{eq:pChEMBL}
    \mathrm{pChEMBL}=-\log_{10}{\left(\mathrm{IC_{50}}|\mathrm{XC_{50}}|\mathrm{EC_{50}}|\mathrm{AC_{50}}|\mathrm{Ki}|\mathrm{LD_{50}}|\mathrm{Potency}\right)}
\end{equation}

\subsection{Fingerprints}
Another methodology is to develop a fingerprint: a unique code based on the chemical structure, either of the atomic arrangement, or by the electron cloud distribution. The latter of these is more fundamental to the activity of molecules but far harder to calculate. Indeed, for accurate representation of the latter, both atomic structure is needed \textit{and} solutions for the Schrödinger equations corresponding to molecule in question.

According to \textcite{Cap20}, the most popular fingerprint in use are Morgan Fingerprints, a form of Extended Chemical Fingerprint (ECFP). ECFPs use a simple algorithm in order to generate a unique identifier, as described by \textcite{Mor2020}:

\begin{enumerate}
    \item \textbf{Initial Assignment}: Each atom has an integer assigned as an identifier.
    \item \textbf{Iterative Updating}: Updating the identifier assigned to atoms based on adjacent atoms and structural duplications.
    \item \textbf{Duplicate Removal}: Duplicate features are removed for hashing.
\end{enumerate}

The iteration process involves each atom and adjacent atoms sharing numbers before in an array. A hash function is applied to this array and becomes the atoms new identifier. Fingerprints of this class are labelled according to the number of iterations, $n$, with the final name given as ECFP\_$\langle{}2n\rangle{}$. Morgan fingerprints, the most common form, are thus also called ECFP\_4 \cite{Cap20, Mor2020}. Thus, these come under the remit of fingerprints based upon two-dimensional chemical structure, rather than three-dimensional or even electron distribution. Morgan fingerprints are readily available for millions of compounds from the publicly accessible ChEMBL database \cite{CHEMBL}.

% Alternative common fingerprints include SMILES, InChI, and the MDL molfile.


    \filetitle{normalise}{Normalise (or rebase) data to particular date}{tseries/normalise}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
X = normalise(X)
X = normalise(X,NormDate,...)
\end{verbatim}

\paragraph{Input arguments}\label{input-arguments}

\begin{itemize}
\item
  \texttt{x} {[} tseries {]} - Input time series that will be
  normalised.
\item
  \texttt{NormDate} {[} numeric \textbar{} \texttt{'start'} \textbar{}
  \texttt{'end'} \textbar{} \texttt{'nanStart'} \textbar{}
  \texttt{'nanEnd'} {]} - Date relative to which the input data will be
  normalised; if not specified, \texttt{'nanStart'} (the first date for
  which all columns have an observation) will be used.
\end{itemize}

\paragraph{Output arguments}\label{output-arguments}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{X} {[} tseries {]} - Normalised time series.
\end{itemize}

\paragraph{Options}\label{options}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{'mode='} {[} \texttt{'add'} \textbar{} \emph{\texttt{'mult'}}
  {]} - Additive or multiplicative normalisation.
\end{itemize}

\paragraph{Description}\label{description}

\paragraph{Example}\label{example}


\documentclass{article}
\usepackage{cite}
\usepackage{amsmath}
\usepackage{hyperref}
\title{What to Model ... }
\author{Seth Chaiken}
\begin{document}
\maketitle

\section{Of a circuit:}
\begin{itemize}
\item KVL and KCL defined spaces and dependencies of edge voltages and currents,
in a (1) graph-based network and more generally an orthogonal complemetary
decomposition of a linear space.
\item Equivalances to avoid circuits of voltage sources and capacitors
and cocircuits of current sources and inductors, in order to better (how?)
choose state variables (generalized coordinates?); existance of tree containing
all the voltage sources and capacitors whose cotree contains all the
current sources and inductors.    (Starting point
of \cite{ChuaMcPhersonLagrange}; find early references ??)
Benefits of this concretely and for Lagrangian formulations.
Generalizes of course.
\item Basic Lagrange and Hamiltonian formulation:
\cite{ChuaMcPhersonLagrange}.
\item Capacitor and inductor flux ($\phi = \int v(t) dt$) and
charge ($q = \int i(t) dt$).
General nonlinear laws: $L(i) = \phi$ and $C(v) = q$.
\item Transforms of linear circuit functions.
\item Resistance and other port quantities within the theory of
\textbf{random walks}\cite{DoyleSnellRandom,ProbOnTreesNetworks}.
Given a graph on states (as with Markov chains)
the discrete Greens function is defined
in \cite{ChungYaoDiscreteGreensFn}
to be the inverse of $\Delta|_S$  where
\[
\Delta f(x)=\sum_y(f(x)-f(y)p_{xy}
\]
is the discrete Laplace equation
when $p_{xy}$ is the transition probability from $x$ to $y$, and
$S$ is a connected subset with non-empty boundary
$\{y\not\in S | p_{xy}\not= 0 \ \text{for some }\ x\in S\}$.
\cite{ChungYaoDiscreteGreensFn} treats Dirichlet eigenvalues
determining Greens functions,
heat kernels, expected hitting times
and Greens functions for paths, lattices and distance regular graphs.

  Spanning tree counting was done by these methods in
  \cite{ChungYaoCovHeatKSpTrees}.

  The normalized Laplacian is the symmetric matrix of weights.

\item Electricity as statistics mechanincs of electron transfer.  Relate to
  random walk models.

\item Resistive port behavior; OM characterizes of
forest term sign.
\item Monotone non-linear well-posedness.
\item OM of solution states.
\item Predictions and constraints derived from OM properties:
\begin{enumerate}
\item How orthogonality with an OM vector predicts one sign from others.
\item How OM covector elimination predicts a zero value is possible.
\item (Possible application of ``fourientation'')
Suppose voltage and current source edges are specified with a source
direction for each.  A source directions is specified by an orientation, that
may one direction to specify a non-zero source, or (perhaps) none to specify a
zero source.  The (1) resistor values and, in the case of two or more sources,
(2) the source values determine a solution; the solution determines another
orientation on all the edges, called the solution orientation.  Rules for the
solution orientation (SO):
\begin{enumerate}
\item SO is defined on all the edges.
\item SO on one edge may to in one direction for non-zero current and voltage
in a resistor edge, or non-zero current or voltage in a voltage or current edge
respectively, or none to indicate those solution quantities are zero.
\item SO on a source edge may be the same or different from the given source
direction.
\end{enumerate}
Questions:
\begin{enumerate}
\item Characterize the solution orientations; maybe there is Tutte-like function
whose evaluation is the number of them.
\item Can a graph be derived so that a fourientation determines the set of
solution orientations?
\item How do these questions differ when the resistor values vary and the
sources values are constant, versus constant resistances and variable sources.
Are the problems of both varying any good?
\end{enumerate}
Geometry questions:  What about the space of solutions with given sign pattern?
\end{enumerate}
\item OM of transients.
\item Signs of transients that might not be OM modelled.
\item Laplace transform polynomials.
\begin{itemize}
\item Bode diagram approx.\\
\textbf{NEW THING: Tropical algebra approximates real algebra!}
\item Stability
\item Phase margin.
\item Discrete model for spanning tree count: Sandpile group order.
\end{itemize}

\item Imaginary frequency $s=i\omega$.
\item Anderson's complex OM (after learning it properly.)
\item Cones of possible phases.  Is that what Anderson did?
\item Orders or levels of resistance, etc. magnitudes; as
in symbolic simulation.
\item Laplacian eigenvalues and eigenvectors  (what are the good for in elec. circuit
study?)

Spectral analysis of a graph laplacian matrix has more applications today than
spectral analysis of the adjacency matrix; see \cite{ChungSpectralGraphTheory}.

Let $L$ be the (non-normalized) Laplacian matrix.  Its eigenvalues have the
following electrical interpretation:
Consider the graph to be a network of unit resistors with an added ground
node $0$ and a unit capacitor between each original node and the ground node.
Let the function of time $v_k(t)$, $k\neq 0$ be the voltage of node $k$
relative to
the ground node.  Then $d\bf{v}/dt = -L\bf{v}$, so the eigenvalue $\lambda_i$
corresponds to the solution $\bf{v}_i(t) = \bf{v}_i(0)e^{-\lambda_i t}$.

Discrete Greens function \cite{ChungYaoDiscreteGreensFn}.

\item Effect or information transfer directionality due to impedance
differences, ``half-resistors'',  \textbf{Bond graphs}.
\item Hamiltonian generalized position and momentum; that Frankel stuff.
\item Voltages and currents are orthogonal under a bilinear form that
represents power.  What's behind this?
\end{itemize}

\section{Recent Inverse Problem Results}

Short survey notice \cite{LamAMSNotice} cites
work by Curtis, Ingerman and Morrow \cite{CurtisIngermanMorrowCircPlanarRes}
and de Verdi{\`e}re, Gitler and Vertigan \cite{VertdiereGitlerVertigan}.
Starting with solutions to the electrical network inverse problems for planar
networks whose response vertices are on their bounding circle, research moved
into such for other surfaces.

See recent preprint by Lam \cite{LamElectroidVar2014}.

Add more refs.

\section{Ports}

Alternative vocabulary:
Distinguished elements, pointed mathematical objects, set pointed objects,
restrictioned objects

In matroid theory literature, a ``port'' is a clutter of subsets; it is the
discrete structure in a matroid associated with a single element extension.
We call a port an element $p$; $M$ on $E$ is the single element extension
of $M\setminus p$.  From \cite{MatroidPortsSteinerShellChari},
$\mathcal{P}= \{ C - e; C\in\mathcal{C}(\mathcal{M}), e\in C\}$.
Chari attributes this to Lehman and cites Seymour, Brylawski and Huseby.
Recently, it was seen to be the structure of secret sharing matroids.

\section{Electric Analogies}

\begin{enumerate}
\item inductance=mass, capacitance=spring stiffness, ...
\item Traffic flow: voltage=trip time, current=flow, resistance=route-time
per unit flow, KVL=each driver adjusts his route to minimize his time.

Braess paradox: Removing an edge reduces travel time. (Thanks, Michael
Sattinger.)
Simplest example [on Wikipedia] occurs with a \textit{voltage source}, an edge
with constant travel time.  Is related to Nash equilibrium.

\url{http://homepage.ruhr-uni-bochum.de/Dietrich.Braess/#paradox}
is a bibliography including
C.M. Penchina and L.J. Penchina,
   ``The Braess paradox in mechanical, traffic, and other networks.''
\cite{BraessAJPhy}
   Amer. J. Phys. 71, 479 - 482 (2003)

\textbf{non-linear monotonic constituitive functions} might be more applicable
here, like when the flow saturates, the time becomes $\infty$ when the capacity
is reached (or exceeded?).  Maybe try to write a note on necessary
conditions for a Braess paradox, which is in contrast to Raleigh's
inequalities.

\item Spider web: voltage=position, current=force, resistance=spring constant.
\end{enumerate}

\section{Benefits of Formal Expression}

Vectors: (1) time series (2) transform expansion.  Good to formalize with
generating functions IE? some general Fourier expansion.  (How the same??)

Vectors: Multidimensional quantities: System state, multidim. signal, complex
value:  Good to formalize with the GROUP ALGEBRA or some of its generalization.

Connection:  Generating functions are the
SEMI-GROUP algebra (over the coefficient space)
generated by $\{ z^n \}$.

\section{Engineering Intuitions}

\begin{enumerate}
\item
\textbf{A Study of paragraph-sized qualitative circuit operation descriptions}
\begin{itemize}
\item In terms of causal tracing of increases or decreases.
\item In terms of sinusoidal frequency response.
\item In terms of exponential frequency response.
\end{itemize}

\item
Impedance differences between parts of circuits; impedance in intuition.

\item
\textbf{Approximation}

\item
\textbf{Purposeful Design}

\begin{itemize}
\item Need to account for
\textbf{parasitic elements}
(1) Sometimes have small effects.
(2) Sometimes they must be compensated for.
\item Need for ``robustness'', researched with
\textbf{Monte-Carlo methods} and
\textbf{Sensitivity analysis}. \cite{HiFreqChaosMakerEE}
\end{itemize}

\item
\textbf{Effects and Strategies}
\begin{itemize}
\item Effect of adding (or displacing) poles and zeros to a transfer function.
\item Compensation.
\item Feedback.
\item (Results of feedback): Miller effect, bootstrapping.
\end{itemize}

\item
\textbf{Physical causes expressed in an electrical model}.  Specifically,
physics of devices (diode junctions, junction transtors,
field-effect transistors, even non-ideal resistors, capacitor, inductor).

\item
\textbf{Active vs. Passive: Bias distinguished from signal}
``\textbf{Active device:} A device that can convert energy from a dc bias
source to a signal at an RF frequency.  Active devices are required for
oscillators and amplifiers.'' Microwave Devices in
\textit{The Electrical Engineering
Handbook}.\cite[ch.37, Streer and Trew]{EEHandbook}
(Find other
definitions in the circuit theory literature?)

\item
\textbf{Thermal Runaway} Old: BJT power transistor latchup.  New: Hotspots
in systems on a chip (SoC). There is a thermal network interacting with the
electical network. Paper on it in VLSI \cite{ThermalVLSI}.

\item (Non-thermal?) Latchup (parasitic transistors)
CMOS\cite{CMOSLatchUpTINote}

\end{enumerate}

\section{Topology}

Engineers use the term topology to  mean ``circuit shape'',
the network graph decorated with element types, which determines
its instance of Kirchhoff law equations with a choice of constituitive laws.
Topologists and mathematical physicists (\cite{Frankel} especially Appendix
B, citing
Eckmann\footnote{
From MR: ``Let numerical values $f(x_i)$ be assigned on the vertices
$x_i$ of a subgraph R of a linear graph K. It is required to find f in
$Q=K−R$ so that $f(x_i)$ for vertices $x_i$ in Q equals the mean of
its values on the vertices joined to $x_i$ by an edge. It is shown
that f always exists, and is unique if and only if R has at least one
vertex in each component of K. This is a generalization of a finite
version of the Dirichlet problem. A similar theorem is given in n
dimensions. The proof is based on the unique representation of a chain
with real coefficients as a sum of a harmonic chain (which is both a
cycle and a cocycle), a boundary and a coboundary.  Reviewed by
H. Whitney''}
(\cite{Eckmann}--perhaps \cite{EckmannWorks},
Bott\cite{BottInducedRep} and a book by Bamberg and
Sternberg\cite{BambergSternbergBookII})
recognize this first as a case for homology and cohomology theory of a
1-dimensional chain complex, and then as a source of analogies for more
general spaces.  Going beyond the formulated (generally) differential
and transform space equations, the dynamical system solutions have been
studied by topologists in their relation to the network topology
\cite{MathFoundElecSmale}.

Some authors pursued the topological view in terms of
Lagrangian and Hamiltonian formulations\cite{ChuaMcPhersonLagrange}.

\subsection{Algebraic Topology}
The Laplacian generalizes to chain complexes, matrix tree theorem
generalizations.
(among others,\cite{Frankel,DuvalKlivansMartin}).

Weighted Laplacian (apps in persistent homology applications)
\cite{WuWeightedCoHLaplacian}.

More on weighted Laplacian, Hodge's theorem
$\text{ker}(\text{Laplacian}) \cong H^i$
\cite{HorakJostSpecCombLaplaceWeightedToo}.

{\bf One-port resistance, current and voltage vector, edge resistance, Laplacian det
extended to simplicial complexes, with Hodge theory. \cite{KOOK201871}.  Reference
to combinatorial Hodge theory used in this paper is \cite{MR1622290}.}

The derivation of the Bott-Duffin constrained inverse \cite{BottDuffinAlgNetworks}
with $\mathbf{k}^n = V \circ V^\perp$ may be an analog to a 3-way direct sum in
\cite{MR1622290}.

Other papers by Kook and co-authors:
\cite{AALIPOUR2018362,KOOK2011417,KOOK201659,KHO2017278}

\subsection{Back to Point Set Topology}

Each network graph vertex models a conducting region of physical space,
ignoring electromagnetics...

Idea: When we consider the system (circuit?) to be a physical object, the
vertices are \textbf{topological contractions} of the conducting regions.
\textbf{The homology group} of the conductor surface is trivial (since the
conductor itself is simply connected.)   The same level homology group for
the whole system is the cycle space which is the subject for Kirchhoff's
current law.

Magnetic phonomena make non-graphic topologies (recalled from one of
Duffin's papers, where a cycle is assumed to have zero flux).

Recall conversation with Dan Silver and Susan Williams about topology, knots and Maxwell's equations.  Work on knot invariants from Laplacian
\cite{SilverWilliamsKnotLaplacian}.

(Refer to homotopy methods for analyzing non-differential non-linear
equations.  Persistent homology is a new theme here.  This may bridge
statistical mechanical microscopic models to our macroscopic models.)

\section{OTHER}

The Boltzmann factor in interplay between combinatorics and statistical
mechanics (after reading Feynman's Lectures on Physics account).

The Boltzmann factor is
$p_{\beta}(x)= C\alpha^{-x}$ $=$ $Ce^{-\beta x}$ is the probability
or probability density of the exponential distribution.
Its origin in statistical mechanics:  $E_\beta = x + (E_\beta-x)$ where the
number of equally probable states of an environment (heat bath)
is $Ce^{E_\beta - x}$ and so the probability of one state of a
(system+environment) is proportional to $e^{-\beta x}$.  It is the probability
of one system state with energy $x$ when the systema and environment are
in \textbf{thermal equilibrium}.  Then, $\beta$ is defined as
\textbf{temperature}.

Caticha: This is a special case of maximizing \textbf{Shannon entropy}
subject to constraints on the expectations of one or more functions, such as
$x(s)$.  Then temperature like quantities emerge as Lagrange multipliers.

Partition and generating function:
\[
Z = \sum_{s\in\text{states}}e^{-\beta x(s)} = \sum_{x}N(x)e^{-\beta x}
\]
where $N(x)= $ number of states $s$ with $x(s) = x$.
\[
\frac{\partial{\log Z}}{\partial\beta}
=
\text{Expected Value}(x)
\]

(Consequences of $\text{max}\Omega(x)\Omega_{\text{bath}}(E_\beta -x )$
\cite{CatichaEIFP})

\textbf{Caticha:} The dynamical system on the microstates is called
the ``subject matter'', which is an assumption part of what we must know or
assume
in order to do science.  Particular equations or their form as
Hamilton's equations are written down.
The dynamical system of evolving an evolving
microstate maps to a dynamical system of evolving probability
distributions.  Our knowledge is represented by a probability distribution
on microstates.

Equal probabilities of all heat bath states with (heat bath) energy
$E_\beta -x$ is
equivalent to the system states' probability distribution has maximum
entropy among those with expected (system) energy value $x$.  But under the
second interpretation, temperature emerges as the value of the Lagrange
multiplier for particular energy value $x$.  (Connection: The Max Ent
distribution over all finite discrete probability distributions is the uniform
distribution.)

Multiple interacting transport phenomena in transistors and other
engineered systems (natural too!).

\textbf{Objects categorized by computational effectiveness:}
\begin{enumerate}
\item Statistical Mechanical Ensemble, through which a world traces
merely a path of measure zero.
\item Countable set; RE set, recursive set.
\item A state of a world, existed physically, an approximation is
impossible to store in computers.
\item A object that can possibly be stored using all the world's
computers.
\item A object feasible to be a state in a computational simulation.
\item An object feasible to present to a human.
\end{enumerate}

\section{Laplace etc from other document}

(a functional transformation, function $->$ function)

(a complex, more specifically, analytic function)

(a generating function, analog with $\int dt$ in place of $\sum$)

(approximation relations with dicrete generating functions,
aka ``$z$-transform''. Digital signal processing implements or
is approximately related to analog signal processing.)

(a formal ratio of an extensor's Plucker coordinates)

(eigenvalue of eigenvector $e^{s t}$ under a differential operator eg
$(a\frac{d}{dx}^2 + b\frac{d}{dx} + c)(e^{st}) = (as^2 +bs + c)e^{st}$

(formal expression for impedances $R$, $1/Cs$, $Ls$)

(linear differential operator $s(f) = \frac{d}{dx}f$)

(deletion/contraction,
``capacitor shorts out on high $s$, inductor opens on low $s$''
\cite{intuitAna})

(characterization of ``responses'' defined among port variables)

(?? Indicator of a step respone)

(asymptotic expansions as $s\rightarrow\infty$
and $s\rightarrow 0$)

\noindent\textbf{More and more}

(asymptotic behavior of a generating function's coefficients, which are
the generated function's values, determined by analytic properties of the
generated function.  Relate EE, circuits and signals literature to
statistical mechanics and combinatorics.
\cite{statMechForGraphers,multivarHalfPlane,AnalyticCombinatoricsBook})

(random generation: \cite{BoltzmanSampRandCombGen})

(geometry of phase shifts)

(risetime related to basic topology, graph theory, topology of lumped
networks expressed by oriented matroids)

(FUTURE hopefully not too much: Complex oriented matroids of Anderson, et.
al. \cite{complexOM})

\bibliography{../../bib/MathOfElec}{}
\bibliographystyle{plain}

\end{document}


% !TEX root = ../thesis.tex

\chapter{Conclusion and Future Work}
We investigated the possibility of evaporative cooling in a box potential which gets dynamically compressed over time. In a static box potential, efficient evaporative cooling is not easily possible due to decreasing densities. We studied an optical box potential made out of two ring beams where we reduce the ring diameter to compress the trap. A numerical simulation of the gas dynamics during evaporation was performed for $^{87}$Rb using different initial phase space densities, atom numbers and temperatures. We found that efficient evaporation is indeed possible in such a trap. However, one important requirement for this is a high initial phase space density as otherwise only a small fraction of the initial atoms can be captured.
One possibility to achieve such a high initial phase space density would be through several cycles of grey molasses cooling with compression stages in between. During grey molasses cooling, the gas can expand freely which is why its density decreases under normal conditions. In a box trap however, the trapping potential can remain active during the grey molasses, allowing for longer durations and therefore lower temperatures. Intermittent compression could then increase the phase space density even further to achieve the best possible starting conditions for evaporation.

A similar scheme could also be employed for other atomic species, e.g.\ $^{39}$K. Its broad Feshbach resonance can be used to control the scattering length \cite{k39Feshbach} and at similar scattering length, its lower mass would lead to higher elastic collision rates, theoretically increasing the evaporation efficiency.

In our simulated cases, we found that long evaporation times were necessary to achieve high phase space densities. This may partly be due to still poor optimisation.
Firstly, optimisation of the evaporation trajectories has to be done manually so far as the inherent statistical scatter of the numerical approach prevents non-linear optimisation strategies. Secondly, one simulation run can take between 7 and 10 minutes on a high-end desktop processor\footnote{AMD Ryzen 7 3700X} which makes brute-force optimisation difficult for a larger set of independent variables. This time constraint was one of the deciding reasons why only one ramp step was employed. It is expected that a subdivision in multiple steps could greatly benefit the evaporation by providing more finely grained control over the density.

Real experiments have also shown that the use of machine learning for optimisation can lead to drastic improvements both in atom numbers and evaporation times \cite{machinelearning1,machinelearning2}. It also brings the benefit that not a full search of the entire parameter space is necessary. It is thus possible that a better optimised evaporation trajectory could be developed by discretising the ramp into several steps and then using a machine learning procedure to find the best combination.

Lastly, we also want to give a brief outlook on how a beam like the one we used in the simulation can be created. Hueck et al.\ \cite{axiconSM} have demonstrated the creation of sharp ring shaped beams with variable diameter between \SI{50}{\micro\meter} and \SI{200}{\micro\meter} in 2017 by using multiple axicon \cite{McLeod} lenses; larger rings with a radius of \SI{400}{\micro\meter} are also possible \cite{MANEK199867}.
The setup designed by Hueck et al.\ is shown in \cref{fig:proposed_beam}.
\begin{figure}[bp]
    \centering
    \input{TexContents/Figures/Evap/AxiconSetup/AxiconSetupNew.tikz}
    \caption[Optical setup to create a ring beam with dynamically adjustable radius]{Not shown here is an additional microscope that demagnifies the beam from the image plane to the target plane. Adapted from \cite{axiconSM}.}
    \label{fig:proposed_beam}
\end{figure}
Here, the first axicon creates a ring shaped beam which is then optically inverted by the second axicon. This is done to shift the steep edge to the inner side. The third axicon collimates the beam and by moving it along the optical axis, different diameters can be achieved. After this, a high-resolution microscope can be used to demagnify the ring and project it onto the atomic cloud.
The use of a motorised translation stage would then provide precise dynamic control over the diameter.

An axicon ring could also be used in conjunction with a DMD to produce even steeper walls if the beam is not already diffraction limited. This would retain a larger intensity than the use of a DMD alone to shape a ring potential.

% \vspace{1ex}\noindent
% The simulation program is publicly available and can be used for future experiments with different potential geometries as well.
% Arbitrary potentials can be implemented through the use of a simple API, as long as they fulfill the requirement of axial symmetry in $x$ and $y$ direction for the doubling procedure.


\documentclass[amssymb,amsmath,aps,prl,twocolumn]{revtex4}
\usepackage{graphicx}
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage[up]{subfigure}

%\documentclass[prl,aps,twocolumn,preprintnumbers]{revtex4}
%\usepackage{amsfonts,amssymb,amsmath}            % for math symbols.
%\usepackage{graphics,graphicx,epsfig}            % for graphics figures.
%\usepackage{amsthm}                              % for theorem environments
%\usepackage{natbib}

\usepackage{gb4e} %added by ES

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title & Authors

\title{Dipole trap for $^{87}$Rb atoms using lasers of different wavelength}

%\date{\today}
%\date[]{November 22, 2004}
%\date[\bf DRAFT:\rm\ ]{1-Jan-04}

\author{C. M. \surname{Chandrashekar}}%
%\email{chandrashekar.madaiah@physics.ox.ac.uk}%

\affiliation{Atomic and Laser Physics,
             University of Oxford,
             Oxford OX1 3PU, UK}

\begin{abstract}

The parity of atomic wave functions prevents neutral atoms from having
permanent electric-dipole moment. Electric-dipole moment is induced in an
atom when exposed to strong light, the electric field of the light.
Hence the optical trapping of neutral atoms relies on the induced dipole
moment. Here we present the calculated numerical values of the detuning, potential depth, minimum laser power required to trap $^{87}$Rb ($D_2$ line) atoms using lasers of wavelength 1064 nm, 850 nm, 820 nm and 800 nm and beam waists 50$\mu$m, 100$\mu$m and 200$\mu$m.

\end{abstract}

\maketitle
%\preprint{Version}

\section{Introduction}

Trapping and storage of charged and neutral particles have laid pathways
for advancement in physics~\cite{chu}. Neutral atoms are trapped on the basis
of magnetic and optical interactions. Magnetic traps represent ideal conservative traps and arise from the state-dependent force on the permanent magnetic dipole moments in inhomogeneous field, restricting the experiments to only few special case. Optical dipole traps~\cite{grimm}, which is much weaker than other trapping mechanism rely on the electric dipole interaction with far-detuned light. Under appropriate conditions, the dipole trapping mechanism is independent of the particular sub-level of the electronic ground-state. The internal ground state can thus be fully exploited for experiments which is not possible in magnetic trapping mechanism.\\

\section{Frequency-detuning and potential depth for $^{87}Rb$ atoms}

Effective laser detuning $\Delta$ for alkali's can be calculated using,
\begin{equation}
\frac{1}{\Delta}=\left(\frac{1}{\Delta_{1}}+\frac{2}{\Delta_{2}}\right)
\end{equation}
\noindent where $ \Delta_{i} $ is detuning from $D_{i}$ line.\\

For an alkali-metal atom, the maximum potential depth is calculated
from~\cite{Cho},
\begin{equation}
U_{0}=\frac{\hbar\Gamma}{2}\frac{P\Gamma}{\pi W_{0}^{2}I_{0}\Delta}
\end{equation}
\noindent where $\Gamma=1/\tau$, is the natural linewidth and
$I_{0}$, the saturation intensity, given by,
\begin{equation}
I_{0}=\frac{\pi^{2}h c
\Gamma}{3\lambda^{3}}=\frac{\pi}{3}\frac{hc}{\lambda^{3}\tau}.
\end{equation}

The numerical value of saturation intensity $I_{0}$ for $D_{2}$ line
($|F=2, m_{F} = \pm2\rangle \rightarrow |F^{\prime}=3,
m_{F^{\prime}}=\pm 3 \rangle $) atomic transition of $^{87}$Rb
atoms is calculated to be 1.67 mW/cm$^{2}$=16.7 W/m$^{2}$ .

\section{Frequency-detuning and potential depth using lasers of different wavelength}

Below is the table with numerical values of detuning and potential
depth for dipole traps using laser lights of different
wavelength.\\

\begin{tabular}{|c|c|c|}
\hline
wavelength & Detuning & Potential Depth $U_{0}$ \\
$nm$       &  $\Delta$ &    $W/m^{2}$ \\
\hline
$1064$ & $-25\times10^{5}\Gamma$ & $1.53\times10^{-35}\frac{P}{W_{0}^{2}}$\\
$850$ & $-6.93\times10^{5}\Gamma$ & $5.5\times10^{-35}\frac{P}{W_{0}^{2}}$\\
$820$ & $-3.46\times10^{5}\Gamma$ & $11.04\times10^{-35}\frac{P}{W_{0}^{2}}$\\
$800$ & $-0.6\times10^{5}\Gamma$ & $63.66\times10^{-35}\frac{P}{W_{0}^{2}}$\\
\hline
\end{tabular}\\

Atoms in an intense laser field experience an ac start shift. This shift
creates a potential $U$ proportional to the light intensity, such that

\begin{equation}
U(r,z)=U_{0}\left[\frac{e^{\frac{-2r^{2}}{W(z)^{2}}}}
{1+(\frac{z}{z_{R}})^{2}}\right]
\end{equation}

\noindent at the focus of a Gaussian laser beam, with $r$ and $z$ being the radial and axial co-ordinates, $z_{R}=\frac{\pi W_{0}^{2}}{\lambda}$ is the Rayleigh
range \footnote{Distance at which the diameter of the spot size
increases by a factor of $\sqrt{2}$} at wavelength $\lambda$ and
beam waist $W_{0}$. $W(z)$ is the beam radius as a function of
axial position $z$ and is given by,

\begin{equation}
W(z)=W_{0}\sqrt{1+\left(\frac{z}{z_{R}}\right)^{2}}.
\end{equation}

\noindent For a beam in horizontal direction the overall potential
due to effect of gravity is given by,

\begin{equation}
U_{g}(r,z)= - mgr -
U_{0}\left[\frac{e^{\frac{-2r^{2}}{W(z)^{2}}}}{\left(1 +
\frac{z}{z_{R}}\right)^{2}}\right]
\label{pot}
\end{equation}

\section{Minimum power required to trap $^{87}Rb$ atoms at distance $z$ from
the focal point of the beam}

To calculate the minimum power required to trap $^{87}$Rb atoms at
distance $z$ from the focal point of the beam in the axial
direction, the above equation (Eq.~\ref{pot}) is differentiated,

\begin{equation}
\frac{d^{2}U}{dr^{2}}= -mg+\frac{4U_{0}r}{W(z)^{2}}\left[\frac{e^
{\frac{-2r^{2}}{W(z)^{2}}}}{1 + (\frac{z}{z_{R}})^{2}}\right]=0
\end{equation}

\begin{equation}
\Longrightarrow r =
\frac{mg}{4U_{0}}\frac{W(z)^{2}}{e^{\frac{-2r^{2}}{W(z)^{2}}}}
\left[1+\left(\frac{z} {z_{R}}\right)^{2}\right] \label{diffpot}
\end{equation}

By substituting the appropriate values for the above equation
(Eq.~\ref{diffpot}) one can calculate the minimum power required
to trap atoms at distance $z$ from the beam focus in the axial
direction. Below is the table with the calculated power required
to trap $^{87}$Rb atoms using laser light with different
wavelengths and beam waist, 50 $\mu m$,
100 $\mu m$ and 200 $\mu m$.\\

For light with beam waist, $W_{0}=50 \mu$m \\

\begin{tabular}{|c|c|c|c|}
\hline
Distance from focus & 1064 nm & 850 nm & 820 nm\\
\hline
$z=$ 5 cm & 3.33 W & 450 mW & 210 mW\\
$z=$ 2 cm & 30 mW & 37 mW & 26.5 mW\\
$z=$1 cm & 16 mW & 8.4 mW & 4 mW\\
$z=$ 0.5 cm & 11.6 mW & 3.8 mW & 1.5 mW\\
$z=$ 0 cm & 9 mW  & 2.7 mW & 1.4 mW\\
\hline
\end{tabular}\\
\\
\\
for $W_{0}=100 \mu$m \\

\begin{tabular}{|c|c|c|c|}
\hline
Distance from focus & 1064 nm & 850 nm & 820 nm\\
\hline
$z=$ 5cm & 610 mW & 110 mW & 47 mW\\
$z=$ 2cm & 140 mW & 31 mW & 15 mW\\
$z=$ 1cm & 91 mW & 23 mW & 12 mW\\
$z=$ 0.5cm & 78 mW & 22 mW & 11 mW\\
$z=$ 0cm & 77 mW  & 22 mW & 11 mW\\
\hline
\end{tabular}\\
\\
\\
for $W_{0}=200 \mu$m \\

\begin{tabular}{|c|c|c|c|}
\hline
Distance from focus & 1064nm & 850nm & 820nm\\
\hline
$z=$ 5cm & 1.53 W & 200 mW & 1.1 W\\
$z=$ 2cm & 650 mW & 180 mW & 900 mW\\
$z=$ 1cm & 610 mW & 180 mW & 900 mW\\
$z=$ 0.5cm & 600 mW & 180 mW & 900 mW\\
$z=$ 0cm & 600 mW  & 180 mW & 900 mW\\
\hline
\end{tabular}\\

The maximum photon scattering rate $\Gamma_{sc}$ is given by
\begin{equation}
\Gamma_{sc}=\frac{\Gamma}{\Delta}\frac{U_{0}}{\hbar}
\end{equation}

\begin{thebibliography}{99}
\bibitem{chu}S. Chu, J.E. Bjorkholm, A. Ashkin and A. Cable, Phys. Rev. Lett., {\bf 57}, 314, (1986)
\bibitem{grimm} R.Grimm, M. Weidermuller and Y.B. Ovchinnikov,
Advances in Atomic Molecular and Optical Physics, {\bf 42}, 95, (2000).
\bibitem{Cho} D. Cho, J. Korean Phys. Soc., {\bf 30}, 373, (1997).
\end{thebibliography}

\end{document}


\section{Equilibrium \& Comparative Statics}
\label{sec:section3}
\subsection{Stationary Equilibrium and Computation}\label{sec:section3.1}
Using the framework and results above, I now present a refined definition for stationary market equilibria:
\begin{definition}
    A Stationary Equilibrium (SE) is a triplet $(\mu^*, \omega^*, \Psi^*)$ such that:
    \begin{enumerate}
        \item $ \mu^*(\theta,b) \text{ attains } V_m(\theta,b),$ for all pairs $\theta, b \in \Theta \times \mathcal{B}_m$, given $\omega^*,\Psi^*$.
        \item $ \omega^*(\theta,b) \text{ attains } V_w(\theta,b),$ for all pairs $\theta, b \in \Theta \times \mathcal{B}_w$, given $\mu^*,\Psi^*$.
        \item $\Psi^*$ satisfies Equations \ref{eq:ss1}, \ref{eq:ss2}, and \ref{eq:ss3} given the strategy profile $(\mu^*, \omega^*)$.
    \end{enumerate}
\end{definition}

Intuitively, the above definition establishes two requirements that must be satisfied by an equilibrium market configuration.
Firstly, it must be the case that $\mu^*$ and $\omega^*$ are mutual best responses given the platform state $\Psi^*$ for which, as previously outlined, a necessary and sufficient condition would have them each solve the sex-specific MDP.
These two conditions alone demand \textit{partially rational expectations}, as per \cite{burdett1997marriage}, since they require agents to play optimally for some fixed steady state $\Psi^*$, imposing rationality on all game aspects other than the platform state dynamics.
Furthermore, in line with other works in mean-field game theory, a consistency check is imposed by the third condition, such that the platform state to which agents are best-responding with $(\mu^*,\omega^*)$ is sustained as a fixed point under that same strategy profile.

Although formal proofs for the existence and uniqueness of SE are outside the scope of this paper, I rely on numerical procedures\footnote{The code required to reproduce all presented analysis is accessible under the GitHub repository \texttt{patohdzs/project-swipe}, with most dependencies covered by the SciPy Stack packages.} to approximate equilibria under various exogenous settings.
This approach has been frequently employed by related works \citep[see][]{iyer2014mean, gummadi2011optimal} as it can help uncover insights provided by mean-field models.
To compute model equilibria, I frame the recurrence relation presented in \autoref{prop:recurrence relation}, as well as Equations \ref{eq:ss1}, \ref{eq:ss2}, and \ref{eq:ss3}, as a system of $2(|\mathcal{B}_m|+|\mathcal{B}_w|+1)$ non-linear equations, and solve this using a modified version of the hybrid Powell method, as implemented by the MINPACK 1 routine \citep{more1980user}.
In what follows, I present SE results for a number of comparative statics experiments.
For all of these, the exogenous settings used to calibrate the model are provided in \autoref{appx: c}, and convergence of numerical procedures was assured by computing the squared loss of the above system, which was exactly equal to zero in all cases (although the runtime required for convergence varied slightly across experiments).

\subsection{Best Response Analysis}\label{sec:section3.2}
Using the computational procedures outlined above, a number of insights can be uncovered related to how exogenous parameters affect an agent's optimal swiping behaviour.
The first parameter I analyse is the discount factor, which represents the probability of remaining inside the platform for an additional time period, but is often interpreted as the representative agent's patience level.
To determine the effects of changes in the discount factor, I computed the best-response policy over a range of different values for $\delta$ (using an arbitrary set of exogenous parameters), with results shown in \autoref{fig:discount-cs}.
Evidently, as the agent becomes less patient, they `lower their standards' for potential matches in the platform, shifting their swiping curve downwards.

\begin{figure}[ht]
    \centering
    \caption{Comparative Statics on the Discount Factor}
    \includegraphics{discount-cs.png}
    \label{fig:discount-cs}
\end{figure}

Another interesting parameter to examine is the absolute risk aversion of agents, which I choose to interpret as their `desperateness' for matching.
In the platform, risk-averse agents prefer a greater likelihood of matching (even if this yields relatively lower payoffs), whilst risk-loving agents prefer to save their swipes for high-yield candidates.
To perform comparative statics on this parameter, I fix a CARA utility function for agents, with parameter $r$ corresponding to the Arrow-Pratt coefficient for absolute risk aversion.
I then compute the optimal swiping rule for various different values of $r$, with results for this shown on \autoref{fig:risk-cs}.
From here, it is evident that as absolute risk aversion rises, agents become `more desperate' for matches, inducing them to lower their standards for right-swiping on a candidate, and thus shifting their swiping curve downwards.

\begin{figure}[ht]
    \centering
    \caption{Comparative Statics on Absolute Risk Aversion}
    \includegraphics{risk-cs.png}
    \label{fig:risk-cs}
\end{figure}

\subsection{Market Configuration Analysis}\label{sec:section3.3}
Finally, I perform comparative statics at the platform level to explore how different exogenous factors affect market configurations.
This is especially important as it considers not only the effects on best-responses for one sex, but also how these propagate across the market, ultimately affecting the other side's swiping behaviour as well.
More specifically, I focus on the aforementioned `Fast-Swiping Men' puzzle, investigating the discrepancies in swiping rates and matching outcomes between men and women.
There are a number of potential explanations for this behaviour, most of which concern sex-specific differential preferences which are compatible with my model.
Indeed, it is reported that women spend around 20\% more time then men on a single Tinder session \citep{web:nytimes_patience}, potentially indicating a higher level of patience which would induce `higher standards' and a lower swiping rate, as explained above.
Departing from these, I consider below a scenario that could explain the `Fast-Swiping Men' puzzle purely as a result of tightness-induced search frictions, for which I analyse the market SE computed under a 6:1 ratio between exogenous arrival rates $\lambda_m$ and $\lambda_w$.
This ratio was calibrated such that the steady state mass of men in the platform is around ten times greater than that of women, in line with demographic estimates for the UK \citep{web:tinder_stats}, and results for such SE are shown in \autoref{fig:mkt-cs}.

\begin{figure}[ht]
    \centering
    \caption{Market Configuration Under Differential Agent Inflows}
    \includegraphics{mkt-cs.png}
    \label{fig:mkt-cs}
\end{figure}

Under the above scenario, men overcrowd the market and struggle to get paired with female candidates, as evidenced by the top-center plot in \autoref{fig:mkt-cs} which shows that male agents are highly concentrated in the top budget levels.
Due to the effect of market tightness on the effective discount rate, male agents become more impatient than women, and this shock is absorbed by their optimal swiping policy, which sits considerably lower than the female swiping curve, effectively showing how a tight market lowers male patience and by extension, their standards, leading them to swipe right on most women.
Ultimately, this explains the `Fast-Swiping Men' puzzle given that, under this particular SE, men swipe right with probability $\overline\mu=0.988$, compared to $\overline\omega=0.491$ for women, thus replicating the observed phenomenon.

One potential intervention to correct this phenomenon would involve relaxing the swiping cap for the shorter side of the market.
To analyse such measure, the SE was computed under the same conditions as above but with a 4:1 swiping cap ratio between women and men; the results for this, shown in \autoref{fig:mkt-cs-bdiff}, indicate the presence of two separate effects that would help alleviate the above scenario.
First, a larger budget set would allow women to stay in the platform for longer by shrinking the number of endogenous departures to zero (at the limit), thus leading to a larger steady state mass of female agents that would reduce market tightness for men.
This is corroborated by the computed results, which show a 6:1 ratio between the male and female agent masses, down from 10:1.
Furthermore, because optimal reservation values are decreasing in the agent's budget, women in the top budget levels can now swipe right at considerably lower thresholds, thus improving matching outcomes for men.
This is highlighted in \autoref{fig:mkt-cs-bdiff}, which shows that female swiping policy quickly descends to a level comparable to its male counterpart since it is allowed to extend over a larger budget set.
Furthermore, under this particular SE, men swipe right with probability $\overline\mu=0.906$, compared to $\overline\omega=0.79$ for women, therefore highlighting the effectiveness of this intervention, which could be of considerable importance given both its simplicity and its potential impact on user experience, as research by \cite{kanoria2021facilitating} identifies asymmetric selectiveness as a profound source of inefficiency in dynamic matching platforms.
\begin{figure}[ht]
    \centering
    \caption{Market Configuration Under Differential Swiping Caps}
    \includegraphics{mkt-cs-bdiff.png}
    \label{fig:mkt-cs-bdiff}
\end{figure}
One potential drawback of this intervention is that general selectiveness falls in the market, since the effect prompting women to swipe more is of greater magnitude than the one prompting men to swipe less.
This could be easily avoided by lowering the swiping cap for men, instead of raising the cap for women, to achieve the desired counterbalancing ratio, but such intervention would be inevitably bounded as the swiping cap for men approaches zero.


\subsection{Dropout, and dropout layers}


\subsection{Calculus of variations}


% chktex-file 1
% chktex-file 26
% chktex-file 35
\documentclass[11pt]{article}
\usepackage[ligature,reserved]{semantic}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[dvipsnames]{xcolor}
\usepackage{hyperref}
\usepackage{hyphenat}
\usepackage{amsfonts}
\usepackage{amsmath} \allowdisplaybreaks
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[margin=1.25in,letterpaper]{geometry}
\usepackage{mathtools}
\usepackage{mathpartir}
\usepackage{scalerel}
\usepackage{stackengine}

\usepackage[
    backend=biber,
    style=apa,
]{biblatex}

\addbibresource{biblio.bib}

\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan,
    citecolor=Green,
    pdfpagemode=FullScreen,
}

% thanks goes to einargs for creating this setup (BNF, \typerule, \typeaxiom)
% (rest is my hacky LaTeX)
% Syntax group
\newcommand{\syng}[2]{#1 \bnf& & \text{#2} \\}
% Line in a syntax group
\newcommand{\syn}[2]{& #1 & \text{#2} \\}
\newcommand{\bnf}{\mathrel{::=}\;}

\newcommand{\tchk}{\Leftarrow}
\newcommand{\tsyn}{\Rightarrow}
\newcommand{\rarr}{\rightarrow}

% found on tex.SE, tortured into compliance
\newlength\arrowheight
\newcommand\doubleRightarrow{
  \mathrel{\ThisStyle{
    \setlength{\arrowheight}{\heightof{$\SavedStyle\Downarrow$}}
    \scalerel*{\rotatebox{90}{\stackengine{.5\arrowheight}{$\SavedStyle\Downarrow$}
      {$\SavedStyle\Downarrow$}{O}{c}{F}{F}{L}}}{\rotatebox[origin=c]{90}{$\Downarrow$}}}
}}

% function & applicand type notation
% stolen from Dunfield 2013
\newcommand{\tapp}[3]{
    #1 \bullet #2 \doubleRightarrow #3
}

\newcommand{\alphahat}{\hat{\alpha}}
\newcommand{\betahat}{\hat{\beta}}

\newcommand{\tprod}[1]{\{#1\}}
\newcommand{\tsum}[1]{\langle#1\rangle}
\newcommand{\ttauibar}{\overline{\tau_i}}
\newcommand{\tall}[3]{\forall (#1 :: #2).#3}
\newcommand{\tlam}[3]{\lambda (#1 :: #2).#3}

\newcommand{\eeibar}{\overline{e_i}}
\newcommand{\ecase}[2]{\<case>\ #1\ \<of>\ #2}

\newcommand{\Nf}{^{\textsf{Nf}}}
\newcommand{\Ne}{^{\textsf{Ne}}}

\newcommand{\typerule}[3]{
    \inferrule{#2}{#3}\quad(\textsf{#1})
}

\newcommand{\typeaxiom}[2]{
    \inferrule{ }{#2}\quad(\textsf{#1})
}

\reservestyle{\literal}{\texttt}
\reservestyle{\keyword}{\textbf}
\literal{true, false, bool, int, cond, fix, mod, and, or, not, project, embed, eq, neq}
\keyword{case, of}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}

\title{Tethys\\
    \large A Toy Functional Programming Language\\
    with a System F$\omega$-based Core Calculus\\
    \url{https://github.com/ThePuzzlemaker/tethys}}
\author{James [Redacted] (aka ThePuzzlemaker)}
\date{\today}

\begin{document}

\maketitle

\tableofcontents
\newpage

\section{Introduction}

This ``paper'' (which is really just a well-typeset, but somewhat informal
    write-up) introduces Tethys, a toy functional programming language based on
    a System F$\omega$-based core calculus. Hence the title.

There are two parts of Tethys: the surface language, and the core calculus. The
    core calculus is the intermediate representation of Tethys which is used
    for type checking and inference, and for interpretation. The surface
    language is the higher-level interface that is eventually desugared by the
    compiler/interpreter to the core calculus.

The reference implementation in Rust will not use any particular ``tricks'' in
    terms of interpretation, instead just using a simple tree-walk interpreter
    or similar.

This language was created in order to conduct informal research (i.e., not
    actually discovering anything interesting, probably) on type systems,
    especially bidirectional typechecking and polymorphism. Tethys is named as
    such as it is the name of the co-orbital moon to Calypso; as my work on
    this language is ``co-orbital'', so to speak, to my work on
    \href{https://calypso-lang.github.io}{Calypso}.

Please note that I am not an expert in pretty much any subject this writeup
    covers. If you notice something you don't understand, or that you think is
    a mistake, don't fret to point it out.

\subsection{Background}

\begin{quote}
    Note: This section is taken from
        \href{https://thepuzzlemaker.info/static/tethys-slides/}{some slides I
        prepared for a lightning talk} in the
        \href{https://discord.gg/26X6ChQQcG}{r/PL Discord server}. If it seems
        a bit un-prose-y, that's why.
\end{quote}

Originally, I thought I needed to use System F$\omega$, an extension of the
    polymorphic typed lambda calculus (System F), with the extension of type
    lambdas. However, it has some problems:

\begin{itemize}
    \item System F is already undecidable enough, with respect to inference.
        Adding \emph{more} types of types does \textbf{not} help.
    \item Theoretically, bidirectional typechecking (my chosen strategy)
        doesn't \emph{need} unification, but it sure makes it nice. And having
        type lambdas means you need higher order unfication, which is scary
        because anything including ``higher-order'' in its name is automatically
        scary. Also it's undecidable, so you have to restrict yourself to
        higher-order pattern unification, which is still quite scary.
    \item I just can't really find much good introductory literature on
        System F$\omega$ (at least, literature that I can understand).
\end{itemize}

As it turns out, System F$\omega$ is more expressive than F, but \textbf{way}
    much more of a pain. Not even Haskell, the paragon of kitchen sink type
    system features has it. (By default, because of course GHC's gonna have it
    as an extension).

Here are some of the key theoretical differences:

\begin{itemize}
    \item Within the type system, type constructors are opaque. Defining a type
        just creates opaque term-level and type-level constants, which don't
        normalize to the type or term they ``really'' mean. Of course, these
        are stripped out after typechecking, once they're no longer needed.
    \item Type constructors are injective, i.e. for some type constructor $C$
        and types $X$ and $Y$, if $C\;X$ and $C\;Y$ are the same type, then $X$
        and $Y$ are the same type.
    \item Differently named type constructors are never equal, even if they
        ``mean'' the same thing, i.e. for some type constructors $C1$ and $C2$,
        and type $T$, $C1\;T$ never equals $C2\;T$, no matter how they are
        defined.
\end{itemize}

Note that this is pretty much nominal typing! (If my understanding of nominal
    typing is correct.)

\section{The Surface Language}

This section has not been started yet.

\section{The Declarative Core Calculus}

This section is, unsurprisingly, work-in-progress.

\section{References}

\subsection{Acknowledements}

Thanks to Brendan Zabarauskas and András Kovács, who have helped with many type
    system details. Many thanks to Mark Barbone (aka MBones/mb64), who provided
    a code sample of their bidirectionally typed (with unification) algorithm
    for typechecking higher-rank System F (\cite{tychk-nbe}), and who also
    noted some issues they had with \citetitle{Dunfield13:bidir}
    (\cite{Dunfield13:bidir}).

\subsection{References}

\nocite{*}

\printbibliography[heading=none]

\end{document}