## 3 Proposed System Model
### Proposed Solution and Algorithm Design
By adapting to these changes and adjusting resource allocation accordingly, the algorithm optimizes the overall cost effectiveness of task offloading while maintaining reliability and performance. The requirements for the algorithm include the resources available, task size, and time constraints. To calculate the total cost, the algorithm considers both the energy and time required for task computation. For local task computation, the amount of energy and time needed to compute the task depends on the available resources of the user devices. If the devices have higher computational capacity or more resources, the local task computation will be faster. If the cost of computation is lower when offloading to the MEC system compared to performing the task locally on the user device and the total execution time at the MEC system is within the time constraints, the user device will offload the task to the MEC system. However, if the total latency at the edge exceeds the time constraints but the total execution time locally on the user device is shorter than the  
Figure 2: Flowchart of the algorithm. time constraints, our algorithm will prioritize executing the task locally. According to Algorithm 1, \(I\) is the total number of computational tasks and \(i\) defines the iterations. The outputs are \(x,l,e,\) and \(c\) where \(x\) is the offloading decision, \(l\) is the total latency, \(e\) is the total energy, and \(,c\) is the computation cost. In the simulation, we set the algorithms to iterate 60 times, and the algorithms can converge while the number of 40 iterations is reached. The algorithm detail explanation is already included in the proposed flowchart. ```
1: Required \(task_{i}=\{C_{i},D_{i},\ T^{max},\ \forall i\in I\}\), \(\{R_{k},C_{i},\ \forall k\in K\ and\ \forall i\in I\}\)
2: Initialize \(if\ x_{i}=0,\ \ \forall i\in I\)\(l_{loc}=I\)
3: Output: \(\{t^{loc},\ e^{loc},\ cost^{loc}\}\)
4:if\(x_{i}=1,\forall i\in I\)\(l_{off}=I\)\(V_{t}^{r}\) adjustment for \(task_{i}\) via LDROA
5:While\(V_{t}^{r}\) not convergedo
6:for\((iteration=1;\ iteration\ \leq\ 60;\ iteration\ ++)\)
7:if\(cost^{edge}>\ cost^{loc},\ \ \forall I\in I_{off}\)
8: i \(\leftarrow\ \underset{l\in I_{off}}{\arg min}(x_{i}(cost^{loc}-\ cost^{edge}))\)
9:\(l_{off}\gets l_{off}-\{i\}\)
10: Update\(x\) by setting \(x_{i}\gets 0\) Update\(V_{m}^{r}\) (available resource of MEC) according to resource allocation
11:elseif\(cost^{edge}<\ cost^{loc},\ \forall I\in l_{off},\ \text{or}\ l_{off}=0\) (empty)
13:endif
14: End
15:While\((t^{off}+t^{edge}>T^{max})\)do
16: i \(\leftarrow\ \underset{i\in I_{off}}{\arg min}(x_{i}(cost^{loc}-cost^{edge}))\)
17:\(l_{off}\gets l_{off}-\{i\}\)
18: Update\(x\) by setting \(x_{i}\gets 0\) Update\(V_{m}^{r}\) (available resource of MEC) according to resource allocation \(V_{t}^{r}\)
20: End
21:\(cost^{edge}<\ cost^{loc},\ \forall i\in I_{off}\ \text{or}\ \ l_{off}=\)0
22:End
23:Output optimal solution \(\{x,l,e,c\}\)
```  
**Algorithm 1** Local and edge server computation time, energy, and cost. The algorithmic flow of a proposed approach focuses on predicting the total cost of local task computation and offloading it to an edge server within the constraints of an IoT application. The algorithm considers various factors, including available resources, task size, and time constraints. It calculates the total cost by considering both the energy and time required for task computation. The algorithm provides a systematic way to decide whether to perform computation locally or offload it to an edge server based on resource availability, task size, and time constraints, optimizing for energy and time efficiency to achieve cost effectiveness in IoT applications. In summary, Algorithm 1 encapsulates a systematic approach to task offloading in IoT applications, emphasizing the prediction of total costs and the fulfillment of time constraints.