### 5.1 Problem reformulation

Although task offloading over unlicensed spectrum is a powerful complement to that via licensed spectrum, the consideration of offloading on unlicensed spectrum introduces additional optimization variables, such as the time fraction occupied by each vehicle and the transmit power on unlicensed channels. As a result, the wireless communication scenario considered becomes complex and the corresponding problem becomes non-convex.

To break this barrier, we introduce a new variable \(\gamma _k\left( t \right)\) defined as \(\gamma _k\left( t \right) = p_{k}^{\mathrm{U}}\left( t \right) s_k\left( t \right)\). By replacing \(p_{k}^{\mathrm{U}}\left( t \right)\) with \(\frac{\gamma _k\left( t \right) }{s_k\left( t \right) }\), problem (7) turns out to be convex, as described in the following process.

Firstly, based on the above replacement, the objective function of problem (20) becomes linear. Secondly, we define a function as

$$\begin{aligned} f\left( x,y \right) =-C_1y\log _2\left( 1+\frac{C_2x}{y} \right) , \end{aligned}$$

(8)

where \(C_1\) and \(C_2\) are constants. Through the positive definiteness of the Hessian matrix, it has been proved to be a convex one. Then, by replacing \(p_{k}^{\mathrm{U}}\left( t \right)\) with \(\frac{\gamma _k\left( t \right) }{s_k\left( t \right) }\), (5) and (7f) are transformed separately into

$$\begin{aligned}D_{k}^{\mathrm{U}}\left( t \right) = s_k\left( t \right) B_k^{\mathrm{U}}\tau \log _2\left( 1+\frac{\gamma _k\left( t \right) h_{k}^{\mathrm{U}}\left( t \right) }{N_0^{\mathrm{U}}s_k\left( t \right) B_k^{\mathrm{U}}} \right) , \end{aligned}$$

(9)

$$\begin{aligned}0\le \gamma _k\left( t \right) \le P_k^{\mathrm{U}}S_k. \end{aligned}$$

(10)

It is not difficult to identify that \(D_{k}^{\mathrm{U}}\left( t \right)\) can be expressed as

$$\begin{aligned} D_{k}^{\mathrm{U}}\left( t \right) = - f\left( \gamma _k\left( t \right) ,s_k\left( t \right) \right) . \end{aligned}$$

(11)

Therefore, constraints in (7) comprise a convex set and the problem now becomes a convex one, which can be solved by Lagrangian dual method [41].

The Lagrange dual function of (7) at time slot *t* can be written as

$$\begin{aligned} {\mathcal {L}}\left( {\mathbf {X}}\left( t \right) , {{\varvec{\lambda }} }\left( t \right) , \eta \left( t \right) \right)&= \sum _{k\in {\mathcal {K}}}{\left( E_{k}^{\mathrm{local}}\left( t \right) +E_{k}^{\mathrm{L}}\left( t \right) + E_{k}^{\mathrm{U}}\left( t \right) \right) } \\&\quad +{\eta \left( t \right) \left( \sum _{k\in {\mathcal {K}}}{\psi _k\left( t \right) } - 1 \right) } + \sum _{k\in {\mathcal {K}}}{\lambda _k\left( t \right) \left( A_k\left( t \right) -D_k\left( t \right) \right) }, \end{aligned}$$

(12)

where \(\eta \left( t \right) , \lambda _k \left( t \right)\) are the Lagrangian multipliers associated with constraint (7d) and (7f), respectively, and \({{\varvec{\lambda }} }\left( t \right)\) is the corresponding Lagrange multiplier vector. Thus, the Lagrange dual problem can be expressed as

$$\begin{aligned} \underset{{\varvec{\lambda }} \left( t \right) , \eta \left( t \right) }{\max } & \quad \underset{{\mathbf {X}}\left( t \right) \in {\varvec{\Omega }} \left( t \right) }{\inf } {\mathcal {L}}\left( {\mathbf {X}}\left( t \right) , {{\varvec{\lambda }} }\left( t \right) , \eta \left( t \right) \right) \end{aligned}$$

(13)

$$\begin{aligned} \text{s.t.} \quad \lambda _k \left( t \right) \ge 0, \forall t\in {\mathcal {T}}, k\in {\mathcal {K}}, \end{aligned}$$

(13a)

$$\begin{aligned}\eta \left( t \right) \ge 0, \forall t\in {\mathcal {T}}, \end{aligned}$$

(13b)

where \({\varvec{\Omega }}\) is the feasible region of \({\mathbf {X}}\left( t \right)\) under the constraints from (7a) to (7f).

### 5.2 A low-complexity lightweight algorithm

Lagrange duality offers an effective method to decouple constraint (7f) and divide problem (7). The Lagrangian dual problem in (13) can be solved optimally by solving the following sub-problems.

#### 5.2.1 Local computing resource allocation

Given the fixed \({{\varvec{\lambda }} }\left( t \right)\), the first sub-problem is to minimize the total energy consumption of all vehicles for local computing in time slot *t*, which can be mathematically written as

$$\begin{aligned} \underset{{\mathbf {f}}\left( t \right) }{\min }\quad \ \,\sum _{k\in {\mathcal {K}}}{\left( E_{k}^{\mathrm{local}}\left( t \right) -\lambda _k\left( t \right) D_{k}^{\mathrm{local}}\left( t \right) \right) }, \end{aligned}$$

(14)

$$\begin{aligned} \text{s.t.} \quad \ \,\ 0\le f_k\left( t \right) \le F_k, \forall k\in {\mathcal {K}}. \end{aligned}$$

(14a)

Each vehicle only needs to use its local computing resources wisely, without sharing local computing information from other vehicles. Hence, the optimisation problem is split up again. The optimal frequency \(f_{k}^{*}\left( t \right)\) for the local CPU of vehicle *k* in time slot *t* can be obtained by solving the following sub-problem :

$$\begin{aligned} \underset{f_k\left( t \right) }{\min }\ \quad E_{k}^{\mathrm{local}}\left( t \right) -\lambda _k\left( t \right) D_{k}^{\mathrm{local}}\left( t \right) , \end{aligned}$$

(15)

$$\begin{aligned} \text{s.t.} \quad 0\le f_k\left( t \right) \le F_k. \end{aligned}$$

(15a)

Problem (15) is a convex optimization problem, and thus, the Karush–Kuhn–Tucker (KKT) conditions can be used to find the optimal solution. In this problem, we can obtain the first-order derivative with respect to local frequency as

$$\begin{aligned} \frac{\partial {\mathcal {L}}}{\partial f_k\left( t \right) }=3\tau \mu _k\left( f_k\left( t \right) \right) ^2-\frac{\lambda _k\left( t \right) \tau }{M_k\left( t \right) }. \end{aligned}$$

(16)

Setting \(\frac{\partial {\mathcal {L}}}{\partial f_k\left( t \right) }=0\), we obtain the optimal CPU frequency of vehicle *k* in time slot *t* as

$$\begin{aligned} f_{k}^{*}\left( t \right) \ =\left[ \sqrt{\frac{\lambda _k\left( t \right) }{3\mu _k M_k\left( t \right) }} \right] _{0}^{F_{k}}, \end{aligned}$$

(17)

where \(\left[ a \right] _{x}^{y}=\min \left( y, \max \left( a,x \right) \right)\).

#### 5.2.2 Licensed communication resource allocation

Given the fixed \({{\varvec{\lambda }} }\left( t \right)\) and \({\eta }\left( t \right)\), the second sub-problem is to minimize the total energy consumption of all vehicles for offloading through the licensed channels. Therefore, the optimal transmit power \(p_{k}^{L*}\left( t \right)\) and proportion of licensed bandwidth \(\psi _{k}^{*}\left( t \right)\) in time slot *t* can be obtained by solving the following sub-problem:

$$\begin{aligned} \underset{{\mathbf{p}}^{\mathrm{L}}\left( t \right) , {{\varvec{\psi }}}\left( t \right) ,}{\min }\quad \ \,\sum _{k\in {\mathcal {K}}}{\left( E_{k}^{\mathrm{L}}\left( t \right) -\lambda _k\left( t \right) D_{k}^{\mathrm{L}}\left( t \right) \right) }+ {\eta \left( t \right) \left( \sum _{k\in {\mathcal {K}}}{\psi _k\left( t \right) } - 1 \right) }, \end{aligned}$$

(18)

$$\begin{aligned} \text{s.t.} \qquad \ \,0\le p_{k}^{\mathrm{L}}\left( t \right) \le P_k^{\mathrm{L}}, \forall k\in {\mathcal {K}}. \end{aligned}$$

(18a)

Considering the high complexity of general convex optimization algorithms, we solve (18) by optimizing the transmit power and the bandwidth allocation in an alternating manner, which is guaranteed to converge to the global optimal solution with a sublinear convergence rate [42]. Hence, we take the first-order derivatives of Lagrange dual function with respect to \(p_{k}^{\mathrm{L}}\left( t \right)\) and \(\psi _{k}\left( t \right)\) as

$$\begin{aligned} \frac{\partial {\mathcal {L}}}{\partial p_{k}^{\mathrm{L}}\left( t \right) } =\tau -\frac{\tau \lambda _k\left( t \right) h_{k}^{\mathrm{L}}\left( t \right) B^{\mathrm{L}}\psi _k\left( t \right) }{\ln 2\left( N_{0}^{\mathrm{L}}B^{\mathrm{L}}\psi _k\left( t \right) +p_{k}^{\mathrm{L}}\left( t \right) h_{k}^{\mathrm{L}}\left( t \right) \right) }, \end{aligned}$$

(19)

$$\begin{aligned} \frac{\partial {\mathcal {L}}}{\partial \psi _k\left( t \right) }=\eta \left( t \right) -\lambda _k\left( t \right) \left[ \frac{D_{k}^{\mathrm{L}}\left( t \right) }{\psi _k\left( t \right) }-\frac{\tau p_{k}^{\mathrm{L}}\left( t \right) h_{k}^{\mathrm{L}}\left( t \right) B^{\mathrm{L}}}{\ln 2\left( N_{0}^{\mathrm{L}}B^{\mathrm{L}}\psi _k\left( t \right) +p_{k}^{\mathrm{L}}\left( t \right) h_{k}^{\mathrm{L}}\left( t \right) \right) } \right] . \end{aligned}$$

(20)

In each iteration, the optimal transmit power and bandwidth allocated to vehicle *k* are achieved at either the stationary point of (19) and (20) or one of the boundary points, which are given by

$$\begin{aligned} p_{k}^{\mathrm{L*}}\left( t \right) =\left[ \psi _k\left( t \right) B^{\mathrm{L}}\left( \frac{\lambda _k\left( t \right) }{\ln 2}-\frac{N_{0}^{\mathrm{L}}}{h_{k}^{\mathrm{L}}\left( t \right) } \right) \right] _{0}^{P_{k}^{\mathrm{L}}}, \end{aligned}$$

(21)

$$\begin{aligned} \psi _{k}^{*}\left( t \right) = \left[ {\tilde{\psi }}_{k}^{*}\left( t \right) \right] _{0}^{1}, \end{aligned}$$

(22)

where \({\tilde{\psi }}_{k}^{*}\left( t \right)\) satisfies the following equation.

$$\begin{aligned} \log _2\left( 1+\frac{1}{X} \right) -\frac{1}{\left( 1+X \right) \ln 2}=\frac{\eta \left( t \right) }{\lambda _k\left( t \right) B^{\mathrm{L}}\tau }, \end{aligned}$$

(23)

where \(X=\frac{{\tilde{\psi }}_{k}^{*}\left( t \right) N_{0}^{\mathrm{L}}B^{\mathrm{L}}}{h_{k}^{\mathrm{L}}\left( t \right) p_{k}^{\mathrm{L}}\left( t \right) }\).

#### 5.2.3 Unlicensed communication resource allocation

Given the fixed \({{\varvec{\lambda }} }\left( t \right)\) and \({\eta }\left( t \right)\), the third sub-problem is to minimize the total energy consumption of all vehicles for offloading through the unlicensed channels in time slot *t*, which can be mathematically written as

$$\begin{aligned} \underset{{\varvec{\gamma }} \left( t \right) , {\mathbf {s}}\left( t \right) ,}{\min }\quad \ \,&\sum _{k\in {\mathcal {K}}}{\left( E_{k}^{\mathrm{U}}\left( t \right) -\lambda _k\left( t \right) D_{k}^{\mathrm{U}}\left( t \right) \right) }, \end{aligned}$$

(24)

$$\begin{aligned} \text{s.t.} \qquad \, 0\le \gamma _k\left( t \right) \le P_k^{\mathrm{U}}S_k, \forall k\in {\mathcal {K}}, \end{aligned}$$

(24a)

$$\begin{aligned} 0\le s_k\left( t \right) \le S_{k}, \forall k\in {\mathcal {K}}, \end{aligned}$$

(24b)

where \({\varvec{\gamma }} \left( t \right) \triangleq \left\{ \gamma _1\left( t \right) , \gamma _2\left( t \right) , \ldots , \gamma _K\left( t \right) \right\}\).

As each vehicle only needs to share an unlicensed channel with nearby WiFi users without competing with other vehicles, the problem can be also split into a per-vehicle optimisation sub-problem. On the basis, the optimal transmit power \(p_{k}^{\mathrm{U*}}\left( t \right)\) and the optimal time fraction \(s_{k}^{*}\left( t \right)\) on the unlicensed channel can be obtained by solving the following sub-problem:

$$\begin{aligned} \underset{\gamma _k \left( t \right) , s_k\left( t \right) ,}{\min } \quad \ \, E_{k}^{\mathrm{U}}\left( t \right) -\lambda _k\left( t \right) D_{k}^{\mathrm{U}}\left( t \right) \end{aligned}$$

(25)

$$\begin{aligned} \text{s.t.} \qquad 0\le \gamma _k\left( t \right) \le P_k^{\mathrm{U}}S_k, \end{aligned}$$

(25a)

$$\begin{aligned} 0\le s_k\left( t \right) \le S_{k}. \end{aligned}$$

(25b)

Since the objective function of (25) is non-increasing with respect to \(s_{k}\left( t \right)\), for any \(k\in {\mathcal {K}}\), the optimal time fraction occupied by vehicle *k* on unlicensed channel is equal to the maximum value, i.e. \(s_{k}^{*}\left( t \right) = S_{k}\).

Similarly, for offloading tasks on unlicensed channels, we have

$$\begin{aligned} \gamma _{k}^{*}\left( t \right) = \left[ S_k B_{k}^{\mathrm{U}}\left( \frac{\lambda _k\left( t \right) }{\ln 2}-\frac{N_{0}^{\mathrm{U}}}{h_{k}^{\mathrm{U}}\left( t \right) } \right) \right] _{0}^{P_{k}^{\mathrm{U}}S_k}. \end{aligned}$$

(26)

Therefore, the optimal transmit power \(p_{k}^{\mathrm{U*}}\left( t \right)\) is achieved at either the stationary point of (25) or one of the boundary points, which is given by

$$\begin{aligned} p_{k}^{\mathrm{U*}}\left( t \right) = \frac{\gamma _{k}^{*}\left( t \right) }{s_{k}^{*}\left( t \right) } = \left[ B_{k}^{\mathrm{U}}\left( \frac{\lambda _k\left( t \right) }{\ln 2}-\frac{N_{0}^{\mathrm{U}}}{h_{k}^{\mathrm{U}}\left( t \right) } \right) \right] _{0}^{P_{k}^{\mathrm{U}}}. \end{aligned}$$

(27)

#### 5.2.4 Optimal Lagrange multiplier

Once the optimal resource allocation is achieved by (17), (21), (22), (27), the solution of dual problem (13) can be determined by a subgradient method as follows [43]:

$$\begin{aligned} \lambda _{k}^{\left( i+1 \right) }\left( t \right) =\ \left[ \lambda _{k}^{\left( i \right) }\left( t \right) +\varsigma _{\lambda }\left( A_k\left( t \right) -D_k\left( t \right) \right) \right] ^+, \end{aligned}$$

(28)

$$\begin{aligned} \eta ^{\left( i+1 \right) }\left( t \right) =\ \left[ \eta ^{\left( i \right) }\left( t \right) +\varsigma _{\eta }\left( \sum _{k\in {\mathcal {K}}}{\psi _k\left( t \right) } - 1 \right) \right] ^+, \end{aligned}$$

(29)

where *i* is the iteration index, and \(\varsigma _{\lambda }\) and \(\varsigma _{\eta }\) are the positive step sizes.

The Lagrange multipliers \({{\varvec{\lambda }} }\left( t \right)\) and \(\eta \left( t \right)\) can be independently updated by (28) and (29), respectively. The update process will be repeated until convergence, indicating that the dual optimal point has been reached. Since the joint power, spectrum and computing resource allocation problem proves to be convex, the duality gap can be guaranteed to zero according to [43, 44]. Algorithm 1 briefly summarizes the proposed algorithm.

### 5.3 Algorithm complexity analysis

In each time slot, the computational complexity of the proposed scheme mainly lies in both loops shown in Algorithm 1. For the inner loop that determines the proportion of tasks offloaded on the licensed channels, alternately updating the transmit power and proportion of licensed bandwidth has been shown in [42] to converge to the optimal solution with a sublinear convergence rate. Besides, the outer loop is a standard convex optimization and a fast convergence speed can be guaranteed for the subgradient method. As will be demonstrated in the simulation, only 6–9 iterations are required for the Lagrange multipliers to converge. Therefore, we can qualitatively conclude that the computational complexity of the proposed algorithm is low and acceptable.