\section{Experiments}

\begin{table*
\small
\centering
\caption{MAP for different methods on FLICKR25K, CIFAR-10 and NUS-WIDE datasets.\label{tab:1}}
	\begin{tabular*}{1\textwidth}{@{\extracolsep{\fill}}l|cccc|cccc|cccc@{}}
		\hline
		& \multicolumn{4}{c|}{FLICKR25K} & \multicolumn{4}{c|}{CIFAR-10} & \multicolumn{4}{c}{NUS-WIDE} \\
		\hline
		Method & 16bits & 32bits & 64bits &128bits & 16bits & 32bits & 64bits &128bits & 16bits & 32bits & 64bits &128bits\\
		\hline
		SH & 0.6091 & 0.6105 & 0.6033 & 0.6014 & 0.1605 & 0.1583 & 0.1509 & 0.1538 & 0.4350 & 0.4129 & 0.4062 & 0.4100\\
		SpH & 0.6119 & 0.6315 & 0.6381 & 0.6451 & 0.1439 & 0.1665 & 0.1783 & 0.1840 & 0.4458 & 0.4537  & 0.4926 & 0.5000\\
		SGH & 0.6362 & 0.6283 & 0.6253 & 0.6206 & 0.1795 & 0.1827 & 0.1889 & 0.1904 & 0.4994 & 0.4869 & 0.4851 & 0.4945\\
		DeepBit &0.5934 & 0.5933 & 0.6199 & 0.6349 & 0.2204 & 0.2410 & 0.2521 & 0.2530 & 0.3844 & 0.4341 & 0.4461 & 0.4917\\
		SSDH & 0.7240 & 0.7276 & 0.7377 & 0.7343 & 0.2568 & 0.2560 & 0.2587 & 0.2601 & 0.6374 & 0.6768 & 0.6829 & 0.6831\\
		DistillHash & 0.6964 & 0.7056 & 0.7075 & 0.6995 & 0.2844& 0.2853 &0.2867 & 0.2895 & 0.6667&0.6752& 0.6769 & 0.6747\\
		CUDH & 0.7332 & 0.7426 & 0.7549 & 0.7561 & 0.2856&0.2903 &0.3025&0.3000&0.6996&0.7222&0.7451&0.7418\\
		MLS$^3$RDUH &0.7587 &0.7754 &0.7870 &0.7927 &0.2876 &0.2962 & 0.3139 &0.3117 &0.7056 &0.7384 &0.7629 &0.7818 \\

		DSG  &\textbf{0.7994} & \textbf{0.8172} & \textbf{0.8197} & \textbf{0.8245} & \textbf{0.3225} & \textbf{0.3241} & \textbf{0.3453} & \textbf{0.3450} & \textbf{0.7795} & \textbf{0.7981} & \textbf{0.8098} & \textbf{0.8187} \\
		\hline
	\end{tabular*}
\end{table*}

\begin{table*
\small
\centering
\caption{Ablation analysis on datasets FLICKR25K, CIFAR-10 and NUS-WIDE.\label{tab:2}}
		\begin{tabular*}{1\textwidth}{@{\extracolsep{\fill}}l|cccc|cccc|cccc@{}}
		\hline
		& \multicolumn{4}{c|}{FLICKR25K} & \multicolumn{4}{c|}{CIFAR-10} & \multicolumn{4}{c}{NUS-WIDE} \\
		\hline
		Method & 16bits & 32bits & 64bits &128bits & 16bits & 32bits & 64bits &128bits & 16bits & 32bits & 64bits &128bits\\
		\hline
		DSG-v2  & 0.6896 & 0.6570 & 0.6228 & 0.6178 & 0.2356 & 0.2099 & 0.1704 & 0.1567 & 0.6967 & 0.6736 & 0.6257 & 0.6062\\
		DSG-v1 & 0.7584 & 0.7432 & 0.7355& 0.7240 & 0.2612 & 0.2496 & 0.2441 & 0.1988 & 0.7632 & 0.7718 & 0.7719 & 0.7703\\
		DSG &\textbf{0.7994} & \textbf{0.8172} & \textbf{0.8197} & \textbf{0.8245} & \textbf{0.3225} & \textbf{0.3241} & \textbf{0.3453} & \textbf{0.3450} & \textbf{0.7795} & \textbf{0.7981} & \textbf{0.8098} & \textbf{0.8187} \\
		\hline
	\end{tabular*}
\end{table*}

We implement extensive experiments on three datasets to evaluate our DSG by comparing with several state-of-the-art unsupervised hashing methods.
\subsection{Datasets and Baselines}
CIFAR-10\cite{krizhevsky2009learning} is a dataset for image classification and retrieval, containing 60K images from 10 different categories. For each class, we randomly select 1,000 images as queries and 500 as training images, resulting in a query set containing 10,000 images and a training set made up of 5,000 images. All images except for the query set are used as the retrieval set.
\noindent NUS-WIDE\cite{chua2009nus} contains 269,648 images, each of the images is annotated with multiple labels referring to 81 concepts. The subset containing the 10 most popular concepts is used here. We randomly select 5,000 images as a test set; the remaining images are used as a retrieval set, and 5000 images are randomly selected from the retrieval set as the training set.
\noindent FLICKR25K\cite{huiskes2008mir} contains 25,000 images collected from the Flickr website. Each image is manually annotated with at least one of the 24 unique labels provided. We randomly select 2,000 images as a test set; the remaining images are used as a retrieval set, from which we randomly select 10,000 images as a training set.

Our method is compared with both traditional hashing methods and state-of-the-art unsupervised deep learning methods. Traditional methods includes SpH\cite{heo2012spherical}, DSH\cite{jin2013density} and SGH\cite{dai2017stochastic}. Deep unsupervised hashing methods includes DeepBits\cite{lin2016learning}, SSDH\cite{yang2018semantic}, DistillHash \cite{yang2019distillhash}, CUDH \cite{2019Clustering}, and MLS$^3$RUDH\cite{ijcai2020-479}.

\subsection{Implementation Details}
The framework is implemented by Pytorch V1.4. The mini-batch size is set to 24 and the momentum to 0.9. The learning rate is fixed at 0.001. The initial weights of the first seven layers of the neural network are from the model pre-trained with ImageNet, and the last fully-connected layer is learnt from scratch. The parameter $\alpha$ and $\beta$ are all set following \cite{yang2018semantic} and the threshold $t$ to $0.1$. The number of clusters is $70$.

\subsection{Evaluation}
The ground-truth similarity information for evaluation is constructed from the ground-truth image labels: two data points are considered similar if they share the same label (for CIFAR-10) or share at least one common label (for FLICKR25K and NUSWIDE).

The retrieval quality are evaluated by the following three evaluation metrics: Mean Average Precision (MAP), Precision-Recall curve and Top N precision curve.

MAP is a widely-used criteria to evaluate retrieval accuracy. Given a query and a list of $R$ ranked retrieval results, the average precision (AP) for the given query can be computed. MAP is defined as the average of APs for all queries. For datasets FLICKR25K and NUSWIDE, we set $R$ as $5000$ for the experiments. For CIFAR-10, $R$ is set as $50000$. Precision-recall curve reveals the precision at different recall levels and is a good indicator of overall performance. In addition, Top N precision curve, which is the precision curve with respect to the top $K$ retrieved instances, also visualizes the performance from a different perspective .
\subsection{Overall Performance and Ablation Study}

Table \ref{tab:1} shows the MAPs for different methods on three datasets with hash code lengths varying from 16 to 128. It can be seen that the performances of deep learning-based algorithms are overall better than traditional methods. For our proposed method, we find that DSG has a significant improvement over the state-of-the-art deep learning-based methods in all cases, which implies the superiority of our model. By comparing with MLS$^3$RUDH, which has the best performance of MAP among the deep hashing methods, DSG improves the MAP by 3.18\%, 3.33\% and 3.69\% for 128 bit length on datasets FLICKER25K, CIFAR-10 and NUS-WIDE respectively. We also find that the larger the bit length, the greater the improvement of DSG over other methods, which implies that DSG can generate more independent hash bits.

\begin{figure}
	\centering
	\subfigure[FLICKR25K]{
	\begin{minipage}{4cm}
	\centering
	\includegraphics[width=4cm]{topk_precision_flickr25k_128_100.png}
	\end{minipage}
	}
	\subfigure[CIFAR-10]{
	\begin{minipage}{4cm}
	\centering
		\includegraphics[width=4cm]{topk_precision_cifar-10_128_100.png}
	\end{minipage}
	}
	\subfigure[NUS-WIDE]{
	\begin{minipage}{4cm}
	\centering
		\includegraphics[width=4cm]{topk_precision_nus-wide_128_100.png}
	\end{minipage}
	}
	\subfigure[FLICKR25K]{
	\begin{minipage}{4cm}
	\centering
		\includegraphics[width=4cm]{precision_recall_flickr25k_128_100.png}
	\end{minipage}
	}
	\subfigure[CIFAR-10]{
	\begin{minipage}{4cm}
	\centering
		\includegraphics[width=4cm]{precision_recall_cifar-10_128_100.png}
	\end{minipage}
	}
	\subfigure[NUS-WIDE]{
	\begin{minipage}{4cm}
	\centering
		\includegraphics[width=4cm]{precision_recall_nus-wide_128_100.png}
	\end{minipage}
	}
\caption{(a), (b) and (c) are the Top N precision curves with code length 128 on FLICKR25K, CIFAR-10 and NUS-WIDE. (d) and (e) and (f) are the precision-recall curves with code length 128 on FLICKR25K, CIFAR-10 and NUS-WIDE.\label{fig:prc}}
\end{figure}

We also compare the performance of the DSG full model, the DSG model without the weight matrix $W_1$ , which is denoted as DSG-v1 and the DSG model without the weight matrix $W_1$ and the distilling matrix $W_2$, which is denoted as DSG-v2.
The results are shown in Table \ref{tab:2}. It is easy to find that DSG always achieves the highest MAPs, which implies that both the confidence information provided by the weight matrix $W_1$ and the global consistency that is ensured by the distilling matrix $W_2$ are necessary in our model. We can also find that DSG-v1 always outperforms DSG-v2, which proves that the clustering alone can help improve performance by removing contradictory similarity relationships between the pseudo-graph $S$ and the relationship matrix $C$.

For a more comprehensive comparison, we draw precision-recall curves and Top N precision curves for our method DSG and three state-of-art methods CUDH, SSDH and MLS$^3$RUDH with the hash code length of 128. Figure \ref{fig:prc} (a), (b) and (c) show the Top N precision curves of CUDH, DSG, SSDH and MLS$^3$RUDH on datasets FLICKR25K, CIFAR-10 and NUS-WIDE. It can be seen that DSG always has the highest precision among these four models and MLS$^3$RUDH always has the second-highest precision. Since the precision curves are based on the ranks of Hamming distance, DSG is able to achieve the highest recall if we directly use Hamming distance for retrieval. It's known that hash codes can also be used for coarse filtering in the form of hash table lookup; we also plot the precision-recall curves for these four models on the same datasets, which are shown in Figure \ref{fig:prc} (d), (e) and (f). It can be clearly seen that the curves of DSG are always on top of the other three models' curves, which implies that the hash codes obtained by DSG are also more suitable for the hash table lookup search strategy, which further demonstrates the superiority of our method.

\begin{figure}[h]
\centering
\includegraphics[width=3.6in]{Interest.png}
\caption{MAP w.r.t different numbers of clusters and threshold $t$ values with code length 128 on CIFAR-10.\label{fig:sen2}}
\end{figure}

\subsection{Parameter Sensitivity}

We further study the number of clusters $K$ and threshold $t$. Figure \ref{fig:sen2} shows the MAPs of different $K$ values ranging $[50,150]$ on the dataset CIFAR-10 with code length 128 and the MAPs of different threshold $t$ values ranging $[0.05,0.20]$ on the dataset CIFAR-10 with code length 128 as well. We find the MAP with the $K$ value of 100 is slightly lower than other $K$ values'. In general, DSG's performance with different $K$ values ranging $[50,150]$ is relatively stable, indicating that the model performance is not sensitive to different $K$ values ranging $[50,150]$. Furthermore, we show that the MAP decreases as the threshold $t$ is over $0.1$ with K fixed to $70$.
In addition, the performance of DSG with different $t$ ranging $[0.05, 0.1]$ is relatively stable, which indicates that the suitable interval for $t$ value is $[0.05, 0.1]$.
Accordingly, we set $K$ as $70$ and $t$ as $0.1$ in our other experiments as default.

\section{Introduction}
Deep learning-based hashing methods can be divided into supervised hashing and unsupervised hashing\cite{luo2020survey}. At the early stage, many researchers mainly focused on the supervised hashing methods, which utilize semantic labels to greatly improve the performance of image retrieval\cite{xia2014supervised}. However, supervised hashing methods are difficult to be applied in practice when there is not enough labeled data, especially when the domain is transferred. To solve this problem, several deep learning-based unsupervised methods were proposed, including deep binary descriptors (DeepBit)\cite{lin2016learning}, semantic structure-based unsupervised deep hashing (SSDH)\cite{yang2018semantic} and unsupervised deep hashing by distilling data pairs (DistillHash)\cite{yang2019distillhash}.

Although deep learning-based unsupervised hashing methods can be applied on unlabelled data, they still have evident limitations. \cite{hu2017pseudo} takes clustering information to generate pairwise pseudo-labels. SSDH further studies the deep feature statistics empirically from a pre-trained model and captures the semantic relationships across different data points. Specifically, it selects image pairs with confident pseudo-labels to guide the training of the model. Nevertheless, SSDH discards most image pairs which are hard to be decided whether they are semantically similar or dissimilar, which causes much information loss and thus limits the performance of the model in further image retrieval. In general, these methods only consider either the local information of similarity signals or the global information such as clustering labels but do not consider this task comprehensively.

To tackle the above issues, we propose a novel method, which comprehensively explores correlations among image pairs. First of all, for the correlation among different samples, we adopt the pre-trained deep convolutional neural network (CNN) to generate features for the input images. Then we compute the pairwise cosine distance and construct the similarity pseudo graph. We take all the image pairs into consideration. To alleviate the effect of wrong pseudo labels, different weights are assigned to image pairs according to the confidence of the pseudo labels. Furthermore, for the global robustness, we adopt clustering on the deep image features and then obtain another similarity graph. According to these two similarity graphs, image pairs with different correlation identification are considered contradictory and thus distilled. Finally, we design a deep neural network based on the distilled data pair set and adopt a deep learning framework to perform the deep representation and hash code learning simultaneously. Our main contributions can be summarized as follows:
\begin{itemize}
	\item We introduce two similarity graphs based on the local (i.e., pairwise cosine similarity) and global information (i.e., clustering) respectively and then obtain the ensemble similarity graph by distilling the contradictory pairs.
	\item We construct a priority loss function for similarity-preserving learning, which prioritizes confident image pairs over fuzzy image pairs based on their pairwise distance to learn deep representations smoothly.
	\item Experiments on three popular benchmark datasets show that our method DSG outperforms current state-of-the-art unsupervised hashing methods by a large margin.
\end{itemize}

\begin{figure*}
\centering
\includegraphics[width=16cm,keepaspectratio=true]{framework_yes.pdf}
\caption{The framework of our model. First, deep features of the dataset are extracted through the pre-trained VGG-F network. Second, the pseudo-graph $S$ and the smooth weight matrix $W_1$ are constructed based on the local information of the cosine distance distribution of deep features. Third, the relationship matrix $C$ is constructed based on the global information of the K-means clustering on deep features and the distilling matrix $W_2$ is obtained by comparing the relationship matrix $C$ with the pseudo-graph $S$. Lastly, iterations are done aiming to minimize the weighted $L_2$ loss for preserving similarity relationship of image pairs (i.e., Equation \ref{eq5}) by using the mini-batch stochastic gradient descent method.}
\label{fig:framwork}
\end{figure*}
\section{Method}
In the problem of deep unsupervised hashing, $\mathcal{X}=\{x_i\}_{i=1}^N$ denotes the training set with $N$ samples without label annotations, it aims to learn a hash function $$\mathcal{H}: x\rightarrow b \in\{-1,1\}^L,$$
where $x$ is the input sample and $b$ is a compact $L$-bit hash code.
It is noticed that $x_i\in \mathbb{R}^d$ is the normalized extracted deep feature for the $i$-th image through the pre-trained neural network by removing the last fully-connected layer. Here we use VGG-F\cite{simonyan2014very} to be consistent with other articles.

\subsection{Pseduo-Similarity Graph}

In our model, the pseudo-similarity graph is constructed firstly. The pseudo-similarity graph is used to capture pairwise similarity information from a local perspective. Based on the pre-trained deep feature $x_i $, the cosine distance between the i-th and the j-th samples can be computed by $d_{ij}= 1 - \frac{x_i\cdot x_j}{||x_i||_2||x_j||_2}$. We set a large threshold $t$, and consider data points with the cosine distance smaller than $t$ as potential similar and data points with the cosine distance larger than $t$ as potential dissimilar. Based on the threshold $t$, we construct the pseudo-graph $S$ as:

\begin{equation}\label{eq1}
    S_{ij}=\left\{
\begin{array}{ll}
 1 & d_{ij}\leq t,  \\
 -1 & d_{ij}> t
\end{array}\right.
\end{equation}

Where $S_{ij}$ is set to 1 if points $x_i$ and $x_j$ are potential similar, and -1 if points $x_i$ and $x_j$ are potential dissimilar.

\subsection{Smooth Weight Matrix}
Although pseudo-similarity graph is constructed, the semantic confidence of pseudo-label for each pair is different. In this section, we construct the weight matrix for the pseudo-graph based on the semantic confidence.

By observing the distribution of cosine distance for deep feature pairs, \cite{yang2018semantic} finds that each distance histogram is similar to two half Gaussian distributions, where $m_l$ and $\sigma_l$ denote the mean and the standard deviation of the first (left half) distribution and $m_r$ and $\sigma_r$ denote the mean and the standard deviation of the second (right half) distribution. Accordingly, we obtain two distance thresholds $d_l= m_l-\alpha \sigma_l $ and $d_r = m_r +\beta \sigma_r$, where the hyper-parameters $\alpha$ and $\beta$ control the values of the distance thresholds $d_l$ and $d_r$ respectively and dictate the percentage of similar points and dissimilar points from all data points respectively as well. According to the theory of confidence interval, the pairs with distances smaller than $d_l$ or larger than $d_r$ have confident semantic similarity information. As a result, we set the weights for confident pairs to 1.
Since the pairs with distance in the interval $[d_l,d_r]$ probably have no certain semantic information, we obtain the weight as:
\begin{equation}\label{eq:2}
    W_{1,ij}=\left\{
\begin{array}{ll}
 \frac{(t - d_{ij})^{2}}{(t - d_l)^{2}} & d_l < d_{ij}\leq t,  \\
 \frac{(d_{ij} - t)^{2}}{(d_r - t)^{2}} & t < d_{ij} < d_r, \\
 1 & d_{ij}\leq d_l \ or \ d_{ij}\geq d_r
\end{array}\right.
\end{equation}

From the equation, the weight for each image pair with the distance out of the interval is set to $1$ and the weight for each image pair with the distance in the interval is smaller if their distance is closer to the threshold in a quadratic form. In this way, all the image pairs are taken into consideration with the guidance of the smooth weight matrix. Accordingly, the confidence of their similarity relationship is guided by the smooth weight $W_1$.

\subsection{Pair Distilling based on clustering}
As we know, the obtained pseudo-label is very coarse. In this section, we try to use the clustering method to distill the pairs by removing contradictory results. To be specific, we first use the extracted features$\{x_i\}_{i=1}^N$ to construct a K-means clustering model. Based on the K-means clustering result, we construct a relationship matrix $C$:
\begin{equation}\label{eq3}
   C_{ij}=\left\{
\begin{array}{ll}
 1 & c_i = c_j,  \\
 -1 & c_i \neq c_j
\end{array}\right.
\end{equation}

where $c_i$ represents the label of the cluster that the data point $x_i$ belongs to. $c_i \in \{0, 1, ..., K\}$ and $K$ is the parameter that represents the number of clusters. By comparing the relationship matrix $C$ with the pseudo-graph $S$, we obtain the distilling matrix $W_2$ as:
\begin{equation}\label{eq4}
    W_{2,ij} = \left\{
\begin{array}{ll}
 1 & S_{ij} = C_{ij},  \\
 0 & S_{ij} \neq C_{ij}
\end{array}\right.
\end{equation}

in which $S_{ij} = C_{ij}$ means that the result of pseudo-graph and clustering for the pair $x_i$ and $x_j$ is consistent.

After setting the weight of contradictory pairs to zero, the final distilled weight matrix is obtained as $$W=W_1\odot W_2, $$ in which $\odot $ denotes the element-wise product of vectors.

\subsection{Hash code learning}
For the purpose of preserving the similarity relationship of data points, similar data points are expected to be mapped into similar hash codes and dissimilar data points are expected to be mapped into dissimilar hash codes. The similarity output $H_{N\times N}$ of hash codes is formulated as
\begin{equation}
H_{i j}=\frac{1}{L} \boldsymbol{b}_{i} \top \boldsymbol{b}_{j}, \quad \boldsymbol{b}_{i} \in\{-1,+1\}^{L}
\end{equation}
To preserve the obtained semantic structures, we minimize the weighted $L_2$ loss between the hash code similarity and the pseudo-graph. In formulation,
$$\mathcal{L}=\frac{1}{N^2}\sum_{i=1}^N\sum_{j=1}^NW_{ij}(H_{ij}-S_{ij})^2$$
in which $b_i = sign(F(x_i;\Theta))$ and $F(x_i;\Theta)$ denotes the output of the neural network, and $\Theta$ is the parameters. In this way, we can integrate the above loss function into the deep architecture. However, it is infeasible to train the neural network with binary outputs by the standard Back Propagation algorithm because of the ill-posed gradient problem. As a result, $tanh(\cdot)$ is utilized to relieve the binary constraint.
\begin{algorithm}
\caption{Training algorithm for our model}
\label{alg1}
\begin{algorithmic}[1]
\REQUIRE Training images $\mathcal{I}=\{I_{1}, \dots, I_{N}\}$;\\
\quad \ \ \ Number of clusters: $K$;\\
\quad \ \ \ Cosine distance threshold: $t$
\ENSURE Parameters $\Theta$ for the neural network;\\
\qquad\ Hash codes $B$ for training images.
\STATE Get deep features of $\mathcal{I}$ through VGG-F: $\mathcal{X} = \{x_1,\dots, x_N\}$.
\STATE Construct the pseudo-graph $S$ by Equation \ref{eq1}
\STATE Construct the weight matrix $W_1$ by Equation \ref{eq:2}
\STATE Cluster $\mathcal{X}$ into $K$ different groups by $K$-means. and construct the distilling matrix $W_2$ by Equation \ref{eq3}
\STATE Calculate distilled weight matrix $W$ by Equation \ref{eq4}
\REPEAT
\STATE Sample N points from $\mathcal{X}$ and then construct a mini-batch.
\STATE Calculate the outputs by forward-propagating through the network.
\STATE Update parameters of the VGG-F network by Back propagation by Equation \ref{eq5}
\UNTIL convergence
\end{algorithmic}
\end{algorithm}
Thus we adopt the following objective function:
\begin{equation}\label{eq5}
\begin{array}{c}\min _{\Theta} \mathcal{L}(\Theta)=\frac{1}{m^{2}} \sum_{i=1}^{m} \sum_{j=1}^{m}W_{ij}\left(H_{i j}-S_{i j}\right)^{2} \\ \\ \text {s.t.} \quad H_{i j}=\frac{1}{L} \boldsymbol{v}_{i} \top \boldsymbol{v}_{j}, \quad \boldsymbol{v}_{i}=\tanh \left(F\left(\boldsymbol{x}_{i} ; \Theta\right)\right)\end{array}
\end{equation}
in which $\boldsymbol{v}_i$ denotes the relaxed binary representation.

For the point $q_i$ not in the training set, its hash code $\boldsymbol{b}_i$ is obtained by directly forward propagating it through the learned neural network.
\begin{equation}
\boldsymbol{b}_{i}=\operatorname{sign}\left(F\left(\boldsymbol{q}_{i} ; \Theta\right)\right)
\end{equation}

\subsection{Optimization}
To optimize the problem, we construct the pseudo-graph $S$ from the pre-trained neural network by using Equation \ref{eq1}. Then the smooth weight matrix $W_1$ and the distilling matrix $W_2$ are constructed to get the distilled weight matrix $W$. Lastly, we minimize Equation \ref{eq5} by using the standard stochastic gradient descent (SGD) method. The whole learning procedure is summarized in Algorithm 1.

\section{Conclusion}
In this paper, we proposed Distilled Smooth Guidance (DSG) for deep unsupervised hashing. DSG not only considers local similarity signals but also considers the confidence of similarity signals from local structure for smoothness. What's more, global information is also explored and the image pairs are distilled by removing contradictory image pairs from two views for the purpose of accuracy. Numeric experiments demonstrates that DSG outperforms the existing state-of-the-art methods.

\bibliographystyle{IEEEtran}

\section{Related Work}
{\bf{Deep Supervised Hashing.}} Deep supervised hashing methods usually map the data points into Hamming space where the semantic similarities can be preserved by learning a deep neural network\cite{luo2020survey}. Typically, as the first supervised deep hashing method, CNNH\cite{xia2014supervised} splits the hash learning into two stages based on a convolutional neural network. Hash codes are learned on the first stage, a specific deep network is learned on the second stage to map the input samples to the learned hash codes. Deep Supervised Hashing\cite{liu2016deep} uses a loss function with product form based on the pairwise similarities and Hamming distances, which can be trained by the end-to-end back propagation algorithm.

\noindent {\bf{Deep Unsupervised Hashing.}}
Unsupervised deep hashing methods aim to turn unsupervised problems into supervised problems by constructing pseudo labels based on deep features. Semantic Structure-based Unsupervised Deep Hashing (SSDH)\cite{yang2018semantic} uses a specific truncated function on the pairwise distances and constructs the similarity matrices. DistillHash\cite{yang2019distillhash} improves the performance of SSDH by distilling the data pairs for confident similarity signals. MLS$^3$RDUH \cite{ijcai2020-479} utilizes the intrinsic manifold structure in feature space to reconstruct the local semantic similarity structure, and achieves the state-of-the-art performance.


\section{Introduction}\label{sec:intro}

	In this paper we deal with macroscopic and multi-scale modeling of traffic flow on a road network, focusing on multi-class dynamics which couple light and heavy vehicles (in the following, cars and trucks). The proposed models are characterized by the fact that cars and trucks interact with each other and that trucks are confined in a part of the road space (slow lane) and cannot overtake. As a consequence, when trucks saturate the space and form a queue, cars can still move, although at reduced speed.

	\paragraph{State of the art.} The literature about traffic flow is very large and many different aspects of traffic dynamics were described through mathematical models.
	Let us start from classic approaches:
	in a single-lane \textit{microscopic} (agent-based) framework with $N$ vehicles and no overtaking, each vehicle $k\in\{1,\ldots,N\}$ is singularly identified by its position $X_k(t)$ and its velocity $V_k(t)$.
	By assumption, the $(k+1)$-th vehicle is always in front of the $k$-th one.
	Also, each vehicle is assumed to adjust its acceleration based on the difference in positions and velocities between the vehicle itself and the vehicle in front of it.
	This approach leads to the following system of ordinary differential equations:
	\begin{equation}\label{FtL}
	\left\{
	\begin{array}{ll}
	\dot X_k=V_k \\ [2mm]
	\dot V_k=A(X_k,X_{k+1},V_k,V_{k+1})
	\end{array}, \quad k=1,\ldots,N-1
	\right.
	\end{equation}
	where $A$ is a given acceleration function. The first vehicle in the row ($k=N$), called \emph{leader}, has an independent dynamics.
	Since the whole dynamics is determined by the leader's one in a domino effect, these kind of models are known as Follow-the-Leader.

	Adopting instead a \textit{macroscopic} (fluid-dynamics) point of view, we describe the mass of vehicles by means of its density $\rho(x,t)$ only. The celebrated LWR model \cite{lighthill1955PRSLA, richards1956OR} is based on the observation that the density $\rho$ evolves in time ruled by the following conservation law
	\begin{equation}\label{LWR}
	\partial_t\rho + \partial_x f(\rho)=0,\qquad x\in\mathbb R, \quad t>0
	\end{equation}
	where the function $f(\rho)$, called \emph{fundamental diagram}, is given and represents the flux of vehicles as a function of the density itself.
	The velocity of the vehicles can be recovered from $\rho$ thanks to the relation
	\begin{equation}\label{f=rhov}
	v(\rho)=\frac{f(\rho)}{\rho}, \qquad (\rho\neq 0).
	\end{equation}

	It is important to note that the microscopic model \eqref{FtL} is second-order, i.e.\ acceleration based, while the macroscopic model \eqref{LWR} is first-order, i.e.\ velocity based.
	The difference is important because velocity based models, allowing nonphysical instantaneous accelerations, are not able to catch effects caused by inertia, like stop \& go waves.
	Due to this difference, it is plain that the model \eqref{LWR} is \emph{not} the many-particle limit of the model \eqref{FtL}.
	We refer the interested reader to the paper \cite{cristiani2019DCDS-B} for a review of various many-particle limits (i.e.\ micro-to-macro correspondences) and the existing multi-scale models.

	\medskip

	A first generalization of the models \eqref{FtL} and \eqref{LWR} is that of \emph{road networks}. While managing junctions in microscopic models is relatively easy, doing the same in a macroscopic setting is more challenging. The reason is that, in general, the conservation of the mass alone is not sufficient to characterize a unique solution at junctions.
	We refer the reader to the book by Garavello and Piccoli \cite{piccolibook} for more details about the ill-posedness of the problem at junctions. Multiple workarounds for such ill-posedness have been suggested in the literature:
	(i) maximization of the flux across junctions and introduction of priorities among the incoming roads \cite{coclite2005SIMA, piccolibook, holden1995SIMA};
	(ii) introduction of a \emph{buffer} to model the junctions by means of additional ordinary differential equation coupled with \eqref{LWR} \cite{bressan2015NHM, garavello2012DCDS-A, herty2009NHM};
	(iii) reformulation of the problem on all possible paths on the network rather than on roads and junctions. The last approach has both a global formulation \cite{bretti2014DCDS-S, briani2014NHM, hilliges1995TRB} and a more manageable local formulation, described in \cite{briani2018CMS}, which is the one we will adopt in this paper.
	All these approaches allow to determine a unique solution for the traffic evolution on the network, but the solutions might be different.

	A second generalization of our interest is that of \emph{multi-class} dynamics. ``Multi-class'' is a very generic term used in literature to refer to the case in which the road is populated by different groups of vehicles/drivers, and tracking each group separately is desired.
	Again, doing this in a microscopic framework is easy since it is sufficient to label each vehicle on the basis of the class it belongs to.
	In the macroscopic setting, instead, we need to introduce as many density functions as there are classes, and then establish the interactions between classes. This leads to a system of conservation laws of the form
	\begin{equation}\label{LWRmc}
	\partial_t \rho_c+ \partial_x f_c(\rho_1,\ldots,\rho_C)=0,\qquad c=1,\ldots,C, \quad x\in\mathbb R, \quad t>0
	\end{equation}
	where $C$ is the number of classes, $c\in\{1,\ldots,C\}$, $\rho_c$ is the density of class $c$, and $f_c$ is the flux of class $c$ which depends of all densities (usually the dependence is on the sum of all densities $\sum_c\rho_c$).
	Multi-class models are used to describe very different situations, like the co-presence of vehicles with
	\begin{itemize}
		\item different driving modes (e.g.\ autonomous vs.\ classic);
		\item different origins and destinations;
		\item different length (i.e.\ space occupied);
		\item different velocity/flux function;
		\item reserved roads or reserved entry/exit lanes.
	\end{itemize}
	A complete review of multi-class models is out of the scope of this paper. We refer to the papers \cite{fan2015SIAP, kessels2016TRR, qian2017TRB} and to the recent books \cite{ferrarabook, kesselsbook} for an overview of the most used multi-class models.

	Before introducing our contributions, let us introduce the \emph{creeping or seepage effect} \cite{fan2015SIAP, agarwal2016TDE} which will be useful to describe the features of the proposed models. This term denotes the situations where the road space is shared by small and large vehicles, and small vehicles are able to move (at reduced velocity) even if large vehicles have reached the maximal density.
	This is in contrast with classical models like the one proposed by Benzoni-Gavage and Colombo \cite{benzoni2003EJAM}, in which the saturation of a class of vehicles stops immediately all the other classes.
	It is useful to note that the creeping phenomenon is typically considered in a context of \emph{disordered traffic}, i.e.\ a traffic with no lane discipline: smaller vehicles (e.g., two wheels) slip into the empty spaces left by large vehicles, similarly to a motion through porous media.
	This is not the case considered here, since we assume a strict lane discipline.

	Finally let us recall some important contributions about the fundamental diagram and its properties. It is well known that a single function $f=f(\rho)$ is not able alone to describe real data correctly. Indeed, by \eqref{f=rhov} we deduce that for any given density value $\rho$ only one velocity $v(\rho)$ is possible.
	This is not what happens in reality, where a scattered fundamental diagram is observed instead, due to the fact that different drivers respond in a different way to the same traffic conditions.
	Many papers investigated this phenomenon from different points of view, trying to explain its features, including instabilities; see, e.g., \cite{balzotti2021NHM, fan2013TRR, fan2014NHM, klar2004SIAP, herty2012KRM, ni2018AMM, paipuri2020TRB, puppo2016CMS, tosin2017MMS, wang2013JAT, CGARZ}.

	\paragraph{Case study.}
	In this paper we consider the Italian motorway A4 Trieste-Venice and its branches to/from Udine, Pordenone and Gorizia, managed by Autovie Venete S.p.A., see Fig.\ \ref{fig:reteAV}.
	%
	\begin{figure}[h!]
		\widefigure
		\includegraphics[width=12cm]{figure_dati/reteAV}
		\caption{The Italian motorway A4 Trieste-Venice and its branches to/from Udine, Pordenone and Gorizia, managed by Autovie Venete S.p.A.}
		\label{fig:reteAV}
	\end{figure}
	%
	\rev{At the time of the present study (2019), the motorway had two lanes per direction, except for the leftmost segment near Venice (Venice -- San Don\`a). To avoid heterogeneous conditions, we have dropped the three-lane segment of the road to focus exclusively on the parts with \emph{two lanes per direction}.}
	In those segments, cars can use both lanes at any time, while trucks can use only the slow lane and cannot overtake. Due to the large flow of heavy vehicles, it happens some times that a queue of trucks is formed.
	In this case, cars move into the fast lane and keep going, although at moderate speed.
	When traffic conditions are sustained, the two classes of vehicles interact with each other: on the one hand, trucks act as moving bottlenecks for cars (cf.\ \cite{bretti2018MiE}), which are forced to slow down due to the restricted space;
	on the other hand, trucks must slow down when cars find it convenient to occupy part of the slow lane.

	\paragraph{Our contribution.}
	In this paper we propose two models for describing multi-class traffic flow on networks in which vehicles belonging to different classes share the road space only partially. More precisely, light vehicles can occupy the whole road, while heavy vehicles only a part of it.
	To align with the case study, we will assume that the road has two lanes in total and trucks can occupy only the slow one, without overtaking.
	\begin{enumerate}
		\item The first model is purely macroscopic. Both cars and truck are described by two coupled first-order LWR-based models. Fundamental diagrams are shaped in order to allow cars to move even in presence of fully congested trucks.
		Considering that the fundamental diagram of each class is influenced by the presence of the other class, in case of unstable (rapidly varying) traffic conditions of one class we observe a scattered behavior in the fundamental diagram of the other class.
		Numerical results will show that this feature allows the model to catch, at least in part, some second-order (inertial) phenomena in traffic behavior, like stop \& go waves.
		%
		\item The second model is multi-scale. Cars are described by a first-order LWR-based model, while trucks are described by a second-order microscopic Follow-the-Leader model.
		For trucks, we consider the microscopic model used in \cite{cristiani2019DCDS-B}, inspired, in turn, by a model originally proposed in \cite{zhao2017TRB} and specifically designed to reproduce  stop \& go waves.
		The choice of second-order model for trucks is crucial, since inertia effects are not at all negligible for those vehicles, while they are less important in car dynamics.
		Finally note that, since trucks are confined in only one lane and cannot overtake, their dynamics perfectly matches the constituting assumptions of the Follow-the-Leader model.
	\end{enumerate}
		Let us finally mention that the idea of coupling first- and second-order models was already exploited in \cite{cristiani2019DCDS-B} in a single-class scenario.

	\begin{Remark}
	Both models distinguish classes, but not lanes. The fact that trucks cannot use the fast lane while cars can occupy both slow and fast lanes is encapsulated in the choice of the fundamental diagrams.
	\end{Remark}

	\section{Dataset}\label{sec:data}
	 Autovie Venete constantly monitors traffic conditions by means of video cameras, mobile sensors, and fixed sensors. \rev{In this paper we focus on the latest kind of data}.
	 Fixed sensors are located along the motorway, on each lane, and measure flux and velocity of all vehicles passing in front of them, distinguishing also the class of vehicles.
	 Data are aggregated per minute and are stored in a data base for later analysis.
	 \rev{For light vehicles, we have further aggregated data coming from slow and fast lanes.
	 For heavy vehicles, instead, we have considered the slow lane only.}
	 In Figs.\ \ref{fig:weeklyflux}--\ref{fig:creepingfluxvel} we show some flux and velocity data coming from some fixed sensors, used to conceive and calibrate the models  presented in this paper. For better readability, flux data are plotted both raw (as is) and smoothed by a Gaussian filter. \rev{Note that the flux data is always a multiple of 60 since it is evaluated every minute but it is expressed in terms of vehicles per hour.}
	 %
	 \begin{figure}[h!]
	 	\subfig{a}\includegraphics[width=12cm]{figure_dati/flux_week_light_new.pdf}\\  [2mm]
	 	\subfig{b}\includegraphics[width=12cm]{figure_dati/flux_week_heavy_new.pdf}
	 	\caption{Typical weekly (from Monday to Sunday) flux data on the A4 motorway of \subfig{a} light and \subfig{b} heavy vehicles \rev{collected on March 2019 near Redipuglia}. Smoothed data are plotted in black. Note the flux drop of cars in the middle of the day and of trucks in the weekend.}
	 	\label{fig:weeklyflux}
	 \end{figure}
  	%
  	 \begin{figure}[h!]
 		\subfig{a}\includegraphics[width=6cm]{figure_dati/normal_flux_cars_new.pdf}
 		\subfig{b}\includegraphics[width=6cm]{figure_dati/normal_flux_trucks_new.pdf}\\  [2mm]
 		\subfig{c}\includegraphics[width=6cm]{figure_dati/normal_vel_cars.pdf}
 		\subfig{d}\includegraphics[width=6cm]{figure_dati/normal_vel_trucks.pdf}
 		\caption{Typical daily (Thursday) flux and velocity data on the A28 motorway of \subfig{a}-\subfig{c} light and \subfig{b}-\subfig{d} heavy vehicles \rev{collected on May 2019 near Sesto al Reghena}.}
 		\label{fig:normalfluxvel}
 	\end{figure}
	%
	\begin{figure}[h!]
		\subfig{a}\includegraphics[width=6cm]{figure_dati/creeping_flux_cars_new.pdf}
		\subfig{b}\includegraphics[width=6cm]{figure_dati/creeping_flux_trucks_new.pdf}\\ [2mm]
		\subfig{c}\includegraphics[width=6cm]{figure_dati/creeping_vel_cars.pdf}
		\subfig{d}\includegraphics[width=6cm]{figure_dati/creeping_vel_trucks.pdf}
		\caption{Creeping phenomenon \rev{registered on May 2019 near Portogruaro}: \subfig{a} Light vehicles move in the fast lane even if \subfig{b} heavy vehicles queue in the slow lane. \subfig{c} Light vehicles' velocity drops from $\sim$140 km/h to $\sim$60 km/h and then to $\sim$20 km/h while \subfig{d} heavy vehicles are completely stopped.}
		\label{fig:creepingfluxvel}
	\end{figure}

	\section{Models}\label{sec:models}

	In this section we present the two models. As already stated in the Introduction, the models are not meant to give the same results or to be one the many-particle limit of the other.
	Nevertheless, they share the most important constitutive assumptions and for this reason they are expected to give the same qualitative results.
	The most important common modeling assumption is that the car dynamics is influenced at any time by the presence of trucks, while the truck dynamics is affected by cars only if the density of cars exceed a certain threshold, which corresponds to the fact that cars cannot be confined in the fast lane any longer and must invade the slow lane where trucks live.
	This assumption comes from an important evidence: cars tend to avoid to be trapped between two trucks in the slow lane, and prefer moving to the fast lane. Doing this, cars move to the side of trucks (overtaking them if possible) and do not affect their dynamics, unless the density of cars is so high that they must necessarily occupy the slow lane too.

	\subsection{Macroscopic model}\label{sec:mama_model}
	We denote by $\ell_\textsc{l}$ and by $\ell_\textsc{h}$ the average length of  light vehicles (cars) and heavy vehicles (trucks), respectively, and we define
	\begin{equation}\label{eq:beta}
	\beta := \frac{\ell_\textsc{l}}{\ell_\textsc{h}}<1.
	\end{equation}
	We also denote by $\rho_\textsc{l}$ the density of cars and by $\rho_\textsc{h}$ the density of trucks.
	Similarly, we denote by $\rhoL^{\text{max}}$ and $\rhoP^{\text{max}}$ the maximal densities for cars and trucks, respectively.
	\rev{They are defined as
		\begin{equation}\label{def_rhomax}
			\rhoL^{\text{max}} = \frac{2}{\ell_\textsc{l}}
			\quad\mbox{ and }\quad
			\rhoP^{\text{max}} = \frac{1}{\ell_\textsc{h}},
		\end{equation}
		having assumed that there are two available lanes for cars and only one for trucks.
	Note that density values are expressed in terms of number of vehicles per unit of space}. Considering that trucks occupy more space than cars, a direct comparison of the two densities is not meaningful. For this reason the two classes are typically compared in terms of occupied space.

	The two-class dynamics is physically admissible if the two densities fall in the set
	\begin{equation}\label{eq:dominio}
	\mathcal{D}:=\left\{(\rho_\textsc{l},\rho_\textsc{h}) :  0\leq \rho_\textsc{l}\leq \rhoL^{\text{max}},\ 0\leq \rho_\textsc{h}\leq \rhoP^{\text{max}},\  0\leq \rho_\textsc{l}+\frac{\rho_\textsc{h}}{\beta}\leq \rhoL^{\text{max}}\right\},
	\end{equation}
	which is well defined if $\rhoL^{\text{max}}-\frac{\rhoP^{\text{max}}}{\beta}\geq 0$.
	In the following, in order to cope with the uneven space occupancy, we assume that the last condition is verified with the strict inequality,
	\begin{equation}\label{eq:DensCondstretta}
	\rhoL^{\text{max}}-\frac{\rhoP^{\text{max}}}{\beta} > 0.
	\end{equation}

	We consider the following two-class model for
	$(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}$,
	\begin{equation}\label{eq:model}
	\begin{cases}
	\partial_t\rho_\textsc{l} + \partial_x f_{\leg}(\rho_\textsc{l},\rho_\textsc{h}) =\, 0
	\smallskip\\
	\partial_t \rho_\textsc{h} + \partial_x f_{\pes}(\rho_\textsc{l},\rho_\textsc{h}) =\, 0
	\end{cases}
	\qquad x\in\mathbb R,\quad t>0,
	\end{equation}
	where
	$$
	f_\leg(\rho_\textsc{l},\rho_\textsc{h}):=\rho_\textsc{l} v_	\leg(\rho_\textsc{l},\rho_\textsc{h}),
	\qquad
	f_\pes(\rho_\textsc{l},\rho_\textsc{h}):=\rho_\textsc{h} v_\pes(\rho_\textsc{l},\rho_\textsc{h})
	$$
	define the two fundamental diagrams and $v_\leg$, $v_\pes$ are the speed functions for light and heavy vehicles, respectively.
	We then have a family of flow-density curves $\rho_\textsc{l}\mapsto f_\leg(\rho_\textsc{l},\rho_\textsc{h})$ for cars, parameterized by the trucks density $\rho_\textsc{h}$, and analogously a family of flow-density curves $\rho_\textsc{h}\mapsto f_\pes(\rho_\textsc{l},\rho_\textsc{h})$ for trucks, parameterized by $\rho_\textsc{l}$.

	We assume that the flux and speed functions satisfy the following properties:
	\begin{enumerate}[label=(L\arabic*)]
		\item $v_{\leg}(\rho_\textsc{l},\rho_\textsc{h}) \geq 0$ for all $(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}$ and  $v_\leg(\rho_\textsc{l},\rho_\textsc{h}) = 0$ iff $\rho_\textsc{l} = \rho^*_\textsc{l}(\rho_\textsc{h})$, where
		\begin{equation}\label{eq:RhoMax}
		\rho^*_\textsc{l}(\rho_\textsc{h}) := \rhoL^{\text{max}} - \rho_\textsc{h}/\beta
		\end{equation}
		is the maximum admissible cars density given the trucks density $\rho_\textsc{h}$;
		\item $v_\leg(\rho_\textsc{l},\rho_\textsc{h})$ is a decreasing function with respect to $\rho_\textsc{l}$ and $\rho_\textsc{h}$;

		%
		\item $f_\leg(0,\rho_\textsc{h}) = 0$ and $f_\leg(\rho^*_\textsc{l}(\rho_\textsc{h}),\rho_\textsc{h}) = 0$ for all $\rho_\textsc{h}\in[0,\rhoP^{\text{max}}]$;
		%
		\item $f_\leg(\rho_\textsc{l},\rho_\textsc{h})$ is concave with respect to $\rho_\textsc{l}$ for any $\rho_\textsc{h}$.
		We define
		\begin{equation}
		\sigma_\leg(\rho_\textsc{h}):=\arg\max_{\rho_\textsc{l}} f_\leg(\rho_\textsc{l},\rho_\textsc{h})
		\end{equation}
		which represents as usual the interface between freeflow and congested regimes;
		%
		\item $f_\leg(\rho_\textsc{l},\rho_\textsc{h})$ is a decreasing function with respect to $\rho_\textsc{h}$ for any $\rho_\textsc{l}$.
	\end{enumerate}

	Similarly,
	\begin{enumerate}[label=(H\arabic*)]
		\item $v_{\pes}(\rho_\textsc{l},\rho_\textsc{h}) \geq 0$ for all $(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}$ and $v_\pes(\rho_\textsc{l},\rho_\textsc{h}) = 0$ iff $\rho_\textsc{h} = \rho^*_\textsc{h}(\rho_\textsc{l})$, where
		\begin{equation}\label{eq:MuMax}
		\rho^*_\textsc{h}(\rho_\textsc{l}) := \min\left\{\rhoP^{\text{max}}, \beta(\rhoL^{\text{max}} - \rho_\textsc{l}) \right\}
		\end{equation}
		is the maximum admissible trucks density given the cars density $\rho_\textsc{l}$;
		%
		\item $v_\pes(\rho_\textsc{l},\rho_\textsc{h})$ is a decreasing function with respect to $\rho_\textsc{l}$ and $\rho_\textsc{h}$;
		%
		\item $f_\pes(\rho_\textsc{l},0) = 0$ and $f_\pes(\rho_\textsc{l},\rho^*_\textsc{h}(\rho_\textsc{l})) = 0$ for all $\rho_\textsc{l}\in[0,\rhoL^{\text{max}}]$;
		%
		\item $f_\pes(\rho_\textsc{l},\rho_\textsc{h})$ is concave with respect to $\rho_\textsc{h}$ for any $\rho_\textsc{l}$. We define
		\begin{equation}
		\sigma_\pes(\rho_\textsc{l}):=\arg\max_{\rho_\textsc{h}} f_\pes(\rho_\textsc{l},\rho_\textsc{h})
		\end{equation}
		which represents as usual the interface between freeflow and congested regimes;
		%
		\item $f_\pes(\rho_\textsc{l},\rho_\textsc{h})$ is a decreasing function with respect to $\rho_\textsc{l}$ for any $\rho_\textsc{h}$.
	\end{enumerate}

	\medskip

	To cope with the peculiarities of the dynamics, we consider a \emph{phase transition} (\rev{cf.\ }\cite{colombo2002SIAP, colombo2010JHDE, dellemonache2021AX}) caused by the presence of two states of the system:
	\begin{itemize}
		\item The \emph{partial-coupling phase} is in place when
		\begin{equation}
		(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}_1:=\Big\{0\leq\rho_\textsc{h}\leq\rhoP^{\text{max}}, \ 0\leq\rho_\textsc{l}\leq \rhoL^{\text{max}}-\rhoP^{\text{max}}/\beta\Big\},
		\end{equation}
		see Fig.\ \ref{fig:dominio_MaMa}.
		%
		\begin{figure}[h!]
			\begin{overpic}
				[width=0.7\columnwidth]{figure_maya/dominio_MaMa}
				\put(17,30){partial}  \put(17,25){coupling}
				\put(27,15){$\mathcal{D}_1$}   \put(57,15){$\mathcal{D}_2$}
				\put(52,30){full}  \put(52,25){coupling}
				\put(44,20){\rotatebox{90}{\small transition level}}
				\put(80,5){$\rhoL^{\text{max}}$}
				\put(5,60){$\rhoP^{\text{max}}$}
			\end{overpic}
			\caption{Domains $\mathcal{D}_1$ and $\mathcal{D}_2$ of the macroscopic model \eqref{eq:model}.}
			\label{fig:dominio_MaMa}
		\end{figure}

		In this phase we assume that cars are mainly in the fast lane and do not affect the trucks dynamics. Trucks are then independent from cars.

		 For trucks we choose a triangular fundamental diagram with
		\begin{equation}\label{eq:HeavyVel_PC}
		v_\pes(\rho_\textsc{h}) = V_\pes^\text{max} \quad \mbox{ for all } \quad \rho_\textsc{h}\leq \sigma_\pes,
		\end{equation}
		 where
		 $V_\pes^\text{max}$ is the maximum speed of trucks, see Fig.\ \ref{fig:Vel_PCphase}\subfig{b}.

		 Cars do not interfere with trucks but adapt their dynamics to the presence of them.

		 Also for cars we choose a (family of) triangular fundamental diagrams, see Fig.\ \ref{fig:Vel_PCphase}\subfig{a}.
		 \rev{Specifically, we set
	\begin{equation}\label{eq:LightVel}
		v_\leg(\rho_\textsc{l},\rho_\textsc{h}) =
		\left\{\begin{array}{lcl}
			 V^*_\textsc{l}(\rho_\textsc{h}) & \mbox{ if } & \rho_\textsc{l}\leq\sigma_\leg(\rho_\textsc{h}),
			\bigskip\\
			\displaystyle
			\frac{V^*_\textsc{l}(\rho_\textsc{h})\ \sigma_\leg(\rho_\textsc{h})} {\rho^*_\textsc{l}(\rho_\textsc{h})-\sigma_\leg(\rho_\textsc{h})}
			\left(\frac{\rho^*_\textsc{l}(\rho_\textsc{h})}{\rho_\textsc{l}}-1\right)& \mbox{ if } & \sigma_\leg(\rho_\textsc{h}) < \rho_\textsc{l}\leq\rhoL^{\text{max}}-\rhoP^{\text{max}}/\beta,
		\end{array}\right.
	\end{equation}
	where $V^*_\textsc{l}(\rho_\textsc{h})$ is the maximum speed of cars given the truck density. We also define $V^*_\textsc{l}(0)=V_\leg^\text{max}$ as the maximum speed of cars in absence of trucks.
	Then, $V^*_\textsc{l}(\rho_\textsc{h})\geq 0$ and $\sigma_\leg(\rho_\textsc{h})\geq 0$ are continuous linear decreasing functions of $\rho_\textsc{h}$.
		 }

		For $(\rho_\textsc{l},\rho_\textsc{h}) \in \mathcal{D}_1$ the model \eqref{eq:model} then becomes
		\begin{equation}\label{eq:model_PC}
		\begin{cases}
		\partial_t\rho_\textsc{l} + \partial_x f_\leg(\rho_\textsc{l},\rho_\textsc{h})=\, 0
		\smallskip\\
		\partial_t \rho_\textsc{h} + \partial_xf_\pes(\rho_\textsc{h})=\, 0
		\end{cases}
		\end{equation}
		where $f_\leg(\rho_\textsc{l},\rho_\textsc{h})=\rho_\textsc{l} v_\leg(\rho_\textsc{l},\rho_\textsc{h})$ and $f_\pes(\rho_\textsc{h})=\rho_\textsc{h} v_\pes(\rho_\textsc{h})$ as described in Fig.\ \ref{fig:Vel_PCphase}.
		%
		\begin{figure}[h!]
			\subfig{a}
			\begin{overpic}
			[width=6cm]{figure_maya/fL_MaMa_pc.pdf}
			\put(50,47){\rotatebox{90}{\tiny transition level}}
			\end{overpic}
			\subfig{b}\includegraphics[width=6cm]{figure_maya/fH_MaMa_pc.pdf}
			\caption{Fundamental diagrams of the macroscopic model in the partial-coupling phase, i.e.\ $(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}_1$.}
			\label{fig:Vel_PCphase}
		\end{figure}
		\item The \emph{full-coupling phase} is in place when $(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}_2:=\mathcal{D}\backslash\mathcal{D}_1$,

		see Fig.\ \ref{fig:dominio_MaMa}.
		In this case, we assume that cars are too much to find it convenient to be confined in the fast lane. For this reason they invade the slow lane, thus influencing the dynamics of trucks. The two equations in system \eqref{eq:model} are then fully coupled.

		As before, we choose for both classes a family of triangular fundamental diagrams which extend by continuity those defined in $\mathcal{D}_1$, as shown in Fig.\ \ref{fig:Vel_FCphase}.
		%
		\begin{figure}[h!]
			\subfig{a}
			\begin{overpic}
				[width=6cm]{figure_maya/fL_MaMa_fc.pdf}
				\put(50,47){\rotatebox{90}{\tiny transition level}}
			\end{overpic}
			\subfig{b}\includegraphics[width=6cm]{figure_maya/fH_MaMa_fc.pdf}
			\caption{Fundamental diagrams of the macroscopic model in the fully-coupling phase, i.e.\ $(\rho_\textsc{l},\rho_\textsc{h})\in\mathcal{D}_2$.}
			\label{fig:Vel_FCphase}
		\end{figure}
	\end{itemize}
\medskip

	\noindent We define the \emph{transition level} the threshold density of light vehicles which act as interface between the two phases, see Fig.\ \ref{fig:dominio_MaMa}.
	In our setting trucks are confined in one of the two available lanes, then the transition level is equal to $\rhoL^{\text{max}}-\rhoP^{\text{max}}/\beta=\rhoL^{\text{max}}/2$.

	Note also that the fundamental diagrams we use in this work verify all the properties (L1)--(L5) and (H1)--(H5).

	\subsection{Multi-scale model}\label{sec:mima_model}

	In this section we describe the multi-scale model. Here cars are described by a first-order LWR model of type \eqref{LWR} and trucks are described by a second-order microscopic Follow-the-Leader model of type \eqref{FtL}.
	Let us describe the microscopic model first, dropping for the moment the coupling with light vehicles.

	\subsubsection{Microscopic model for heavy vehicles}

	The microscopic model is the one presented in \cite{cristiani2019DCDS-B}, which is, in turn, inspired by the model originally proposed by Zhao and Zhang in \cite{zhao2017TRB}.

	In the following we denote by $\Delta_k$ the gap between truck $k$ and truck $k+1$ at any time $t$,
	$$
	\Delta_k(t):=X_{k+1}(t)-X_k(t).
	$$
	It is plain that this gap is inversely proportional to the density of heavy vehicles

	We define in \eqref{FtL}
	\begin{equation}\label{def:Acinese}
		A\big(X_k,X_{k+1},V_k,V_{k+1}\big)=
		\left\{
		\begin{array}{ll}
		\frac{1}{\tau_\text{acc}}\Big(v^\textsc{zz}(\Delta_k)-V_k\Big), & \text{ if\ \ } v^\textsc{zz}(\Delta_k)\geq V_k \\
		\frac{1}{\tau_\text{dec}}\Big(v^\textsc{zz}(\Delta_k)-V_k\Big), & \text{ if\ \ } v^\textsc{zz}(\Delta_k)<V_k
		\end{array}
		\right.
	\end{equation}
	where the function $v^\textsc{zz}$ represents the equilibrium velocity all drivers tend to, and depends on the gap $\Delta_k$.
	Parameters $\tau_\text{acc},\tau_\text{dec}>0$ are the relaxation times as usual, differentiated for the acceleration and the deceleration phase. Diversifying the relaxation times appeared to be crucial to fit real data.

	The velocity function $v^\textsc{zz}$ is defined by

	\begin{equation}\label{def:vZZ}
		v^\textsc{zz}(\Delta):=\left\{
		\begin{array}{ll}
			0, & \text{ if\ \ }\Delta\leq \Delta_\text{close} \\ [2mm]
			\frac{V_\textsc{h}^\text{max}}{\Delta_\text{far}-\Delta_\text{close}}(\Delta-\Delta_\text{close}), & \text{ if\ \ } \Delta_\text{close}<\Delta< \Delta_\text{far}\\ [3mm]
			V_\pes^\text{max}, & \text{ if\ \ }\Delta\geq \Delta_\text{far}
		\end{array}
		\right.
	\end{equation}
	where $\Delta_\text{close}$, $\Delta_\text{far}$, $V_\pes^\text{max}$ are positive parameters, see Fig.\ \ref{fig:vZZ}.
	%
	\begin{figure}[h!]
	\begin{overpic}
		[width=6cm]{figure_emi/VZZ_continuous}
		\put(15,5){$\Delta_\text{close}$}
		\put(65,5){$\Delta_\text{far}$}
		\put(-15,80){$V_\pes^\text{max}$}
	\end{overpic}
	\caption{The shape of the velocity function $v^\textsc{zz}(\Delta)$ defined in \eqref{def:vZZ}.}
	\label{fig:vZZ}
	\end{figure}
	%

	The plateau in $\Delta\in[0,\Delta_\text{close}]$ is crucial for correctly reproducing stop \& go waves. Indeed, once the relaxation times $\tau_\text{acc}$, $\tau_\text{dec}$ are fixed, the capability of the model to trigger stop \& go waves is ruled precisely by $\Delta_\text{close}$.

	\subsubsection{Full model}
	First of all, given a parameter $\delta>0$, we assume that cars located at $x$ are influenced by a truck iff the distance between the truck and $x$ is less than $\delta$.
	We denote the number of trucks falling in the road interval $[x-\delta,x+\delta)$ at any time $t$ by
	\begin{equation}\label{def:Nh}
		N^\delta_\pes(x,t):=\#\{k:X_k(t)\in[x-\delta,x+\delta)\}.
	\end{equation}

	Second, we denote by $\rho_\textsc{l}$ the density of light vehicles and $v_\leg$ their velocity. To couple the dynamics of the two classes we assume that $v_\leg$ depends on both $\rho_\textsc{l}$ (as in the classical LWR model) and $N^\delta_\pes$. As usual we assume that $v_\leg$ is decreasing with respect to both arguments.

	Finally, we couple the dynamics of heavy vehicles with those of light vehicles.
	The interaction is obtained by introducing the dependence on $\rho_\textsc{l}$ in the parameters $\Delta_\text{close}$  and $\Delta_\text{far} $.
	More precisely, we introduce the increasing functions
	$\Delta_\text{close}  =\Delta_\text{close}(\rho_\textsc{l})$ and $\Delta_\text{far}=\Delta_\text{far}(\rho_\textsc{l})$
	and we denote by $A^\textsc{c}=A^\textsc{c}(X_k,X_{k+1},V_k,V_{k+1},\rho_\textsc{l})$ the coupled acceleration defined as $A$ in \eqref{def:Acinese}--\eqref{def:vZZ}, with the new dependence on $\rho_\textsc{l}$.

	We are now ready to present the fully coupled multi-scale model which reads as
	\begin{equation}\label{multiscalemodel}
	\left\{
	\begin{array}{l}
	\left\{
	\begin{array}{l}
	\dot X_k=V_k \\ [2mm]
	\dot V_k=A^\textsc{c}(X_k,X_{k+1},V_k,V_{k+1},\rho_\textsc{l})
	\end{array}, \qquad  k=1,\ldots,N-1
	\right.
	\\ [5mm]
	\partial_t\rho_\textsc{l}+\partial_x\Big(\rho_\textsc{l} v_\leg(\rho_\textsc{l},N^\delta_\pes)\Big)=0,\qquad x\in\mathbb R,\quad t>0.
	\end{array}
	\right.
	\end{equation}
	To be coherent with our modeling assumptions, the functions $\Delta_\text{close}$ and $\Delta_\text{far}$ are constant for cars densities below the transition level, i.e.\ $\rho_\textsc{l}\leq\rhoL^{\text{max}}/2$. In this case the dynamics of trucks is independent from those of cars.
	Conversely, for $\rho_\textsc{l}>\rhoL^{\text{max}}/2$, we assume that the distances $\Delta_\text{close}$ and $\Delta_\text{far}$ increase linearly with respect to the average number of cars which are positioned between two trucks. This number can be easily computed considering the average number of cars in a road segment of length $\ell$ (equal to $\rho_\textsc{l}\ell$) and the number of trucks in the same road segment (assuming that all vehicles are uniformly distributed).
	We were unable to precisely calibrate the shape of the functions $\Delta_\text{close}$ and $\Delta_\text{far}$ from real data because it happens rarely that many cars are found between trucks: indeed, trucks tend to ``push'' cars in the fast lane rather than reacting to their presence.

	\subsection{Extension of the models to general road networks}\label{sec:generalizations}
	In order to perform a complete simulation on a generic network of highways, some important generalizations are needed.

	\subsubsection{Any number of lanes}\label{sec:generalizations-lanes}
	Highways have often more than two lanes. Consider a road with $n$ lanes of which $n_\pes$ can be occupied by trucks. To allow the creeping phenomenon, we assume that $n_\pes<n$, which corresponds to $\rhoL^{\text{max}}\ell_\textsc{l}-\rhoP^{\text{max}}\ell_\textsc{h}>0$ in terms of space occupied, cf.\ \eqref{eq:DensCondstretta}.

	In the macroscopic approach the model is easy generalized. Fundamental diagrams are modified in such a way that trucks start interacting with cars when the density of cars becomes greater than $\frac{n_\pes}{n} \rhoL^{\text{max}}$.

	In the microscopic model instead, an important modification is needed if $n_\pes>1$. Indeed, in this case trucks can overtake and the microscopic model must be able to handle this. Typically, some new parameters are introduced in order to establish when a truck decides to overtake and if the truck can actually overtake, considering suitable safety constraints.
	From the computational point of view, an additional difficulty arises when one has to find the truck in front of any other truck, since the ordering is lost whenever a truck overtakes.
	To make the search of the preceding vehicle computationally feasible, one can keep track, in a specific list, of all trucks located in each numerical cell, and then update the list whenever a truck leaves or enter the cell.

	\subsubsection{Junctions}\label{sec:generalizations-junctions}
	In order to perform a full simulation on a network of highways both theoretical and numerical treatment of junctions are needed. Typically highways have not roundabouts, traffic lights or complex junctions, so we can limit ourself to handle simple merge (2 incoming roads and 1 outgoing road) and diverge (1 incoming road and 2 outgoing roads).
	We have adopted the approach detailed in \cite{briani2018CMS}, in which the dynamics is reformulated along paths and junctions ``disappears''.
	The price to pay is that the number of equations is multiplied by the number of possible paths the drivers can follow at junctions. In both merge and diverge, we have only two possible paths: for example, in the case of the diverge, one can choose among the first and the second outgoing road, while in a merge one can decide to come from the first or the second incoming road.

	Following this approach in the macroscopic model, the densities of each class of vehicles are split around every junction, ending up with a system of four conservation laws (two paths for each of the two classes of vehicles) with discontinuous flux.
	After the junctions, densities are gathered together again and the two-equation system \eqref{eq:model} is restored.

	In the multi-scale model instead, the path-based approach is applied only for cars dynamics since managing trucks is much simpler. Indeed, in the microscopic model one can just move vehicles from one road to another on the basis of their destination, see \cite{cristiani2016NHM}.
	Unfortunately, the ordering of trucks is lost every time a change of road takes place.
	In order to reduce the computational effort need for the computation of the preceding truck of every truck, the same solution proposed in Sect.\ \ref{sec:generalizations-lanes} can be applied.

	\section{Numerical approximation and calibration}\label{sec:implementation}
	In this section we describe how the models introduced above can be actually implemented. First, we briefly recall the numerical methods we have adopted, then we describe how we have used real data to set the models' parameters.

		\subsection{Macroscopic model}\label{sec:numerics_mama}
		For the numerical approximation of the macroscopic model \eqref{eq:model} we employ the extension of the \textit{cell transmission model} (CTM) to heterogeneous multi-class model proposed in \cite{fan2015SIAP}.
		Let $\Delta x$ and $\Delta t$ be the space and time step respectively, and $(\rho_\textsc{l}^{n,i},\rho_\textsc{h}^{n,i})$ the traffic densities in the $i$th cell at the $n$th time step.
		The finite volume numerical scheme reads
		%
			\begin{subequations}\label{eq:num2classes}
			\begin{empheq}[left=\empheqlbrace]{align}
			\hspace{3mm} \rho_\textsc{l}^{n+1,i}=\rho_\textsc{l}^{n,i} + \frac{\Delta t}{\Delta x}\left(\mathcal{F}_\textsc{l}^{n,i-1/2} -\mathcal{F}_\textsc{l}^{n,i+1/2}\right) \label{eq:num2classes_cars}\\
			\hspace{3mm} \rho_\textsc{h}^{n+1,i}=\rho_\textsc{h}^{n,i} + \frac{\Delta t}{\Delta x}\left(\mathcal{F}_\textsc{h}^{n,i-1/2} -\mathcal{F}_\textsc{h}^{n,i+1/2}\right) \label{eq:num2classes_trucks}
			\end{empheq}
		\end{subequations}
		%
		where
		\begin{equation}\label{eq:num_flux2classes_cars}
		\mathcal{F}^{n,i+1/2}_{\leg} := \min\Big\{S_{\leg}(\rho_\textsc{l}^{n,i},\rho_\textsc{h}^{n,i}),R_{\leg}(\rho_\textsc{l}^{n,i+1},\rho_\textsc{h}^{n,i+1})\Big\},
		\end{equation}
		\begin{equation}\label{eq:num_flux2classes_trucks}
		\mathcal{F}^{n,i+1/2}_{\pes} := \min\Big\{S_{\pes}(\rho_\textsc{l}^{n,i},\rho_\textsc{h}^{n,i}),R_{\pes}(\rho_\textsc{l}^{n,i+1},\rho_\textsc{h}^{n,i+1})\Big\},
		\end{equation}
		and $(S_\textsc{l}, R_\textsc{l})$, $(S_\textsc{h}, R_\textsc{h})$ represent the sending and receiving functions of the two vehicles classes respectively, defined by
		\begin{equation}\label{eq:SR1}
		\begin{array}{c}
		S_\textsc{l}(\rho_\textsc{l},\rho_\textsc{h}):=\left\{\begin{array}{lr}
		f_\leg(\rho_\textsc{l},\rho_\textsc{h}), &\mbox{if } \rho_\textsc{l} \leq \sigma_\leg(\rho_\textsc{h}),
		\smallskip\\
		f_\leg(\sigma_\leg(\rho_\textsc{h}),\rho_\textsc{h}), &\mbox{if } \rho_\textsc{l} > \sigma_\leg(\rho_\textsc{h}),
		\end{array}\right.
		\medskip\\
		R_\textsc{l}(\rho_\textsc{l},\rho_\textsc{h}):=\left\{\begin{array}{lr}
		f_\leg(\sigma_\leg(\rho_\textsc{h}),\rho_\textsc{h}), &\mbox{if } \rho_\textsc{l} \leq \sigma_\leg(\rho_\textsc{h}),
		\smallskip\\
		f_\leg(\rho_\textsc{l},\rho_\textsc{h}), &\mbox{if } \rho_\textsc{l} > \sigma_\leg(\rho_\textsc{h}),
		\end{array}\right.
		\end{array}
		\end{equation}
		and similarly for $(S_\textsc{h},R_\textsc{h})$.

		The numerical grid is chosen as $\Delta x$=100 m and $\Delta t$=2.6 s.
		\rev{The choice of the space step comes from the fact that the company Autovie Venete finds such granularity convenient to share traffic information to drivers, while the time step is dictated by the CFL condition.}

		\medskip

		Calibration of the fundamental diagrams was performed by fitting real data. We used all data measured in 2019 by one fixed sensor located near Cessalto, see Figs.\ \ref{fig:Calib_MaMa_cars}-\ref{fig:Calib_MaMa_trucks}.

		Note that for high densities, the velocities drop rapidly to zero. Since we have no data for completely stationary vehicles under the sensor, we are not able to reconstruct data on high traffic density.
		For this reason, the maximal densities $\rhoL^{\text{max}}$ and $\rhoP^{\text{max}}$ are estimated by simply computing the ratio between the number of available lanes for the class and the average length of vehicles of that class, see Eq.\ \eqref{def_rhomax}.

		Model parameters are summarized in Table \ref{tab:Calib_param_MaMa}. All functions which rule the dependence of $\rho, v, f$ on the density of the other class are linear.
	%
	\begin{figure}[h!]
		\subfig{a}\includegraphics[width=6cm]{figure_maya/Calib_MaMa_1.pdf}
		\subfig{b}\includegraphics[width=6cm]{figure_maya/Calib_MaMa_2.pdf}
		\caption{\subfig{a} Flux-density and \subfig{b} velocity-density relationships for cars with real data superimposed.}
		\label{fig:Calib_MaMa_cars}
	\end{figure}
	%
	\begin{figure}[h!]
		\subfig{a}\includegraphics[width=6cm]{figure_maya/Calib_MaMa_4.pdf}
		\subfig{b}\includegraphics[width=6cm]{figure_maya/Calib_MaMa_3.pdf}
		\caption{\subfig{a} Flux-density and \subfig{b} velocity-density relationships for trucks with real data superimposed.}
		\label{fig:Calib_MaMa_trucks}
	\end{figure}
	%
	\begin{specialtable}[h!]
	\caption{Parameters for the macroscopic model.}
	\label{tab:Calib_param_MaMa}
	\small
	\begin{tabular}{lll}\toprule
		& Light vehicles & Heavy vehicles  \\ \midrule
		veh.\ length + safety dist.\ (km) &  $7.5\cdot 10^{-3}$ & $18\cdot 10^{-3}$  \\ \hline
		max max density (veh/km) & $\rho^*_\textsc{l}(0) = 267$ & $\rho^*_\textsc{h}(0) = 56$ \\ \hline
		min max density (veh/km)  & $\rho^*_\textsc{l}(\rhoP^{\text{max}}) = 133$ & $\rho^*_\textsc{h}(\rhoL^{\text{max}}) = 0$ \\ \hline
		%
		max max speed (km/h)  & $v_\leg(0,0) = 130$ & $v_\pes(0,0) = 90$\\ \hline
		min max speed (km/h) & $v_\leg(0,\rhoP^{\text{max}}) = 65$ & $v_\pes(\rhoL^{\text{max}},0) = 0$\\ \hline
		%
		max max flux (veh/h) & $f_\leg(\sigma_\leg(0),0) = 4200$ & $f_\pes(0,\sigma_\pes(0)) = 1500$ \\ \hline
		min max flux (veh/h) & $f_\leg(\sigma_\leg(\rhoP^{\text{max}}),\rhoP^{\text{max}}) = 1200$ & $f_\pes(\rhoL^{\text{max}},\sigma_\pes(\rhoL^{\text{max}})) = 0$
		\\\bottomrule
	\end{tabular}
	\end{specialtable}

	\subsection{Multi-scale model}
	For the numerical approximation of the macroscopic part of the multi-scale model \eqref{multiscalemodel} we employ again the scheme \eqref{eq:num2classes_cars}, where $N_\pes^\delta$ plays the role of $\rho_\pes$ in the obvious manner.
	Numerical grid is chosen as $\Delta x$=100 m and $\Delta t$=2 s.

	The dependence of the flux on $N_\pes^\delta$ can generate some issues. For example, consider the case of no trucks and  a car density $\hat\rho_\leg$ close to $\rhoL^{\text{max}}$.
	When a truck enters the road, the maximal density allowed in the cell occupied by the truck drops to $\rho^*_\textsc{l}(N^\delta_\pes)$ according to \eqref{eq:RhoMax}.
	Now, if $\rho^*_\textsc{l}(N^\delta_\pes)<\hat\rho_\leg$, the current density $\hat\rho_\leg$ is found not to be compatible with the new maximal density.
	Although the entering truck perceives the cars, it is not guaranteed that the compatibility with the maximal density is respected at any time.
	To avoid this problem, trucks must be prevented from entering cells if the new maximal density caused by the presence of the truck itself is not compatible with current traffic conditions.

	For the numerical approximation of the microscopic part we used a standard Euler scheme with a time step $\delta t$= 0.1 s. Note that this time step is much smaller than the time step $\Delta t$ used for the Godunov scheme, meaning that the updates of the trucks and cars are asynchronous.

	\medskip

	Regarding the parameters, the macroscopic part of the model is treated as in Section \ref{sec:numerics_mama} (Table \ref{tab:Calib_param_MaMa}).
	For the microscopic model, some parameters are easily calibrated by using real data and considering physical constraints.
	For example $V_\pes^\text{max}$ was defined as in the macroscopic model.

	$\Delta_\text{far}$ was set in order to guarantee that trucks do not collide even in the event that a truck suddenly brakes with full power until it stops (note that our model allows in principle collisions since deceleration is bounded).
	$\Delta_\text{close}$, instead, was set to a distance which guarantees to catch the maximal observed density of trucks. In other words, when a queue of trucks is formed, the model predicts the correct maximal density.

	Parameters $\tau_\text{acc}$ and $\tau_\text{dec}$ are instead more difficult to calibrate since they are not easily measurable.
	For those values, we considered a real stop \& go wave observed by the company staff on June 12, 2017, generated by the slowdown of a truck near a bottleneck. \rev{The initial perturbation (slowdown) was amplified and in short time generated a queue which propagated backwards. We have run the microscopic  model using real inflow data as left boundary conditions, then we have fitted the parameters in order to catch the real queue as measured on the field}, see Fig.\ \ref{fig:calibrazione_tau}.
	%
	\begin{figure}[h!]
		\includegraphics[width=11cm]{figure_emi/calibrazione_tau.pdf}
		\caption{\rev{Simulated trajectories obtained with real inflow data as left boundary conditions} (not all vehicles are plotted for visualization purposes). Horizontal blue lines and vertical black lines indicate, respectively, the position and the duration of the real queue as measured on the field.}
		\label{fig:calibrazione_tau}
	\end{figure}

    The role of the parameters $\tau_\text{acc}$ and $\tau_\text{dec}$ is to adjust the points/times of start and end of the queue.
   \rev{We have noted a strong sensitivity of the model to those parameters. As a consequence, it is quite difficult to catch the correct speed of the backward propagation of a queue when the inertia comes into play.}
	We summarize the values of the parameters in Table \ref{tab:parametri_mima}.
	%
	\begin{specialtable}[h!]
		\caption{Parameters for the microscopic model.}
		\label{tab:parametri_mima}
		\begin{tabular}{lcl}\toprule
			$\delta$ & $50\times 10^{-3}$ & km \\ \hline
			$\Delta_\text{close}$ & $25\times 10^{-3}$ & km \\ \hline
			$\Delta_\text{far}$ & $50\times 10^{-3}$ & km \\ \hline
			$V_\pes^\text{max}$ & $90$ & km/h \\ \hline

			$\tau_\text{dec}$ & $2\times 10^{-4}$ & h \\ \hline
			$\tau_\text{acc}$ & $1.4\times 10^{-2}$ & h
			\\\bottomrule
		\end{tabular}
	\end{specialtable}
	%

	%

	\section{Numerical results}\label{sec:numericaltests}
	In this section we present the numerical results obtained with the models \eqref{eq:model} and \eqref{multiscalemodel}.

	\subsection{Macroscopic model}\label{sec:mamatests}
	Here we present three tests which highlight how the macroscopic model reproduces some interesting phenomena arising from the coupled dynamics of cars and trucks. In particular we focus on the creeping phenomenon, the shared occupancy and the stop \& go waves.

		\subsubsection{Test 1A: creeping}\label{sec:T1mama}
		In this simple test we observe the creeping phenomenon, see Fig.\ \ref{fig:T1maya}.
		The simulation starts with a constant density $(\rho_\textsc{l},\rho_\textsc{h})=(10,13)$ veh/km all along the road. At the end of the road (right boundary), trucks are stopped by fixing their density at its maximum value $\rhoP^{\text{max}}=56$:
		a queue of trucks is propagating backward from the end of the road while a constant flux of cars approaches the beginning of the queue.
		Once cars reach the trucks' queue they have to slow down but do not stop completely. More precisely, the cars' velocity drops to 65 km/h.
		Note that cars density remains under the transition level and then the dynamics is in the partial-coupling phase all the time. Moreover, cars are always in the freeflow regime and then move at maximal speed, but the maximal speed changes as a function of the trucks' density.
		%
		\begin{figure}[h!]
		\subfig{a}\includegraphics[width=.45\linewidth]{figure_maya/Test1_MaMa_dens.pdf}
		\subfig{b}\includegraphics[width=.45\linewidth]{figure_maya/Test1_MaMa_vel.pdf}		\subfig{c}\includegraphics[width=.48\linewidth]{figure_maya/Test1_MaMa_densAuto.pdf}
		\subfig{d}\includegraphics[width=.48\linewidth]{figure_maya/Test1_MaMa_densCamion.pdf}
		\caption{Test 1A: \subfig{a} Density and \subfig{b} velocity of light and heavy vehicles as a function of space at final time. \subfig{c} Density of light and \subfig{d} heavy vehicles in the space-time.}
		\label{fig:T1maya}
		\end{figure}

		\subsubsection{Test 2A: cars congestion affects truck dynamics}\label{sec:T2mama}
		In this test we observe the effect of a congestion of cars, see Fig.\ \ref{fig:T2maya}.
		The simulation starts with a constant density $(\rho_\textsc{l},\rho_\textsc{h})=(10,8)$ veh/km all along the road. At the end of the road (right boundary), the density of cars is fixed to 186 veh/km to create the slowdown.
		Car density is larger than the transition level, then cars have to invade the slow lane.
		Trucks facing cars congestion slow down but do not just occupy the space left to them by cars; rather, they conquer some extra space, thus decreasing the car density. As a result, both cars and trucks proceed slowly without stopping, and the initial cars congestion propagates backward with a density lower than the transition level.
\begin{figure}[h!]

	\subfig{a}\includegraphics[width=.45\linewidth]{figure_maya/Test2_MaMa_dens.pdf}
	\subfig{b}\includegraphics[width=.45\linewidth]{figure_maya/Test2_MaMa_vel.pdf}
	\subfig{c}\includegraphics[width=.48\linewidth]{figure_maya/Test2_MaMa_densAuto.pdf}
	\subfig{d}\includegraphics[width=.48\linewidth]{figure_maya/Test2_MaMa_densCamion.pdf}
	\caption{Test 2A: \subfig{a} Density and \subfig{b} velocity of light and heavy vehicles as a function of space at final time. \subfig{c} Density of light and \subfig{d} heavy vehicles in the space-time.}
	\label{fig:T2maya}
\end{figure}

\subsubsection{Test 3A: stop \& go wave}\label{sec:T3mama}
In this test we study the evolution of a small perturbation in the trucks density, see Fig.\ \ref{fig:T3maya}.
At initial time the trucks density is constant and equal to 12 veh/km except for a small perturbation at the end of the road where the density is equal to 30 veh/km. Cars density instead oscillates just above the transition level.
It is plain that a single-class LWR model for trucks only would flatten the perturbation in short time. Conversely, in this case the coupling with cars dynamics makes the perturbation propagate backward without vanishing. This second-order-like effect is obtained thanks to the fact that the fundamental diagram of trucks is continuously modified by the oscillating cars density.
\begin{figure}[h!]
	\subfig{a}\includegraphics[width=.45\linewidth]{figure_maya/Test3_MaMa_dens.pdf}
	\subfig{b}\includegraphics[width=.45\linewidth]{figure_maya/Test3_MaMa_vel.pdf}
	\subfig{c}\includegraphics[width=.48\linewidth]{figure_maya/Test3_MaMa_densAuto.pdf}
	\subfig{d}\includegraphics[width=.48\linewidth]{figure_maya/Test3_MaMa_densCamion.pdf}
	\caption{Test 3A: \subfig{a} Density and \subfig{b} velocity of light and heavy vehicles as a function of space at $t=\Delta t$ (i.e.\ just after the initial time).
		\subfig{c} Density of light and \subfig{d} heavy vehicles in the space-time. It is perfectly visible the evolution of the initial perturbation of trucks density starting at km 9, which creates, in turn, a perturbation of cars density.
	}
	\label{fig:T3maya}
\end{figure}
	\subsection{Multi-scale model}\label{sec:mimatests}
	Here we replicate, with the multi-scale model, the first two scenarios already investigated in Section \ref{sec:mamatests}. The third scenario was already considered in Fig.\ \ref{fig:calibrazione_tau} where the second-order microscopic model is able to reproduce stop \& go waves alone, without  the need to couple cars dynamics.
	Finally we consider the case of a merge.

	\subsubsection{Test 1B: creeping effect}\label{sec:T1mima}
	As in Test 1A in Section \ref{sec:T1mama}, here one truck stops completely and creates a long queue of trucks behind, which saturates the slow lane. When cars reach the trucks queue, they all move to the fast lane keeping moving at (the new, reduced) maximal velocity of 65 km/h, see Fig.\ \ref{fig:T1emi}.
	%
	\begin{figure}[h!]
		\subfig{a}\includegraphics[width=.45\linewidth]{figure_emi/T1_mima_trucks_new.pdf}
		\subfig{b}\includegraphics[width=.482\linewidth]{figure_emi/T1_mima_cars_new.pdf}
		\caption{Test 1B:
			\subfig{a} Trajectories of trucks in the space-time (for visualization purposes not all trucks are actually plotted). When the first truck stops, a queue is formed behind.
			\subfig{b} Cars density, cars velocity, and cars maximal density given the number of trucks at final time. Creeping is visible between km 7 and km 9.
		}
		\label{fig:T1emi}
	\end{figure}

	\subsubsection{Test 2B: cars congestion affects truck dynamics}\label{sec:T2mima}
	As in Test 2A in Section \ref{sec:T2mama}, a congestion of cars at the end of the road slows down trucks, see Fig.\ \ref{fig:T2emi}.
	Results are similar to those obtained by the macroscopic but here trucks stop completely, forming a queue.
	%
	\begin{figure}[h!]
		\subfig{a}\includegraphics[width=.45\linewidth]{figure_emi/T2_mima_trucks_new.pdf}
		\subfig{b}\includegraphics[width=.482\linewidth]{figure_emi/T2_mima_cars_new.pdf}
		\caption{Test 2B:
			\subfig{a} Trajectories of trucks in the space-time (for visualization purposes not all trucks are actually plotted). They stop for a while then accelerate.
			\subfig{b} Cars density, cars velocity, and cars maximal density given the number of trucks at final time.
		}
		\label{fig:T2emi}
	\end{figure}

	\subsubsection{\rev{Test 3B: merge}}\label{sec:T3mima}
	In this test we consider a merge (2 incoming roads and 1 outgoing road). At time $t=0$ the three roads are empty. A constant inflow of trucks (1 every 4 s) comes from the left boundary of both incoming roads, while a constant density of cars ($\rho_\textsc{l}=32$)  is imposed as Dirichlet left boundary condition on the second incoming road only. The first incoming road has no cars.
	When trucks reach the junction and merge, they suddenly break and rapidly form a queue which propagates backward along both incoming roads, see Fig.\ \ref{fig:T3emi}(\textbf{a},\textbf{b}).
	%
	\begin{figure}[h!]
		\subfig{a}\includegraphics[width=.295\linewidth]{figure_emi/T3_mima_trucks_inc1.pdf}
		\subfig{b}\includegraphics[width=.295\linewidth]{figure_emi/T3_mima_trucks_inc2.pdf}
		\subfig{c}\includegraphics[width=.295\linewidth]{figure_emi/T3_mima_trucks_out.pdf}\\
		\subfig{d}\includegraphics[width=.47\linewidth]{figure_emi/T3_mima_cars_inc2.pdf}	 		\subfig{e}\includegraphics[width=.47\linewidth]{figure_emi/T3_mima_cars_out.pdf}
		\caption{Test 3B:
			(\textbf{a},\textbf{b},\textbf{c}) Trajectories of trucks in the space-time on the first incoming road, second incoming road and outgoing road, respectively (for visualization purposes not all trucks are actually plotted).
			(\textbf{d},\textbf{e}) Cars density on  second incoming road and outgoing road, respectively.
		}
		\label{fig:T3emi}
	\end{figure}
  %
  Queues are not identical due to the presence of cars along the second incoming road.
  One can note that when the trucks downstream of the queue start moving again, their flux is not maximal: indeed, if the flow were maximum, a queue at the junction would immediately reform as it happened in the first place.
  This is the well known \emph{capacity drop} phenomenon, ruled by $\tau_\text{acc}$, cf.\ \cite{calvert2018JTTE}.
  As a consequence, trucks are able to cross the junction without spillback.
  Cars, instead, move at maximal flux until they encounter the trucks queue. The queue acts as a moving bottleneck and drops the road capacity, therefore the car traffic immediately enters the congested state and the density increases. Downstream, the density remains in the free flow state and cars cross the junction without spillback, see Fig.\ \ref{fig:T3emi}(\textbf{d},\textbf{e}).

	\section{Conclusions and future work}\label{sec:conclusions}
	In this paper we have presented two models for two-class traffic flow.
	Although models are tailored for a specific case study, they are sufficiently general to be useful in other motorways.
	Moreover, both models can be easily generalized to more than two classes of vehicles and a different ratio between the number of lanes used by trucks and  the number of lanes used by cars.

	We have shown that the models are able to reproduce both qualitatively and quantitatively some notable traffic phenomena arising from the interactions of the two classes.
	Interestingly, the macroscopic model, although purely first-order, is able to reproduce stop \& go waves thanks to the coupling of the two classes.

	After this preliminary analysis, it is possible to sketch some conclusions about advantages and drawbacks of the two models:
	the multi-scale model has a greater potential since the second-order microscopic part makes it more realistic and then suitable for quantitative predictions. Nevertheless, the macroscopic model appears to be simpler and more manageable, thus representing a valid alternative if one wants to avoid tracking all single vehicles, especially for saving computational time.

	\rev{In conclusions, we think that both the proposed models represent the best compromise between accuracy and implementability. In fact, decoupling the dynamics of different classes simplifies excessively the problem description and does not allow to get accurate forecast;
	conversely, moving to second-order macroscopic models or including multi-lane features to the models increases notably the complexity of the code as well as the number of parameters to be tuned. These generalizations would allow in principle to catch easily inertia-based phenomena in all classes of vehicles and to track the density of \emph{each class} of vehicles in \emph{each lane} but, in our opinion, they make that model unfeasible for practical applications.}

	\medskip

	In the next future we plan to improve the models including the possibility that they are fed by both Lagrangian (GPS-like) and Eulerian data coming from mobile and fixed sensors, respectively, cf.\ \cite{colombo2016M3AS}.
	Moreover, we plan to estimate in real time the difference between predicted and measured  densities using the machinery developed in \cite{briani2018CMS}, hopefully creating an algorithm for the auto-calibration of the models in real time.

	\authorcontributions{Conceptualization, Maya Briani and Emiliano Cristiani; Data curation, Paolo Ranut; Funding acquisition, Maya Briani, Emiliano Cristiani and Paolo Ranut; Investigation, Maya Briani, Emiliano Cristiani and Paolo Ranut; Methodology, Maya Briani and Emiliano Cristiani; Visualization, Maya Briani and Emiliano Cristiani; Writing – original draft, Maya Briani and Emiliano Cristiani; Writing – review \& editing, Maya Briani, Emiliano Cristiani and Paolo Ranut.}

	\funding{
	This work was partially funded by the company Autovie Venete S.p.A.

	The work was also carried out within the research project ``SMARTOUR: Intelligent Platform for Tourism'' (No.\ SCN\_00166) funded by the Ministry of University and Research with the Regional Development Fund of European Union (PON Research and Competitiveness 2007-2013).

	Authors also acknowledge the Italian Minister of Instruction, University and Research to support this research with funds coming from the project entitled \textit{Innovative numerical methods for evolutionary partial differential equations and applications} (PRIN Project 2017, No.\ 2017KKJP4X).

	M.B.\ and E.C.\ are members of the INdAM Research group GNCS.
}

	\acknowledgments{
		The authors want to thank all the Autovie Venete staff as well as Gabriella Bretti, Matteo Piu, Elisa Iacomini, Caterina Balzotti, and Elia Onofri for valuable help.
	}

	\conflictsofinterest{The authors declare no conflict of interest.}

\end{paracol}

\reftitle{References}
\externalbibliography{yes}