Task Offloading and Resource Allocation Mechanism of Moving Edge Computing in Mining Environment

The mine improves the response speed of the IoT control system by sinking computing services into the MEC Server. In this case, computing resources are scattered and it is difficult to cope with the changing computing requirements of mobile terminal devices. To solve this problem, we optimize from the supply side by build P.M.R (problem of maximum revenue) problem. In P.M.R, we comprehensively consider the air rate of wireless communication, network delay, computing resource demand and other factors that affect the offloading task of terminals. To obtain the relative optimal solution of P.M.R, we construct a task unloading algorithm based on particle swarm optimization. And we set up a simulation experiment environment according to the mine network parameters. The experimental results show that this task unloading algorithm can effectively improve the efficiency of computing facilities in the system and achieve load balancing.


I. INTRODUCTION
To improve the production efficiency of mines but also to avoid production accidents, mining companies are gradually building unmanned mines by applying artificial intelligence technology and Internet of Things technology. Many computing-capable devices are deployed in the mine to achieve the above goals. The centralized architecture of the traditional Internet of Things control system has natural limitations in terms of flexibility and safety [1], [2]. This single centralized computing service is difficult to meet the needs of various mine IoT devices. And the centralized system has serious performance bottlenecks in the face of massive terminal devices [3], [4]. Therefore, mining companies choose to decentralize many functions from cloud server to build a moving edge computing layer. [5]. MEC technology deploys computing services to the data generation side [6]. In the mine Internet of Things, data generated by terminal devices can be processed through lower communication delays [7], [8].
With the development of wireless communication technology, coal mine can cover mobile communication network on a large scale in the production area. This widely connected communication capability provides the basis of data interaction for the continuous improvement of the intelligent level of coal mine production.
But the moving edge computing in coal mine still faces those following problems: 1) With the computing service sinks, the area served by the computing facility decreases. The distribution of underground computing resources is scattered by the topological structure of the mine.
2) The computing requirements in the region serviced by MEC server change as the terminal device moves across regions.
To solve this problem, the mine IoT system needs to have the ability of cross-computing resource allocation. Due to the heterogeneity of the mine Internet of Things, the computing resource scheduling problem can be modeled as a task scheduling problem on heterogeneous multiprocessors. It is well known that this problem is a NP-hard problem without known polynomial solutions.
We will allocate computing tasks from the supply side of computing services considering the indicators of computing needs. At the same time, all calculation requirements should be met to ensure the normal production of mines.
Our contribution can be summarized as follows: (1) We deeply analyze the structure of the mine Internet of Things and establish the mine tunnel wireless communication model and MEC Server computing model.
(2) We designed a task offloading algorithm based on the special mine environment and the communication delay requirement of the mine Internet of Things. Based on the algorithm, computing tasks can be assigned to appropriate MEC servers on the premise of satisfying terminal computing requirements, to achieve load balancing and increase the number of terminal devices accommodated in the system.
(3) We test and evaluate the performance of the task unloading algorithm and resource scheduling mechanism proposed in this paper through simulation experiments. Theoretical analysis and numerical simulation results show that the mechanism and algorithm can effectively improve the utilization rate of MEC server in the mine IoT.
The structure of the rest of this paper is as follows. The related work is summarized in the second part. The third part introduces the overview of mine IoT system. The task offloading algorithm is given in fourth part. In the fifth part, the performance evaluation of resource allocation mechanism and optimization strategy is introduced. It is summarized in the sixth part.

II. Related Works
Researchers proposed multiple resource allocation models for different edge computing architectures. Tayebeh Bahreini et al. designed a envy-free edge computing resource auction mechanism, and verified that when the resource auction ended, no demand-side of the resource would be more interested in the results of another user, so this mechanism can achieve the optimal allocation of multi-stage computing resources from the edge to the cloud without envy [9]. Li, Zhenni, Z. Yang et al established an iterative auction to optimize the allocation of computing resources in the edge cloud-assisted Internet of Things (IoT) by using blockchain technology, maximizing the network benefits on the premise of ensuring the interests of both buyers and sellers [10]. Yunan Gu et al. studied the allocation of wireless communication and fog computing resources to optimize system performance [11]. They take into account service delay, link quality, mandatory benefits and other important factors to improve user satisfaction through efficient SPA algorithm matching fog computing resources. Huaqing Zhang et al. designed a hierarchical game framework for cloud computing resource management [12]. They use this framework to solve the problems of information asymmetry in fog computing services. By applying deep learning to the allocation of fog computing resources, Nguyen Cong Luong et al. can achieve optimal auction design and maximize the revenue of resource suppliers [13].Shuchen Zhou et al. proposed a machine learning -based offloading strategy [14]. This strategy includes transmission power allocation, computational offload strategy, local computational power dynamic adjustment and global optimization strategy of receiving energy channel selection. Ehzaz Mustafa et al. studied task offloading in wireless power transmission scenarios. And they investigated the challenges of task offloading in conjunction with WPT [15]. However, the above research work is based on the background of generalization, and does not consider the topological structure of industrial ring network and the characteristics of wireless communication in mine tunnel. The summarize of those papers is shown in Table I. Therefore, it is difficult to apply these mechanisms directly to the mine environment. Mine application background Reference [9] X X X Reference [10] O X X Reference [11] O O X Reference [12] O X X Reference [13] X X X Reference [14] O O X The offloading of computing tasks needs to fully consider the situation of communication links, especially in the industrial control scenarios represented by mines. In the mine tunnel environment, wireless communication is limited by terrain on the one hand, on the other hand, the mine electromagnetic environment is complicated due to the alternating connection of mine working face and the existence of many large electric drive mechanical equipment. Reference [16] builds wireless sensor networks in coal mines, and designs a five-layer monitoring system framework according to the special environment of coal mines. Reference [17] and [18] have done a lot of research on the wireless communication characteristics of mine roadway, and proposed a threedimensional band type terminal node deployment model. The model discusses several important characteristics of mine wireless communication in detail, including radio transmission, efficiency and coverage.
To sum up, this paper fully considers the wireless communication environment and network topology of mines, and proposes a resource allocation mechanism for mobile terminal edge computing in mine environment.

III. System Overview
In this section, we will introduce the basic structure of iot in mines.

A. The Structure of Mine I-IoT system
The structure of coal mine I-IoT system is shown in figure  1. Besides the cloud servers in the central computer room, there are several MEC servers distributed in each areas of coal mine along with base stations. Because the MEC server is deployed together with the base station, terminal devices connected to the base station can obtain lowlatency computing services. Terminals can be divided into two categories: mobile terminal and non-mobile terminal. Because the location of non-mobile terminals is fixed, the computing service relationship between the terminal and the MEC server is also fixed. In this case, we can easily evaluate the amount of computing resources required by this part of the terminal.
However, the problem lies with the mobile terminals. When the mobile terminal is working normally, it often shuttles within the service range of different base stations. When the resource of MEC server is enough, we always hope that computing services will be provided by the MEC server of the connecting base station. In this case, mobile terminals can obtain low-latency computing services. This strategy will frequently change the service relationship between the terminal and the MEC server even if the network delay can still guarantee the quality of service.
Therefore, we need to establish a dynamic resource scheduling mechanism that considers multiple aspects of computing task delay requirements, required computing resources, and wireless communication energy consumption.

B. Communication Model
The mobile terminal in the coal mine moves along the roadway which is long and narrow. The special environment of coal mine roadways leads to limited electromagnetic wave signal transmission distance. For example, we test the maximum transmission distance of LoRa with 20dBm transmit power in coal mine roadway is only 300m. However, the value measured in an open area on the ground using the same parameters is about 8000m. In this case, the base stations deployed in coal mines are denser than other industrial sites. As shown in Figure 2, it is a common distribution of base stations in coal mines.

Figure 2. Typical wireless communication scenarios in coal mines.
The difference between mines and general industrial sites is mainly in the communication environment. Due to the barrier of tunnel walls, the range of wireless communication in mines is greatly reduced compared with the ground environment. At the same time, the topological structure of mine industrial network is limited by the topological structure of roadway. Packets travel along a fixed path on the network. Therefore, the communication environment will change dramatically with the terminal moves.
Due to the poor communication environment increase the risk of bit error and frame loss of multi-hop transmission, we adopt the point-to-point as communication manner. The communication model of roadway can be seen similar as tunnel channel model. The tunnel channel model was proposed by Professor Cerasoli in 2004 [19]. He spaced the propagation path of radio frequency signals in confinement by establishing a Cartesian coordinate system. Sun Z. et al. further improved the wireless network communication model of roadway in combination with the coal mine environment [20].
As shown in Figure 3, we use a combination of rectangle and semicircle to describe the cross section of the roadway. And we define ℎ , , as the RF signal loss parameters in vertical, horizontal and air directions.
Where 0 is the conductivity in vacuum; , ℎ , are the relative permittivity in the air, horizontal and vertical directions, respectively; 0 is the center frequency of the signal; and , ℎ , are conductivity of medium. The power consumption of mobile terminal wireless communication includes two parts. One is the fixed consumption of modulation circuit. And the another one is the power of the signal transmitted by the terminal. The transmission power is related to the communication distance. The power of mobile terminals in coal mines away supplied by batteries. In this case, power save of wireless communication is necessary for mobile terminals. And the energy consumption of a mobile terminal at time t is: ( , ) is the energy consumption of sending signal; ( ) is the energy consumption of receiving signal; , are the power of the transmitting circuit and the receiving circuit respectively.
, are the fixed power of the encode and decode respectively. And ( , ) can be expressed by the following formula: ( ) is the energy consumption generated by the baseband chip; 0 is the far-field reference distance of the antenna. Because of the wireless communication in roadway of coal mine is small-scale wireless local area network, we set the 0 as 1meter. When the transmitting distance d is smaller than 0 , the power of the transmitting circuit is expressed by the free space model. When ≥ 0 is expressed by lognormal fading model. and are the parameters of amplifying circuit. The power consumption of ( ) except for the baseband chip is negligible.
Mobile terminals in coal mine always powered by battery. In this case, it is necessary to control the power of transmitting the wireless signal to save the energy of mobile terminals. The signal-to-noise ratio , 1 ( ) is influenced by the change of the transmitting power. The transmit rate of mobile terminal i to base station s on subchannel 1 can be computed as: Where is the bandwidth; , 1 ( ) is the signal-tointerference-plus-noise ratio between mobile terminal i and base station s, which can be expressed as: Where , 1 ( ) is the channel gain from mobile terminal i to base station s on channel 1 ; ( ) is the noise power. Due to the shielding effect of the earth, the source of electromagnetic noise in underground coal mines is single. Environmental noise is mainly generated by the reflection of signals from other wireless communication devices.
In mines, MEC Servers are deployed with wireless communication base stations. Each base station The communication delay between the base station and the MEC server can be ignored. The movement of terminal equipment in the communication range of base station mainly affects the air speed of wireless communication. The cross-region movement mainly affects the network topology path between terminal devices and MEC server, thus affecting the communication delay.

C. Computing Model
MEC server is a small to medium-sized computing unit. It deployed nearly wireless base station and includes computing, storage, and network resources. Different from the literature [21], mobile terminals in coal mine away are weakly on computing. So, it is not reasonably to let terminals executing same task as MEC server. The terminals only perform data sorting tasks, and then submit the data to the MEC server to complete the computationally intensive part of the task.
The computing tasks assigned by the terminal to the MEC server are deployed and run in a containerized form [22]. In this way, MEC server can quickly and easily get the image from cloud server and deploy it. And tasks from different terminals are running independently. When computing tasks are dynamically offloaded to the MEC server, the task processing model of the MEC server has the following characteristics: 1) Dynamic adjustment of the number of task queues: As shown in Fig. 3, since the number of computing resources required for computing tasks is different, the number of tasks processed in parallel by MEC server at different times will change dynamically.
2) Dynamic partitioning of computing resource blocks: Due to the different size of resource blocks required for computing tasks, the size of resource blocks divided by MEC server at different time points is also different.
The above characteristics lead to the task processing model of MEC server is not a simple one-dimensional time series, but a two-dimensional dynamic time series.
On the other hand, because of tasks from different terminals are running independently, tasks can be abstracted into a profile with series parameters, such as: The start time and end time of the task. The number of computation input data bits ( ) of the terminal . The number of resource demands . The maximum network delay that the computing task can tolerate.

IV Problem Formulation and Algorithm Design
In this section, we first put forward the problem in mathematical form, and then give the task offloading algorithm.

A. Problem Formulation
MEC servers in the mine network are all private. The mission of these MEC servers is to ensure the efficient and normal operation of mines. Therefore, ensuring that the computing requirements of all terminals are met and increasing the capacity of the system are our principles for task scheduling. When resources of the base station's MEC server which the mobile terminals accessed is enough, the MEC server can provide the lowest latency service for mobile terminals. But when the resources of the nearest MEC server is short, the MEC server need offload tasks of terminals to other MEC server. We will establish a market in the system to drive the flow of computing resources in real time by adjusting the service price of each MEC server in the market from the supply side.
It is unreasonable to offload tasks to any MEC server. Network delay, wireless connection status between the terminal and the base station and operational benefits of all MEC servers should be considered.
We assume there is a group of MEC servers that can indicates that provider provides resources to meet demand . If the value of is 0, there is no service transaction between the demands and the provider . If the value of is 1, the service transaction is completed. We name B as resource transfer matrix. To ensure the normal operation of the edge equipment, every requirement must be met. This means that B does not have a zero row. At the same time, since one computation requirement cannot be satisfied by multiple providers. the resource transfer matrix B can only have one non-zero element per row.
Because certain types of resources can only be allocated with a fixed size as a unit when dividing. For example, when scheduling CPU resources, a single core is used as the minimum scheduling unit. The CPU models carried by different fog computing nodes may be different, so we need to quantify the core performance of different models of CPUs. The single-core performance of the CPU is the unit of CPU resource division. So the amount of resource that the j-th fog node supplied to i-th demand is indexed as a victor = { | ∈ {1,2,3,4,5}}. And the value of is constrained by formula (10).
Where is minimum scheduling unit of type k resources of the j-th MEC server. We named as resource block.
is the number of resource blocks required to meet demand. At the same time, the amount of resources that MEC server used to provide services should not more than the total amount of resources it holds.
When matching requirements and resource providers, we need to shorten the network distance between the two parties as much as possible to reduce communication delay and transmission distance. In the task offloading mechanism, we realize network distance control by defining communication cost variables. Communication cost is not only including wired network cost, but also include the wireless communication cost between terminal and base station. We assume demand needs to transmit quantity of data per unit time. The communication cost can be defined as: Where is the wired distance between the terminal who make the demand and the provider . The distance between all requirements and all MEC server is recorded as Z = { | ∈ {1,2 ⋯ }, ∈ {1,2 ⋯ }} . The resources held by MEC server is composed of multiple hardware resources. Various computing resources are combined to complete computing services. Therefore, when the resource structure is extremely unbalanced, the MEC server may not be able to continue to provide computing services. This requires the scheduling mechanism to pay attention to the adaptability of the MEC server's computing resources and computing demands when matching computing resources, and avoid unbalanced consumption of resources as much as possible. To this end, we define the resource satisfaction as : To make full use of all MEC server's resources in the network, MEC servers with lighter loads should be mobilized as much as possible. Here we let the resource price of the lightly loaded node be inversely proportional to the proportion of idle resources, to achieve the purpose of driving the task allocation to the lightly loaded node by adjusting the price of computing resources. The price of kth resource of provider is indexed as : is the ratio of the kth resource used in the previous round of transactions on the server.
We define the revenue of the j-th MEC server as: 1 , 2 , 3 are income adjustment coefficients. Then the total revenue of all MEC server in the network is: We hope that our mechanism can make full use of the resources of the MEC server in the network. That is to maximize the revenue of all MEC servers in the network, which is the problem of maximum revenue (P.M.R). P.M.R: There are some objective conditions in the resource scheduling mechanism to restrict this problem. The constraints are as follows: is the maximum limit of the network communication distance required by .

B. Task Offloading Algorithm Design
We assume each MEC server evaluate its load status every T time. And each MEC server will share its load status and local computing demands to all MEC servers. In this case, each MEC server can independently find the optimal solution to the P.M.R problem and propose its own task allocation plan. In this case, the objective of our task unload algorithm is to find the relative optimal solution of the PMR problem with dynamic constraints.
It is difficult to solve P.M.R directly, so it is necessary to find the optimal solution through algorithms. Since the resource scheduling system hopes to reduce the time required for resource matching as much as possible, this puts forward requirements for the time complexity of the optimization algorithm. Fortunately, the system does not pursue a strict optimal solution. For this reason, we design task offloading algorithm based on Particle Swarm optimization (PSO) [23].
According to the constraints of P.M.R, each row of the target result matrix B has one and only one non-zero element, but the position of the non-zero element in each row is uncertain. Therefore, the optimization conversion for this problem is to determine the location of the nonzero elements of each row of matrix B. The position of the non-zero element in ith row of matrix B is indexed as , and ∈ {1,2 ⋯ }. The matrix B can be indexed as: The different solutions of P.M.R can be regarded as the non-zero elements of each row of matrix B moving, which coincides with the characteristics of particle swarm algorithm. Therefore, this problem is very suitable to use particle swarm algorithm to search for the optimal deployment plan. Suppose that there is a group of L particles in dimensional feasible region of R.M.P. Each particle contains three characteristics: position, speed and fitness. The position of the particle in the feasible region represents the configuration of a feasible solution matrix B of P.M.R. We index the position of lth particle is = { | ∈ {1,2 ⋯ }}, ∈ {1,2 ⋯ }. The speed represents the rate of change of the particle's moving distance relative to time in the feasible region. The fitness represents the pros and cons of the particle's position, which can be calculated by the fitness function.
Calculate the fitness corresponding to the position of the lth ( = 1,2, ⋯ , ) particle at the nth iteration. By tracking the individual particle's best position ( ) and the global optimal position of the group ( ), the particle velocity and position are updated according to formulas (23) and (24). The particle velocity ( + 1) and position ( + 1) of the n+1th iteration are obtained.
( + 1) = ( ) + ( + 1) Perform iteratively in the above manner until all particles converge at the same position in the feasible region or reach the maximum number of iterations. The global optimal position of the particle swarm is the result.
All demands of terminals are transparent to each MEC server. In this case, all MEC server can propose their own solutions based on the task offloading algorithm. From the structure of the algorithm, we can know that when the number of iterations reaches the maximum, even if the algorithm does not find the global optimal solution, it will take the relative optimal solution as the output result. The initial value of the algorithm and the randomness of the optimization process lead to different task offloading solutions for each MEC server running algorithm. Therefore, to get the best task offloading solutions as much as possible, we designed a bidding mechanism based on the idea of blockchain. Update global optimal value 9 for in O: 10 Calculate particle velocity according to Formula (9). 11 Update particle position according to Formula (10)  12 n=n-1 13 if n=0 or particle swarm converges at the same point: 14 flag=0; 15 Publish results to other brokers; 16 Collect the results of other brokers; 17 The optimal result is selected by formula (8); 18 Write to the blockchain and execute.
The time complexity of the algorithm is O( × ). Where is the maximum number of iterations of the algorithm that we set. l is the number of particles in a swarm. The space complexity of the algorithm is O( ).
MEC server propose its own solution based on the task offloading algorithm and distribute the solution to other MEC servers through P2P network. It is easy for MEC server to verify which solution is the best. When all MEC servers have selected the same optimal solution, they reach a consensus and execute the optimal solution.
This optimization process is in real time. Every time the MEC Server receives a new computation request, it checks to see if there is a better alternative to uninstall.

V Performance Evaluation
In this part, we will evaluate the performance of our mechanism. And compare with other mechanism under same experimental setup. VOLUME XX, 2017  As shown in Figure 6, we hosted eight MEC servers as virtual machines on two desktop computers. Each MEC server VM is independent of each other. The hardware parameters of desktop computer are AMD Ryzen7 5800X 3.8GHz and 32GB DDR4-3200MHz RAM. The terminal device is an Internet of things controller designed by us based on STM32F103 chip. It supports TCP, UDP, MQTT and other protocols. The terminal sends the computing request to the nearest MEC server based on its location. In the actual system, we need to determine the network distance between the terminal and the MEC server. In our experiment, we set the coordinate points of all terminal devices and MEC servers in a two-dimensional plane, and use the distance between the two points as the network distance. Figure 7 shows the initial distribution of terminal devices and MEC server in a two-dimensional plane. The computing request sent by the terminal device contains its own virtual location. The virtual position is the coordinate obtained by adding random motion to the initial position shown in Figure  7. When the experiment begins, the terminal device will send virtual computing requests to the nearest MEC server at a fixed frequency. After receiving the request, the MEC server shares the request information with other MEC servers on the P2P network. MEC Server calculates the best offloading plan based on the new request information.

Figure 7 Initial distribution of two parties in a two-dimensional coordinate system
Performance Evaluation: By controlling the number of demands make by each terminal device, we evaluated the four scenarios of 8 demands, 16 demands, 32 demands, and 64 demands. The relationship between the total number of revenue in the network and the number of iterations of the matching algorithm is shown in Figure 8. Through observation, it can be concluded that the total revenue increases as the number of iterations of the algorithm increases until it converges to a fixed value. As the number of computing demands submitted by terminal devices increases, the supply relationship that may exist between terminal devices and MEC server also increases. The larger the dimension of the solution space that the algorithm needs to search for. This will cause the algorithm to find the optimal solution with more iterations and longer matching time. To solve this problem, we expand the search range through the joint proposal of all MEC server, and find the relative optimal solution as much as possible. We compared with other similar mechanism under same experimental setup. It should be pointed out that other similar mechanisms are not optimized for the mine environment, so the experimental results only represent the performance of each mechanism in the mine environment.
In reference [13], a computing resource auction algorithm based on machine learning is proposed. We built the test algorithm according to the structure in the reference and made simple modifications to adapt it to our experimental settings and background. At the same time, we also compared the situation where there is no resource offloading algorithm, and the terminal computing requirements are only provided by the nearest MEC server.
In the same experimental environment, we compared the resource occupancy rate, service achievement rate and algorithm running time of each node in the system under different mechanisms. Figure 9 shows the comparison of resource occupancy rate of each node under the three conditions. The resource usage of each node is most unbalanced in the case of no task uninstallation mechanism. The MEC server in the hotspot area is under heavy load and cannot meet all tasks. MEC server resources in low hotspot areas are idle and wasted.  Table II shows the service achievement rates for each mechanism. The so-called achievement rate is the ratio of the demands satisfied to the total demands. We test those algorithms with different number of MEC servers, terminals and demands. It should be noted that the realization of the service in the experiment means that the network delay of the MEC server providing the service meets the terminal requirements. As can be seen from the experimental results, when there is no task unloading mechanism, the two MEC servers 1 , 2 have exhausted all the computing resources, but still cannot meet the computing requirements of all terminals in the region. The mechanism proposed in this paper can better unload tasks to the MEC server that meets the requirements of the terminal. The mechanism in reference [13] does not take into account the minimum unit of resource scheduling, which leads to it meeting all computing requirements but occupying more resources.

VI. CONCLUSIONS AND FUTURE WORK
In this paper, to improve the resource utilization efficiency of MEC Servers in mines, we comprehensively analyze the characteristics of communication environment and network topology, and design a task offloading algorithm. When there are too many demands in the region, the MEC Server will select an appropriate MEC server and offload computing tasks to it on the premise of ensuring service quality. Theoretical analysis and experimental results show that this algorithm can improve the resource utilization of all MEC servers in the system and balance the system load moderately. In future work, we will consider how to combine data flows to optimize computational resource allocation and introduce deep learning algorithms to seek optimization.