# Traffic-Aware Optimization of Task Offloading and Content
## 4 Joint Optimization for Offloading and Content Caching with Traffic Stream Prediction
### Description of the Algorithm  
Algorithm 1 provides an overview of the optimization process. Steps 1-4 involve the pre-processing traffic stream data and initializing trainable parameters for model training. Steps 5-24 focus on joint optimization of task offloading and content caching using MOEA/D. First, \(G\) is denoted as the maximum number of iterations, and \(T\) is denoted as the number of neighbours of each weight vector \(w_{i}\). To initialize the population \(P_{0}\), \(p\) individuals are randomly generated within the decision space. Each individual in population \(P_{0}\) computes the values of \(\overline{T}^{i}(t)\) and \(E^{i}(t)\) for the objective function defined in Equation (15). Initialize the reference point \(z^{*}=\left\{z_{1}^{*},z_{2}^{*}\right\}^{T}\) and the set of uniformly distributed individual weight vectors \(V=\left\{v_{1},v_{2},\ldots,v_{T}\right\}\). Next, the Euclidean distance between every pair of weight vectors is calculated to identify the \(T\) nearest weight vectors for each weight vector, denoted as \(B(i)=\left\{i_{1},i_{2},\cdots,i_{T}\right\}\). After that, the evolutionary process is carried out with updates. Subsequently, the minimum delay and minimum energy consumption are updated. If the termination condition is met, the computation is concluded, and the results are generated. Finally, the corresponding set of offloading policies \(A\) and caching policies \(S\) are outputted. MOEA/D needs to maintain its internal population of \(N\) solutions, and external population EP. MOEA/D is a technique that breaks down a multi-objective optimization problem into numerous scalar optimization subproblems, all of which are tackled simultaneously [30]. These subproblems draw on information from their neighboring subproblems during optimization, leading to a reduced computational complexity within the TOCC framework.  
```
0:historical traffic stream \(\{TS_{i}(t)|1\leq i\leq I,1\leq t\leq T\}\), task set \(Q\), maximum number of iterations \(G\), population size \(P\), reference point \(z^{\star}\)
0:Offloading policy \(A\), content caching policy \(S\), time-delay optimal solution objective \(\overline{T}^{i}(t)\), energy consumption optimal solution objective \(E^{i}(t)\)
1 Traffic Stream Forecasting
2 Pre-processing data formats, training train and graph data, adapting models ;
3 MLP RNN to extract temporal correlation, GNN to extract spatial correlation for modeling training, and the model set Fusion;
4 Output \(\{TS_{i}(T+1)|1\leq i\leq I\}\) ;
5 Joint Optimization for Task Offloading and Edge Content Caching Optimization
6 Initialize \(P_{0}\gets TS_{i}(T+1)\)
7 Calculate \(\overline{T}^{i}(t)\) by (11), Calculate \(E^{i}(t)\) by (12)
8 Initialize \(z^{\star}=\{z^{\star}_{1},z^{\star}_{2}\}^{T}\), \(V\)
9 Record the \(T\) vector in \(B(i)\) that is closest to any vector
10 for\(g=1\) to \(G\)do
11 for\(j=1\) to \(N\)do
12 Randomly choose \(f\) and \(h\) at \(B(i)\)
13 The genetic operators \(x^{f}\) and \(x^{h}\) evolve to produce the solution set \(y\)
14 if\(z^{\star}_{1}<\overline{T}^{i}(t)\)then
15\(z^{\star}_{1}=\overline{T}^{i}(t)\)
16 end if
17 if\(z^{\star}_{1}<E^{i}(t)\)then
18\(z^{\star}_{2}=E^{i}(t)\)
19 end if
20 foreach\(j\in B(i)(j=1,2,\dots)\)do Update the neighborhood solution set \(B(i)\);
21 end for
22 Update \(P_{0}\) according to the dominant solution
23 end for Return \(A,S\)
```  
**Algorithm 1**TOCC: Task offloading and content caching strategy based on MOEA/D