\section{Introduction}
\IEEEPARstart{T}{he} Internet of Things (IoT) has become an important networking paradigm which enables massive connections among ubiquitous physical objects. To address the spectrum scarcity caused by large-scale IoT device access and low spectrum efficiency of static spectrum allocation, a promising solution is to apply the cognitive radio (CR) technology to the IoT, which is well-known as CR-IoT \cite{CRIoT2017Survey}. The CR technology enables the IoT device without dedicated spectrum to work as a secondary user (SU) and accesses the licensed channel of the nearby legitimate IoT device, i.e. the primary users (PU), without causing performance degradation to primary service. There are mainly three CR spectrum sharing strategies, including underlay, overlay, and interweave schemes.
Due to the ease of implementation, the interweave scheme is more preferred and extensively adopted in the CR-IoT system, where the SU first monitors the status of the licensed channel and accesses the channel only when it is not occupied by the PU.

\par
Massive emerging IoT services could be promoted by applying the CR technology, such as smart cities, pollution control, wildfire monitoring and smart agriculture, etc. In these scenes, the wireless connected, battery-operated IoT devices are deployed to monitor certain time-critical physical processes, while there are two common concerns in the design of such systems. One is the battery lifetime, since replacing batteries usually incurs high cost, while the CR functionalities, e.g., channel sensing and switching, are energy consuming. Thus, the CR scheme should be carefully designed to maximize the energy efficiency. The second one is the information freshness, since outdated state information loses value and may even cause severe accidents. The freshness of information can be evaluated by a new concept, i.e. age of information (AoI), which is defined as the time elapsed since the most recent received update was generated at the source~\cite{2012AoI}.

\par
The AoI has been investigated as an important performance metric in the cognitive radio networks (CRNs) \cite{2019EHCR,2020CRCollision,CRAoI2017,2019IoTJUorO}. The authors in \cite{2019EHCR} investigate the optimal sensing and update scheme of an energy harvesting CR-based sensor for AoI minimization, taking into consideration the partially observability of the state of the PU. Instead of considering slotted transmission and strict slot synchronization between the PU and the SU, the work in \cite{2020CRCollision} focuses on the unsynchronized case and formulates the scheduling policy design problem of the SU for the average AoI minimization as a Markov decision process (MDP) with a collision constraint. The authors in \cite{CRAoI2017} consider an interweave-based cognitive wireless sensor network, and propose a joint framing and scheduling policy   optimizing the  energy efficiency under strict expected AoI constraints. In \cite{2019IoTJUorO}, the underlay scheme and the overlay scheme are compared with each other with respect to the average peak AoI of both the PU and the SU under standard ARQ.

\par
However, the above existing studies haven't investigated the impact of heterogeneous traffic patterns of IoT devices on the energy efficiency and on the AoI performance in the CR-IoT system. The primary IoT device (PD) and the secondary IoT device (SD) may have distinct traffics, e.g. the packet generation rate and data size. The energy efficiency and the AoI of the SD may be quite different under different PD traffic patterns, since in the interweave mode, the SD can only transmit when the PD is idle, and the secondary transmission may be frequently interrupted by the arrival of primary traffic. Hence, in this work we are motivated to focus on the effect of heterogeneous traffic on the energy efficiency and AoI of the SD in the CR-IoT system. The main contributions of this article are summarized as follows:
\begin{itemize}
  \item
With the consideration of the randomness of spectrum access in the considered CR-IoT system, we derive the closed-form expressions of the energy efficiency and average AoI of the SD. In particular, we show that the average AoI tends to infinity under two extreme cases, which implies the AoI performance is closely related to the specific traffic patterns.

  \item
We explore how the energy efficiency and the average AoI evolves with the transmit power, and prove the convexity of the average AoI as well as the convexity and monotonicity of the energy consumption w.r.t the required transmission time. With the above properties, we propose an optimal transmit power optimization algorithm for the SD to maximize its energy efficiency while maintaining the average AoI under the predefined threshold.
\end{itemize}
\par
The remainder of this paper is organized as follows. We introduce the system model in Section II and derive the closed-form expression of the energy efficiency and average AoI in Section III. An energy-efficient, AoI aware power optimization scheme is proposed in Section IV. In Section V, numerical results are reported with discussions.

\section{System Model}
We consider a CR-IoT system, where the SD with no dedicated spectrum performs a certain remote monitoring task and opportunistically accesses the licensed channel legitimate to the PD to update the monitored status information to a secondary access point (SAP). From the SD's point of view, the availability of a licensed channel can be modelled as two states, i.e. IDLE and BUSY, which correspond to the two cases where the PD is or isn't utilizing the channel, respectively. We assume that the state transition of the channel follows a two-state continuous-time Markov Chain (CTMC), which is a reasonable and widely-adopted assumption \cite{CTMC2018,CTMC2020}. Let $u$ and $v$ be the transition rates from IDLE to BUSY and from BUSY to IDLE, which jointly represent the traffic pattern of the PD. Then, the continuous IDLE and BUSY periods denoted by $T^I$ and $T^B$ are independent and exponentially distributed random variables with mean value $1/u$ and $1/v$, respectively.
\par
The SD monitors a physical process which randomly generates status updates of size $D$ bits according to a Poisson process of rate $\lambda$, and thus the traffic pattern of the SD is modeled by the packet size and generation rate. The terms status update and packet are used interchangeably throughout this paper. We assume that the SD can simultaneously handle or hold only one packet, and thus the packets that arrive during transmission will be discarded. Besides, for information freshness, newly-generated packets will take the place of the old one when the SD is waiting for transmission opportunities. We assume the SD transmits at the Shannon capacity $C=B\log_2{\left(1+\frac{P^T}{{N_0}B}\right)}$, where $P^T$ is the transmission power and $N_0$ is the equivalent noise power per unit bandwidth at the receiver in consideration of the channel effect\footnote{For analysis simplicity, the equivalent noise power only accounts for the path loss, which can be seen as a fixed value. However, the analysis in this paper, more specifically, the derivation of energy efficiency and expected AoI in Section III, can be easily extended to the block fading case.}.
During transmission, if the PD reclaims the channel, the SD has to quit the current transmission, hand over the channel to the PD and wait for the next IDLE period to restart the transmission.

\subsection{Age of Information}
Denote the generation time of the $i$-th packet by $g_i$. Note that not every generated packet will be finally received at the SAP, since packets generated during the transmission will be discarded, and packets to be transmitted will be replaced by the newly-generated ones. Thus we denote by $g_i^\prime$ and $d_i$ the generation time and the departure time of the $i$-th successfully transmitted packet. At time instant $t$, we define the index of the most recently received packet at the SAP as $N_t=\max{\{i\mid d_i \leq t\}}$. Then, the instantaneous AoI at $t$ is defined as follows \cite{2012AoI}.
\vspace{-.2cm}
\begin{definition} \
  \label{def:AoI}
  $\!\!\!$An~instantaneous~AoI~at~time~point~$t$~is~defined~as
  \vspace{-.35cm}
  \begin{equation}\vspace{-.2cm}
    \label{AoIdef}
    \Delta (t) = t - g_{N_t}.
  \end{equation}
\end{definition}
A sample path of AoI is illustrated in Fig. \ref{AoISamplePath}. To calculate the average AoI, we define the interval between the $i$-th and $(i-1)$-th departures as
\vspace{-.2cm}
\begin{equation}\vspace{-.1cm}
  \label{Ydef}
  Y_i = d_i - d_{i-1},
\end{equation}
and define the service time of the $i$-th successful received packet as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{Sdef}
  S_i = d_i - g_i^\prime.
\end{equation}
$Y_i$ in (\ref{Ydef}) can be divided into two intervals: $W_i$ and $K_i$. $W_i$ is defined as the time elapsed since the last departure $d_{i-1}$ until a new packet is generated, which can be expressed as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{Wdef}
  W_i = \min{\{g_i \left.\right| g_i\geq d_{i-1} \}} - d_{i-1},
\end{equation}
The other interval $K_i$ is defined as the time elapsed since the first packet generation after the last departure until the next successful reception $d_i$, which can be expressed as
\vspace{-.1cm}
\begin{equation} \vspace{-.1cm}
  \label{Kdef}
  K_i = d_i - \min{\{g_i \left.\right| g_i\geq d_{i-1}\}}.
\end{equation}
Following the above definitions, the average AoI can be calculated based on the polygon area $Q_i$ depicted in Fig.\ref{AoISamplePath}:
\vspace{-.1cm}
\begin{equation}\vspace{-.2cm}
  \label{AoIArea}
  \bar{\Delta}
  =\lim_{t \to \infty}{\frac{N_t}{t} \frac{1}{N_t} \sum_{i=1}^{N_t}{Q_i}}
  =\frac{\mathbb{E} [Q_i]}{\mathbb{E} [Y_i]},
\end{equation}
where
\vspace{-.2cm}
\begin{equation}
  \label{QArea}
  Q_i
  = \frac{(S_{i-1}+Y_i)^2}{2} - \frac{S_{i-1}^2}{2}
  = \frac{Y_i^2}{2} + S_{i-1}Y_i.
\end{equation}
Then, we have the following lemma representing the relationship between
the service time and the inter-departure time.

\vspace{-.1cm}
\begin{lemma}
  \label{lemma_S&Y}
  $S_{i-1}$ is independent of $Y_i$.
\end{lemma}
\begin{IEEEproof}
Since $Y_i=W_i+K_i$, $\mathbb{E}\left[ S_{i-1} Y_i \right]=\mathbb{E}\left[S_{i-1}\right]\mathbb{E}\left[Y_i\right]$ holds if $S_{i-1}$ is independent of both $W_i$ and $K_i$. The packet generation process, which follows an Poisson process, is independent of the state transition of the channel as well as the packet transmission. $W_i$ is the waiting time from the $i-1$-th departure to the generation of the first packet after $d_{i-1}$, and thus follows an exponential distribution and has the memoryless property. Therefore, $W_i$ is independent of the events happened before $d_i$ and thus $W_i$ is independent of $S_{i-1}$. $K_i$ is the time elapsed from the generation of a first packet after $d_{i-1}$ to the next departure $d_i$, and thus it depends on the channel state transition process and the packet generation process. Note that the former has the Markovian property and the latter has the memoryless property, so $K_i$ is also independent of the events happened before the packet generation. Therefore, $K_i$ is independent of $S_{i-1}$, and thus Lemma~\ref{lemma_S&Y} is proved.
\end{IEEEproof}

According to Lemma~\ref{lemma_S&Y}, the expression of the average AoI can be simplified as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{AoISimplified}
  \bar{\Delta}
  \!=\!\mathbb{E}[S_{i-1}] \!+\! \frac{\mathbb{E}[Y_i^2]}{2\mathbb{E}[Y_i]}
  \!=\!\mathbb{E}[S_{i-1}] \!+\! \frac{\!\mathbb{E}[W_i^2]\!+\!2\mathbb{E}[W_i K_i]\!+\!\mathbb{E}[K_i^2]\!}{2(\mathbb{E}[W_i]\!+\!\mathbb{E}[K_i])}.
\end{equation}
\par
Note that the sequences $\{W_1,W_2,\cdots\}$, $\{K_1,K_2,\cdots\}$, $\{Y_1,Y_2,\cdots\}$ and $\{S_1,S_2,\cdots\}$ form i.i.d processes, which allows us to drop the subscript index of $W_i$, $K_i$, $Y_i$ and $S_{i-1}$ in (\ref{AoISimplified}). As a result, the average AoI can be further~reformulated~as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{AoIDefFinal}
  \bar{\Delta}
  = \mathbb{E}[S] + \frac{\mathbb{E}[Y^2]}{2\mathbb{E}[Y]}
  = \mathbb{E}[S] + \frac{\mathbb{E}[W^2]+2\mathbb{E}[WK]+\mathbb{E}[K^2]}{2(\mathbb{E}[W]+\mathbb{E}[K])},
\end{equation}
where $W$ represents the waiting time from a successful reception to the generation of a new status update, $K$ represents the time elapsed from the first packet generation after a successful reception to the next successful reception, and $S$ represents the service time of a successfully transmitted packet.
\begin{figure}[!t]
\centering
\includegraphics[width=2.7 in, trim= 0 35 0 20]{AoI}
\captionsetup{font={small}}
\caption{A sample path of AoI and the corresponding intervals.}
\label{AoISamplePath}
\vspace{-.53cm}
\end{figure}

\subsection{Energy Efficiency}
Energy efficiency in this work is defined as the average number of successfully transmitted bits per unit energy consumption. We assume that the power consumption of the SD consists of three parts \cite{2016CRPowerConsumption}: the packet transmit power $P^T$, the static circuit power $P^C$ and the spectrum sensing power $P^S$. We denote by $E^T$, $E^S$ and $E^C$ the average energy consumption of packet transmission, spectrum sensing and static circuit operation between two consecutive departures, respectively. Besides, we define the corresponding average power consumption time as $T^T$, $T^S$ and $T^C$. Based on the above definitions, the energy efficiency can be expressed as
\begin{equation}
  \label{EEdef}
  {EE}
  = \frac{D}{E^T+E^S+E^C}
  = \frac{D}{P^T T^T + P^S T^S + P^C T^C}.
\end{equation}

\par
So far, we have introduced the general models of AoI and the energy efficiency. In the following section, we derive the explicit expressions of them.

\section{Correlation Analysis between energy efficiency and average AoI}
As for the energy efficiency, the static circuit power consumption lasts for the whole interval between two departures, so $T^C=\mathbb{E}[Y]$. After a successful reception, the SD starts to sense the allocated channel when a new packet is generated, and keeps monitoring the channel state until a packet is successfully received, i.e. $T^S=\mathbb{E}[K]$. In this way, the SD can release the channel immediately on arrival of the PD's traffic and access the channel when the next transmission opportunity comes. As a result, to evaluate the energy efficiency, we need to derive $\mathbb{E}[Y]$, $\mathbb{E}[K]$ and $T^T$.
As for evaluating the average AoI, according to \eqref{AoIDefFinal}, the main difficulty is to derive the terms $\mathbb{E}[S]$, $\mathbb{E}[Y]$ and $\mathbb{E}[Y^2]$.
Hence, in the following we first derive the expressions of $\mathbb{E}[Y]$, $\mathbb{E}[Y^2]$ and $T^T$ in Section III-A as well as $\mathbb{E}[S]$ in Section III-B.

\subsection{Characterization on $\mathbb{E}[Y]$, $\mathbb{E}[Y^2]$ and $T^T$}
The packet generation process follows a Poisson process of rate $\lambda$, which is a memoryless process. Thus, the elapsed time for generating a packet from a certain instant follows an exponential distribution of parameter $\lambda$. Then $W$, which is the time elapsed from the last departure to the generation of a new packet, also follows the exponential distribution of parameter $\lambda$. So the probability density function (PDF) denoted by $f_W(t)$ is $f_W(t) = \lambda e^{-\lambda t}$, and we have $\mathbb{E}[W]=1/{\lambda}$, $\mathbb{E}[W^2]=2/{{\lambda}^2}$.

\par
To derive the first and second moment of $K$, note that $K$ evolves differently for different channel states at the initial moment. Specifically, if the channel is in IDLE state when a new packet is generated, the SD can immediately start the transmission. On the other hand, if the channel is in BUSY state, the SD has to wait until the PD finishes its transmission. We denote by $I_K$ and $B_K$ the events that the channel is in IDLE or BUSY state at the initial moment of $K$, respectively. Then the expectation of $K$ can be expressed as
\begin{equation}
  \label{conditionalK}
  \mathbb{E}[K] =
  \mathrm{Pr}\{I_K\} \mathbb{E}[K | {I_K}] +
  \mathrm{Pr}\{B_K\} \mathbb{E}[K | {B_K}],
\end{equation}
and the corresponding expectation of $K^2$ is given by
\begin{equation}
  \label{conditionalK2}
  \mathbb{E}[K^2] =
  \mathrm{Pr}\{ I_K \} \mathbb{E} [{K^2}| {I_K} ] +
  \mathrm{Pr}\{ B_K \} \mathbb{E} [{K^2}| {B_K} ].
\end{equation}
\par
The two probability terms in (\ref{conditionalK}) and (\ref{conditionalK2}) can be calculated from the transition probabilities of the channel CTMC. The channel must be in the IDLE state at the last departure, so the probability of $I_K$ and $B_K$ equals the probability that the CTMC transfers from IDLE to IDLE and BUSY after a period of $W$, respectively. Denote by $P_{II}(t)$ and $P_{IB}(t)$ the transition probability from IDLE to IDLE and from IDLE to BUSY after time $t$, which are given by \cite{medhi2002stochastic}
\begin{equation}
  \label{P_II}
  P_{II}(t) = \frac{v}{u+v}+\frac{u}{u+v} e^{-(u+v)t},
\end{equation}
\begin{equation}
  \label{P_IB}
  P_{IB}(t) = \frac{u}{u+v}-\frac{u}{u+v} e^{-(u+v)t}.
\end{equation}
\par
According to the transition probabilities and the PDF of $W$, $\mathrm{Pr}\{I_K\}$ and $\mathrm{Pr}\{B_K\}$ can be obtained as follows:
\begin{equation}
  \label{conditionalK_I}
  \mathrm{Pr} \left\{ I_K \right\} =
  \int_0^{+\infty} P_{II}(t) \lambda e^{-\lambda t} dt =
  \frac{v+\lambda}{u+v+\lambda},
\end{equation}
\begin{equation}
  \label{conditionalK_B}
  \mathrm{Pr} \left\{ B_K \right\} =
  \int_0^{+\infty} P_{IB}(t) \lambda e^{-\lambda t} dt =
  \frac{u}{u+v+\lambda}.
\end{equation}
\par
Since the IDLE period $T^I$ and the BUSY period $T^B$ are both exponential random variables, they also have memoryless property. Inspired by \cite{gu2019timely,2019IoTJUorO}, the two conditional expectation terms $\mathbb{E}[K|{I_K}]$ and $\mathbb{E}[K|{B_K}]$ in (\ref{conditionalK}) can be evaluated in a recursive manner. Denote by $t^P$ the time required for the SD to transmit an entire packet at the Shannon rate, which is calculated as $t^P=D/C$. As for $\mathbb{E}[K|{I_K}]$, the channel is IDLE at the beginning of $K$, and thus the SD can transmit the generated packet immediately. There are two cases. The first one is that $t^P$ is shorter than the IDLE period $T^I$. In this case the SD finishes its transmission without being interrupted by the PD traffic. The second one is that the channel state transfers from IDLE to BUSY during the SD transmission. In this case, the SD has to quit its current transmission and wait until the channel turns to IDLE again. With the memoryless property of $T^B$, the time elapsed from the instant that channel state transfers to BUSY to the next departure is equal to that the channel is occupied at the beginning of $K$. With the analysis above, $\mathbb{E}[K|{I_K}]$ can be evaluated as follows
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{K_I_recursive}
  \mathbb{E}[K|{I_K}] =
  t^P \int_{t^P}^{+\infty}{ue^{-ut}dt}+
  \int_0^{t^P}\left({t+\mathbb{E}[K|{B_K}]}\right) {ue^{-ut}dt}.
\end{equation}
The first term on the right side of (\ref{K_I_recursive}) corresponds the first case, where $\mathbb{E}[K|{I_K}]$ equals the required transmission time for one packet. The second term represents that $\mathbb{E}[K|{I_K}]$ is composed of the already transmitted time before interruption and the expected elapsed time before the next departure when the channel happens to be BUSY at the packet generation moment.
In the same way, $\mathbb{E}[K|{B_K}]$ can be expressed as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{K_B_recursive}
  \mathbb{E}[K|{B_K}] =
  \int_0^{t^P}\left({t+\mathbb{E}[K|{I_K}]}\right) {ve^{-vt}dt}.
\end{equation}
which is composed of the waiting time before the next transmission opportunity and the expected time before a successful reception when the channel is IDLE at the initial moment of $K$.
By jointly considering (\ref{K_I_recursive}) and (\ref{K_B_recursive}), we can obtain the expressions of $\mathbb{E}[K\left|{I_K}\right.]$ and $\mathbb{E}[K\left|{B_K}\right.]$. Substitute the results along with (\ref{conditionalK_I}) and (\ref{conditionalK_B}) to (\ref{conditionalK}), and $\mathbb{E}[K]$ is expressed as
\vspace{-.1cm}
\begin{equation} \vspace{-.1cm}
  \label{K_final}
  \mathbb{E}[K] =
  h e^{ut^P} +
  \frac{u}{v(u+v+\lambda)} - h,
\end{equation}
where $h = 1/u + 1/v$,
and $\mathbb{E}[Y]$ can be finally obtained as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{Y_final}
  \mathbb{E}[Y]  = \frac{1}{\lambda} + h e^{ut^P} + \frac{u}{v(u+v+\lambda)} - h.
\end{equation}
\par
Since all interruptions happen with identical probability, which only depends on the required packet transmission time of the SD and the channel CTMC, the number of transmission interruptions follows the Geometric distribution of probability $p^I = \mathrm{Pr} \left\{T^I<t^P\right\}= 1 - e^{-ut^P}$.
We define $t^I$ as the expected time spent for transmission before interruption, given by
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{TimeBeforeInterruption}
  t^I =
  \frac{\int_0^{t^P}{tue^{-ut}}}{p^I} =
  \frac{1}{u} - \frac{e^{-ut^P}}{1-e^{-ut^P}} t^P.
\end{equation}
So the expected transmission time spent between two departures can be evaluated as the sum of the interrupted transmissions and one successful transmission, given by.
\begin{equation}
  \label{TT}
  T^T = \sum_{n=0}^{+\infty}{{p^I}^n\left(1-p^I\right)} n t^I + t^P = \frac{e^{ut^P}-1}{u}.
\end{equation}
\par
Next we turn to the two conditional expectations of $K^2$. Denote by $f_{K|I_K}(t)$ and $f_{K|B_K}(t)$ the PDF of $K$ conditioned on $I_K$ and $B_K$, respectively. Similar to the analysis on $\mathbb{E}[K|{I_K}]$, $\mathbb{E}[{K^2} | {I_K}]$ can be derived based on (\ref{K_I_recursive}) as follows:\vspace{-.1cm}
\begin{align}
  \label{K2_I_recursive}
  \mathbb{E}\left[K^2\left|{I_K}\right.\right] = {} & \underbrace{{t^P}^2 \int_{t^P}^{+\infty}{ue^{-ut}dt}}_{S_1} \notag \\
  {} & + \underbrace{{\int_0^{t^P}{\int_0^{+\infty}{(t+s)^2 {f_{K|I_K}(s)} u e^{-ut} ds dt}}}}_{S_2}.
\end{align}
The terms $S_1$ and $S_2$ correspond to the first and second terms on the right side of (\ref{K_I_recursive}), respectively. $S_2$ can be further transformed into
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{S2}
  S_2 = \int_0^{t^P} {
    \left(
    {
    t^2 +
    2t \mathbb{E} [{K}| {B_K}] +
    \mathbb{E} [{K^2}| {B_K}]
    }
    \right)
    ue^{-ut}dt
    }.
\end{equation}
Similarly, based on (\ref{K_B_recursive}). the expectation of $K^2$ conditioned on $B_K$ can be expressed as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{K2_B_recursive}
  \mathbb{E}[K^2|{B_K}]
  = \int_0^{t^P} {
  \left(
  {
  t^2 +
  2t \mathbb{E} [{K}| {I_K}] +
  \mathbb{E} [{K^2}| {I_K}]
  }
  \right)
  ve^{-vt}dt
  }.
\end{equation}
With the derived results of $\mathbb{E}[K|{I_K}]$ and $\mathbb{E}[K|{B_K}]$, $\mathbb{E}[K^2|{I_K}]$ and $\mathbb{E}[K^2|{B_K}]$ can be solved from (\ref{K2_I_recursive}), (\ref{S2}) and (\ref{K2_B_recursive}). We omit the two expressions here and directly give the result of $\mathbb{E}[K]$ as follows
\vspace{-.1cm}
\begin{align}
  \label{K2_final}
  \mathbb{E}[K^2] = {} & \frac{2}{uv} - \frac{2}{v(u+v+\lambda)} + 2h^2 e^{2ut^P} \notag \\
  {} & + 2\left[
  h \left( \frac{u}{v(u+v+\lambda)} - h - t^P \right) - \frac{1}{uv}
  \right]e^{ut^P}.
\end{align}
\par
Now we derive the expression of $\mathbb{E}[WK]$. We can find that $W$ and $K$ are independent of each other when conditioned on $I_K$ and $B_K$. Then, we have
\begin{align}
  \label{WK}
  \mathbb{E}[WK] = {} &
  \mathbb{E}[ WK | I_K ] \mathrm{Pr} \{I_K\} +
  \mathbb{E}[ WK | B_K ] \mathrm{Pr} \{B_K\} \notag \\
  = {} &
  \mathbb{E}[ W | I_K ] \mathbb{E}[ K | I_K ] \mathrm{Pr} \{I_K\} +
  \mathbb{E}[ W | B_K ] \mathbb{E}[ K | B_K ] \mathrm{Pr} \{B_K\}
\end{align}
For the term $\mathbb{E}[ WK | I_K ]$, denote by $f_{W|I_K}(t)$ the PDF of $W$ conditioned on event $I_K$, then it can be calculated as
\begin{align}
  \label{W_I_K}
  \mathbb{E}[ W | I_K ] = {} &
  \int_0^{+\infty}{f_{W | I_K }(t)tdt}
  =  \int_0^{+\infty} { \frac{P_{II}(t)f_W(t)}{\mathrm{Pr}\{ I_K \}}tdt} \notag \\
  = {}& \left( \frac{1}{u\lambda} + \frac{\lambda}{v(u+v+\lambda)^2} \right) \left( e^{ut^P} - 1 \right).
\end{align}
Similarly, $\mathbb{E}[ W | B_K ]$ is given by
\begin{equation}
  \label{W_B_K}
  \mathbb{E}[ W | B_K ] = \left( \frac{1}{v\lambda} - \frac{\lambda}{v(u+v+\lambda)^2} \right)
  \left( e^{ut^P} - \frac{v}{u+v} \right).
\end{equation}
By substituting (\ref{conditionalK_I}), (\ref{conditionalK_B}), (\ref{W_I_K}) and (\ref{W_B_K}) into (\ref{WK}), $\mathbb{E}[WK]$ is finally given as follows
\begin{equation}
  \label{WK_final}
  \mathbb{E}[WK] = \frac{1}{\lambda}\left[ he^{ut^P} + \frac{u}{v(u+v+\lambda)} - h \right]
  + \frac{u}{v(u+v+\lambda)^2}.
\end{equation}
Finally, the expression of $\mathbb{E}[ Y^2 ]$ can be obtained as
\begin{equation}
  \label{Y2_final}
  \mathbb{E}[ Y^2 ] =  2\left\{h^2e^{2ut^P} + \left[ h\left( g - t^P \right) - \frac{1}{uv} \right]e^{ut^P} + \frac{g}{\lambda} + q \right\}
\end{equation}
where $g = \frac{1}{\lambda} + \frac{u}{v(u+v+\lambda)} - h$ and $q = \frac{1}{uv} - \frac{v+\lambda}{v(u+v+\lambda)^2}$,
and the $\mathbb{E}[Y^2]/2\mathbb{E}[Y]$ term in (\ref{AoIDefFinal}) can be expressed as
\begin{equation}
  \label{Y2_2Y_final}
  \frac{\mathbb{E}[ Y^2 ]}{2\mathbb{E}[Y]} = \frac{h^2 e^{2ut^P} + \left[ h(g-t^P) - \frac{1}{uv} \right]e^{ut^P} + \frac{g}{\lambda} + q}
  {he^{ut^P} + g}.
\end{equation}

\subsection{Characterization on $\mathbb{E}[S]$}
Similar to $K$, to derive $\mathbb{E}[S]$, we also need to distinguish different channel states at the initial moment. Define $I_S$ and $B_S$ as the event that the channel is IDLE and BUSY at the initial moment of $S$. Then the expectation of $S$ follows
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{S}
  \mathbb{E}[S] = \mathbb{E}[ S | I_S ] \mathrm{Pr} \{ I_S \} +
  \mathbb{E}[ S | B_S ] \mathrm{Pr}\{ B_S \}.
\end{equation}
Both $I_S$ and $B_S$ imply the event denoted by $\Phi_S$ that packet is finally successfully received at the destination without being replaced by a new one. In this sense, we let $I_G$ and $B_G$ represent the events that the channel is IDLE and BUSY when a packet is generated, and then $I_S$ and $B_S$ represent the events $I_G$ and $B_G$ conditioned on $\Phi_S$, respectively. Therefore, the probability of event $I_S$ and $B_S$ can be calculated as
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{Pr_I_S}
  \mathrm{Pr} \{ I_S \}
  = \frac{\mathrm{Pr}\{ I_G \} \mathrm{Pr} \{ \Phi_S | I_G \}}
  {\mathrm{Pr}\{ I_G \} \mathrm{Pr} \{ \Phi_S | I_G \} + \mathrm{Pr}\{ B_G \} \mathrm{Pr} \{ \Phi_S | B_G \}},
\end{equation}
\vspace{-.01cm}
\begin{equation}\vspace{-.05cm}
  \label{Pr_B_S}
  \mathrm{Pr} \{ B_S \}
  = \frac{\mathrm{Pr}\{ B_G \} \mathrm{Pr} \{ \Phi_S | B_G \}}
  {\mathrm{Pr}\{ I_G \} \mathrm{Pr}\{ \Phi_S | I_G \} + \mathrm{Pr}\{ B_G \} \mathrm{Pr} \{ \Phi_S | B_G \}}.
\end{equation}
$\mathrm{Pr} \{ \Phi_S | I_G \}$ and $\mathrm{Pr} \{ \Phi_S | B_G \}$ can be derived in a similar recursive manner as in (\ref{K_I_recursive}) and (\ref{K_B_recursive})
\vspace{-.1cm}
\begin{align} \vspace{-.1cm}
  \mathrm{Pr}\{ \Phi_S | I_G \}  &\!= \!
  \int_{t^P}^{+\infty}\!\!{ue^{-ut}dt} \!+\!
  \mathrm{Pr}\{ \Phi_S | B_G \} \int_0^{t^P}{ue^{-ut}dt}, \label{Phi_S_I_G_recursive} \\
  \mathrm{Pr} \{ \Phi_S | B_G \}  &\!=\!
  \mathrm{Pr} \{ \Phi_S | I_G \}
  \int_0^{+\infty}{\int_s^{+\infty}{\lambda e^{-\lambda t}dtv e^{-vs}ds}}. \label{Phi_S_B_G_recursive}
\end{align}

Similar to (\ref{K_I_recursive}), the first term on the right side of (\ref{Phi_S_I_G_recursive}) corresponds to the successful packet reception on the first transmission attempt, and the second term corresponds to the case that the SD transmission is interrupted by the PD. In contrast, (\ref{Phi_S_B_G_recursive}) is different from (\ref{K_B_recursive}) in that $\mathrm{Pr}\{ \Phi_S | I_G \}$ should satisfy the condition that the packet isn't replaced by a newly-generated one during the BUSY period. By jointly considering (\ref{Phi_S_I_G_recursive}) and (\ref{Phi_S_B_G_recursive}), the $\mathrm{Pr} \{ \Phi_S | I_G \}$ and $\mathrm{Pr}\{ \Phi_S | B_G \}$ can be solved.
\par
Since the generation process of packets and the state transition process of a channel are independent of each other, the probability of $I_G$ or $B_G$ is just the steady state probability of the IDLE or BUSY state, i.e. $\mathrm{Pr} \{ I_G \} = v/(u+v)$, $\mathrm{Pr} \{ B_G \} = u/(u+v)$. Consequently, $\mathrm{Pr} \{ I_S \}$ and $\mathrm{Pr} \{ B_S \}$ can be calculated by substituting the derived results to~\eqref{Pr_I_S} and~\eqref{Pr_B_S}.
\par
Compared to $\mathbb{E}[ S | I_G ]$ and $\mathbb{E}[ S | B_G]$, $\mathbb{E}[ S| I_S ]$ and $\mathbb{E}[ S| B_S ]$ are further conditioned on the event that the packet is finally successfully received at the SAP without being dropped. As a result, the two terms should further divide the conditional probabilities $\mathrm{Pr}\{ \Phi_S| I_G \}$ and $\mathrm{Pr}\{ \Phi_S | B_G \}$ on the basis of $\mathbb{E}[ S| I_G]$ and $\mathbb{E}[ S | B_G ]$, respectively. Based on (\ref{Phi_S_I_G_recursive}) and (\ref{Phi_S_B_G_recursive}), the expectation of $S$ conditioned on $I_G$ and $B_G$ are given as
\vspace{-.2cm}
\begin{align}
\label{S_I_G_recursive}
  \mathbb{E}[ S | I_S ] = {}& \frac{1}{\mathrm{Pr}\{ \Phi_S | I_G \}} \int_{t^P}^{+\infty}{t^P ue^{-ut} dt} \notag \\
  {}& + \frac{\mathrm{Pr} \{ \Phi_S | B_G \}}{\mathrm{Pr}\{ \Phi_S | I_G \}}
  \int_0^{t^P}{\left( t + \mathbb{E}[ S | B_S ] \right) ue^{-ut}dt}
\end{align}
\begin{align}
  \label{S_B_G_recursive}
  \!\!& \!\!\mathbb{E} \left[ S \left| B_S \right. \right] =\notag \\
  \!\!&\!\! \frac{\mathrm{Pr} \left\{ \Phi_S \left| I_G \right. \right\}}{\mathrm{Pr} \{ \Phi_S | B_G \}}
  \int_0^{+\infty}\!\!\!\!{\left( s + \mathbb{E} \left[ S \left| I_S \right. \right] \right)
  \int_s^{+\infty}\!\!\!\!{\lambda e^{-\lambda t}dtve^{-vs}ds}},
\end{align}
and the two terms can be solve jointly. Finally, $\mathbb{E}[S]$ can be expressed as follows:
\begin{equation}
  \label{S_final}
  \mathbb{E}[S] =
  \frac{\left( l + \lambda t^P \right)e^{ut^P} - l + \frac{u}{u+v+\lambda}}
  {\lambda e^{ut^P} + v}.
\end{equation}
where $l \!=\! v/u \!+\! (u\!+\!v)/(u\!+\!v\!+\!\lambda)$.
The average AoI can now be characterized by substituting (\ref{Y2_2Y_final}) and (\ref{S_final}) into (\ref{AoIDefFinal}), given by
\begin{align}
  \label{AoI_final}
  \bar{\Delta} = {} & \frac{h^2 e^{2ut^P} + \left[ h(g-t^P) - \frac{1}{uv} \right]e^{ut^P} + \frac{g}{\lambda} + q}
  {he^{ut^P} + g} \notag \\
  {} & + \frac{\left( l + \lambda t^P \right)e^{ut^P} - l + \frac{u}{u+v+\lambda}}
  {\lambda e^{ut^P} + v},
\end{align}
and the energy efficiency can also be derived by substituting (\ref{K_final}), (\ref{Y_final}) and (\ref{TT}) into (\ref{EEdef}), given by
\begin{equation}
  \label{EE_final}
  \!EE \!= \!\frac{D}
  {\!\frac{P^T}{u}\!\left(\!e^{ut^P}\!\!-\!1\right)\! \!+\! \frac{P^C}{\lambda}\!+\! (P^S\!+\!P^C)\left(h e^{ut^P} \!+\! \frac{u}{v(u\!+\!v\!+\!\lambda)} \!-\! h\right)\!}.
\end{equation}
We further analyse the property of the derived average AoI and obtain the following lemma:
\begin{lemma}
\label{lemma_u}
For any finite ratio of average IDLE period and average BUSY period denoted by $k = v/u$, the average AoI tends to positive infinity when $u$ tends to $0$ or positive infinity.
\end{lemma}
\begin{IEEEproof}
See Appendix-B.
\end{IEEEproof}
According to Lemma~\ref{lemma_u}, for a fixed and moderate $k$, a very large $u$ corresponds to the case that both the continuous IDLE and BUSY period are statistically very short so that the transmission of the SD will be frequently interrupted by the PD. On the other hand, $u$ with an extremely small value corresponds to the case that both the continuous IDLE and BUSY period last very long in a statistical sense, and thus there will be a long time that the SD can obtain no transmission opportunity to update the status information of the monitored physical process. As a result, both cases will lead to a very high average AoI. We can also know from Lemma~\ref{lemma_u} that a large ratio $k$ doesn't guarantee a low average AoI, which seems counter-intuitive since a large $k$ usually means more transmission opportunities.

\section{Transmit Power Optimization}
In this section, the SD has to carefully decide its transmit power since a higher transmit power means a higher rate and lower AoI, however, this may cause lower energy efficiency. Since the status information will lose its value if it is outdated, the SD has a predefined AoI threshold denoted by $\Delta^{\mathrm{max}}$. Our objective is to maximize the energy efficiency of the SD subject to the average AoI constraint. The transmit power optimization problem is given by
\begin{subequations}
  \label{P1}
  \begin{alignat}{2}
    \mathbf{P1:}\max_{P^T}\quad & {EE( P^T )}&\quad & \tag{43}\\
    \text{s.t.}\quad & 0\leq P^T \leq P^{\mathrm{max}}, \label{P1:C1}\\
    &\bar{\Delta} ( P_n^T ) \leq {\Delta}^{\mathrm{max}}. \label{P1:C2}
  \end{alignat}
\end{subequations}
where $P^{\mathrm{max}}$ is the maximum transmit power. Constraint (\ref{P1:C1}) is the power budget for the SD. Constraint (\ref{P1:C2}) is used to guarantee that the average AoI of the SD should not exceed its AoI threshold. Due to the complexity of the energy efficiency and the average AoI derived in (\ref{EE_final}) and (\ref{AoI_final}), it is hard to directly analyse the convexity and monotonicity of the two terms w.r.t the transmit power $P^T$. Note that there is a one-to-one correspondence between the required transmission time of one packet $t^P$ and the transmit power $P^T$. More specifically, $t^P$ monotonously decreases with the increasing of $P^T$. As a result, we can change the optimization variable from $P^T$ to $t^P$ equivalently. Besides, according to the definition of the energy efficiency in (\ref{EEdef}), it is inversely proportional to the sum of three part of expected energy consumption between two consecutive successful receptions. Therefore, the optimization objective can be substituted by the sum of energy consumptions of transmi(ssion, spectrum sensing and static circuit, without changing the solution of the problem. With the above mentioned manipulations, we can obtain an equivalent problem to P1 given by
\vspace{-.1cm}
\begin{subequations}
  \label{P2}
  \begin{alignat}{2}
    \mathbf{P2:}\min_{t^P}\quad & {E^{\mathrm{sum}}( t^P )\triangleq  E^T( t^P )+ E^S( t^P ) + E^C( t^P )
    }&\quad & \tag{44}\\
    \text{s.t.}\quad & t^P \geq t^{\mathrm{min}}, \label{P2:C1}\\
    &\bar{\Delta} ( t^P ) \leq {\Delta}^{\mathrm{max}}. \label{P2:C2}
  \end{alignat}
\end{subequations}
\vspace{-.1cm}
where
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{min_t_P}
  t^{\mathrm{min}} = \frac{D}
  {B \log_2{\left( 1 + \frac{P^{\mathrm{max}}}{{N_0} B}\right)} }
\end{equation}
is the required packet transmission time at the maximum transmit power. To solve P2, we first analyse the monotonicity and the convexity of $E^{\mathrm{sum}}( t^P )$ and $\bar{\Delta} ( t^P )$ and obtain the following two lemmas.

\begin{lemma}
\label{lemma_E_sum}
$E^{\mathrm{sum}}(t^P)$ is convex in $t^P \in (0,\sqrt{\frac{D\ln2}{B u}})$ and strictly monotonously increases for $t^P \in [\sqrt{\frac{D\ln2}{B u}},+\infty)$. Besides, $E^{\mathrm{sum}}(t^P)$ is a quasi-convex function and first decreases and then increases in interval $(0,+\infty)$.
\end{lemma}
\begin{IEEEproof}
  See Appendix-C.
\end{IEEEproof}

\begin{lemma}
  \label{lemma_AoI}
  $\bar{\Delta} ( t^P )$ is a strictly monotonously increasing function in interval $(0,+\infty)$.
\end{lemma}
\begin{IEEEproof}
  See Appendix-D.
\end{IEEEproof}
With the convexity and monotonicity in Lemma~\ref{lemma_E_sum} and Lemma~\ref{lemma_AoI}, P2 and its equivalent problem P1 can be solved using binary search and gradient decent method, which is elaborated in Algorithm~1.
\begin{algorithm}[!t]
\captionsetup{font={small}}
\caption{TPOA: Transmit Power Optimization Algorithm}
\label{alg:TPOA}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{small}
\begin{algorithmic}[1]
\linespread{1}\selectfont
\Require $\lambda,D,{N_0},{\Delta}^{\mathrm{max}},P^{\mathrm{max}},u,v,B$
\Ensure solution to P2
\State Calculate $t^{\mathrm{min}}$ and $\bar{\Delta}(t^{\mathrm{min}})$ from (\ref{min_t_P}) and (\ref{AoI_final}).
\If {$\bar{\Delta}(t^{\mathrm{min}}) > {\Delta}^{\mathrm{max}}$}
\parState {P2 has no feasible solution. The SD isn't able to meet its information freshness requirement.}
\Else
\State Select some large $t^{\prime}$ that satisfies $\bar{\Delta}(t^{\prime})>{\Delta}^{\mathrm{max}}$.
\parState {Do binary search in interval $[t^{\mathrm{min}},t^{\prime}]$ until find a $t^{\mathrm{max}}$ that satisfies $\bar{\Delta}(t^{\mathrm{max}}) = \Delta^{\mathrm{max}}.$}
\State Calculate $\Omega = (0,\sqrt{\frac{D\ln2}{B u}})\cap[t^{\mathrm{min}},t^{\mathrm{max}}]$.
\If ${\Omega = \emptyset}$
\State ${t^P}^{\ast} = \sqrt{\frac{D\ln2}{B u}}$.
\Else
\State Obtain ${t^P}^{\ast}$ in $\Phi$ using gradient decent method.
\EndIf
\State Calculate ${P^T}^{\ast}=P^T({t^P}^{\ast})$, $EE^{\ast}=EE({P_n^T}^{\ast})$.
\EndIf
\end{algorithmic}
\end{small}
\end{algorithm}
\section{Numerical Simulations}
In this section, we present the numerical results of the energy efficiency and AoI performance of the considered CR-IoT system. In the simulations, we set the bandwidth of the licensed channel to be $B=180$ kHz, which equals the bandwidth of a sub-channel in NB-IoT, and set the spectrum sensing power, the static circuit power and the maximum transmit power to be $P^S = 1\times10^{-3}$ W, $P^C = 1\times10^{-4}$ W and $P^{\mathrm{max}}=0.1$ W, respectively. The equivalent noise power per unit bandwidth at the SAP in the simulation is set to be ${N_0}=N_0^R/\eta$, where $N_0^R$ is the noise power per unit bandwidth at the receiver of SAP and $\eta$ is the path loss of SD. We set $N_0^R=-110$ dBm and adopt $\eta = L^{-\theta}$ for the simulation of path loss with path loss factor $\theta=3$ and the distance between the SD and the SAP denoted by $L$.
\par
We first analyse the energy efficiency and AoI performance under different traffic patterns in Fig. $2$. To characterize different PD traffic patterns, we fix the IDLE/BUSY ratio while varying the parameter $u$. It can be seen that the results derived in (\ref{EE_final}) and (\ref{AoI_final}) coincide well with the Monte Carlo simulation results, which verifies the characterization on the energy efficiency and the average AoI. Besides, as shown in Fig. \ref{fig_ee_u}, the energy efficiency under both the two traffic patterns first increases then decreases with the increasing $u$, which means there exists a best $u$ to achieve the highest energy efficiency. Similarly, in Fig. \ref{fig_aoi_u}, the average AoI first decreases then increases and tends to positive infinity on both sides, which verifies Lemma~\ref{lemma_u}. More importantly, the $u$ that maximizes the energy efficiency or minimize the average AoI for the two SD traffic patterns are different, which implies that the SDs with different traffic have different preferences toward different PD traffic patterns. Moreover, comparing the two subfigures, for a single SD, the best $u$ w.r.t the two performance indcators are also different, which indicates that the SD have different preferences towards the PD traffic pattern for the two performance demands.

\begin{figure}[t]
  \captionsetup{font={small}}
  \centering
  \subfloat[Energy efficiency.]{
  \label{fig_ee_u}
  \includegraphics[width=0.75\linewidth, trim = 30 5 20 30]{fig2_ee_u_2SD.eps}
  }
  \hfill
  \subfloat[Average AoI.]{
  \label{fig_aoi_u}
  \includegraphics[width=0.75\linewidth, trim = 30 5 20 20]{fig2_aoi_u_2SD.eps}
  }
  \caption{{Energy efficiency and AoI performance versus CTMC parameter $u$ where $L=250$. The two SD traffic patterns are $D_1 = 400, \lambda_1 = 10$ and $D_2=100,\lambda_2=100$.}}
 \vspace{-.53cm}
\end{figure}

Next, we present the energy efficiency and AoI performance of a SD under different transmit power in Fig. \ref{fig_ee_transmitpower} and \ref{fig_aoi_transmitpower}. The solid and dashed lines in the two figures correspond to two PD traffic patterns, i.e. different CTMC parameters $u$ and $v$, under the same IDLE/BUSY ratio $k=v/u$ . The black line in Fig. \ref{fig_aoi_transmitpower} represents the sum of the average packet generation interval and the required transmission time for a single packet, which is a lower bound of the average AoI. It can be observed that with the increasing transmit power, the energy efficiency of the SD first increases and then decreases, while the average AoI keeps decreasing, which verifies Lemma~\ref{lemma_E_sum} and Lemma~\ref{lemma_AoI}. We can also find that although the energy efficiency under PD traffic pattern~$1$ is lower than $2$, the lowest reachable average AoI under pattern~$1$ is lower than that under pattern~$2$. As a result, when the average AoI constraint is strict, e.g. 2 times of the lower bound, pattern~$2$ isn't able to satisfy the information freshness requirement of the SD while pattern~$1$ is, so the SD would prefer pattern~$1$ with a lower energy efficiency. This implies that the transmit power control introduces a trade-off between the energy efficiency and the average AoI.

\section{Conclusion}
In this paper, we have investigated the impact of heterogeneous traffic pattern on the energy efficiency and average AoI of the SD in a CR-IoT system. The closed-form expressions of the energy efficiency and the average AoI have been derived. We have designed for the SD an optimal transmit power optimization algorithm aiming at maximizing the energy efficiency while satisfying the average AoI constraint.
The solution is facilitated by exploring the convexity and monotonicity of the objective and constraint functions.
The  numerical results   have confirmed our analytical model. In addition, we  showed that the SD has different preferences toward different PD traffic patterns, and there is a tradeoff between the energy efficiency and the average AoI.
\begin{figure}[t]
  \captionsetup{font={small}}
  \centering
  \subfloat[Energy efficiency.]{
  \includegraphics[width=0.75\linewidth,  trim = 30 5 20 30]{fig1_ee_transmitpower.eps}
  \label{fig_ee_transmitpower}}
  \hfil
  \subfloat[Average AoI.]{
  \includegraphics[width=0.75\linewidth,  trim = 30 5 20 20]{fig2_aoi_transmitpower.eps}
  \label{fig_aoi_transmitpower}}
  \caption{{Energy efficiency and AoI performance versus transmit power where $L=300$, $D = 400$ and $\lambda = 200$.}}
    \vspace{-.53cm}

\end{figure}

\section*{Appendix}
\subsection{Proof of Lemma 2}
When $u$ tends to zero, for a finite $k=v/u$, substitute $k$ for $v$ in (\ref{Y2_2Y_final}) and (\ref{S_final}), and utilize the Taylor expansion of term $\mathrm{exp}({ut^P})$ and $\mathrm{exp}({2ut^P})$, the limit of term $\mathbb{E}[Y^2]/2\mathbb{E}[Y]$ and $\mathbb{E}[S]$ can be expressed as\vspace{-.1cm}
\begin{align}
  \lim_{u\rightarrow 0}{\frac{\mathbb{E}[Y^2]}{2\mathbb{E}[Y]}} &=
  \lim_{u\rightarrow 0}{\frac{\frac{1}{k^2}\left(t^P+\frac{1}{\lambda}\right) \frac{1}{u} + o\left(\frac{1}{u}\right)}{\left(1+\frac{1}{k}\right)\left( t^P + \frac{1}{\lambda} \right) + o(1)}} =
  +\infty, \\
  \lim_{u\rightarrow 0}{\mathbb{E}[S]} &=
  \lim_{u\rightarrow 0}{\frac{\lambda t^P + o(1)}{\lambda + o(1)}} =
  t^P.
\end{align}
Therefore, the limit of average AoI at $u \rightarrow 0$ is given by
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \lim_{u\rightarrow 0}{\bar{\Delta}} =
  \lim_{u\rightarrow 0}{\left(\frac{\mathbb{E}[Y^2]}{2\mathbb{E}[Y]} + \mathbb{E}[S] \right)} =
  +\infty.
\end{equation}
\par
When $u$ tends to positive infinity, as for $\mathbb{E}[Y^2]/2\mathbb{E}[Y]$, the $\mathrm{exp}({2ut^P})$ term in the numerator and the $\mathrm{exp}({ut^P})$ term in the denominator play a dominant role, and we can obtain that\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \lim_{u\rightarrow +\infty}{\frac{\mathbb{E}[Y^2]}{2\mathbb{E}[Y]}} =
  \lim_{u\rightarrow +\infty}{\frac{{\left(1+\frac{1}{k}\right)}^2 \frac{1}{u^2} e^{2ut^P}}{\left(1+\frac{1}{k}\right) \frac{1}{u} e^{ut^P}}} =
  +\infty.
\end{equation}
Similarly, the $\mathrm{exp}({ut^P})$ terms play a dominant role in both the numerator and denominator of the term $\mathbb{E}[S]$ when $u$ tends to positive infinity, and the limit is given by\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \lim_{u\rightarrow +\infty}{\mathbb{E}[S]} =
  \lim_{u\rightarrow +\infty}{\frac{\left(k+\frac{u+ku}{u+ku+\lambda}+\lambda t^P\right)e^{ut^P}}{\lambda e^{ut^P}}} =
  \frac{1+k+t^P}{\lambda}.
\end{equation}
Finally we can get\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \lim_{u\rightarrow +\infty}{\bar{\Delta}} =
  \lim_{u\rightarrow +\infty}{\left(\frac{\mathbb{E}[Y^2]}{2\mathbb{E}[Y]} + \mathbb{E}[S] \right)} =
  +\infty,
\end{equation}
and Lemma~\ref{lemma_u} is proved.

\subsection{Proof of Lemma 3}
According to (\ref{K_final}) and (\ref{Y_final}), we have
\vspace{-.1cm}
\begin{align}
  E^{S}( t^P ) & = P^S \left( he^{ut^P} + \frac{u}{v(u+v+\lambda)} - h \right), \label{ES} \\
  E^{C}( t^P ) & = P^C \left( he^{ut^P} + \frac{1}{\lambda} + \frac{u}{v(u+v+\lambda)} - h  \right). \label{EC}
\end{align}
From (\ref{ES}) and (\ref{EC}), we know that both $E^{S}( t^P )$ and $E^{C}( t^P )$ are convex and strictly monotonously increasing w.r.t $t^P$ in interval $(0,+\infty)$. As for the convexity and monotonicity of $E^{S}( t^P )$, its expression can be obtained from (\ref{EEdef}) and (\ref{TT}), which is given by\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{ET}
  E^{T}( t^P ) = N_0 B \left[ \mathrm{exp}\left( \frac{D \ln{2}}{Bt^P} \right) -1 \right]
  \left[ \mathrm{exp}\left( ut^P \right) -1 \right].
\end{equation}
According to the structure of $E^{S}( t^P )$ in (\ref{ET}), consider a function of this kind\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{f(x)}
  f(x)= \left( e^{ax} -1 \right) \left( e^{\frac{b}{x}} -1  \right), a>0,b>0,x\in(0,+\infty).
\end{equation}
Take the first derivative of $f(x)$ and we can get\vspace{-.1cm}

\begin{equation}\vspace{-.1cm}
  \label{f'(x)}
  f^{\prime}(x) = e^{ax+ \frac{b}{x}}\left( a - \frac{b}{x^2} -ae^{-\frac{b}{x}} + \frac{b}{x^2} e^{-ax} \right).
  \end{equation}
Let $s(x) =  a - \frac{b}{x^2} -ae^{-\frac{b}{x}} + \frac{b}{x^2} e^{-ax}$, we can easily find that $s(\sqrt{\frac{b}{a}})=0$ and $f^{\prime}(\sqrt{\frac{b}{a}})=0$. When $x>\sqrt{\frac{b}{a}}$, we can obtain that the derivative of $s(x)$
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{s'(x)}
  s^{\prime}(x)
  =  \frac{2b}{x^2} \left( 1 - e^{-ax} \right) + \frac{ab}{x^2} \left( e^{-\frac{b}{x}} - e^{-ax} \right) >0.
\end{equation}
Therefore, $f^{\prime}(x)>0$ when $x>\sqrt{\frac{b}{a}}$, which means $f(x)$ is strictly monotonously increasing in interval $[\sqrt{\frac{b}{a}},+\infty)$.

When $x\in(0,\sqrt{\frac{b}{a}})$, take the second-order derivative of $f(x)$

$\!\!\!\!\begin{array}{ll}
  \!\!\!\!f^{\prime\prime}(x) \!\!
   &\!\!\!\!=\! {\left( a \!-\! \frac{b}{x^2} \right)}^2 e^{ax+\frac{b}{x}} \!+\! \frac{2b}{x^3} e^{ax+\frac{b}{x}} - a^2e^{ax} \!-\! \frac{2b}{x^3} e^{\frac{b}{x}} - \frac{b^2}{x^4} e^{\frac{b}{x}} \notag \\
  & \!\!\!\!=\! \left( e^{ax} \!\!-\!1 \!\right) e^{\frac{b}{x}} {\left( a \!-\! \frac{b}{x^2}\! \right)}^{\!2} \!\!+\! a^2\left( e^{\frac{b}{x}} \!-\! e^{ax} \! \right)  \!+\! \frac{2be^{\frac{b}{x}}}{x^3} \!\left( e^{ax} \!\!-\! ax \!-\! 1 \right)
  \notag \\
  &\!\!\!\!>\!  0.
\end{array}$

Therefore, $f(x)$ is convex in interval $(0,{\textstyle {\sqrt{\frac{b}{a}}}})$. Let $a=u$ and $b=\frac{D\ln2}{Bu}$, we find that $E^T(t^P)$ is  convex  in $t^P \in (0,\sqrt{\frac{D\ln2}{Bu}})$ and strictly monotonously   in $t^P \in[ \sqrt{\frac{D\ln2}{Bu}}, +\infty)$. Along with the convexity and monotonicity of $E^{S}( t^P )$ and $E^{C}( t^P )$, we come to the conclusion that $E^{\mathrm{sum}}( t^P )$ is a convex function in $(0,\sqrt{\frac{D\ln2}{Bu}})$ and strictly monotonously increases in interval $[ \sqrt{\frac{D\ln2}{Bu}}, +\infty)$ and Lemma~\ref{lemma_E_sum} is proved.

\subsection{Proof of Lemma 4}
To analyse the monotonicity of $\mathbb{E}[S]$, we take the derivative of it in (\ref{S_final}) w.r.t $t^P$ and obtain that
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{dE[S]}
  \frac{\mathrm{d}\mathbb{E}[S]}{\mathrm{d}t^P} =
  \frac
  {e^{ut^P} \left[ {\lambda}^2 e^{ut^P} + v(\lambda + \lambda u t^P + v + 1 + \frac{u(u+\lambda+1)}{u+v+\lambda} )
  \right]}
  {( \lambda e^{ut^P} + v )^2} > 0
\end{equation}

Similarly, we take the derivative of $\mathbb{E}[Y^2]/2\mathbb{E}[Y]$ as follows,
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{dEY22EY}
  \frac{\mathrm{d}}{\mathrm{d}t^P} \frac{\mathbb{E}[Y^2]}{2\mathbb{E}[Y]} =
  \frac{e^{ut^P}r(t^P)}{{\left( he^{ut^P} + g\right)}^2},
\end{equation}
where
\vspace{-.1cm}
  \begin{align}
  \label{r(t)}
  r(t^P) =& uh^2e^{2ut^P} + (2ug-1)h^2e^{ut^P} - uhgt^P \notag \\
  &+ uhg^2 - hg(1+\frac{u}{v}) - \frac{h+g}{v} + \frac{u(v+\lambda)h}{v(u+v+\lambda)^2}.
\end{align}
We can easily find that
\vspace{-.1cm}
  \begin{equation}\vspace{-.1cm}
  \label{r(0)}
  r(0) = \frac{u(u+v)^2(2v+\lambda)}{\lambda v^2 (u+v+\lambda)^2} > 0.
\end{equation}
We further take the derivative of $r(t^P)$ and obtain that
\vspace{-.1cm}
\begin{equation}\vspace{-.1cm}
  \label{dr(t)}
  \frac{\mathrm{d}r(t^P)}{\mathrm{d}t^P}
  = uh\left(he^{ut^P}+g\right) \left[ 2\left(1+\frac{u}{v}\right)e^{ut^P} - 1\right] > 0.
\end{equation}
As a result, $r(t)>0$ for $t^P\in(0,+\infty)$ and thus $\mathbb{E}[Y^2]/2\mathbb{E}[Y]$ strictly monotonously increases $(0,+\infty)$. Lemma~\ref{lemma_AoI} is proved.

\small
\bibliographystyle{IEEEtran}


\section{Introduction}

\IEEEPARstart{O}{ptical} flow represents the 2D motion and correspondence relationship between two images at the pixel level, which is a fundamental problem in the field of computer vision. Optical flow has lots of applications in autonomous driving, such as  visual odometry \cite{min2020voldor}, target tracking \cite{ke2018real}, moving object detection, and mapping \cite{menze2018object,jiang2021moving}. In addition, the optical flow can be used to analyze the motion attributes of pedestrians and vehicles, so as to realize the dynamic understanding of scenes and decision-making. With the development of deep learning, good performance of optical flow estimation has been achieved by training on synthetic data \cite{dosovitskiy2015flownet,ilg2017flownet}. However, the gap between real data and synthetic data makes the supervised models on synthetic data have limited performance in real data. This spawned a large number of unsupervised studies of optical flow to make the trained optical flow network without the
gap when applied in real applications \cite{jason2016back,ren2017unsupervised,wang2018occlusion,meister2018unflow,alletto2018self,janai2018unsupervised,liu2019ddflow,liu2019selflow,zou2018df,ranjan2019competitive,wang2020unsupervised,jonschkowski2020matters}. Besides, the unsupervised method can utilize a large number of videos on the internet. The common basic idea behind the unsupervised learning of optical flow is based on the consistency between the target image and the reconstructed image. The reconstructed image is obtained by warping the source image utilizing the estimated optical flow field by the neural network model. Then, the neural network model is trained and updated to minimize the difference between the target image and the reconstructed image. This consistency assumption is not satisfied in the occlusion regions of images, so there are many previous works exploiting a lot of how to mask the occlusion regions \cite{wang2018occlusion,zou2018df,janai2018unsupervised,ranjan2019competitive,wang2020unsupervised,jonschkowski2020matters}.

However, there are seldom studies on the constraints of optical flow on non-occlusion regions. The smoothness loss is for all optical flow in an image. The reconstruction loss utilizes the luminosity constraint, not considering the geometry of the optical flow.
In this paper, it is found that there are also some geometric laws for the optical flow in the non-occlusion regions. To our best knowledge, this paper is the first to study the non-occlusion constraints of unsupervised optical flow learning. In this work, we reveal new geometric laws of the optical flow in non-occlusion regions and design two new unsupervised losses for the unsupervised learning of optical flow. Our contributions are as follows:

\begin{itemize}
	\item By carefully analyzing the motion of each pixel in real 3D space and 2D projected image, non-occlusion is defined in the 2D image in detail. New geometric laws of optical flow in the non-occlusion regions are revealed.
	\item Based on the insight into the geometric laws of optical flow in the non-occlusion regions, two novel loss functions, the optical flow non-intersection loss and the optical flow non-blocking loss, are proposed for the unsupervised learning of optical flow. The non-intersection loss defines that optical flows should not cross each other in non-occlusion regions. The non-blocking loss defines that a pixel should not be surrounded by other nearby pixels during the pixel motion between adjacent frames.
	\item We integrate our proposed unsupervised losses into a unified framework of unsupervised optical flow and the experiments demonstrated the effectiveness of our proposed losses. The experiments on real dataset, KITTI 2015 dataset \cite{geiger2012we,menze2015joint}, show the good generalization ability of our model.
\end{itemize}

The rest of this paper is organized as follows. Section II summarizes the related works. Section III analysis the optical flow of each pixel from 3D to 2D and reveals new geometric laws of optical flow in the non-occlusion regions. The architecture of our unsupervised system and two novel loss functions based on the geometric laws are introduced in Section IV. The experiments details and results are in Section V. And Section VI concludes this paper.

\begin{figure*}[t]
	\centering
	\resizebox{1.00\textwidth}{!}
	{
		\includegraphics[scale=1.00]{fig1.pdf}}
	\vspace{-3mm}
	\caption{Optical flow intersection and pixel blocking caused by occlusion. Fig. (a) shows the case of occlusion for rigid objects, while Fig. (b) shows the case of non-occlusion for flexible objects.}
	\label{occlusion_visual}

\end{figure*}

\begin{figure}[t]
	\centering
	\resizebox{1.00\columnwidth}{!}
	{
		\includegraphics[scale=1.00]{fig2.pdf}}
	\vspace{-4mm}
	\caption{An extreme situation that there are intersected flows, but there are not occlusion because of the big motion in consecutive frames.}
	\label{intersection}
	\vspace{-0pt}
\end{figure}

\begin{figure}[t]
	\centering
	\resizebox{0.80\columnwidth}{!}
	{
		\includegraphics[scale=1.00]{Fig3-1.pdf}}
	\vspace{-0mm}
	\caption{An extreme situation that there are blocked pixels, but there are not occlusion because of the big motions of multiple objects in consecutive frames. }
	\label{encircling}
	\vspace{-0pt}
\end{figure}

\section{Related Work}

Optical flow describes the pixel displacement on a 2D projected image because of the relative 3D motion between objects and the camera for observing \cite{gibson1950perception}.
Traditional methods define optical flow estimation as an energy minimization problem based on brightness consistency and spatial smoothness \cite{horn1981schunck,brox2004high,sun2010secrets}. With the rapid development of deep learning,
optical flow neural network can predict optical flow directly from a pair of images in an end-to-end manner \cite{dosovitskiy2015flownet,ilg2017flownet}. Ranjan et al. \cite{ranjan2017optical} propose the coarse-to-fine pyramid structure to make the network model size much smaller and improve the accuracy. Sun et al. \cite{ranjan2017optical} propose the PWC-Net, which performs warp operations and cost volume calculations for each level of the pyramid, showing the strong performance. Yang et al. \cite{yang2019volumetric} improve the volumetric layer by using the encoder-decoder architectures, to reduce parameters and achieve better performance. These supervised approaches need numerous data with optical flows labels to achieve better performance. However these data are expensive to obtain \cite{butler2012naturalistic,geiger2012we}, and sometimes special methods are even needed to get them, \cite{baker2011database}, which limits the application of these supervised methods.

The unsupervised approach avoids the need for labels through some regularization and has been the focus of recent research \cite{jason2016back,ren2017unsupervised,wang2018occlusion,meister2018unflow,alletto2018self,janai2018unsupervised,liu2019ddflow,liu2019selflow,zou2018df,ranjan2019competitive,wang2020unsupervised,jonschkowski2020matters}. The unsupervised method generates the optical flow by learning a function from the unlabeled dataset. As research goes on, the constraints of unsupervised training continue to increase, which allows neural networks to make more full use of unlabeled data, such as edge-aware smoothness \cite{wang2018occlusion}, photometric consistency loss \cite{wang2004image,sun2010secrets,zou2018df,meister2018unflow,ranjan2019competitive,liu2019ddflow,wang2019unos}, occlusion estimation \cite{wang2018occlusion,zou2018df,janai2018unsupervised,ranjan2019competitive,wang2020unsupervised}, distillation learning based on teacher and student models \cite{liu2019ddflow,liu2019selflow} and so on.
UFlow \cite{jonschkowski2020matters} systematically compares those key components in an unsupervised optical flow model to identify which is most effective and choose the best combination of those components, achieving the better performance in all benchmarks.

Besides those key components of unsupervised optical flow estimation, there are many other improvements. Wang et al. \cite{wang2018occlusion} explicitly model occlusion and propose a new warping approach to solve the problem of large estimation errors caused by large motions. Alletto et al. \cite{alletto2018self} divide the optical flow estimation into two steps: global transformation with homography and refinement by a deeper network, which can make the optical flow estimation more accurate. Janai et al. \cite{janai2018unsupervised} firstly use multi-frame information for occlusion processing in the unsupervised learning of optical flow. SelFlow \cite{liu2019selflow} utilizes temporal information from multiple frames for better flow estimation. Zhong et al. \cite{zhong2019unsupervised} propose Deep Epipolar Flow which incorporates global geometric constraints into network learning. Flow2Stereo \cite{liu2020flow2stereo} trains a network to estimate both flow and stereo, using triangle constraint loss and quadrilateral constraint loss. Df-net \cite{zou2018df} proposes the cross consistency loss of the depth and pose based rigid flow and optical flow in rigid regions. Ranjan et al. \cite{ranjan2019competitive} bring forward the idea of competitive collaboration to achieve unsupervised coordinated training of four tasks: depth, camera motion, optical flow, and motion segmentation. Wang et al. \cite{wang2019unsupervised,wang2020unsupervised} jointly estimate pose, depth, and optical flow in an unsupervised method by dividing an image into three parts: the occluded region, the non-rigid region, and the rigid region.

Many studied have done in these years for unsupervised learning of optical flow, as mentioned above. However, lots of works focus on the occlusion problem as the occlusion regions are not suitable for image reconstruction. There are seldom works on non-occlusion constraints. In this paper, novel unsupervised losses of optical flow are proposed based on geometric constraints in non-occlusion regions. The pixels in the non-occlusion regions are used to calculate these proposed losses: optical flow non-intersection loss and optical flow non-blocking loss, to punish the pixels that do not meet the constraints, which plays a guiding role in the model training.

\section{Geometric Laws of Optical Flow Field in the Non-occlusion Regions}\label{sec:laws}

2D image is a reflection of the real 3D world and the real motion takes place in 3D space. The 2D optical flow can be obtained by projecting the 3D scene flow to the 2D image plane as in Fig. \ref{occlusion_visual}. For the convenience of presentation and explanation, the camera is assumed to be stationary and the occlusion is caused by the motion of observed objects. In Fig. \ref{occlusion_visual}(a), at t frame, the car and the pedestrian can be seen by the camera, while the nearer car will occlude the farther pedestrian at $t+1$ frame. The pixels of cars and pedestrians at $t$ and $t+1$ frames are visualized on the image plane. The occluded pixels of the pedestrian will be surrounded by the pixels of the car. Similarly, the pixels of the car covering the pedestrian is also surrounded by the pixels of the pedestrian. At the same time, the pixels of different objects are intersected when occlusion appears. That is, flow intersection and pixel blocking have a connection with occlusion. Fig. \ref{occlusion_visual}(b) presents a non-occlusion flexible and deformable object. It can be seen that some pixels have a motion away from the camera in 3D space. There is an aggregated optical flow field but the optical flow is not intersected and the pixels are not blocked by surrounding adjacent pixel clusters.

From these observations, we infer the laws that the optical flow will not intersect each other and the pixels will not be blocked by surrounding adjacent pixel clusters in the non-occlusion regions. There are two extreme situations that are not consistent with the laws. It will be found that they happens so rarely in practice that the laws are satisfied in real applications.

As shown in Fig. \ref{intersection}, there is an extreme situation, where the car has a big motion and has intersected optical flows with the pedestrian, but they are not being occluded. They may accomplish the occlusion process in the consecutive frames or the trajectory of the car in the 2D image bypasses the pixels of the pedestrian. As in the consecutive frames, the motions are usually small compared with the size of the objects in the scene, our constraints are suitable in the real scenes.

If the pixels of something (eg. pedestrian in Fig. \ref{occlusion_visual}) are surrounded by the pixels of a nearer continuous body (eg. car in Fig. \ref{occlusion_visual}), the further thing will be occluded. However, if the surrounding four pixels are not from a continuous body, the assumption will not satisfied, as in Fig. \ref{encircling}. But the situation is so extreme that the inserted pedestrian and the two cars move so fast in the consecutive frames, and the pedestrian moves into the gap created by the movement of the cars.

\section{Unsupervised Learning of Optical Flow Based on Non-occlusion Constraints} \label{sec:constraints}

\subsection{The Overview of Our Unsupervised Framework of Optical Flow}  \label{sec:overview}

\begin{figure*}[t]
	\centering
	\resizebox{0.95\textwidth}{!}
	{
		\includegraphics[scale=1.00]{fig4.pdf}}
	\vspace{-0mm}
	\caption{The overview of our unsupervised learning pipeline of optical flow. Two images, $X_t$ and $X_{t+1}$, are fed into our network to estimate the optical flow. The forward-backward consistency based on the flow fields is used to estimate occlusion. The census loss compares the warped image $\widehat X_{t}$ to the corresponding original image $X_t$ and expresses their difference. Forward flow $V_t$ and backward flow $V_{t+1}$ are regularized using smoothness loss. Finally, the non-intersection loss and the non-blocking loss based on geometric constraints of optical flow are used to guide the training.}
	\label{network}
	\vspace{-0pt}
\end{figure*}

The overview of our unsupervised learning pipeline of optical flow is shown in Fig. \ref{network}. There are two adjacent images $X_t \in \mathbb{R}^{H \times W \times 3}$ and $X_{t+1} \in \mathbb{R}^{H \times W \times 3}$. They are input to an optical flow estimation network $f_\theta$ to get the forward optical flow $V_t = f_\theta(X_t,X_{t+1})$ and backward optical flow $V_{t+1} = f_\theta(X_{t+1},X_{t})$. The $V_t \in \mathbb{R}^{H \times W \times 2}$ indicates the 2D flow vector from $X_{t}$ to $X_{t+1}$ for each pixel in $X_t$, while $V_{t+1}$ indicates the optical flow from $X_{t+1}$ to $X_{t}$. Our objective is to obtain perfect parameters $\theta$ of the network from image sequences without the ground truth of optical flow to realize the optimized performance of optical flow. Fig. \ref{network} gives the losses in one direction ($t$ to $t+1$), and the other direction ($t+1$ to $t$) is similar. The consistency of forward and backward optical flow is used to estimate the occlusion regions \cite{wang2018occlusion}. Then, the non-occlusion regions are the other part in an image.

The optical flow connects the images of adjacent frames at the pixel level. The optical flow can be unsupervised trained  by measuring the corresponding matching of the pixels between two frames. The idea of measuring pixel matching between adjacent frames is commonly realized through image warping \cite{ranjan2017optical,sun2018pwc}. Firstly, the corresponding coordinates after optical flow are calculated as: $[\hat{i},\hat{j}]^T=[i,j]^T + [u_t,v_t]^T$. Then, the warped image can be obtained by the differentiable bilinear interpolation: $\hat{X}_t(i,j)=\sum_{i\in{\lfloor \hat i \rfloor,\lceil \hat i \rceil},j\in{\lfloor \hat j \rfloor,\lceil \hat j \rceil}}w^{ij}X_t(i,j)$, $\sum_{i,j}w^{ij} = 1$. $\lceil \cdot \rceil$ means rounding up to ceil, and $\lfloor \cdot \rfloor$ means rounding down to floor. Then, census loss \cite{meister2018unflow} is used to enforce the consistency of warped image $\widehat X_{t}$ and original image $X_{t}$ as shown below:
\begin{equation}
\begin{split}
L_{census} =& \sum_{} ( 1 - O_t) \cdot  \sigma(\rho(X_t, \hat X_t))\\ + &\sum_{}(1-O_{t+1}) \cdot  \sigma(\rho(X_{t+1}, \hat X_{t+1})),
\end{split}
\end{equation}
where $O_t$ and $O_{t+1}$ are forward occlusion mask and backward occlusion mask, respectively. $\sigma\left(x\right) = \left( |x| + \epsilon \right)^q$ is the robust loss function \cite{liu2019ddflow}, where $\epsilon = 0.01$, $q = 0.4$. The brightness constancy $\rho (X_t,\hat X_t)$ is used to measure the difference between warped image and original image.

The smooth loss makes the estimated flow smooth according to the pixel gradient of the image. As with most methods, we use first-order and second-order smooth loss. The formula is shown as below:
 \begin{equation}
 L_{smooth\left(k\right)}=\frac{1}{N} \sum |\nabla^k V_t| \cdot  exp(-\frac{\mu}{3} \sum_{i}|\nabla X_t^i| ),
 \end{equation}
where $\mu$ is weight based on the color channel ($i\in\{0,1,2\}$) of $X_t^i$ and $\mu = 150$. $k$ expresses the order of smoothness.

The non-intersection loss $L_{non-inter}$ and non-blocking $L_{non-block}$ loss are proposed in this paper to constraint and regulate optical flow learning inspired by the geometric laws of flow field introduced in Section \ref{sec:laws}. These losses are introduced in Section \ref{sec:intersection} and Section \ref{blocking}. In addition, we also utilize the idea of  distillation learning based on teacher and student models \cite{liu2019ddflow, liu2019selflow}. The loss of distillation learning is represented as $L_{dist}$.

In summary, the overall loss function is:
 \begin{equation}
 \begin{split}
L_{all} =& \alpha_1 L_{census} + \alpha_2 L_{smooth\left(k\right)} + \alpha_3 L_{non-inter} \\+& \alpha_4 L_{non-block} + \alpha_5 L_{dist},
\end{split}
 \end{equation}
where $\alpha_1 = 1$, $\alpha_2 = 4$, $\alpha_3 = \alpha_4 = 0.01$. As for the setting of $\alpha_5$, we follow the method of UFlow \cite{jonschkowski2020matters}, which is 0 for the first 50 percent of the training and then increases to a constant.

\subsection{The Non-intersection Loss} \label{sec:intersection}

Because the motion is small, the displacement described by optical flow can be regarded as the actual trajectories of pixel. Usually, an image has a big amount of pixels (eg. $448 \times 1024$ pixels in an image for the Sintel dataset \cite{butler2012naturalistic}), which is massive to calculate the relationship for the optical flow vectors of every two pixels. Inspired by the convolution in 2D, we calculated the results of each local regions and make all local calculation paralleled.

A $3 \times 3$ sliding kernel is used to calculate the loss in each local area, and 1 is as the sliding step. For an image with a size of $H \times W$, there are $(H-2) \times (W-2)$ basic units totally. Fig. \ref{non_intersection} is a schematic diagram of the basic unit extracted by the sliding kernel, and the dashed box represents a basic unit extracted by the sliding kernel. With 1 as the sliding step, the sliding kernel moves one pixel to the right or to the down to extract the next basic unit. Based on this principle, $(H-2) \times (W-2)$ basic units with a size of $3 \times 3$ can be extracted from an image with a size of $H \times W$.

Parallel calculation is used to improve calculation efficiency. The whole image is divided into several basic units, and the optical flow non-intersection loss is calculated between the middle pixel and the 8 adjacent pixels in each basic unit. For the non-occlusion regions of the image $X_t$, as analysed in Section \ref{sec:laws}, the pixels will not intersect with each other, so the loss of optical flow non-intersection is calculated to penalize outliers. Among them, $P_{mid}$ corresponds to the middle pixel of a basic unit, and $P_i$ ($i=1,2,...8$) corresponds to other pixels adjacent to $P_{mid}$ in the basic unit. As shown in Fig. \ref{non_intersection}, the pixel points $P_i^t$ and $P_{mid}^{t}$ are in the first frame, and the corresponding pixels in the second frame are $P_i^{t+1}$ and $P_{mid}^{t+1}$. If the optical flow $\overrightarrow{P_{mid}^t P_{mid}^{t+1}}$ does not intersect the optical flow $\overrightarrow{P_i^{t} P_i^{t+1}}$, then the optical flow non-intersection loss between the pixel points $P_{mid}^t$ and $P_i^t$ is 0; Otherwise, it is considered that occlusion occurs between pixels. The optical flow non-intersection loss is calculated as the following steps.

There are usually different colors on both sides of the object edge, where the occlusion is prone to occur. The interior of the object is not easy to be occluded. Therefore, the loss function has a greater punishment on the interior of the object and less to the edge of the object. Therefore, the weight $w_i$ of optical flow non-intersection loss is calculated based on the degree of color difference between the middle pixel $P_{mid}$ and the surrounding 8 pixel points $P_i$ in each basic unit:
\begin{equation}{w_i} = \exp ( - \frac{1}{3}\sum\limits_{j \in \{ R,G,B\} } {\left| {{P_{i,j}} - {P_{mid,j}}} \right|} ),
\end{equation}
where $P_{mid}$ is the middle pixel of the basic unit, $P_i$ corresponds to other pixels adjacent to $P_{mid}$ in the basic unit ($i=1,2,...,8$). $P_{i,j}$ and $P_{mid,j}$ represent the three channel values of the RGB color space corresponding to the pixel points of $P_i$ and $P_{mid}$.

As shown in Fig. \ref{non_intersection}, the optical flow intersection coefficients $\mu_i$ and $\lambda_i$ represent the ratio of the intersection position to the length of the optical flow vector:
\begin{equation}\begin{gathered}
		{\lambda _i} = \frac{1}{\Lambda }\left| {\begin{array}{*{20}{c}}
				{{x_i^t} - {x_{mid}^t}}&{ - \Delta {x_i^t}} \\
				{{y_i^t} - {y_{mid}^t}}&{ - \Delta {y_i^t}}
		\end{array}} \right|, \hfill \\
		{\mu _i} = \frac{1}{\Lambda }\left| {\begin{array}{*{20}{c}}
				{\Delta {x_{mid}^t}}&{{x_i^t} - {x_{mid}^t}} \\
				{\Delta {y_{mid}^t}}&{{y_i^t} - {y_{mid}^t}}
		\end{array}} \right|, \hfill \\
	\Lambda  =  - \Delta {x_{mid}^t}\Delta {y_i^t} + \Delta {x_i^t}\Delta {y_{mid}^t},
	\end{gathered}
\end{equation}
where $(x_{mid}^t, y_{mid}^t)$ is the coordinate of the intermediate pixel $P_{mid}^t$ in the $t$ frame, and $(x_i^t, y_i^t)$ is the coordinate of adjacent pixel $P_{i}^t$ in the $t$ frame.  $\overrightarrow{P_{mid}^t P_{mid}^{t+1}} = (\Delta {x_{mid}^t}, \Delta {y_{mid}^t})$ and $\overrightarrow{P_{i}^t P_{id}^{t+1}} = (\Delta {x_{i}^t}, \Delta {y_{i}^t})$ are the optical flow displacements of the pixel points, $P_{mid}^t$ and $P_{i}^t$ , from the $t$ frame to the $t+1$ frame. When $0<\mu_i,\lambda_i<1$, $\overrightarrow{P_{mid}^t P_{mid}^{t+1}}$ and $\overrightarrow{P_{i}^t P_{id}^{t+1}}$ will intersect.

The optical flow non-intersection loss $L_k$ of the intermediate pixel relative to all 8 adjacent surrounding pixels in the $k$-th basic unit is calculated as follows:
\begin{equation}
{L_k} = \left\{ {\begin{array}{*{20}{l}}
		{\frac{1}{8}\sum\limits_{i = 1}^8 {{w_i}\sigma\left(\exp ( - {{\left| {{\lambda _i} - {\mu _i}} \right|}^2})\right)},}&{0 < {\lambda _i},{\mu _i} < 1,} \\
		{0,}&{{\text{Others}}.}
\end{array}} \right.
\end{equation}

\begin{figure}[t]
	\centering
	\resizebox{0.90\columnwidth}{!}
	{
		\includegraphics[scale=1.00]{fig5.pdf}}
	\vspace{-1mm}
	\caption{Schematic diagram of the intersection of optical flow $\protect\overrightarrow{P_{mid}^t P_{mid}^{t+1}}$ and optical flow $\protect\overrightarrow{P_6^{t} P_6^{t+1}}$.}
	\label{non_intersection}
	\vspace{-0pt}
\end{figure}

$L_k$ is calculated in one basic unit and a total of $(H-2)\times(W-2)$ basic units are extracted. Then, $L_{non-inter}$ represents the average non-intersection loss of optical flow for these $(H-2)\times(W-2)$ units:
 \begin{equation}
  L_{non-inter} = \frac{1}{(H-2)\times(W-2)}\sum\limits_{k = 1}^{(H-2)\times (W-2)} {L_k}. \end{equation}

\subsection{The Non-blocking Loss}\label{blocking}

As analysed in Section \ref{sec:laws}, in the non-occlusion area, there will be no pixel blocking when the object moving. The parallelization technique is also used here similar to Section \ref{sec:intersection}.

Taking $4\times 4$ as the sliding kernel size and 1 as the sliding step size. Fig. \ref{non_blocking} shows the schematic diagram of the pixel blocking for a basic unit extracted by the sliding kernel, and the dashed box represents a basic unit extracted by the sliding kernel. With 1 as the sliding step, the sliding kernel moves one pixel to the right or to the down to extract the next basic unit. Based on this principle, $(H-3) \times (W-3)$ basic units with a size of $4 \times 4$ can be extracted from the image at $t$ frame with a size of $H \times W$. Parallelization is used to calculate the extracted $(H-3) \times (W-3)$ basic units. In each basic unit, the optical flow non-blocking loss of 12 pixels in the periphery is calculated based on the blocking calculation with the 4 pixels in the middle. Our proposed method determines and measures how far the surrounding pixels flow into the inside of the quadrilateral composed of 4 pixels in the middle.

Define a basic unit with 4 pixels ${A,B,C,D}$ in the middle and 12 pixels $P_i$ in the periphery, where $i=1,2,...,12$. The four pixels $A, B, C, D$ in the middle of the basic unit at $t$ frame constitute a quadrilateral $\overline {ABCD}$ at $t+1$ frame, which can be divided into two triangles by a diagonal line. When the quadrilateral $\overline {ABCD}$ at the second frame is a convex quadrilateral, according to the selection of different diagonals $\overline {AC}$ or $\overline {BD}$ for division, there are two cases where the quadrilateral $\overline {ABCD}$ contains two triangles. For any of the two division cases, if the peripheral pixels flow into a triangle, it can be inferred that occlusion occurs. (For the sake of brief expression, we classify the points falling on the boundary of the triangle as being within the triangle, because this will not affect the subsequent distance calculation.) As shown in Fig. \ref{non_blocking}(a), According to the diagonal $\overline {AC}$, the quadrilateral is divided into triangles $\overline {ABC}$ and $\overline {ACD}$. The point $P_i$ flows inside triangle $\overline {ABC}$.

However, if the quadrilateral $\overline {ABCD}$ at the second frame is a concave quadrilateral, the division case with diagonals $\overline {AC}$ as shown in Fig. \ref{non_blocking}(b) is not enough to determine that the pixel $p_5$ falls inside the quadrilateral $\overline {ABCD}$. If $\overline {AC}$ is as the diagonal in the calculation progress, the point $P_5$ is simultaneously inside triangles $\overline {ABC}$ and $\overline {ACD}$. However, the point $P_5$ is not blocked by the quadrilateral $\overline {ABCD}$, but this can be judged by using the diagonal $\overline {BD}$ to divide. According to the diagonal $\overline {BD}$, the quadrilateral $\overline {ABCD}$ is divided to triangles $\overline {ABD}$ and $\overline {BCD}$, and the point $P_5$ is not inside $\overline {ABD}$ or $\overline {BCD}$. Therefore, only the point $P_i$ is inside a triangle both in the two division cases, the pixel blocking occurs for the point $P_i$.

For triangle $\overline {ABC}$ and point $P_i$, when $\overrightarrow{BA} \times \overrightarrow{BP}, \overrightarrow{AC} \times \overrightarrow{AP}, \overrightarrow{CB} \times \overrightarrow{CP}$ are in the same direction, it can be judged that $P_i$ is within $\overline {ABC}$. In the same way, it can be inferred if $P_i$ is within ${\overline{ACD}}$, $\overline{ABD}$ and $\overline{BCD}$. The logic expression is as follows:
\begin{small}\begin{equation}\begin{gathered}
			{\Gamma _{\overline {ABC} }} =\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {BA} }}}\!\!\! &\!\! {{x_{\overrightarrow {BP} }}} \\
						{{y_{\overrightarrow {BA} }}}\!\!\! &\!\! {{y_{\overrightarrow {BP} }}}
				\end{array}} \!\!\!\right| \!\! \geqslant \!\! 0} \right)\!\! \wedge \!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {AC} }}}\!\!\! &\!\! {{x_{\overrightarrow {AP} }}} \\
						{{y_{\overrightarrow {AC} }}}\!\!\! &\!\! {{y_{\overrightarrow {AP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {CB} }}}\!\!\! &\!\! {{x_{\overrightarrow {CP} }}} \\
						{{y_{\overrightarrow {CB} }}}\!\!\! &\!\! {{y_{\overrightarrow {CP} }}}
				\end{array}} \!\!\! \right| \!\!\geqslant\!\! 0} \right) \hfill \\
			{\Gamma _{\overline {ACD} }} =\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {CA} }}}\!\!\! &\!\! {{x_{\overrightarrow {CP} }}} \\
						{{y_{\overrightarrow {CA} }}}\!\!\! &\!\! {{y_{\overrightarrow {CP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {AD} }}}\!\!\! &\!\! {{x_{\overrightarrow {AP} }}} \\
						{{y_{\overrightarrow {AD} }}}\!\!\! &\!\! {{y_{\overrightarrow {AP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {DC} }}}\!\!\! &\!\! {{x_{\overrightarrow {DP} }}} \\
						{{y_{\overrightarrow {DC} }}}\!\!\! &\!\! {{y_{\overrightarrow {DP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \hfill \\
			{\Gamma _{\overline {ABD} }} =\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {BA} }}}\!\!\! &\!\! {{x_{\overrightarrow {BP} }}} \\
						{{y_{\overrightarrow {BA} }}}\!\!\! &\!\! {{y_{\overrightarrow {BP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {AD} }}}\!\!\! &\!\! {{x_{\overrightarrow {AP} }}} \\
						{{y_{\overrightarrow {AD} }}}\!\!\! &\!\! {{y_{\overrightarrow {AP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {DB} }}}\!\!\! &\!\! {{x_{\overrightarrow {DP} }}} \\
						{{y_{\overrightarrow {DB} }}}\!\!\! &\!\! {{y_{\overrightarrow {DP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \hfill \\
			{\Gamma _{\overline {BCD} }} =\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {BD} }}}\!\!\! &\!\! {{x_{\overrightarrow {BP} }}} \\
						{{y_{\overrightarrow {BD} }}}\!\!\! &\!\! {{y_{\overrightarrow {BP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {DC} }}}\!\!\! &\!\! {{x_{\overrightarrow {DP} }}} \\
						{{y_{\overrightarrow {DC} }}}\!\!\! &\!\! {{y_{\overrightarrow {DP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \!\!\wedge\!\! \left( {\left|\!\!\! {\begin{array}{*{20}{c}}
						{{x_{\overrightarrow {CB} }}}\!\!\! &\!\! {{x_{\overrightarrow {CP} }}} \\
						{{y_{\overrightarrow {CB} }}}\!\!\! &\!\! {{y_{\overrightarrow {CP} }}}
				\end{array}} \!\!\!\right| \!\!\geqslant\!\! 0} \right) \hfill
\end{gathered} \end{equation}\end{small}
where $\Gamma_{\overline {ABC} },\Gamma_{\overline {ACD} },\Gamma_{\overline {ABD} }$, and $\Gamma_{\overline {BCD} }$ represent if $P_i$ is in the triangles $\overline {ABC}, \overline {ACD},\overline {ABD}$, and $\overline {BCD}$, respectively. As analysed above, it is inferred that $P_i$ flows into  the quadrilateral $\overline {ABCD}$ when $P_i$ flows at least into a triangle both in the two division cases, that is:
\begin{equation}
	{\Gamma _{\overline {ABCD} }}=\left( {{\Gamma _{\overline {ABC} }} \vee {\Gamma _{\overline {ACD} }}} \right) \wedge \left( {{\Gamma _{\overline {ABD} }} \vee {\Gamma _{\overline {BCD} }}} \right).
\end{equation}

\begin{figure}[t]
	\centering
	\resizebox{0.95\columnwidth}{!}
	{
		\includegraphics[scale=1.00]{fig6.pdf}}
	\vspace{-3mm}
	\caption{The geometric relation diagram of peripheral  pixels and quadrilateral $\overline {ABCD}$. (a) corresponds to the situation that quadrilateral $\overline {ABCD}$ is convex quadrilateral, and (b) corresponds to the situation that quadrilateral $\overline {ABCD}$ is concave quadrilateral. }
	\label{non_blocking}
	\vspace{-0pt}
\end{figure}

According to the spatial geometric relationship between the quadrilateral $\overline {ABCD}$ formed by the intermediate four pixels and each peripheral pixel $P_i$ in a basic unit, the optical flow non-blocking loss $E_i$ of the pixel $P_i$ is defined as:
\begin{equation}
{{E_k}} = \left\{ {\begin{array}{*{20}{l}}
			{\frac{1}{{12}}\sum\limits_{i = 1}^{12}{e^{ - \frac{1}{{{d_i}}}}},}&{{\Gamma _{\overline {ABCD} }} = True,} \\
			{0,}&{{\Gamma _{\overline {ABCD} }} = False,}
	\end{array}} \right.\end{equation}
where $d_i$ is the minimum distance of $P_i$ to each side of the quadrilateral $\overline {ABCD}$.

The above is about the loss for a peripheral pixel $P_i$ in a basic unit. There are a total of $(H-3)\times (W-3)$ basic units for the source image, and each unit includes $12$ peripheral pixels. The optical flow  non-blocking loss of the entire image is as follows:
\begin{equation}
{L_{{\text{non  -  blocking }}}} = \frac{1}{{(H - 3)\times(W - 3)}}\sum\limits_{k = 1}^{(H - 3)\times(W - 3)} {{E_k}}.
\end{equation}

\setlength{\tabcolsep}{6mm}
\begin{table*}[t]
	\centering
		\caption{The experiment results training and testing on synthetic dataset. 'ft' means that the models of optical flow estimation are fine-tuned on specific evaluation datasets after supervising, which is not conducive to practical application. The results in parentheses are not comparable because its training set contains the evaluation set. "()" means that the results are supervised trained on the evaluation set. "\{\}" means that the results are unsupervised trained on the evaluation set, and "[]" means that the results are trained on the dataset related to the evaluation set. The best results under every evaluation set are marked in bold. Unpublished results are marked as '-'.}

	\footnotesize
	\begin{center}

		\begin{tabular}{lccccc}
			\toprule

			&&\multicolumn{2}{c}{EPE on Sintel Clean\cite{butler2012naturalistic}}  &\multicolumn{2}{c}{EPE on Sintel Final\cite{butler2012naturalistic}}       \\
			\cline{3-6}\noalign{\smallskip}
			\multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}} Method\end{tabular}}

			&\multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}} Multi-frame\end{tabular}}
			& Train & Test & Train & Test \\

			\hline
			\noalign{\smallskip}

			FlowNet2-ft \cite{ilg2017flownet}
			&
			&(1.45)	&4.16
			&(2.01)	&5.74

			\\

			PWC-Net-ft \cite{sun2018pwc}
			&
			&(1.70)	&3.86
			&(2.21)	&5.13

			\\

			SelFlow-ft \cite{liu2019selflow}
			&
			&(1.68)	&[3.74]
			&(1.77)	&\{4.26\}

			\\

			VCN-ft \cite{yang2019volumetric}
			&
			&(1.66)	&2.81
			&(2.24)	&4.40

			\\
			\hline
			\noalign{\smallskip}

			FlowNet2 \cite{ilg2017flownet}
		    &
			&\bf2.02	&\bf3.96
			&\bf3.14	&\bf6.02

			\\

			PWC-Net \cite{sun2018pwc}
			&
			&2.55	&-
			&3.93	&

			\\

			VCN \cite{yang2019volumetric}
			&
			&2.21	&-
			&3.62	&-

			\\
			\hline
			\noalign{\smallskip}
			DSTFlow \cite{ren2017unsupervised}
			&
			&\{6.16\}	&10.41
			&\{7.38\}	&11.28

			\\

			OAFlow \cite{wang2018occlusion}
			&
			&\{4.03\}	&7.95
			&\{5.95\}	&9.15

			\\

			UnFlow \cite{meister2018unflow}
			&
			&-      &-
			&7.91	&10.21

			\\

			MFOccFlow \cite{janai2018unsupervised}
			&$\surd$
			&\{3.89\}	&7.23
			&\{5.52\}	&8.81
			\\

			EPIFlow \cite{zhong2019unsupervised}
			&$\surd$
			&3.94	&7.00
			&5.08	&8.51
			\\

			DDFlow \cite{liu2019ddflow}
			&$\surd$
			&\{2.92\}&6.18
			&\{3.98\}	&7.40
			\\

			SelFlow \cite{liu2019selflow}
			&$\surd$
			&[2.88]	&[6.56]
			&\{3.87\}	&\{6.57\}
			\\

			UFlow-test\cite{jonschkowski2020matters}
			&
			&3.01	&-
			&4.09	&-
			\\

			UFlow-train\cite{jonschkowski2020matters}
			&
			&\{2.50\}	&5.21
			&\{3.39\}	&6.50
			\\

			Our-test
			&
			&\bf2.94	&-
			&\bf3.95	&-
			\\

			Our-train
			&
			&\{2.47\}	&\bf4.26
			&\{3.57\}	&\bf6.28
			\\
			\bottomrule
		\end{tabular}

	\end{center}
	\vspace{-0pt}
	\label{sintel}
\end{table*}

\setlength{\tabcolsep}{4.5mm}
\begin{table*}[t]
	\centering
		\caption{The experiment results training on the synthetic datasets while testing on both synthetic and real datasets. 'MF' means that the method utilizes the information of multiple frames. The best results for each evaluation dataset are marked in bold. }

	\footnotesize
	\begin{center}

		\begin{tabular}{clcccccc}
			\toprule

			&&\multicolumn{1}{c}{Flying Chairs \cite{dosovitskiy2015flownet}}  &\multicolumn{2}{c}{Sintel train \cite{butler2012naturalistic}}  	&\multicolumn{3}{c}{KITTI-2015 train \cite{menze2015joint}}
			\\
			\cline{3-8}\noalign{\smallskip}

			\multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}} Training Dataset\end{tabular}}
			&\multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}} Method \end{tabular}}& Test & Clean & Final & All &Noc &ER\% \\

			\hline
			\noalign{\smallskip}
			\multirow{5.5}{*}{\begin{tabular}[c]{@{}c@{}} Flying Chairs \cite{dosovitskiy2015flownet} \\dataset \end{tabular}}

			&PWC-Net \cite{sun2018pwc}
			&\bf2.00	&3.33
			&4.59	&13.20
			&-      &41.79

			\\

			&DDFlow \cite{liu2019ddflow} {(MF)}
			&2.97   &4.83
			&4.85	&17.26
			&-      &-
			\\

			&UFlow-test \cite{jonschkowski2020matters}
			&\{2.82\}	&4.36
			&5.12	&15.68
			&7.96      &32.69
			\\

			&UFlow-train \cite{jonschkowski2020matters}
			&2.55	&3.43
			&4.17	&11.27
			&5.66   &30.31
			\\

			&Ours-test
			&2.72	&4.63
			&5.32	&15.43
			&7.23   &28.11
			\\

			&Ours-train
			&2.52	&\bf3.23
			&\bf4.15	&\bf9.84
			&\bf4.65   &\bf26.67
			\\

			\hline
			\noalign{\smallskip}
			\multirow{5.5}{*}{\begin{tabular}[c]{@{}c@{}}Sintel  \\dataset \cite{butler2012naturalistic}\end{tabular}}

			&PWC-Net\cite{sun2018pwc}
			&3.69	&\bf(1.86)
			&\bf(2.31)	&10.52
			&-      &30.49

			\\

			&DDFlow \cite{liu2019ddflow} (MF)
			&3.46   &\{2.92\}
			&\{3.98\}	&12.69
			&-      &-
			\\

			&UFlow-test \cite{jonschkowski2020matters}
			&3.39	&3.01
			&4.09	&7.67
			&3.77      &\bf17.41
			\\

			&UFlow-train \cite{jonschkowski2020matters}
			&3.25	&\{2.50\}
			&\{3.39\}	&9.40
			&4.53   &20.02
			\\

			&Ours-test
			&2.87	&2.94
			&3.95	&\bf7.52
			&\bf3.38   &18.63
			\\

			&Ours-train
			&\bf2.82	&\{2.47\}
			&\{3.57\}	&8.40
			&3.60   &20.27
			\\

			\bottomrule
		\end{tabular}

	\end{center}
	\vspace{-0pt}
	\label{KITTI}
\end{table*}

\section{Experiments}
\subsection{Training and Testing Details}\label{detail}
In order to demonstrate the effectiveness of our proposed method, our model is evaluated on the standard optical flow benchmark datasets: Flying Chairs dataset \cite{dosovitskiy2015flownet}, Sintel dataset \cite{butler2012naturalistic}, and KITTI 2015 datasets \cite{geiger2012we,menze2015joint}. Flying Chairs and Sintel are synthetic datasets, and KITTI is a real dataset. The Flying Chairs dataset contains a total of 22,872 pairs of images, of which 22,232 pairs are used as the training set and the remaining 640 pairs are used as the test set. For the Sintel dataset, we divide the training set and test set according to the standard classification criteria, where the training set contains 2082 images and the test set contains 1128 images. The training set and test set in KITTI 2015 dataset both contain 200 pairs of images. For Sintel, it is  common to train on the training set, and report the benchmark performance on the test set, which is included in our experiment. We expect to evaluate the generalization ability of our model on different datasets. However, the test set does not have public labels and there is a limit on the number of submissions to the official test set, so to be convenient for our experiments, we also train on the test set and evaluate on the training set. Therefor, there are two trained models for Sintel dataset. One is trained on the training set, the other is trained on the test set. Since the Sintel dataset contains both final and clean parts, they are used both when training the model and separately when evaluating the model, like UFlow \cite{jonschkowski2020matters}. In addition, pretraining is a very common method to improve accuracy in both supervised\cite{dosovitskiy2015flownet,sun2018pwc} and unsupervised\cite{liu2019ddflow,zhong2019unsupervised} optical flow estimation, so we have a pretraining stage in the trainging set of Flying Chairs before our formal training on Sintel. For KITTI, the raw KITTI 2015 dataset is used to verify the generalization ability of our model. We use the training set of KITTI 2015 as our evaluation set because the training set has public ground truth of the optical flow. It is expected that our method can be trained on synthetic datasets and evaluated on real datasets to achieve better generalization performance.

\begin{figure*}[t]
	\centering
	\resizebox{1.00\textwidth}{!}
	{
		\includegraphics[scale=1.00]{vision.pdf}}
	\vspace{-4mm}
	\caption{The visualization of our qualitative results compared with UFlow \cite{jonschkowski2020matters} on Sintel Clean, Sintel Final, and KITTI 2015 datasets respectively. These qualitative results show the effect of our method, with good results for independent moving objects as well as fine details.}
	\label{vision}
	\vspace{-0pt}
\end{figure*}

As with most previous works, we use EPE (Endpoint Error) and ER (Error Rates) as our evaluation metrics. Our network structure is based on PWC-Net \cite{sun2018pwc}, similar to UFlow \cite{jonschkowski2020matters}. All experiments are performed with 1 as the batch size on a single of RTX 2080Ti. Our experiments are based on TensorFlow 2.2.0. The Adam \cite{kingma2014adam} method is used as the optimizing strategy of training, where $\beta_1 = 0.9$, $\beta_2 = 0.999$. In the pretraining stage, the learning rate is a constant, $10^{-4}$. In the training phase, exponential decay is used. The learning rate decays 0.5 times per 200 epochs from $10^{-4}$ to $10^{-8}$, similar to UFlow \cite{jonschkowski2020matters}.

\subsection{Results}

Two series of experiments are conducted. The first group of experiments are trained and evaluated on the synthetic dataset. The second group of experiments are trained on synthetic dataset and evaluated on real dataset to verify the generalization ability of our method. Experimental methods and details are as Section \ref{detail}.

\subsubsection{Testing on Synthetic Dataset}

The quantitative evaluation results on the synthetic dataset (Sintel dataset) are shown in Table \ref{sintel}, which shows the results of unsupervised and supervised optical flow methods. Compared with MFOccFlow \cite{janai2018unsupervised}, EPIFlow \cite{zhong2019unsupervised}, DDFlow \cite{liu2019ddflow} and SelFlow \cite{liu2019selflow}, our method does not need to use the information of multiple frames but achieves better performance, which depends on our proposed novel constraints in the non-occlusion regions. In addition, SelFlow \cite{liu2019selflow} downloads the raw Sintel movie and extracts about 10,000 images, which makes its training data include both the official training set and the test set, while our method only trains on the official training set or test set. UFlow \cite{jonschkowski2020matters} systematically compares and improves occlusion segmentation methods. On the basis of getting the fine non-occlusion regions, we propose a geometry-based unsupervised constraint method for the optical flow in the non-occlusion regions. Compared with UFlow \cite{jonschkowski2020matters}, we make better use of the details of the non-occlusion regions and achieve better performance.

\subsubsection{Generalization Test on Real Dataset}

We evaluate the generalization of the model on the real dataset, KITTI. To evaluate the generalization of the model broadly, the models trained on different datasets will be evaluated on all datasets, and the results are shown in Table \ref{KITTI}. Specifically, models are trained on synthetic datasets, Flying Chairs and Sintel, and tested on multiple datasets, Flying Chairs, Sintel, and KITTI. Compared with PWC-Net \cite{sun2018pwc}, our unsupervised results are not as good as that of PWC-Net \cite{sun2018pwc} when trained and tested on the Flying Chairs dataset. However, our generalization performance outperforms the supervised approach, PWC-Net \cite{sun2018pwc}, on both the more complex synthetic data, Sintel, as well as the real dataset, KITTI. When trained on Sintel dataset, our generalization performance on both Flying Chairs and KITTI also outperforms PWC-Net \cite{sun2018pwc}. We use the network structure similar to PWC-Net \cite{sun2018pwc}, and our results are not as good as it in the training set, but achieve higher generalization performance in other datasets. It is difficult to obtain the ground truth of optical flow for the real dataset, so our unsupervised method has great practical application ability. DDFlow \cite{liu2019ddflow} is a multi-frame approach, and we only use two adjacent frames to achieve better results. After the UFlow \cite{jonschkowski2020matters} segments the occlusion regions, we implement fine geometric constraints of optical flow in the non-occlusion regions to achieve higher generalization performance, which indicates that better use of the essential information of optical flow in the non-occlusion regions can further improve the unsupervised performance of optical flow.

The qualitative results of our method compared with UFlow \cite{jonschkowski2020matters} on Sintel and KITTI 2015 benchmarks are shown in Fig ~\ref{vision}. It can be seen that our optical flow estimation is more uniform inside each moving objects, such as machetes, moving people, cars, grass, etc. This is because the optical flow cannot move randomly due to the proposed non-intersection and non-blocking losses inside the objects. Thus, the optical flow inside a single object is kept flexibly consistent for its motion, and the overall smoothness of optical flow for each object is ensured. At the same time, the constraints between adjacent objects also make the estimation of optical flow more accurate, such as the car motion estimation in the last two lines of Fig.~\ref{vision}. After the estimation the occlusion mask, the relative movement between adjacent objects can only be towards to cover occlusion regions. Otherwise, the relative movement of the adjacent objects can produce intersection and blocking of the optical flow. So that the relative movements of the adjacent objects are constrained, improving the optical flow estimation of adjacent objects. In addition, our visualized results are also better at detailed movements, such as pedestrian legs and butterfly movements.

\section{Conclusion}

In this paper, the motion regularity of the optical flow in the non-occlusion regions is carefully analyzed, and the geometric constraint laws of the optical flow in the non-occlusion regions are proposed. Two loss functions, non-intersection loss and non-blocking loss, are proposed based on the insight into the motion laws of optical flow in the non-occlusion regions. Their effectiveness has been proved by theoretical analysis and experiments. Optical flow is widely used in visual odometry, target tracking, dynamic segmentation, and other autonomous driving fields. The proposed method has a higher generalization performance on the real dataset, which makes the unsupervised method of optical flow in this paper have good practical application ability. Pixel-level geometric analysis and occlusion analysis are also instructive for depth estimation, visual odometry, depth completion, and scene flow estimation.

\bibliographystyle{IEEEtran}