#### Abstract

The rapid growth of the Internet of Vehicles applications leads to unreasonable resource allocation, task computing delay, and large energy consumption. To solve this problem, this paper proposes a computing resource allocation strategy based on mobile edge computing in the Internet of Vehicles environment. Firstly, we analyze the process of mobile edge computing network and resource allocation. Then, it is improved by introducing the Halton sequence into the traditional genetic algorithm, and the difference between populations is reduced by canceling the randomness to generate an initial population with smaller individual differences. Furthermore, by optimizing the parameter setting method of traditional genetic algorithm, the crossover probability and mutation probability that change dynamically with fitness value are given, which improves the accuracy of the algorithm. Finally, the simulation results show that under the premise of the same number of tasks, the average delay and total cost of the proposed strategy are also the smallest. When the number of tasks is 45, the average delay of the proposed method is 0.32 s and the total cost is 0.34, which are better than the comparison method. Simulation results show that the improved algorithm has more advantages in delay and overhead.

#### 1. Introduction

Nowadays, with the rapid development of communication technology, the increasing number of smart devices increases the burden of network transmission and makes the data transmission delay more and more obvious [1, 2]. The proposal of mobile edge computing solves the computationally intensive computing tasks to a certain extent [3–5]. The proposal of the Internet of Vehicles (IoV) system realizes a wireless connection between the drive test unit and pedestrians. The in-vehicle business is composed of various computing tasks, and the calculation results generated by different computing tasks will be sent to in-vehicle terminals, which is the basic basis for ensuring the normal operation of vehicles [6–8]. In process of computing tasks, resource allocation plays an important role. A reasonable resource allocation strategy can accelerate the result generation of computing tasks and improve the security of vehicle-mounted terminals [9, 10].

At present, a mobile edge computing server is usually configured in an IoV system to reduce the delay of vehicle-to-infrastructure and vehicle-to-vehicle services, and a reasonable resource allocation strategy is used to save the energy consumption of mobile terminals and the delay caused by computing tasks, so as to achieve vehicle safety [11–13]. Reference [14] aimed at the dynamic allocation of IoV resources, and the target problem was transformed into a semi-Markov decision model by introducing resource retention and a secondary allocation mechanism. However, this method did not solve the problem of resource usage and system optimization when vehicle terminal resources were limited. Reference [15] aimed at the resource block conflict in the resource allocation method of the IoV system, based on the characteristics of the driving direction of vehicles, the interference between vehicles in opposite directions is reduced by dividing resource pools. Besides, the collision probability of resource reselection is reduced by having each resource block carry location information. However, it is difficult for this method to obtain accurate channel state information in a high-speed moving vehicle environment. Aiming at the problem that the resource allocation method in the IoV system is not suitable for video semantics and other services, reference [16] gave a video semantic-driven resource allocation guidance model and a corresponding solution method with target detection as the objective function. They proposed a resource allocation algorithm based on reinforcement *Q*-learning by constructing a resource allocation optimization model. However, this method has only been studied for services such as video semantics, which has certain limitations. Reference [17] analyzed the optimal channel matching problem with the objective function of maximizing the utilization rate of spectrum resources, aiming at the problem of terminal equipment and insufficient capacity of the IoV system to meet the basic service quality of IoV communication. The problem was solved using KM (Kuhn Munkres) algorithm. But this method did not consider wireless delay, network delay, and computational delay. Reference [18] established a Markov decision process model with the objective function of maximizing total channel capacity and the successful delivery rate of load by considering the V2V link as a separate individual. The SAC reinforcement learning algorithm was used to solve the model, and the optimal allocation of V2V link spectrum resources was realized. However, the convergence rate of this method was slow. Reference [19] divided the tasks generated by vehicles in view of problems such as the differentiated resource allocation mechanism in the in-vehicle cloud system. The divided subtasks were downloaded to an on-board cloud system and executed collaboratively by different vehicles, thereby improving the offloading efficiency of tasks. On this basis, the DiffServ model was used to sort and process tasks according to task pricing, and the optimization of resource allocation was realized. But this method did not reduce the impact of resource mobility on vehicle cloud performance. Reference [20] aimed at the problem of limited Vehicle Fog Computing (VFC) resources in the IoV system, which cannot allow multiple vehicles to simultaneously offloading computing tasks from the cloud to the network edge and formulated a corresponding fog resource allocation strategy by using parked vehicles. The optimization of the resource allocation strategy was achieved by introducing reinforcement learning into the heuristic algorithm. However, this method increased task delay while reducing energy loss, and the success rate of the task needs to be improved [21–25].

Based on the above-given analysis, aiming at the problems of unreasonable resource allocation, large task computing delay, and energy consumption brought about by the rapid growth of IoV applications, this paper proposes a computing resource allocation strategy based on mobile edge computing in the IoV environment. The network model and allocation strategy based on mobile edge computing are constructed, and the model is solved by improving the genetic algorithm. The proposed method is simulated and analyzed by simulation experiments. The experimental results show that the introduction of the Halton sequence into a genetic algorithm can reduce the differences between individuals and strengthen the global search ability of the algorithm. Moreover, dynamically and adaptively changing the crossover probability and mutation probability can solve the problem of the local optimal solution and improve algorithm accuracy. Compared with traditional computing resource allocation strategies, the innovation of the proposed method lies in the following statements:(1)The delay and energy consumption cost of local processing and mobile edge computing server processing are comprehensively considered, and the total task cost and calculation method are quantified(2)Halton sequence is introduced in process of generating the initial population by genetic algorithm, which reduces the differences between individuals in the population(3)By giving the crossover probability and mutation probability that change dynamically with fitness value, the local optimization problem is solved and calculation accuracy is improved

#### 2. System Model

The mobile edge computing network model based on the drive test unit in the IoV environment is shown in Figure 1.

It is assumed that each drive test unit has *R* independent computing execution units, and the arrival of mobile terminal request to uninstall the application follows the Poisson formula with an average rate of . The specific process is as follows:(1)If a move request runs in the drive test unit, the end of the task will follow an exponential distribution with rate , and the average service time of this move request in the drive test unit is . In the model shown in Figure 1, the CPU that each task request is allowed to be assigned in the drive test unit is a fixed value .(2)If the system decides to complete tasks locally, the end of tasks will follow an exponential distribution with a rate , and the average service time of this movement request in the drive test unit is . At this time, each vehicle in Figure 1, the execution of mobile applications is supported with a fixed number of CPUs.

The specific process of resource allocation decision-making is shown in Figure 2.

As shown in Figure 2, when a new request arrives, the system decides whether to accept it or not based on the current state. If the request is acceptable, the system assigns a new service request to the drive test unit or offloads it locally. The ultimate goal is to decide how the task is offloaded, i.e., whether to accept mobile service requests. If the request is accepted, it is necessary to finalize how many resources the running mobile application should allocate to maximize system benefits.

#### 3. Problem Definition

##### 3.1. Local Processing Cost

Using to represent the location information of vehicle and using to represent the location information of mobile edge computing server. For the local offloading request, when , the task is processed by the vehicle itself and the cost of the vehicle task is mainly composed of the following two parts.

###### 3.1.1. The Time It Takes for the Vehicle Itself to Complete Tasks

For local task processing, the processing delay of tasks is mainly generated by the time of the vehicle itself to process tasks, so the processing delay of local tasks is shown in the following formula:

Here, represents the processing delay of the local task of the vehicle. represents the data size of the task. represents the number of turns that the CPU rotates to process 1 bit data. represents the computing power of the car itself.

###### 3.1.2. the Energy Consumption Required by Vehicle to Complete Tasks

For the local task processing, the energy consumed by task processing is mainly generated by the process of the vehicle itself processing tasks, so the processing energy consumption of local task is shown in the following formula:

Here, represents the processing energy consumption of the local task of the vehicle. represents the energy consumed by the CPU to make one revolution.

##### 3.2. Processing Cost of Mobile Edge Computing Servers

For the mobile edge computing server, when ; that is, the vehicle decides to offload some tasks to the mobile edge computing server for processing. The entire task processing process includes three processes: offloading the task, moving edge computing server to process the task, and feeding back task result. For the vehicle, the delay and energy consumption are also generated by these following three processes:(1)The vehicle uploads some tasks and related data to the mobile edge computing server, resulting in a delay. In process of task offloading, when the vehicle decides to offload some tasks to the mobile edge computing server, the user needs to upload the relevant tasks and data to the mobile edge computing server. Therefore, the delay of task offloading can be obtained from the task size and transmission rate, and the specific process is shown in the following formula: Here, represents the delay of task offloading to the mobile edge computing server. represents the task offloading decision for the vehicle. represents the data transmission rate of uplink between the vehicle and the mobile edge computing server, and the data transmission rate can be calculated by the following formula: Here, represents the link channel bandwidth allocated between the vehicle and the mobile edge computing server. represents the signal-to-noise ratio, which can be calculated by the following formula: Here, represents the received power, represents the interference power, and represents the noise power. In process of mobile edge computing server processing tasks, after receiving the task and data of the vehicle, the mobile edge computing server will allocate certain computing and communication resources to process tasks. The time delay is also generated from this, as shown in the following formula: Here, represents the delay in allocating computing and communication resources to process tasks. represents the computing resources allocated by the mobile edge computing server to the current task, and its value satisfies the constraints shown in the following formula: Here, represents the total computing resources of the mobile edge computing server. After the mobile edge computing server processes the task, the task result is fed back to the vehicle. Thus, the resulting delay is the time for the vehicle to receive task results from the downlink, which can be expressed by the following formula: Here, represents the time delay for the vehicle to receive task results from the downlink. represents the ratio of output data to input data, which can generally be set to 0.1. represents the data transmission rate of downlink, and the transmission rate of uplink and the downlink can be considered to be the same for the vehicle. It can be seen from formula (8) that the total delay of mobile edge computing server to complete tasks is shown in the following formula: (2)The mobile edge computing server allocates part of communication and computing resources to process tasks and generates energy consumption for processing tasks. Since the energy consumption of the mobile edge computing server is not considered in the set vehicle edge network, only the energy consumed by the first vehicle to complete the task needs to be considered. The process of generating energy consumption is mainly composed of three parts: the energy consumption of task offloading of the vehicle, the computing energy consumption of the vehicle completing the local task, and the energy consumption of the vehicle receiving result feedback.

During the process of offloading tasks from the vehicle, when the vehicle decides to offload some tasks to the mobile edge computing server, the relevant data needs to be transmitted to the mobile edge computing server. The energy consumption generated by this process is shown in the following formula:

Here, represents the energy consumed by the transmission of related data to a mobile edge computing server. represents the energy consumed to transmit 1 bit data.

After the vehicle uploads part of the tasks to the mobile edge computing server, the remaining part of the tasks needs to be executed locally, thus generating energy consumption. This part of energy consumption can be obtained from the remaining task size and the unit data processing energy consumption, and the specific process is shown in the following formula:

Here, represents the energy consumption generated by executing the remaining partial tasks locally. represents the energy consumed to transmit 1 bit data.

When a mobile edge computing server processes the task, it needs to feedback task results to the vehicle and the vehicle also needs to consume energy to receive task result. The specific process of solving this part of energy consumption is shown in the following formula:

Here, represents the energy consumed by the vehicle to receive the feedback task result. represents the path loss factor, which can generally be set to −4.

It can be seen from formula (12) that the total energy consumption of the vehicle to complete the task is generated by the above-given three processes, and the calculation method of total energy consumption can be obtained as shown in the following formula:

##### 3.3. Total Cost and Problem Definition

In the proposed mobile edge computing network based on the drive test unit in the IoV environment, the delay cost and energy consumption cost are comprehensively considered. Therefore, the total cost of the system can be defined as the weighted sum of total energy consumption and total delay, thus forming a new cost objective function as shown in the following formula:

Here, and represent the weights of delay and energy consumption, respectively, and have . The proposed network has higher requirements for delay, so it is set as , .

For the delay of the vehicle, it is necessary to comprehensively consider the processing time of the local task and the processing time of some tasks uploaded to the mobile edge computing server, as shown in the following formula:

The purpose of considering delay and energy consumption is to minimize the total system cost by jointly optimizing the task offloading decision of the vehicle and the resource allocation strategy of the mobile edge computing server. Therefore, we can consider this joint optimization problem and propose the corresponding objective function as shown in the following formula:

The total cost of the system can be minimized by finding the optimal task offloading and resource allocation strategy of mobile edge computing server, but this needs to consider the constraints of limited communication and computing resources. Considering the proposed constraints comprehensively, it is shown in the following formula:

Here, the first constraint indicates that the value of offloading strategy is a value between 0 and 1. The second constraint indicates that the task must meet the delay requirement, and indicates the maximum tolerated delay. The third constraint shows that the sum of computing resources allocated by all tasks cannot exceed the total computing resources of the mobile edge computing server. The fourth constraint guarantees that the sum of bandwidth allocated by all tasks cannot exceed the total channel bandwidth.

#### 4. Design of Adaptive Improved Genetic Algorithm

##### 4.1. Genetic Algorithm

A genetic algorithm is an intelligent algorithm that simulates natural selection and biological evolution in nature and is a computational model that simulates Darwin’s theory of evolution. According to Darwin’s theory of evolution, the evolution of biological species follows the principle of “natural selection, survival of fittest,” and there is fierce competition within and between species. Only adaptive individuals can survive. The genetic algorithm searches for the optimal solution by simulating the biological evolution process, which transforms the solving process of the problem into the selection, crossover, and mutation process of chromosomal genes. Only individuals with strong adaptability to the environment can retain it with a high probability.

The genetic algorithm regards the feasible solution set space as a population, and each feasible solution corresponds to an individual. Through continuous selection, crossover, and mutation operations, a group of individuals more adapted to the environment is generated. After several iterations, individuals who do not adapt to the environment are gradually eliminated by the environment. The individual with the largest fitness function value is the optimal solution of the problem. The flow of the genetic algorithm is shown in Figure 3.

##### 4.2. Genetic Algorithm Improvement

In process of solving the traditional standard genetic algorithm, the generation of the initial population of the algorithm and the setting of parameters such as genetic operators are relatively random. After many iterations, excellent individuals will occupy the entire population and it is difficult to generate new individuals, resulting in premature convergence of the algorithm and easy to fall into local optimum. At this time, the characteristics of the population remain basically unchanged, so it is considered to improve the traditional genetic algorithm to prevent the algorithm from falling into the local optimal solution.

Genetic algorithms generate different populations through crossover and mutation operations, so it is considered to generate initial populations with less difference by introducing Halton sequences. Strengthening the global search ability of the algorithm as much as possible and improving the search accuracy, thereby preventing the algorithm from prematurely converging and falling into a local optimum.

The first step of the genetic algorithm is to generate the initial population, which is to be able to obtain information of the target. This step is essential and very important in algorithm operation and often has a great impact on the results of algorithm solution. Generally, many individuals with uneven distribution are randomly generated by a computer when the population is initialized. However, the uniform distribution of individuals in the initial population has more optimization ability than the nonuniform distribution, and it is also more reasonable in algorithm search. Therefore, by introducing the Halton sequence, the individual differences between the populations become smaller, and the population differences are reduced by canceling the randomness.

In the Halton sequence, the generated initial population can be represented by base , where is a prime number and , and any integer N can be represented by base , as shown in the following formula:

Here, represents the base, which can represent any prime number; represents a sequence number, which exists and is unique, so that the formula holds. For different integers, the one-dimensional Halton sequence under the corresponding base can be obtained as shown in the following formula:

Halton sequence was introduced to randomly generate 100 points, and an initial population with less difference in initial numbers was generated. The individuals of this population are more evenly distributed on the number line, which greatly improves the quality of the initial population.

##### 4.3. Solving Steps of Adaptive Genetic Algorithm

The following is an analysis of the problem-solving process using an adaptive genetic algorithm, which is improved on the basis of a traditional algorithm. By giving the crossover probability and mutation probability that change dynamically with the fitness value, the problem of the local optimal solution of the algorithm is solved and the accuracy of the algorithm is improved. The specific steps of the adaptive genetic algorithm are as follows.(1)*Chromosome Coding*. For the proposed model, binary coding is adopted, and the coding of each chromosome is an offloading strategy , and is used to represent the value of bit in strategy offloading strategy , and the value of is 0 or 1. In order to indicate that all computing tasks can be offloaded to servers, the number of coding bits should satisfy the constraints shown in the following formula: The offloading strategy of the computing task can be represented as , and the number of offloaded mobile edge computing server can be represented by the following formula: The computing task strategy coding of no more than 8 mobile edge computing servers is shown in Figure 4.(2)*Chromosome Initialization*. The main purpose is to initialize the relevant parameters of the genetic algorithm, including the maximum number of iterations, chromosome length, mutation probability, crossover probability, population size, and reserved population. In the initial population with less difference generated by introducing the Halton sequence, the encoding of the class with the highest weight in a chromosome is set as the following formula(22). The purpose is to first offload the computing tasks of the highest weight class to the mobile edge computing server to which the vehicle-mounted terminal belongs. If a total of computing tasks are predefined, the codes of remaining computing tasks are randomly generated to maintain the randomness of the population.(3)*Fitness Evaluation*. The traditional genetic algorithm decides whether an individual inherits to the next generation according to the size of fitness value. Here, the reciprocal of user’s total cost is selected as the fitness function evaluation index of the quality of the chromosome individual, and the expression is shown in the following formula:(4)*Select an Operation*. The roulette selection method based on fitness proportional selection is used to select some outstanding individuals from the parent individuals.(5)*Crossover and Mutation Operations*. Here, single-point crossover and basic bit mutation operations are performed according to the crossover probability and mutation probability, thereby generating chromosomes with new genes. Among them, the crossover probability and mutation probability of dynamically changing according to the fitness value of an individual can be expressed by the following formulas (24) and (25):

In formulas (24) and (25), represents the maximum value of fitness. represents the mean value of fitness. represents a feasible solution with crossover probability. represents the maximum value of crossover probability. represents the minimum value of crossover probability. represents the maximum value of variation probability. represents the minimum value of mutation probability.

#### 5. Experiment and Analysis

##### 5.1. Experimental Parameter Setting

The performance of the proposed scheme is verified by simulation experiments, and the experimental environment settings and experimental results are given, which proves the superiority of the proposed scheme compared with other schemes. Firstly, vehicle nodes and mobile edge computing server nodes are randomly assigned in a simulation area of 200 m × 200 m. Then, parameters such as the number of vehicles and mobile edge computing servers, communication resources, and computing resources in experiment are set. The simulation experiment of the proposed strategy is carried out on the MATLAB platform (MATLAB2016a). The relevant parameters of the experiment are shown in Table 1.

##### 5.2. Algorithm Performance Comparison Analysis

The convergence speed of the algorithm, the relationship between the average cost and amount of data, the relationship between the average delay and number of tasks, and the relationship between the total task cost and the total number of tasks are important evaluation indicators to measure the performance of the strategy. In the following, for the above-given four evaluation indicators, the resource allocation strategy based on mobile edge computing in the IoV environment proposed in this paper and the methods in reference [15], reference [16], and reference [19] are compared under the same conditions.

Firstly, the maximum number of iterations to 100 is set and the convergence rates of different algorithms are compared and analyzed. The calculation results of different algorithms are shown in Figure 5.

It can be seen from Figure 5 that the proposed strategy has the fastest convergence speed compared to the other three methods, and it tends to converge when the number of iterations is 20. This is because the Halton sequence is introduced in process of generating the initial population, and the obtained initial population is less different, which improves the speed of the algorithm to find the global optimal solution.

The performance comparison results of several algorithms are shown in Figures 6–8.

As can be seen from Figures 6–8, compared with the other three methods, the average overhead of the strategy proposed in this paper is the smallest in the case of the same task data size. And, as the amount of task data gradually increases, its average overhead grows the slowest. The average overhead of the proposed method is 0.28 when the task data size is 90, which is much smaller than 0.74, 0.67, and 0.58 of the other three methods. Under the premise of the same number of tasks, the average delay and total cost of the proposed strategy are also the smallest. And, as the number of tasks increases, the growth rate of average delay and total overhead is also the smallest. When the number of tasks is 45, the average delay of the proposed method is 0.32 s, and the total cost is 0.34. The experimental results show that the introduction of the Halton sequence into a genetic algorithm can reduce the differences between individuals and strengthen the global search ability of the algorithm. Moreover, dynamically and adaptively changing the crossover probability and mutation probability can solve the problem of the local optimal solution and improve algorithm accuracy.

#### 6. Conclusion

Aiming at the problems of unreasonable resource allocation, large task computing delay, and energy consumption brought about by the rapid growth of IoV applications, this paper proposes a computing resource allocation strategy based on mobile edge computing in the IoV environment. The basic idea of this paper is as follows: (1) the problems that need to be solved in the current IoV environment and their quantitative calculation methods are analyzed. (2) The mobile edge computing network and resource allocation decision-making framework in the IoV environment are designed. (3) The applicability of genetic algorithm in research problem is improved by making corresponding improvements. The simulation results show that the performance of the proposed method is better than that of the comparison method.

Future work will further study the applicability and improvement methods of the proposed algorithm in complex vehicle behaviors such as vehicle acceleration, deceleration, overtaking, and lane change. In addition, the adaptive genetic algorithm designed in this paper still has some shortcomings in computational accuracy. In future research, specific problems are analyzed to improve the population structure and further improve the quality and efficiency of the solution.

#### Data Availability

The data used to support the findings of this study are included within the article.

#### Conflicts of Interest

The author declares that there are no conflicts of interest regarding the publication of this paper.