\section{Introduction}

While the first traffic signals were controlled completely in open loop, various approaches have been taken to adjust the green light allocation based on the current traffic situation. To mention a few, SCOOT~\cite{robertson1991optimizing}, UTOPIA~\cite{mauro1990utopia} and SCATS~\cite{sims1980sydney}. Also, learning based approaches have been taken, e.g.,~\cite{JIN20175301}.

However, these approaches lack of formal stability, optimality, and robustness guarantees. In~\cite{nilsson2015entropy, nilsson2017generalized}, a decentralized feedback controller for traffic control was proposed, refereed to as Generalized Proportional Allocation (GPA) controller, which has both stability and maximal throughput guarantees. In those papers, an average control action for traffic signals in continuous time is given.  Since the controller has several desired properties, it is motivated to investigate if this controller performs well in a micro-simulator with more realistic traffic dynamics. First of all, under the assumptions that the controller can measure the whole queue lengths at each junction, the averaged controller is throughput optimal from a theoretical perspective. With this, we mean that when the traffic dynamics is modeled as a simple system of point queues there exists no controller that can handle larger constant exogenous inflows to a network than this controller. This property of throughput-optimality also means that there are formal guarantees that the controller will not create gridlock situations in the network. As exemplified in~\cite{varaiya2013max}, feedback controllers that perform well for a single isolated junction may cause gridlock situations in a network setting.

At the same time, this controller requires very little information about the network topology and the traffic flow propagation. All information the controller needs to determine the phase activation in a junction is the queue lengths on the incoming lanes to a junction and the static set of phases.  Those requirements on information make the controller fully distributed, i.e., to compute the control action in one junction, no information is required about the state in the other junctions.

The proposed traffic signal controller also has the property that it adjusts the cycle lengths depending on the demand. The fact that during higher demands, the cycle lengths should be longer to waste less service time due to phase shifts, has been suggested previously for open loop traffic signal control, see e..g~\cite{roess2011traffic}.

Another feedback control strategy for traffic signal control is the MaxPressure controller~\cite{Varaiya:13, varaiya2013max}. The MaxPressure controller utilizes the same idea as the BackPressure controller, proposed for communication networks in~\cite{tassiulas1992stability}. While the BackPressure controller controls both the routing (to which packets the should proceed after received service)  and the scheduling (which subset of queues that should be severed), the MaxPressure controller only controls the latter, i.e., the phase activation but not the routing. More recently, due to the rapid development of autonomous vehicles, it has been proposed in~\cite{zaidi2018backpressure} to utilize the routing control from the BackPressure controller in traffic networks as well. The MaxPressure controller is also throughput optimal, but it requires information about the tuning ratios at each junction, i.e., how the vehicles (in average) propagate from one junction to the neighboring junctions. Although various techniques for estimating those turning ratios have been made, for example~\cite{coogan2017traffic}, with more and more drivers or autonomous vehicles doing their path planning through some routing service, it is likely to believe that the turning ratios can change in an unpredictable way when a disturbance occurs in the traffic network.

If the traffic signal controller has information about the turning ratios, other control strategies are possible as well, for instance, MPC-like as proposed in~\cite{hao2018modelI, hao2018modelII, grandinetti2018distributed} and robust control as proposed in~\cite{bianchin2018network}.

In~\cite{nilsson2018} we presented the first discretization and validation results of the GPA in a microscopic traffic simulator. Although, the results were promising, the validations were only performed on an artificial network and only compared with a fixed timed traffic signal controller. Moreover, the GPA was only discretized in a way such that the full cycle is activated. In this paper, we extend the results in~\cite{nilsson2018} by showing another discretization that does not have to utilize the full cycle and we also perform new validations. The new validations both compare the GPA to the MaxPressure controller on an artificial network (the reason for chosen a artificial network will be explained later), but also validate the GPA controller in a realistic scenario, namely for the Luxembourg city during a whole day.

The outline of the paper is as follows: In Section~\ref{sec:problem} we present the model we are using for traffic signals, together with a problem formulation of the traffic signal control problem. In Section~\ref{sec:controllers} we present two different discretization of the GPA that we are using in this study, but also give a brief description of the MaxPressure controller. In Section~\ref{sec:comparision} we compare the GPA controller with the MaxPressure controller on an artificial Manhattan-like grid, and in Section~\ref{sec:lust} we investigate how the GPA controller performs in a realistic traffic scenario. The paper is concluded with some ideas about further research.

\subsection{Notation}
We let $\mathbb{R}_+$ denote the non-negative reals. For a finite sets $\mathcal A, \mathcal B$, we let $\mathbb{R}_+^{\mathcal A}$ denote non-negative vectors indexed by the elements in $\mathcal A$, and $\mathbb{R}_+^{\mathcal A \times \mathcal B}$ the matrices indexed by elements $\mathcal A$ and $\mathcal B$.

\section{Model and Problem Formulation}\label{sec:problem}
In this section, we describe the model for traffic signals to be used throughout the paper together with the associated control problem.

We consider an arterial traffic network with signalized junctions. Let $\mathcal J$ denote the set of signalized junctions. For a junction $j \in \mathcal J$, we let $\mathcal L^{(j)}$ be the set of incoming lanes, on which the vehicles can queue up. The set of all signalized lanes in the whole network will be denoted by $\mathcal L = \cup_{j \in \mathcal J} \mathcal L^{(j)}$. For a lane $l \in \mathcal L^{(j)}$, the queue-length at time $t$ --measured in the number of vehicles--  is denoted by $x_l(t)$.

Each junction has a predefined set of \emph{phases} $\mathcal P^{(j)}$ of size $n_{p_j}$. For simplicity, we assume that phases $p_i \in \mathcal P^{(j)}$ are indexed by $i = 1, \ldots, n_{p_j}$. A phase  $p \in \mathcal P^{(j)}$ is a subset of incoming lanes to the junction $j$ that can receive green light simultaneously. Throughout the paper, we will assume that for each lane $l \in \mathcal L$, there exists only one junction $j \in \mathcal J$ and at least one phase $p \in \mathcal P^{(j)}$ such that $l \in p$.

The phases are usually constructed such that the vehicles paths in a junction do not cross each other. This to avoid collisions.
Examples of this will be shown later in this paper. After a phase has been activated, it is common to signalize to the drivers that the traffic signal is turning red and give time for vehicles that are in the middle of the junction to leave it before the next phase are activated. Such time is usually referred to as clearance time. Throughout the paper we shall refer to those phases only containing red and yellow traffic light as \emph{clearance phases} (in contrast to phases, that models when lanes receives green traffic light). We will assume that each phase activation is followed by a clearance phase activation. While we will let the phase activation time vary, we will make the quite natural assumption that the clearance phases has to be activated for a fixed time.

For a given junction $j \in \mathcal J$, the set of phases can be described through a phase matrix $P^{(j)}$, where
$$P_{il}=\left\{\begin{array}{lcl}1&\text{ if }&\text{lane }l\text{ belongs to the }i\text{-th phase}\\ 0&\text{ if }&\text{otherwise\,.}\end{array}\right.$$

While the phase matrix does not contain the clearance phases, to each phase $p \in \mathcal P^{(j)}$ we will associate a clearance phase, denoted $p'$. We denote the set of real phases and their corresponding clearance phases $\bar{\mathcal P}^{(j)}$.

The controller's task in a signalized junction is to define a \emph{signal program}, $\mathcal T^{(j)} = \{ (p, t_\text{end} ) \in  \bar{\mathcal P}^{(j)} \times  \mathbb{R}_+  \}$, where the phase $p$ is activated until $t_\text{end}$. When $t = t_\text{end}$, the phase $p'$, where $(p', t_\text{end}) \in \mathcal T^{(j)}$, with smallest $t_\text{end} > t$ is activated. Formally, we can define the function $c^{(j)}(t)$ that gives the phase that is activated at time $t$ as follows
\begin{align*}
c^{(j)} (t) =  \{ & p : (p, t_\text{end}) \in { \mathcal T}^{(j)}  \mid \\ &  t_\text{end} > t \text{ and }  t_\text{end} \leq t'_\text{end} \textrm{ for all } (p', t'_\text{end}) \in   { \mathcal T}^{(j)}  \} \, .
\end{align*}
What $c^{(j)} (t)$ is doing is to find the phase with the smallest end-time greater than the current time.

\medskip
\begin{example} \label{ex:phasesandprogram}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{scope}[scale=0.5]
\draw[thick] (-3, 1) -- (-1, 1) -- (-1,3);
\draw[thick] (-3, -1) -- (-1, -1) -- (-1, -3);
\draw[thick] (1,3) -- (1,1) -- (3,1);
\draw[thick] (1, -3) -- (1,-1) -- (3, -1);

\draw [->, thick] (-1, -0.5) to [bend right] (0.3, 1);
\draw [->, thick] (-1, -0.5) to (1, -0.5);
\draw [->, thick] (-1, -0.5) to [bend left] (-0.7, -1);

\draw [->, thick] (1, 0.5) to [bend left] (0.7, 1);
\draw [->, thick] (1, 0.5) to (-1, 0.5);
\draw [->, thick] (1, 0.5) to [bend right] (-0.3, -1);

\node (l1) at (-1.5, -0.5) {$l_1$};
\node (l2) at (0.5, -1.5) {$l_2$};
\node (l3) at (1.5, 0.5) {$l_3$};
\node (l4) at (-0.5, 1.5) {$l_4$};
\end{scope}

\begin{scope}[scale=0.5, shift={(7, 0)}]
\begin{scope}[rotate=90]
\draw[thick] (-3, 1) -- (-1, 1) -- (-1,3);
\draw[thick] (-3, -1) -- (-1, -1) -- (-1, -3);
\draw[thick] (1,3) -- (1,1) -- (3,1);
\draw[thick] (1, -3) -- (1,-1) -- (3, -1);

\draw [->, thick] (-1, -0.5) to [bend right] (0.3, 1);
\draw [->, thick] (-1, -0.5) to (1, -0.5);
\draw [->, thick] (-1, -0.5) to [bend left] (-0.7, -1);

\draw [->, thick] (1, 0.5) to [bend left] (0.7, 1);
\draw [->, thick] (1, 0.5) to (-1, 0.5);
\draw [->, thick] (1, 0.5) to [bend right] (-0.3, -1);
\draw[dashed] (0, 3) -- (0,1);
\draw[dashed] (-3, 0) -- (-1, 0);
\draw[dashed] (0, -1) -- (0, -3);
\draw[dashed] (3, 0) -- (1, 0);
\end{scope}
\node (l1) at (-1.5, -0.5) {$l_1$};
\node (l2) at (0.5, -1.5) {$l_2$};
\node (l3) at (1.5, 0.5) {$l_3$};
\node (l4) at (-0.5, 1.5) {$l_4$};
\end{scope}

\begin{scope}[scale=0.5]
\draw[dashed] (0, 3) -- (0,1);
\draw[dashed] (-3, 0) -- (-1, 0);
\draw[dashed] (0, -1) -- (0, -3);
\draw[dashed] (3, 0) -- (1, 0);
\end{scope}
\end{tikzpicture}
\caption{The phases for the junction in Example~\ref{ex:phasesandprogram}. This junction has four incoming lanes and two phases, $p_1 = \{l_1, l_3\}$ and $p_2 = \{l_2, l_4\}$. Hence there is no specific lane left-turning left.}
\label{fig:phasesexamplejunc}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1.2]
\draw[->] (0, 0) -- (6.5, 0) node[right] {$t$};

\draw[-] (0, 0.1) -- (0, -0.1) node[below] {$0$} ;
\draw[-] (2.5, 0.1) -- (2.5, -0.1) node[below] {$25$} ;
\draw[-] (3, 0.1) -- (3, -0.1) node[below] {$30$} ;
\draw[-] (5.5, 0.1) -- (5.5, -0.1) node[below] {$55$} ;
\draw[-] (6, 0.1) -- (6, -0.1) node[below] {$60$};

\node (c) at (0, 0.4) {$c(t)$};
\node (p1) at (1.25, 0.4) {$p_1$};
\node (p1p) at (2.75, 0.4) {$ p_1'$};
\node (p2) at (4.25, 0.4) {$p_2$};
\node (p2p) at (5.75, 0.4) {$ p_2'$};

\begin{scope}[scale=0.20, shift={(6, 8)}]
\draw[thick] (-3, 1) -- (-1, 1) -- (-1,3);
\draw[thick] (-3, -1) -- (-1, -1) -- (-1, -3);
\draw[thick] (1,3) -- (1,1) -- (3,1);
\draw[thick] (1, -3) -- (1,-1) -- (3, -1);

\fill[mygreen] (-1, -1) -- (-1.4, -1) -- (-1.4, 0) -- (-1, 0) -- cycle;
\fill[mygreen] (1, 1) -- (1.4, 1) -- (1.4, 0) -- (1, 0) -- cycle;
\fill[myred] (1, -1) -- (1, -1.4) -- (0, -1.4) -- (0, -1) -- cycle;
\fill[myred] (-1, 1) -- (-1,1.4) -- (0, 1.4) -- (0, 1) -- cycle;
\end{scope}

\begin{scope}[scale=0.20, shift={(13.75, 8)}]
\draw[thick] (-3, 1) -- (-1, 1) -- (-1,3);
\draw[thick] (-3, -1) -- (-1, -1) -- (-1, -3);
\draw[thick] (1,3) -- (1,1) -- (3,1);
\draw[thick] (1, -3) -- (1,-1) -- (3, -1);

\fill[myyellow] (-1, -1) -- (-1.4, -1) -- (-1.4, 0) -- (-1, 0) -- cycle;
\fill[myyellow] (1, 1) -- (1.4, 1) -- (1.4, 0) -- (1, 0) -- cycle;
\fill[myred] (1, -1) -- (1, -1.4) -- (0, -1.4) -- (0, -1) -- cycle;
\fill[myred] (-1, 1) -- (-1,1.4) -- (0, 1.4) -- (0, 1) -- cycle;
\end{scope}

\begin{scope}[scale=0.20, shift={(21.25, 8)}]
\draw[thick] (-3, 1) -- (-1, 1) -- (-1,3);
\draw[thick] (-3, -1) -- (-1, -1) -- (-1, -3);
\draw[thick] (1,3) -- (1,1) -- (3,1);
\draw[thick] (1, -3) -- (1,-1) -- (3, -1);

\fill[myred] (-1, -1) -- (-1.4, -1) -- (-1.4, 0) -- (-1, 0) -- cycle;
\fill[myred] (1, 1) -- (1.4, 1) -- (1.4, 0) -- (1, 0) -- cycle;
\fill[mygreen] (1, -1) -- (1, -1.4) -- (0, -1.4) -- (0, -1) -- cycle;
\fill[mygreen] (-1, 1) -- (-1,1.4) -- (0, 1.4) -- (0, 1) -- cycle;
\end{scope}

\begin{scope}[scale=0.20, shift={(28.75, 8)}]
\draw[thick] (-3, 1) -- (-1, 1) -- (-1,3);
\draw[thick] (-3, -1) -- (-1, -1) -- (-1, -3);
\draw[thick] (1,3) -- (1,1) -- (3,1);
\draw[thick] (1, -3) -- (1,-1) -- (3, -1);

\fill[myred] (-1, -1) -- (-1.4, -1) -- (-1.4, 0) -- (-1, 0) -- cycle;
\fill[myred] (1, 1) -- (1.4, 1) -- (1.4, 0) -- (1, 0) -- cycle;
\fill[myyellow] (1, -1) -- (1, -1.4) -- (0, -1.4) -- (0, -1) -- cycle;
\fill[myyellow] (-1, 1) -- (-1,1.4) -- (0, 1.4) -- (0, 1) -- cycle;
\end{scope}

\begin{scope}[scale=0.20, shift={(6, 8)}]
\draw[dashed] (0, 3) -- (0,1);
\draw[dashed] (-3, 0) -- (-1, 0);
\draw[dashed] (0, -1) -- (0, -3);
\draw[dashed] (3, 0) -- (1, 0);
\end{scope}

\begin{scope}[scale=0.20, shift={(13.75, 8)}]
\draw[dashed] (0, 3) -- (0,1);
\draw[dashed] (-3, 0) -- (-1, 0);
\draw[dashed] (0, -1) -- (0, -3);
\draw[dashed] (3, 0) -- (1, 0);
\end{scope}

\begin{scope}[scale=0.20, shift={(21.25, 8)}]
\draw[dashed] (0, 3) -- (0,1);
\draw[dashed] (-3, 0) -- (-1, 0);
\draw[dashed] (0, -1) -- (0, -3);
\draw[dashed] (3, 0) -- (1, 0);
\end{scope}

\begin{scope}[scale=0.20, shift={(28.75, 8)}]
\draw[dashed] (0, 3) -- (0,1);
\draw[dashed] (-3, 0) -- (-1, 0);
\draw[dashed] (0, -1) -- (0, -3);
\draw[dashed] (3, 0) -- (1, 0);
\end{scope}

\end{tikzpicture}
\caption{Example of a signal program for the junction in Example~\ref{ex:phasesandprogram}. In this example the signal program is $\mathcal T = \{ (p_1, 25), (p_1', 30), (p_2, 55), (p_2', 60)\}$.}
\label{fig:signaltiming}
\end{figure}
Consider the junction in Fig.~\ref{fig:phasesexamplejunc} with the incoming lanes numbered as in the figure. In this case the drivers turning left have to solve the collision avoidance by themselves. The phase matrix is
$$P = \begin{bmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1  \end{bmatrix} \, .$$

An example of signal program is shown in Fig.~\ref{fig:signaltiming}. Here the program is $\mathcal T = \{ (p_1, 25), (p_1', 30), (p_2, 55), (p_2', 60)\}$. which means that both the phases are activated for $25$ seconds each, and the clearance phases are activated for $5$ seconds each.
\end{example}
\medskip

Moreover, we let
$$T^{(j)} = \max\{t_\text{end}  \mid (p, t_\text{end}) \in {\mathcal P}^{(j)} \}$$
denote the time when the signal program for junction $j$ ends, and hence a new signal timing program has to be determined.

\section{Feedback Controllers}\label{sec:controllers}
In this section, we present three different traffic signal controllers that all determine the signal program. The first two are discretization of the GPA controller, where the first one makes sure that all the clearance phase are activated during one cycle, and the second one only activates the clearance phases if their corresponding phase has been activated. The third controller is the MaxPressure controller.

All the three controllers are feedback-based, i.e., when one signal program has reached its end, the current queue lengths are used to determine the upcoming signal program. Moreover, the GPA controllers are fully distributed, in the sense that to determine the signal program in one junction, the controller only needs information about the queue-lengths on the incoming lanes for that junction. The MaxPressure controller is also distributed in the sense that it does not requires network wide information, but it requires queue length information from the neighboring junctions as well.

For all of the controller presented in this section, we assume for simplicity of the presentation that after a phase has been activated, a clearance phase has to be activated for a fixed amount of time $T_w > 0$, that is independent of which phase that has just been activated.

\subsection{GPA with Full Clearance Cycles} \label{sec:GPAfull}
For this controller, we assume that all the clearance phases have to be activated for each cycle. When $t = T^{(j)}$, a new signal program is computed by solving the following convex optimization problem:
\begin{equation}\label{eq:gpa}
\begin{aligned}
\optmax{\begin{matrix} \hspace{0.2em} \nu\in\mathbb{R}_+^{n_{p_j}} \\  w\in\mathbb{R}_+ \end{matrix}} &  \sum_{l \in \mathcal L^{(j)}} x_l(t) \log\left( (P^T\nu)_l \right) + \kappa \log(w)  \, , \\
\text{subject to}\quad &  \sum_{1 \leq i \leq n_{p_j}} \nu_i + w = 1 \,, \\
&  w \geq \bar{w} \, .
\end{aligned}
\end{equation}
In the optimization problem above, $\kappa > 0$ and $\bar{w} \geq 0$ are tuning parameters for the controller, and their interpretation will be discussed later.

The vector $\nu$ in the solution of the optimization problem above, determines the fraction of the cycle time that each phase should be activated, where each element in $\nu$ contains this fraction. The variable $w$ tells how large fraction of the cycle time that should be allocated to the clearance phases. Observe that as long as the queue lengths are finite $w$ will be strictly greater than zero. Since we assume that each clearance phase has to be activated for a fixed amount of time, $T_w > 0$, the total cycle length $T_\text{cyc}$ for the upcoming cycle can be computed by
$$T_\text{cyc} = \frac{n_{p_j} T_w}{w} \, .$$
With the knowledge of the full-cycle length, the signal program for the upcoming cycle can be computed according to Algorithm~\ref{algo:gpafull}.

Although the optimization problem can be solved in real-time using convex solvers, the optimization problem can also be solved analytically in the spacial cases. One such case is when the phases are orthogonal, i.e., every incoming lane only belongs to one phase. If the phases are orthogonal, then $P^T \mathbbm{1} = \mathbbm{1}$. In the case of orthogonal phases and $\bar{w} = 0$, the solution to the optimization problem in~\eqref{eq:gpa} is given by

\begin{equation} \label{eq:gpaorthogonal}
\begin{aligned}
 \nu_i (x(t)) &= \frac{\sum_{l \in \mathcal L^{(j)}}P_{il}x_l(t)}{\kappa+\sum_{l \in \mathcal L^{(j)}} x_l(t)}\,,\qquad i=1,\ldots,n_{p_j}\,,  \\
 w(x(t)) &= \frac{\kappa}{\kappa+\sum_{l \in \mathcal L^{(j)}} x_l(t)} \,.
 \end{aligned}
\end{equation}
From the expression of $w$ above, a direct expression for the total cycle length can be obtained
\begin{equation*}
\displaystyle T_\text{cyc} = T_w n_{p_j} +\frac{T_w n_{p_j}}{\kappa}{\sum_{l \in \mathcal L^{(j)}} x_l(t)} \, .\label{eq:cycletime}
\end{equation*}

From the expressions above we can observe a few things. First, we see that the fraction of the cycle that each phase is activated is proportional to the queue lengths in that phase, and this explains why we done this control strategy generalized proportional allocation. Moreover, we get an interpretation of the tuning parameter $\kappa$, it tells how the cycle length $T_\text{cyc}$ should scale with the current queue lengths. If $\kappa$ is small, even small queue lengths will cause longer cycles, while if $\kappa$ is large the cycles will be short even for large queues. Hence, a too small $\kappa$ may give too long cycles, which can result in that lanes get more green-light than needed and the controller ends up giving green light to empty lanes, while vehicles in other lanes are waiting for service. On the other hand, a too large $\kappa$ may make the cycle lengths so short, so that the fraction of the cycle that each phase gets activated is too short for the drivers to react on.

\begin{figure}[!t]
\let\@latex@error\@gobble
\begin{algorithm}[H]
\caption{GPA with Full Clearance Cycles}\label{algo:gpafull}
\DontPrintSemicolon
\KwData{Current time $t$, local queue lengths $x^{(j)}(t)$, phase matrix $P^{(j)}$, clearance time $T_w$, tuning parameters $\kappa, \bar w$}
\KwResult{Signal program $\mathcal T^{(j)}$}
   $\mathcal T^{(j)} \leftarrow \emptyset$ \;
   $n_{p_j} \leftarrow $ Number of rows in $P^{(j)}$ \;
   $(\nu, w)$ $\leftarrow$ Solution to~\eqref{eq:gpa} given $x^{(j)}(t), P^{(j)}, \kappa, \bar w$\;
   $T_\text{cyc} \leftarrow n_p \cdot T_w / w$ \;
   $t_\text{end} \leftarrow t$ \;
  \For{$i\leftarrow 1$ \KwTo $n_{p_j}$}{
     	$t_\text{end} \leftarrow t_\text{end} + \nu_i \cdot T_\text{cyc}$ \;
	$\mathcal T^{(j)} \leftarrow \mathcal T^{(j)} + (p_i, t_\text{end})$  \Comment*[r]{Add phase $p_i$}
	$t_\text{end} \leftarrow t_\text{end} + T_w$ \;
         $\mathcal T^{(j)} \leftarrow \mathcal T^{(j)} + (p'_i, t_\text{end})$ \Comment*[r]{Add clearance phase $p_i'$}
   }
\end{algorithm}
\end{figure}

\begin{remark}
In~\cite{nilsson2017generalized} we showed that the averaged continuous time GPA controller can stabilize, and hence keep the queue-lengths bounded, the network. Moreover, this averaged version is throughput-optimal, which means that no controller can handle more exogenous inflow to network than this controller.
\end{remark}

However, when the controller is discretized, the following example shows that an upper bound on the cycle length, i.e., $\bar{w} > 0$ is required to guarantee stability even for an isolated junction.

\begin{example}\label{ex:unstableunboundedcycle}
Consider a junction with two incoming lanes with unit flow capacity, both having their own phase, and let the exogenous inflows $\lambda_1 = \lambda_2 = \lambda$, $T_w = 1$, $\bar w = 0$, $x_1(0) = A > 0$, and $x_2(0)  = 0$. The control signals and the cycle time for the first iteration is then given by
\begin{align*}
u_1(x(0)) &=  \frac{A}{A+\kappa} \, , \\
u_2(x(0)) &= 0 \, , \\
T(x(0)) &= \frac{A+\kappa}{\kappa}.
\end{align*}
Observe that the cycle time $T(x(0))$ is strictly increasing with $A$. After one full service cycle, i.e., at $t_1 = T(x(0))$ the queue lengths are
\begin{align*}
x_1(t_1) &= A + T(x(0)) \left(\lambda - \frac{A}{A+\kappa} \right)= \overbrace{A + \lambda \frac{A+\kappa}{\kappa} - \frac{A}{\kappa}}^{f(A)} \, , \\
x_2(t_1) &= T(x(0)) \lambda = \lambda \left( \frac{A+ \kappa}{\kappa} \right).
\end{align*}
If $x_1(t_1) = 0$, then due to symmetry, the analysis of the system can be repeated in the same way with a new initial condition. To make sure that one queue always get empty during the service cycles, it must hold that $f(A) \leq 0$. Moreover, to make sure that the other queue grows, it must also hold that $x_2(t_1) > A$ which can be equivalently expressed as
\begin{align*}
A \kappa  + \lambda(A + \kappa) - A &\leq 0 \, , \\
A \kappa - \lambda(A+\kappa) &< 0 \, .
\end{align*}
The choice of $\lambda = \kappa =  0.1$ and $A= 1$ is one set of parameters satisfying the constraints above, and will hence make the queue lengths and cycle times grow unboundedly. How queue lengths and cycle times evolve in this case is shown in Fig.~\ref{fig:unstableunboundedcycle}.
\end{example}
\begin{figure}
\centering
\input{tikzpictures/exampleblowup.tikz}
\caption{How the traffic volumes evolve in time together with the cycle times for the system in Example~\ref{ex:unstableunboundedcycle}. We can observe that the cycle length increases for each cycle.}
\label{fig:unstableunboundedcycle}
\end{figure}
\medskip
Imposing an upper bound on the cycle length, and hence a lower bound on $w$ will then shrink the throughput region. An upper bound of the cycle length may occurs naturally, due to the fact that the sensors cover a limited area and hence the measurements will saturate. However, we will later observe in the simulations that $\bar{w} > 0$ may improve the performance of the controller when it is simulated in a realistic scenario, even when saturation of the queue length measurements is possible.

\subsection{GPA with Shorted Cycles}\label{sec:GPAshorted}
One possible drawback of the controller in Section~\ref{sec:GPAfull} is that it has to activate all the clearance phases in one cycle. This property implies that if the junction is empty when the signal program is computed, it will take $n_{p_j} T_w$ seconds until a new signal program is computed. Motivated by this, we also present a version of the GPA where only the clearance phases get activated if their corresponding phases have been activated. If we let $n_{p_j}'$ denote the number of phases that will be activated during the upcoming cycle, the total cycle time is given by
$$T_\text{cyc} = \frac{n_{p_j}' T_w}{w} \, .$$
How to compute the signal program in this case, is shown in Algorithm~\ref{algo:gpashorted}.
\begin{figure}[!t]
\let\@latex@error\@gobble
\begin{algorithm}[H]
\caption{GPA with Shorted Cycles}\label{algo:gpashorted}
\DontPrintSemicolon
\KwData{Current time $t$, local queue lengths $x^{(j)}(t)$, phase matrix $P^{(j)}$, clearance time $T_w$, tuning parameters $\kappa, \bar w$}
\KwResult{Signal program $\mathcal T^{(j)}$}
   $\mathcal T^{(j)} \leftarrow \emptyset$ \;
   $n_{p_j} \leftarrow $ Number of rows in $P^{(j)}$ \;
   $(\nu, w)$ $\leftarrow$ Solution to~\eqref{eq:gpa} given $x^{(j)}(t), P^{(j)}, \kappa, \bar w$\;
   \Comment*[l]{Compute the number of phases to be activated}
    $n_{p_j}' \leftarrow 0$ \;
   \For{$i\leftarrow 1$ \KwTo $n_{p_j}$}{
   	\If{$\nu_i > 0$}{
		$n_{p_j} ' \leftarrow n_{p_j}' + 1$ \;
	}
    }

   \uIf{$n_{p_j} ' > 0$}{
   	   	\Comment*[l]{If vehicles are present on some phases, activate those}

       $T_\text{cyc} \leftarrow n'_{p_j} \cdot T_w / w$ \;
       $t_\text{end} \leftarrow t$ \;
      \For{$i\leftarrow 1$ \KwTo $n_p$}{
      	  \If{$\nu_i > 0$} {
         	$t_\text{end} \leftarrow t_\text{end} + \nu_i \cdot T_\text{cyc}$ \;
	 \Comment*[l]{Add phase $p_i$}
    	$\mathcal T^{(j)} \leftarrow \mathcal T^{(j)} + (p_i, t_\text{end})$ \;
    	$t_\text{end} \leftarrow t_\text{end} + T_w$ \;
	\Comment*[l]{Add clearance phase $p'_i$ }
             $\mathcal T^{(j)} \leftarrow \mathcal T^{(j)} +  (p'_i, t_\text{end})$
       }}
   }
   \Else{
   	\Comment*[l]{If no vehicles are present, hold a clearance phase for one time unit}
   	 $\mathcal T^{(j)} \leftarrow (p'_1, t+1)$
   }
\end{algorithm}
\end{figure}
\subsection{MaxPressure}
As mentioned in the introduction, the MaxPressure controller is another throughput optimal feedback controller for traffic signals. The controller computes the difference between the queue lengths and their downstream queue lengths in each phase, to determine each phase's pressure. It then activates the phase with the most pressure for a fixed time interval. To compute the pressure, the controller needs information about where the outflow from every queue will proceed. To model this, we introduce the routing matrix $R \in \mathbb{R}_+^{\mathcal E \times \mathcal E}$, whose elements $R_{ij}$ tells the fraction of vehicles that will proceed from lane $i$ in the current junction to lane $j$ in a downstream junction.

With the knowledge of the routing matrix and under the assumption that the flow rates are the same for all phases, the pressure, $w_i$, for each phase $p_i \in \mathcal P^{j}$ can then be computed as
$$w_i = \sum_{l \in p_i} \biggl( x_l(t) - \sum_k R_{lk} x_k(t) \biggr) \, .$$
The phase that should be activated is then any phase in the set $ \argmax_i w_i \,.$

Apart from the routing matrix, the MaxPressure controller has one tuning parameter, the phase duration $d > 0$. That parameter tells how long a phase should be activated, and hence how long it should take until the pressures are resampled, and a new phase activation decision is made.

How to compute the signal program with the MaxPressure controller is shown in Algorithm~\ref{algo:maxpressure}.
\begin{figure}[!t]
 \let\@latex@error\@gobble
  \begin{algorithm}[H] \DontPrintSemicolon

   \caption{MaxPressure}\label{algo:maxpressure}
   \KwData{Current time $t$, local queue lengths $x(t)$, phase matrix $P^{(j)}$, routing matrix $R$, phase duration $d$}
   \KwResult{Signal program $\mathcal T^{(j)}$}
   $\mathcal T^{(j)} \leftarrow \emptyset$ \;
   $n_{p_j} \leftarrow $ Number of rows in $P^{(j)}$ \;
   \For{$i\leftarrow 1$ \KwTo $n_{p_j} $}{
   	\For{$l \in \mathcal L^{(j)}$} {
		\If{$l \in p_i^{(j)}$} {
		 	$w_i \leftarrow w_i + x_l(t) - \sum_{k} R_{lk} x_k(t)$
		}
	}
   }
   $i \leftarrow \argmax_i w_i$ \;
   \Comment*[l]{Add phase $p_i$}
   $\mathcal T^{(j)} \leftarrow \mathcal T^{(j)} + (p_i, t + d)$ \;
    \Comment*[l]{Add clearance phase $p'_i$}
   $\mathcal T^{(j)} \leftarrow \mathcal T^{(j)} + (p'_i, t+ d + T_w)$ \;
  \end{algorithm}
\end{figure}

\section{Comparison Between GPA and MaxPressure} \label{sec:comparision}
\begin{figure}
\centering
\input{tikzpictures/manhattangrid.tikz}
\caption{The Manhattan-like network used in the comparison between GPA and MaxPressure. }
\label{fig:network}
\end{figure}

\begin{figure}
\centering
\begin{tabular}{cc}

\input{tikzpictures/2by2junction.tikz}
&
\input{tikzpictures/2by3junction.tikz} \\
2 by 2 junction & 2 by 3 junction
\\
 & \\
\input{tikzpictures/3by2junction.tikz}
&
\input{tikzpictures/3by3junction.tikz} \\

3 by 2 junction & 3 by 3 junction
\end{tabular}
\caption{The four different types of junctions present in the Manhattan grid, together with theirs phases.} \label{fig:junction}

\end{figure}

\subsection{Simulation setting}

To compare the proposed controller and the MaxPressure controller, we simulate both controllers on an artificial Manhattan-like grid with artificial demand.
The simulator we are using is open source micro simulator SUMO~\cite{SUMO2012}, which is a simulator that simulates every single vehicle's behavior in the traffic network.
A schematic drawing of the network is shown in Fig.~\ref{fig:network}. In a setting like this, we can elaborate with the tuning ratios, and provide the MaxPressure controller both correct and incorrect turning ratios. This allows us to investigate the robustness properties of both the controllers.

The Manhattan grid in Fig.~\ref{fig:network}  has ten bidirectional north to south streets (indexed A to J) and ten bidirectional east to west streets (indexed 1 to 10). All streets with an odd number or indexed by letter A, C, E, G or I consist of one lane in each direction, while the others consist of two lanes in each direction. The speed limit on each lane is 50 km/h. The distance between each junction is three hundred meters. Fifty meters before each junction, every street has an additional lane, reserved for vehicles that want to turn left. Due to the varying number of lanes, four different junction topologies exist, all shown in Fig.~\ref{fig:junction}, together with the set of possible phases. Each junction is equipped with sensors on the incoming lanes that can measure the number of vehicles queuing up to fifty meters from the junction. The sensors measure the queue lengths by the number of stopped vehicles.

Since the scenario is artificial, we can generate demand with prescribed turning ratios and hence let the MaxPressure controller to run in an ideal setting. For the demand generation, we assume that at each junction a vehicle will with probability $0.2$ will turn left, with probability $0.6$ go straight and with probability $0.2$ turn right. We do assume that all vehicles depart from lanes connected to the boundary of the network, and all vehicles will also end their trips when they have reached the boundary of the network. In other words, no vehicles will depart or arrive inside the grid. We will study the controllers' performance for three different demands, where the demand determined by the probability that a vehicle will depart from each boundary lane each second. We denote this probability $\delta$, where the probabilities for the three different demands are $\delta = 0.05$, $\delta = 0.1$ and $\delta = 0.15$. We generate vehicles for $3600$ seconds and then simulate until all vehicles have left the network.

We also compare the results for the GPA controller and the MaxPressure controller with a standard fixed time (FT) controller and a proportional fair (PF) controller, i.e., the GPA controller with full clearance cycles, but with $\kappa =0$ and a prescribed fixed cycle length. For the fixed time controller, the phases which contain a straight movement are activated for $30$ seconds and phases only containing left or right turn movements are activated for $15$ seconds. The clearance time for each phase is still set to $5$ seconds. This means that the cycle lengths for each of the four types of junctions will be $110$ seconds. This is also the fixed cycle time we are using for the proportional fairness controller.

\subsection{GPA Results}
Since the phases in this scenario are all orthogonal, the expressions in~\eqref{eq:gpaorthogonal} can be used to solve the optimization problem in~\eqref{eq:gpa}. The tuning parameter $\bar{w}$ is set to $\bar{w} = 0$ for all simulations.  In Table~\ref{tab:gpamanhattan} we show how the total travel time varies for the GPA controller with shorted cycles for different values of $\kappa$. For the demand $\delta = 0.15$ and $\kappa =1$ a gridlock situation occurs, probably due to the fact that vehicles back-spills into upstream junctions. We can see that a $\kappa =10$ seems to be the best choice for $\delta = 1$ and $\delta = 0.15$, while a higher $\kappa$ slightly improves the total travel time for the lowest demand investigated. Letting $\kappa = 10$ has been shown to be reasonable for other demand scenarios in the same network setting, as observed in~\cite{nilsson2018}. How the total queue lengths varies with time for $\kappa =5$ and $\kappa = 10$ is shown in Fig.~\ref{fig:gpamanhattan}.
\begin{table}
\centering
\caption{GPA with Shorted Cycles - Manhattan Scenario}
\label{tab:gpamanhattan}
\begin{tabular}{rcc}
$\kappa$ & $\delta$ & Total Travel Time [h] \\ \hline \hline
$1$ & $0.05$ &  $1398$ \\
$5$ & $0.05$ &  \phantom{0}$715$ \\
$10$ & $0.05$ & \phantom{0}$699$   \\
$15$ & $0.05$ & \phantom{0}$696$   \\
$20$ & $0.05$ & \phantom{0}$690$   \\
$1$ & $0.10$ & $7636$ \\
$5$ & $0.10$ &  $1898$ \\
$10$ & $0.10$ &  $1992$ \\
$15$ & $0.10$ &  $2263$ \\
$20$ & $0.10$ &  $2495$ \\
$1$ & $0.15$ & $+\infty$ \\
$5$ & $0.15$ &  $5134$ \\
$10$ & $0.15$ &  $4498$ \\
$15$ & $0.15$ &  $5140$ \\
$20$ & $0.15$ &  $6050$ \\ \hline
\end{tabular}
\end{table}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[ymode=log, width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=6000, legend style={at={(0.5,-0.25)},anchor=north}]
\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k10_l0.05.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k10_l0.10.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k10_l0.15.csv};
\addplot[mark=none, color=mycolor1, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k5_l0.05.csv};
\addplot[mark=none, color=mycolor2, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k5_l0.10.csv};
\addplot[mark=none, color=mycolor3, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k5_l0.15.csv};
\legend{GPA $\kappa=10 \, \delta = 0.05$, GPA $\kappa=10 \, \delta = 0.10$, GPA $\kappa=10 \, \delta = 0.15$ , GPA $\kappa=5 \, \delta = 0.05$, GPA $\kappa=5 \, \delta = 0.10$, GPA $\kappa=5 \, \delta = 0.15$ }
\end{axis}
\end{tikzpicture}
\caption{How the queue length varies with time when the GPA with shorted cycles are used in Manhattan grid. The GPA is tested with two different values of $\kappa=5,10$ for the three demand scenarios $\delta = 0.05, 0.10, 0.15$. To improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:gpamanhattan}
\end{figure}

\subsection{MaxPressure Results}
The MaxPressure controller decides its control action not only based on queue-lengths on the incoming lanes, but also on the downstream lanes. It is not always clear in which downstream lane a vehicle will end up in after leaving the junction. If a vehicle can choose between several lanes that are all valid for its path, the vehicle's lane choice will be determined during the simulation, and depend upon how many other vehicles that are occupying the possible lanes. Because of this, we assume that if a vehicle can choose between several lanes, it will try to join the shortest one. To exemplify how the turning ratios are estimated in those situations, assume that Moreover, assume that the overall probability  that a vehicle is turning right is $0.2$, and going straight is $0.6$. If a vehicle going straight can choose between lane $l_1$, $l_2$, but $l_2$ is also used by vehicles turning right, the probability that the vehicle going straight will queue up in lane $l_1$ is assumed to be $0.4$ and that the probability that the vehicle will queue up in lane $l_2$ is estimated to be $0.2$.

To also investigate the MaxPressure controller's robustness with respect to the routing information, we perform simulations both when the controller has the correct information about the turning probabilities, i.e., that a vehicle will turn right with probability $0.2$, continue straight with probability $0.6$ and turn left with probability $0.2$. For the simulations when the MaxPressure has the wrong turning information, the controller instead has the information that with probability $0.6$ the vehicle will turn right, with probability $0.3$ the vehicle will proceed straight and with probability $0.1$ the vehicle will turn left. In the simulations, we consider three different phase durations, $d=10$ seconds, $d=20$ seconds and $d=30$ seconds.

How the total queue lengths vary over time for the different demands is shown in Fig.~\ref{fig:mpmanhattand0.05}, Fig.~\ref{fig:mpmanhattand0.10}, and~Fig.~\ref{fig:mpmanhattand0.15}. The total travel time, both when the MaxPressure controller is operating with the right, and the wrong turning ratios are shown in Table~\ref{tab:mpmanhattan}. From these results, we can conclude that a shorter phase duration, i.e., $d = 10$, is the most efficient for all demands. This probably has to do with a longer phase duration the activation time is becoming larger than the time it takes to empty the measurable part of the queue. Another interesting observation is that if the MaxPressure controller has wrong information about the turning ratios, its performance does not decrease significantly.

\begin{table}
\centering
\caption{MaxPressure - Manhattan Scenario}
\label{tab:mpmanhattan}
\begin{tabular}{cccc}
 $d$ & $\delta$ & TTT correct TR [h] & TTT incorrect TR [h] \\ \hline \hline
$10$ & $0.05$ &  858 &   856\\
$20$ & $0.05$ &  1 079 & 1 102 \\
$30$ & $0.05$ &  1 172 & 1 193 \\
$10$ & $0.10$ &  1 865 & 1 864 \\
$20$ & $0.10$ &  2 254 & 2 312 \\
$30$ & $0.10$ &  2 690 & 2 718 \\
$10$ & $0.15$ &  3 511 & 3 488 \\
$20$ & $0.15$ &  3 992 & 4 102  \\
$30$ & $0.15$ &  5 579 & 5 590 \\ \hline
\end{tabular}

\end{table}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=5000, legend pos=north west, scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace
      }, ,  legend style={at={(0.5,-0.25)},anchor=north}]
\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d10_l0.05.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d20_l0.05.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d30_l0.05.csv};
\addplot[mark=none, color=mycolor1, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d10_l0.05.csv};
\addplot[mark=none, color=mycolor2, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d20_l0.05.csv};
\addplot[mark=none, color=mycolor3, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d30_l0.05.csv};
 \legend{MP $d =10$, MP $d=20$, MP $d=30$}
\end{axis}
\end{tikzpicture}
\caption{The total queue length over time in the Manhattan grid with the MaxPressure (MP) controller with right turning ratios (solid) and wrong turning ratios (dashed). The demand is $\delta = 0.05$. To improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:mpmanhattand0.05}
\end{figure}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=5000, legend pos=north west, scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace
      },  legend style={at={(0.5,-0.25)},anchor=north}]
\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d10_l0.10.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d20_l0.10.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d30_l0.10.csv};
\addplot[mark=none, color=mycolor1, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d10_l0.10.csv};
\addplot[mark=none, color=mycolor2, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d20_l0.10.csv};
\addplot[mark=none, color=mycolor3, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d30_l0.10.csv};
 \legend{MP $d =10$, MP $d=20$, MP $d=30$}
\end{axis}
\end{tikzpicture}
\caption{The total queue length over time in the Manhattan grid with the MaxPressure (MP) controller with right turning ratios (solid) and wrong turning ratios (dashed). The demand is $\delta = 0.10$. To improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:mpmanhattand0.10}
\end{figure}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=6000, legend pos=north west, scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace
      },  legend style={at={(0.5,-0.25)},anchor=north}]
\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d10_l0.15.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d20_l0.15.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d30_l0.15.csv};
\addplot[mark=none, color=mycolor1, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d10_l0.15.csv};
\addplot[mark=none, color=mycolor2, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d20_l0.15.csv};
\addplot[mark=none, color=mycolor3, dashed, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bpw_d30_l0.15.csv};
 \legend{MP $d =10$, MP $d=20$, MP $d=30$}
\end{axis}
\end{tikzpicture}
\caption{The total queue length over time in the Manhattan grid with the MaxPressure (MP) controller with right turning ratios (solid) and wrong turning ratios (dashed). The demand is $\delta = 0.15$. To improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:mpmanhattand0.15}
\end{figure}

\subsection{Summery of the Comparison}
To better observe the difference between the GPA and MaxPressure, we have plotted the total queue length with the GPA controller with $\kappa = 5$ and $\kappa = 10$, and the best MaxPressure configuration with $d = 10$. The results are shown in Fig.~\ref{fig:comparisonl0.05}, Fig.~\ref{fig:comparisonl0.10} and Fig.~\ref{fig:comparisonl0.15}. In the figures we have also included for reference the total queue lengths for the fixed time controller and the proportional fair controller. The total travel travel times for those controllers are given in Table~\ref{tab:fixedmanhattan}. When the demand is $\delta = 0.15$, a gridlock situation occurs with the proportional fair controller, just as happened with the GPA controller with $\kappa = 1$. From the simulations, we can conclude that, for this scenario, during high demands, the MaxPressure controller performs better than the GPA controller, while during low demands the GPA performs better. One explanation for this could be that during low demands, adopting the cycle length is critical, while during high demands when almost all the sensors are covered, it is more important to keep the queue balanced between the current and downstream lanes. The proportional fair controller that does not adopt its cycle length, performs always the worst, and in most of the cases a fixed time controller performs second worst. It is just for the demand $\delta = 0.15$, and during the draining phase that the fixed time controller performs better than the GPA controller.

\begin{table}
\centering
\caption{Fixed Time and Proportional Fair Control - Manhattan Scenario}
\label{tab:fixedmanhattan}
\begin{tabular}{ccc}
Controller & $\delta$ & Total Travel Time [h] \\ \hline \hline
FT & $0.05$ & $1201$ \\
FT & $0.10$ & $2555$ \\
FT & $0.15$ & $4642$   \\
PF & $0.05$ & $1694$   \\
PF & $0.10$ & $4165$   \\
PF & $0.15$ & $+\infty$ \\ \hline
\end{tabular}
\end{table}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[ymode=log, width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=5000, legend pos=north west, scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace
      }, , legend style={at={(0.5,-0.25)},anchor=north}, legend columns=2]

\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k5_l0.05.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k10_l0.05.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d10_l0.05.csv};
\addplot[mark=none, color=mycolor4, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_fixed_l0.05.csv};
\addplot[mark=none, color=black, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf_fixed_l0.05.csv};
\legend{GPA $\kappa =5$, GPA $\kappa =10$, MP $d = 10$, Fixed Time, PF}
\end{axis}
\end{tikzpicture}
\caption{A comparison between different control strategies for the Manhattan grid with the demand $\delta = 0.05$.o improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:comparisonl0.05}
\end{figure}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[ymode=log, width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=5500, legend pos=north west, scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace
      }, , legend style={at={(0.5,-0.25)},anchor=north},  legend columns=2]

\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k5_l0.10.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k10_l0.10.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d10_l0.10.csv};
\addplot[mark=none, color=mycolor4, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_fixed_l0.10.csv};
\addplot[mark=none, color=black, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf_fixed_l0.10.csv};
\legend{GPA $\kappa =5$, GPA $\kappa =10$, MP $d = 10$, Fixed Time, PF}
\end{axis}
\end{tikzpicture}
\caption{A comparison between different control strategies for the Manhattan grid with the demand $\delta = 0.10$. To improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:comparisonl0.10}
\end{figure}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[ymode=log, width=8cm,  height=6cm,  ylabel={Total Queue Length [m] }, xlabel={Time [s]}, xmax=6500, legend pos=north west, scaled y ticks = false,
      y tick label style={/pgf/number format/fixed,
      /pgf/number format/1000 sep = \thinspace
      }, , legend style={at={(0.5,-0.25)},anchor=north},  legend columns=2]

\addplot[mark=none, color=mycolor1, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k5_l0.15.csv};
\addplot[mark=none, color=mycolor2, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_pf2_k10_l0.15.csv};
\addplot[mark=none, color=mycolor3, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_bp_d10_l0.15.csv};
\addplot[mark=none, color=mycolor4, thick] table [x index=0, y index=1]{plotdata/bpvspf/queue_fixed_l0.15.csv};
\legend{GPA $\kappa =5$, GPA $\kappa =10$, MP $d = 10$, Fixed Time}
\end{axis}
\end{tikzpicture}
\caption{A comparison between different control strategies for the Manhattan grid with the demand $\delta = 0.15$. Since the proportional fair controller (PF) creates a gridlock, it is not included in the comparison. To improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:comparisonl0.15}
\end{figure}

\section{LuST scenario} \label{sec:lust}

\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{luxnetwork.png}
\caption{The traffic network of Luxembourg city}
\label{fig:lust}
\end{figure}

To test the proposed controller in a realistic scenario, we make use of the Luxembourg SUMO Traffic (LuST) scenario presented in~\cite{codeca2017luxembourg}\footnote{The scenario files are obtained from \url{https://github.com/lcodeca/LuSTScenario/tree/v2.0}}. The scenario models the city center of Luxembourg during a full day, and the authors of~\cite{codeca2017luxembourg} have made several adjustments from some given population data when creating the scenario, to make it as realistic as possible.

The LuST network is shown in Fig.~\ref{fig:lust}. To each of the $199$ signalized junctions, we have added a lane area detector to each incoming lane. The length of the detectors are $100$ meters, or as long as the lane is if it is shorter than $100$ meters. Those sensors are added to give the controller real-time information about the queue-lengths at each junction.

As input to the system, we are using the Dynamic User Assignment demand data. For this data-set, the drivers try to take their shortest path (with respect to time) between their current position and destination. It is assumed that $70$ percent of the vehicles can recompute their shortest path while driving, and will do so every fifth minute. This rerouting possibility is introduced in order to model the fact that more and more drivers are using online navigation with real-time traffic state information, and will hence get updates about what the optimal route choice is.

In the LuST scenario, the phases are constructed in a bit more complex way and are not always orthogonal. For non-orthogonal phases, it is not always the case that all lanes receive yellow light when a clearance phase is activated. If the lane receives a green light in the next phase as well, it will receive green light during the clearance phase too. This property makes it more difficult to shorten the cycle, and for that reason, we choose to implement the controller which activates all the clearance phases in the cycle, i.e., the controller given in Section~\ref{sec:GPAfull}.

As mentioned, the phases in the LuST scenario are not orthogonal in each junction. Hence we have to solve the convex optimization problem in~\eqref{eq:gpa} to compute the phase activation. The computation is done by using the solver CVXPY\footnote{https://cvxpy.org} in Python. Although the controller can be implemented in a distributed manner, the simulations are in this paper performed on a single computer. Despite the size of the network, and that the communication via TraCI between the controller written in Python and SUMO slows down the simulations significantly, the simulations are still running about $2.5$ times faster than real-time.  This shows that there is no problem with running this controller in a real-time setting.

Since the demand is high during the peak-hours in the scenario, gridlock situations occur. Those kinds of situations is unavoidable since there will be conflicts in the car following model. To make the simulation continue to run, SUMO has a teleporting option that is utilized in the original LuST scenario. The original LuST scenario is configured such that if that a vehicle has been looked for more than $10$ minutes, it will teleport along its route until there is free space. It is therefore important when we evaluate the control strategies that we keep track of the number of teleports, to make sure that the control strategy will not create a significantly larger amount of gridlocks, compared to the original fixed time controller. In Table~\ref{tab:lust} the number of teleports are reported for each controller. It is also reported how many of those teleports that are caused directly due to traffic jam, but one should have in mind that e.g., a gridlock caused by that two vehicles want to swap lanes, is often a consequence of a congestion.

The total travel time and the number of teleports for different choices of tuning parameters are shown in Table~\ref{tab:lust}. For the fixed time controller, we keep the standard fixed time plan provided with the LuST scenario. How the queue lengths vary with time for different $\bar w$ is shown in Fig.~\ref{fig:lustkappa5} for $\kappa =5$ and in Fig.~\ref{fig:lustkappa10} for $\kappa = 10$.

From the results, we can see that any controller with $\kappa = 10$  and $\bar{w}$ within the range of investigation will improve the traffic situation. However, the controller that yields the overall shortest total travel time is the one with $\kappa =5$ and $\bar{w} = 0.40$. This result suggests that tuning the GPA only with respect to $\kappa$, and keep $\bar{w} = 0$, may not lead to the best performance with respect to total travel time, although it gives higher theoretical throughput.

\begin{table}
\caption{Comparison of the different control strategies}
\label{tab:lust}
\centering
\begin{tabular}{lcccc}
& $\kappa$ & $\bar{w}$ & Teleports (jam) & Total Travel Time [h] \\ \hline \hline
GPA & $10$ & $0$ & 76 (6) & 49 791 \\
GPA & $10$ & $0.05$ & 65 (1) & 49 708  \\
GPA & $10$ & $0.10$ & 37 (0) & 49 519 \\
GPA & $10$ & $0.15$ & 57 (19) & 49 408  \\
GPA & $10$ & $0.20$ & 50 (10) & 49 380 \\
GPA & $10$ & $0.25$ & 35 (0) &  49 265\\
GPA & $10$ & $0.30$ & 30 (0) &  48 930\\
GPA & $10$ & $0.35$ & 25 (1) &  48 922\\
GPA & $10$ & $0.40$ & 51 (0) &  48 932 \\
GPA & $10$ & $0.45$ & 49 (5) &  49 076 \\
GPA & $10$ & $0.50$ & 42 (15) & 49 383 \\
GPA & $5$ & $0$ & 668 (76) & 57 249 \\
GPA & $5$ & $0.05$ & 234 (62) & 54 870  \\
GPA & $5$ & $0.10$ & 68 (10)  & 52 038 \\
GPA & $5$ & $0.15$ & 47 (9)  & 50 696 \\
GPA & $5$ & $0.20$ & 50 (6) & 49 904 \\
GPA & $5$ & $0.25$ & 41 (3) & 49 454 \\
GPA & $5$ & $0.30$ & 23 (0) & 48 964 \\
GPA & $5$ & $0.35$ & 30 (1) & 48 643 \\
GPA & $5$ & $0.40$ & 35 (5) & 48 445 \\
GPA & $5$ & $0.45$ & 39 (1) & 48 503 \\
GPA & $5$ & $0.50$ & 42 (10) & 48 772 \\
Fixed time & -- & -- & 122 (80) & 54 103\\ \hline
\end{tabular}

\end{table}

\begin{figure}
\begin{tikzpicture}
\begin{axis}[ymode=log, width=8cm,  height=8cm,  ylabel={Total Queue Length [m] }, xlabel={Time}, legend pos=north west, xmin=0, xmax=24.00, xtick={0, 4, 8, 12, 16, 20, 24},
x filter/.code={\pgfmathparse{#1/3600+0}},
xticklabel={
        \pgfmathsetmacro\hours{floor(\tick)}%
        \pgfmathsetmacro\minutes{(\tick-\hours)*0.6}%

        \pgfmathprintnumber{\hours}:\pgfmathprintnumber[fixed, fixed zerofill, skip 0.=true, dec sep={}]{\minutes}%
    },
    legend columns=2,  legend style={at={(0.5,-0.25)},anchor=north}
]
\addplot[mark=none, color=mycolor1] table [x index=0, y index=1]{plotdata/csv/queue_pf_k5_tmin0.0.csv};
\addplot[mark=none, color=mycolor2] table [x index=0, y index=1]{plotdata/csv/queue_pf_k5_tmin0.1.csv};
\addplot[mark=none, color=mycolor3] table [x index=0, y index=1]{plotdata/csv/queue_pf_k5_tmin0.2.csv};
\addplot[mark=none, color=mycolor4] table [x index=0, y index=1]{plotdata/csv/queue_pf_k5_tmin0.30.csv};
\addplot[mark=none] table [x index=0, y index=1]{plotdata/csv/queue_pf_k5_tmin0.40.csv};
\addplot[mark=none, color=black, dotted] table [x index=0, y index=1]{plotdata/csv/queue_static.csv};
\legend{GPA  $\bar{w} = 0$, GPA  $\bar{w} = 0.1$, GPA $\bar{w} = 0.2$, GPA $\bar{w} = 0.3$, GPA $\bar{w} = 0.4$, Fixed Time }
\end{axis}
\end{tikzpicture}
\caption{How the queue lengths varies with time when the traffic lights in the LuST scenario are controlled with the GPA controller and the standard fixed time controller. For the GPA controller the paramters $\kappa = 5$ and different values of $\bar{w}$ are tested.  In order to improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:lustkappa5}
\end{figure}

\begin{figure}
\begin{tikzpicture}
\begin{axis}[ymode=log, width=8cm,  height=8cm,  ylabel={Total Queue Length [m] }, xlabel={Time}, legend pos=north west, xmin=0, xmax=24.00, xtick={0, 4, 8, 12, 16, 20, 24},
x filter/.code={\pgfmathparse{#1/3600+0}},
xticklabel={
        \pgfmathsetmacro\hours{floor(\tick)}%
        \pgfmathsetmacro\minutes{(\tick-\hours)*0.6}%

        \pgfmathprintnumber{\hours}:\pgfmathprintnumber[fixed, fixed zerofill, skip 0.=true, dec sep={}]{\minutes}%
    },
    legend columns=2,  legend style={at={(0.5,-0.25)},anchor=north}
]
\addplot[mark=none, color=mycolor1] table [x index=0, y index=1]{plotdata/csv/queue_pf_k10_tmin0.0.csv};
\addplot[mark=none, color=mycolor2] table [x index=0, y index=1]{plotdata/csv/queue_pf_k10_tmin0.1.csv};
\addplot[mark=none, color=mycolor3] table [x index=0, y index=1]{plotdata/csv/queue_pf_k10_tmin0.2.csv};
\addplot[mark=none, color=mycolor4] table [x index=0, y index=1]{plotdata/csv/queue_pf_k10_tmin0.30.csv};
\addplot[mark=none] table [x index=0, y index=1]{plotdata/csv/queue_pf_k10_tmin0.40.csv};
\addplot[mark=none, color=black, dotted] table [x index=0, y index=1]{plotdata/csv/queue_static.csv};
\legend{GPA  $\bar{w} = 0$, GPA  $\bar{w} = 0.1$, GPA $\bar{w} = 0.2$, GPA $\bar{w} = 0.3$, GPA $\bar{w} = 0.4$, Fixed Time }
\end{axis}
\end{tikzpicture}
\caption{How the queue lengths varies with time when the traffic lights in the LuST scenario are controlled with the GPA controller and the standard fixed time controller. For the GPA controller the paramters $\kappa = 10$ and different values of $\bar{w}$ are tested.  In order to improve the readability of the results, the queue-lengths are averaged over $300$ seconds intervals.}
\label{fig:lustkappa10}
\end{figure}

\section{Conclusions}

In this paper, we have discussed implementational aspects of the Generalized Proportional Allocation controller. The controller's performance was compared to the MaxPressure controller both on an artificial Manhattan-like grid and for a real scenario. In comparison with MaxPressure, it was shown that the controller performs better than the MaxPressure controller when the demand is low, but the MaxPressure performs better during high demand. Those observations hold true even if the MaxPressure controller does not have correct information about the turning ratios in each junction.

While the information about the turning ratios and the queue lengths at neighboring junctions are needed for the MaxPressure controller, the GPA controller does not require any such information. This makes the GPA controller easier to implement in a real scenario, where the downstream junction may not be signalized and equipped with sensors. We showed that it is possible to both implement the GPA controller in a realistic scenario covering the city of Luxembourg and that it improves the traffic situation compared to a standard fixed time controller.

In all simulations, we have used the same tuning parameters for all junctions in the LuST scenario, while the fixed time controller is different for different junction settings. Hence the GPA controller's performance can be even more improved by tuning the parameters specifically for each junction. Ideally, this should be done with some auto-tuning solution, but it may also be worth to take static parameters into account, such as the sensor lengths. This is a topic for future research.

\bibliographystyle{ieeetr}%


\section{INTRODUCTION}

It is generally supposed that the high energy emission from blazars --
ie BL Lac objects and quasars which display some evidence of relativistic
jets -- arises from Compton scattering of low energy seed photons.
However the evidence for this supposition is quite weak.
There has been remarkably little progress, despite a great deal
of observational effort, in determining the details of the high energy
emission models. Various possibilities exist, all of which require
that the scattering particles are the relativistic electrons in the
jet.  The most popular hypothesis is the Synchrotron Self-Compton
(SSC) model in which the seed photons are the synchrotron photons from
the jet, up-scattered by their parent electrons. Alternatively the
seed photons may arise externally to the jet (the External Compton,
EC, process) or, in a combination of the two models, photons from the
jet may be mirrored back to the jet (the Mirror Compton, MC, model)
from a gas cloud before scattering up to high energies. The various
models make slightly different predictions about the lags between the
seed and Compton-scattered variations, and about the relative
amplitudes of the two components and so, in principle, the models can
be distiguished (eg see Ghisellini and Maraschi 1996 and Marscher 1996
for summaries of the predictions of the various models). Much
observational effort has therefore been devoted to attempting to find
correlated variability in the high and low energy bands.

\begin{figure*}
\begin{center}
  \leavevmode
  \epsfxsize 0.8\hsize
  \epsffile{xkmmmm.ps}
\end{center}
\caption{X-ray, infrared and millimetre lightcurves.
The X-ray counts are the total from 3 PCUs of the PCA.
The 1.3mm data are from the JCMT (filled circles), with some points from
OVRO (open squares).  The 3mm data are all from OVRO. }
\label{fig:lcurves}
\end{figure*}

In the SSC model, it has generally been expected that, as the peak of
the synchrotron photon number spectrum lies in the mm band for most
radio-selected blazars, the mm would provide the bulk of the seed
photons and so would be well correlated with the X-ray emission.
However in the case of 3C273, one of the brightest blazars, extensive
searches have been carried out for a connection between the X-ray and
millimetre bands on both daily (M$\rm^{c}$Hardy\, 1993) and monthly (Courvoisier
\it et al.~\rm 1990; M$\rm^{c}$Hardy\, 1996) timescales but no correlation has been
found. The SSC model may, however, be saved if the flaring synchrotron
component is self-absorbed at wavelengths longer than $\sim1$ mm. We
therefore undertook a search for a correlation between the X-ray
and infrared emission in 3C273; previous observations (eg Courvoisier
\it et al.~\rm 1990; Robson \it et al.~\rm 1993) have confirmed that infrared flares in
3C273 are due to variations in a synchrotron component.  In the past,
large amplitude infrared flares have been seen only rarely in 3C273
(eg Courvoisier \it et al.~\rm 1990; Robson \it et al.~\rm 1993), partially because of
limited sampling which usually could not detect flares with overall
timescales $\sim$week. Nonetheless the previous sampling was
sufficient to show that such flare activity is not a continual
occurence.  It may be relevant that the present observations,
during which large amplitude infrared variability was detected,
were made during a period when the millimetre flux from 3C273 was very
high.

Here we present what we believe is the
best sampled observation of correlated variability between the
synchrotron and Compton-scattered wavebands in any blazar. The
observations cover not just one flaring event, which could be due to
chance, unrelated, flaring in the two wavebands, but two large
variations.  The observations, including the X-ray, infrared and
millimetre lightcurves, and cross-correlation of the X-ray and other
waveband lightcurves, are described in Section 2. The origin of the
X-ray seed photons is discussed in Section 3, the implications of the
observations are discussed in Section 4 and the overall
conclusions are given in Section 5.

\section{OBSERVATIONS}

\subsection{X-ray Observations}

During the 6 week period from 22 December 1996 to 5 February 1997,
X-ray observations were carried out twice a day by RXTE and nightly near
infrared service observations were made at the United Kingdom Infrared
Telescope (UKIRT).

The X-ray observations were made with the large area (0.7 m$^{2}$)
Proportional Counter Array (PCA) on RXTE (Bradt, Rothschild
and Swank 1993). Each observation lasted for
$\sim1$ksec.  The PCA is a non-imaging device with a field of view of
FWHM $\sim1^\circ$ and so the background count rate was calculated
using the RXTE q6 background model. Standard selection
criteria were applied to reject data of particularly high background
contamination.

3C273 is detectable in each observation in the energy range 3-20 keV
and its spectrum is well fitted by a simple power law.  As with other
PCA spectra (eg The Crab --see
http://lheawww.gsfc.nasa.gov/users/keith/pcarmf.html) the measured
energy index, $\alpha$=0.7, is 0.1 steeper than measured by previous
experiments, eg GINGA (Turner \it et al.~\rm 1990).  The X-ray spectra, and
spectral variability during the present observations are discussed in
detail by Lawson \it et al.~\rm (in preparation).  The average count rate of 45 counts
s$^{-1}$ (3-20 keV) (the total for 3 of the proportional counter units,
PCUs, of the PCA) corresponds to a flux of $1.5 \times 10^{-10}$ ergs
cm$^{-2}$ s$^{-1}$ (2-10 keV).

In figure~\ref{fig:lcurves} we present the count rate in the 3-20 keV
band. We see two large X-ray flares. The first flare begins on
approximately 1 January 1997, reaches a peak on 4 January and returns
to its pre-flare level on 10 January. The flare is quite smooth. The
second flare begins on 22 January and lasts until approximately 1
February. The initial rise is faster than that of the first flare, and
the overall shape indicates a superposition of a number of smaller
flares. X-ray spectral variations are seen during the flares (Lawson
\it et al.~\rm in preparation), showing that changes in the Doppler factor of the jet
cannot, alone, explain the observed variability.

\subsection{Infrared and Millimetre Observations}

In figure~\ref{fig:lcurves} we show 1.3 and 3 mm observations from the
James Clerk Maxwell Telescope (JCMT - see Robson \it et al.~\rm 1993 for
reduction details) and from the Owens Valley Radio Observatory
(OVRO); the latter data were obtained from the calibration
database.  There is no evidence of flares of comparable amplitude to
those in the X-ray lightcurve, but the sampling is poorer and the
errors are larger.

We also show the K-band lightcurve derived from service observations
at the United Kingdom Infrared Telescope (UKIRT) from 1 January until
3 February 1997. The observations were made with the infrared imaging
camera IRCAM3 with typical exposures of 3 minutes. The observations
were made in a standard mosaic manner and the data were also reduced
in a standard manner. There are some gaps due to poor weather but
increases in the infrared flux at the same time as the X-ray flares
can be seen clearly.  The average K error is $\sim1$mJy (ie 1 per
cent). Approximately half of the error comes from the Poisson noise
and the rest comes from calibration uncertainties.

\subsection{X-ray/Infrared Cross-Correlation}

We have cross-correlated the X-ray lightcurves with the millimetre and
K-band lightcurves using the Edelson and Krolik (1988) discrete
cross-correlation algorithm as coded by Bruce Peterson (private communication).
As found previously there is no correlation of the
X-ray emission with the millimetre emission but there is a very strong
correlation with the infrared emission (figure~\ref{fig:xcor}) with
correlation coefficient close to unity. The cross-correlation peaks
close to zero days lag but is asymetric. Although we can rule out the
infrared lagging the X-rays by more than about one day, a lag of the
infrared by the X-rays by up to 5 days is possible.

The observations presented here are the first to show a definite
correlation in 3C273 between the X-ray emission and that of any
potential seed photons.

\begin{figure}
\begin{center}
  \leavevmode
  \epsfxsize 1.0\hsize
  \epsffile{xir_0.5.ps}
\end{center}
\caption{Cross-correlation of the 3-20 keV X-ray lightcurve and
K-band lightcurves shown in figure~\ref{fig:lcurves}.
}
\label{fig:xcor}
\end{figure}

\section{THE ORIGIN OF THE X-RAY SEED PHOTONS}

An important question is whether the infrared photons are actually the
seed photons for the X-ray emission or whether they are simply tracers
of a more extended spectral continuum, with the X-rays arising from
scattering of another part of the continuum. Robson \it et al.~\rm (1993) state
that in 3C273 the onset and peak of flares occur more or less
simultaneously (ie lags of $<1$ day) from K-band to 1.1 mm.
Therefore although we have not adequately monitored at wavelengths
longer than 2.2$\mu$, we assume that the whole IR to mm continuum does
rise simultaneously.

We have therefore calculated the Compton scattered spectrum resulting
from the scattering of individual decades of seed photon energies,
from the infrared to millimetre bands. The seed photons are taken from
a typical photon distribution and are scattered by a typical electron
distribution.  The resulting scattered spectra are shown in
figure~\ref{fig:scatter} and details of the photon and electron
distributions are given in the caption to figure~\ref{fig:scatter}.
It is assumed that the emission region is optically thin which, in
blazars, is true for the large majority of frequencies discussed in
figure~\ref{fig:scatter}.  Note that although the electron and input
photon spectra are self-consistent as regards the SSC mechanism, the
result is general and applies to scattering of seed photons produced
by any mechanism.  At the highest Compton scattered energies, ie GeV,
only the highest energy seed photons below the break in the photon
distribution (ie near infrared) are important. However at medium
energy X-rays we get approximately equal contributions from each
decade of seed photons. Thus scattered infrared photons probably
contribute about 20 per cent of the medium energy X-ray flux and the sum of
the scattered X-ray emission from lower energy seed photons exceeds
that from the infrared alone. These ratios can be altered slightly by
different choices of seed photon and electron spectral index, but the
general result is robust.

If the infrared is indeed a tracer of the seed photon continuum, we
can extrapolate to find the expected variability in the millimetre
band.  The peak and minimum observed K fluxes during our observations
are 124 and 93 mJy respectively, ie a range of 31 mJy, although we
note that we do not have K observations at either the peak or minimum
of the X-ray lightcurves and so the true range of K-band variability
may be somewhat more.  If the spectral index, $\alpha$, of the seed
spectrum is 0.75 (as reported by Robson \it et al.~\rm and Stevens \it et al.~\rm 1998)
we would then expect a rise of $\sim$3.7 Jy at 1.3 mm, which we cannot
rule out in the present observations and which would not have been
easy to detect in previous, less well sampled, monitoring
observations, explaining the lack of success of previous searches for
millimetre/X-ray correlations.  At 3mm the predicted variability
amplitude would be 7 Jy.  Robson \it et al.~\rm states that the 3mm rises lag
1mm rises by about 6 days, and 3mm decays are substantially longer,
which would all make them easier to detect, given our sampling
pattern.  However, with the exception of the very last datapoint at
day 44, no deviations of more than 5 Jy from the mean level are
detected. The implication is that $\alpha \leq 0.75$ or that the
flaring component is self absorbed by 3mm.  If the flaring component
has $\alpha=1.2$ as derived for the 1983 flare by Marscher and Gear
(1985), that component would have to be self absorbed by 1.3mm.

\begin{figure}
\begin{center}
  \leavevmode
  \epsfxsize 1.0\hsize
  \epsffile{compton.ps}
\end{center}
\caption{Compton scattered spectrum resulting from the scattering of
a seed photon spectrum stretching from $\nu=10^{8}$ to $10^{20}$ Hz.
At low frequencies the spectral index, $\alpha$, where flux,
$F, \propto \nu^{-\alpha}$, is 0.75 and, above a break frequency
of $10^{14}$ Hz, $\alpha = 1.5$. The electron number energy spectrum,
$N(\gamma) \propto \gamma^{-m}$, where $\gamma$ is the Lorentz factor
of the individual electrons, stretches from $\gamma=10$ to $10^{7}$,
with a slope, $m$, at low energies of 2.5 and $m=4.0$ above
$\gamma=10^{4}$. The proper Klein-Nishina cross section is used.
No bulk relativistic motion is included.
The thick line represents the total scattered spectrum. The
other lines represent the result of scattering seed photons with
only one decade of energy.
Note that, in the medium energy X-ray band (4 keV= $10^{18}$ Hz), seed
photons from all decades from cm to near infrared contribute equally
to the scattered flux, with each contributing about 20 per cent.}
\label{fig:scatter}
\end{figure}

\section{DISCUSSION}

There are two major observational constraints on the X-ray emission
mechanism: the relative amplitudes of the synchrotron and Compton
scattered components, and the time lag between them. Here we
attempt to constrain these parameters by modelling the X-ray lightcurve.

\subsection{Modelling the X-ray lightcurve}

If the X-ray emission is physically related to the infrared emission,
then we can parameterise the relationship by:

\[ X_{predicted}(t)= A \, (K_{flux}(t-\delta t) - K_{quiescent})^{N}
\, + \, X_{quiescent} \]

$K_{quiescent}$ is a non-varying K-band component. Robson \it et al.~\rm (1993)
show that such a component, steady on a timescale of years, is
contributed probably by warm dust in the broad line clouds,
heated to the point of evaporation.
Following Robson \it et al.~\rm we fix $K_{quiescent}=50$mJy.
$K_{flux}(t-\delta t)$ is the total observed K-band flux at time
$t-\delta t$ and $X_{predicted}(t)$ is then the predicted total X-ray
flux at time $t$.  $X_{quiescent}$ is the part of the X-ray flux which
does not come from the flaring region. The variable $\delta t$ is
included to allow for lags between the X-ray and infrared variations.
Initially we set $\delta t = 0$ but, in section 4.2, we consider the
implications of allowing $\delta t$ to vary.
$A$ is the constant of proportionality
(containing information about the electron
density, magnetic field and the various flux conversion constants)
and $N$ contains information about the emission mechanism.  For
example if the X-rays arise from variations in electron density then
we expect $N=2$ in the SSC and MC processes, but in the EC model $N=1$.
We have therefore performed a $\chi^{2}$ fit, using a standard
Levenburg-Marquardt minimisation routine, comparing the predicted
X-ray flux with the observed flux, in order to determine the three
unknowns, $A$, $X_{quiescent}$ and $N$. The errors on the predicted
X-ray flux are derived from the observed errors on the infrared flux.

The present infrared lightcurve is not well enough sampled to
determine all 3 parameters independently but, if $X_{quiescent}$ could
be determined precisely from other observations, then we could
determine $N$ to $\pm0.2$. Here $N$ varies from 0.5 for
$X_{quiescent}=0$ to 1.0 for $X_{quiescent}=23$ and 2.0 for
$X_{quiescent}=35$.  The minimum observed value of the total X-ray
count rate during the present observations was 35 count s$^{-1}$.
Hence as some part of those 35 count s$^{-1}$ almost certainly comes
from X-ray components which are not associated with the flaring
activity, eg a Seyfert-like nucleus or other parts of the jet, then
the maximum allowed value of $N$ is probably just below 2.  Typical
RXTE count rates outside of major flaring periods are in the range
20-25 counts s$^{-1}$ and fluxes observed by previous satellites (eg
see Turner \it et al.~\rm 1990) correspond to the same flux range. If that
count rate represents the true value of $X_{quiescent}$, then $N$ is
probably nearer unity, favouring EC models, or SSC or MC models in
which variations in the magnetic field strength play an important part
in flux variations.

\subsection{Implications of lightcurve modelling for lags}

Comparison of the best-fit predicted and observed X-ray fluxes reveals
that, in the first flare, the predicted fluxes exceed the observed
fluxes on the rise and the reverse is true on the fall.  A better fit,
at least for the first flare, occurs if the predicted lightcurve is
delayed by about a day (in other words, the observed IR leads the
X-rays).  We therefore introduced a variety of time shifts, $\delta
t$ above,
into the IR lightcurve, and also separately considered the first
and second flares, and refitted. We applied simple linear
interpolation to estimate the IR flux at the exact (shifted) time of
the X-ray observations.  The results are shown in
figure~\ref{fig:lagschi}.

When considering all of the IR data, we obtain a plot (top panel of
figure~\ref{fig:lagschi}) which is rather similar to the
cross-correlation plot (figure~\ref{fig:xcor}), which is not too
surprising as the analysis techniques are similar, although the
modelling in principle allows us to quantify the goodness of fit.
We are cautious of overinterpreting the above datasets and so, we
prefer to plot figure~\ref{fig:lagschi} in terms of raw $\chi^{2}$
rather than probabilities which might be taken too literally.  As in
many analyses where the errors are small, slight (real) differences in
data streams lead to low probabilities of agreement even though
overall agreement is very good. Here a minor variation in either
X-rays or IR from a region not associated with the flare could
provide that small difference. However the change in relative
goodness of fit can be easily seen from the $\chi^{2}$ plots.
When we consider separately the IR data from the first flare
(ie the 11 data points up to day 20 of 1997), or from the second flare
(the remaining 5 data points) we obtain much better fits. We find
that the first flare is best fitted if the IR leads the X-rays by
about 0.75 days.  We are again cautious in ascribing exact errors
to the lag but changes of $\delta \chi^{2}$ of 6.4, corresponding
to 40 per cent confidence, occur in the first flare at 0.25 days from
the minimum value. A lag of the X-rays by the IR by less
than 0.25 days is ruled out at the 99.97 per cent confidence level.
The more limited data of the second flare is, however,
best fitted by simultaneous IR and X-ray variations.

Again with caution, we note that Lawson \it et al.~\rm (in preparation) find
different X-ray spectral behaviour between the two flares. In the
first flare the spectrum hardens at the flare onset but, at the peak,
the spectrum is softer than the time averaged spectrum; in the second
flare the hardness tracks the flux quite closely with the hardest
emission corresponding to the peak flux. Thus there do appear to be
differences between the two flares. However whether the observed
differences are due to differences in, for example the physical
parameters of the emitting region (eg density, magnetic field
strength), the strength of any exciting shock, or the geometry of the
emitting regions, is not yet clear but is an interesting subject
for future investigations.

Although not really intended for such analysis, blind application of
Keith Horne's Maximum Entropy Echo Mapping software to the whole
dataset also leads to the conclusion that the IR leads the X-rays by
0.75 days (Horne, private communication).

As an example we show, in figure~\ref{fig:xpred}, the observed X-ray
lightcurve and the predicted lightcurve, based on parameters derived
from fitting to just the first flare with the IR leading by 0.75 days
(the best fit). We see that such a lag does not fit the second flare
well. In particular the predicted X-ray fluxes for the second flare
all lie above the observed fluxes by about 4 counts s$^{-1}$ and the
predicted fluxes now slightly lag (by about half a day) the observed
fluxes. One possible explanation of the excess is that $X_{quiescent}$
is lower during the second flare.  From our long term weekly
monitoring (in preparation) we note that the two flares shown here are
actually superposed on a slowly decreasing trend of the correct slope
to explain the excess. Inclusion of such a trend into our fitting
procedure does produce a slightly better fit for the overall dataset,
but the different lags between the first and second flare still
prevent a good overall fit from being obtained.  We therefore favour
the explanation that the long term lightcurve is actually made
up of a number of short timescale (week) flares, superposed on a more
slowly varying (months) `quiescent' component, rather than proposing
that the lightcurve is made up entirely of short flares, with no
underlying `quiescent' component.

\begin{figure}
\begin{center}
  \leavevmode
  \epsfxsize 1.0\hsize
  \epsffile{lagschi.ps}
\end{center}
\caption{
Results of comparing the observed X-ray lightcurve with that predicted
from the infrared variations, with all parameters allowed to remain
free apart from the X-ray/infrared lag. The numbers of degrees of
freedom are 13 (both flares), 8 (first flare) and 2 (second flare).
Note that it is impossible
to obtain a good fit to both X-ray flares simultaneously but acceptable
fits can be obtained to both fits individually. However the lags are
different for the two flares with the X-rays lagging the infrared by
$\sim0.75$ days in the first flare but the X-rays and infrared being
approximately simultaneous in the second flare.
}
\label{fig:lagschi}
\end{figure}

\begin{figure}
\begin{center}
  \leavevmode
  \epsfxsize 1.0\hsize
  \epsffile{xpredict.ps}
\end{center}
\caption{Observed X-ray lightcurve (histogram) and the best fit
predicted X-ray flux (filled squares) based on the parameters derived
from fitting the infrared observations to the first flare (11 data points)
only. The best-fit parameters are $A=0.47$, $N=0.98$ and $X_{quiescent}=22.1$.
Following from figure~\ref{fig:lagschi} the lead of the
IR over the observed X-rays is fixed at 0.75 days,
the best-fit value for the first flare.
The observed X-ray errorbars (see figure~\ref{fig:lcurves})
are not repeated here to avoid cluttering the diagram.
Note how the predicted X-ray fluxes for the second `flare' are then
systematically overestimated and also slightly lag the observed
X-ray fluxes.}
\label{fig:xpred}
\end{figure}

\subsection{The X-ray Emission Mechanism}

The similarity between the present infrared variations and those of
previous infrared variations where the whole IR to mm continuum varied
together (Robson \it et al.~\rm 1993), and the lack of any other likely source
of rapidly variable infrared radiation, means that the varying
component of the infrared flux is almost certainly synchrotron
radiation from the jet. The very strong correlation between the X-ray
and infrared lightcurves shows that the same electrons which produce
the infrared synchrotron emission must also produce the scattered
X-ray emission.  The original version of the EC
model (Dermer and Schlickeiser 1993)
in which the high energy variations are
caused by variations in the external seed photons is thus ruled out.
The next version, in which the electrons in the jet which produce the
infrared synchrotron emission also scatter an all-pervading ambient
nuclear photon field (Sikora, Begelman and Rees 1994)
is also ruled out, at least for the first flare,
as we would then expect exactly simultaneous  X-ray and
infrared variations.

The remaining possible emission mechanisms are the SSC process,
which must occur at some level, and the MC process. In the SSC process
we expect, for moderate variations such as those observed here where
the emission region probably remains optically thin, that the X-ray
flares will lag the IR flares (in the source frame) by approximately
the light travel time across the radius of the emission region. The lag is
because most photons will not be scattered where they
are produced but will typically travel the radius of the emission
region before being scattered.  In this model we can therefore deduce
the radius if we know the bulk Lorentz factor of the jet.
In the MC model the low energy photons also lead the high energy
photons, in this case by approximately the light travel time between
the emission region in the jet and the cloud.
If the cloud forms part of the broad line region we
might reasonably expect lags of order days.

The EC model is ruled out by the IR/X-ray lag but both the SSC and MC
models are consistent with the lag. The parameter $N$ is not yet well
defined but the present indications are that it is closer to 1 than to
2, which, for the SSC and MC models, implies that changes in magnetic
field strength are at least partially responsible for the observed
variations.  The MC compton scattered flux has a higher dependence on
the bulk Lorentz factor of the jet than does the SSC mechanism, but
that factor is very hard to measure.

\section{CONCLUSIONS}

We have demonstrated, for the first time, a strong relationship between
the X-ray emission and that in any other lower frequency band in
3C273.  We have shown that the IR and X-ray emission in 3C273 are very
strongly correlated. By means of a simple calculation we have shown that
each decade of the synchrotron spectrum from the cm to IR bands probably
contributes equally (at about 20 per cent per decade) to the Compton scattered
X-ray flux. Overall the lag between the IR and X-ray bands is very small
but, in at least the first flare, the IR
leads the X-ray emission by $\sim0.75\pm0.25$ days.
This lag rules out the EC model but is consistent with either the
SSC or MC model.

We have attempted to measure the parameter $N$ which determines the
relationship between the seed photon and Compton
scattered flux. The present data do not greatly constrain $N$ although
they indicate that 2 is the absolute upper limit and that a lower
value is probable. In terms of the SSC or MC models the implication is
that changes in the magnetic field strength are responsible for
at least part of the observed variations and, for  $N=1$, could
be responsible for all of the variations.

Because of their intrinsic similarity, the SSC and MC models
are hard to distinguish. However if it were possible to measure
IR/X-ray lags for a number of flares, of similar amplitude, in the
same source, then in the SSC model one would expect broadly similar
lags in each case, assuming that the emission comes from physically
similar emission regions. However in the MC model the reflecting
clouds will probably be at a variety of different distances and
so the lags should be different in each case.

We may also examine variations in optical and UV emission line
strength. If synchrotron radiation from the jet is irradiating
surrounding clouds (MC process), then we would expect the resultant
recombination line radiation to vary with similar amplitude to, and
simultaneously with, the synchrotron emission. However in
the SSC process we would expect no change in emission line
strength.

Further X-ray/IR observations with $\sim$few hour time resolution
are required to refine the lag found here and to determine whether
the lag is different in different flares.
\\

{\bf Acknowledgements} We are very pleased to thank the management and
operatonal staff of both RXTE and UKIRT for their cooperation in
scheduling and carrying out these observations.
We thank Keith Horne for running our data through his MEMECHO software.
IM$\rm ^{c}$H thanks PPARC for grant support
and APM was
supported in part by NASA Astrophysical Theory Grant NAG5-3839.