A blockchain-based mobile edge computing resource allocation method and system

By combining blockchain and federated learning in mobile edge computing systems, resource allocation and consensus energy consumption are optimized, solving the problems of high energy consumption, low security and slow efficiency in mobile edge computing systems, and achieving efficient and secure resource allocation and task execution.

CN121455679BActive Publication Date: 2026-05-12INNER MONGOLIA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INNER MONGOLIA UNIV OF TECH
Filing Date
2025-11-05
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Mobile edge computing systems suffer from high energy consumption, low security, and slow efficiency. In particular, the high energy consumption of the blockchain consensus process and the security and privacy risks of distributed systems have not been effectively addressed during the execution of complex tasks.

Method used

We adopt a blockchain-based mobile edge computing resource allocation method that combines federated learning and deep reinforcement learning. By collecting device computing power data in real time, we calculate the action instructions for resource allocation strategies and perform security authentication. We optimize resource allocation using a global model and integrate an attention mechanism for weight aggregation to optimize consensus energy consumption and latency.

Benefits of technology

It achieves the minimization of total system power consumption under strict latency constraints, improves the security and execution efficiency of mobile devices in complex task execution, and combines high efficiency, security and adaptability, protects data privacy and optimizes global performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121455679B_ABST
    Figure CN121455679B_ABST
Patent Text Reader

Abstract

The application provides a kind of blockchain-based mobile edge computing resource allocation method and system, belong to computer technology field, the method includes: constructing a federal reinforcement learning framework, wherein each mobile device utilizes proximal policy optimization PPO algorithm to make local task offloading and resource allocation decision, while the energy consumption of blockchain consensus is included in the optimization target;By introducing the attention mechanism, the model parameters uploaded by the device are intelligently weighted and aggregated, effectively improving the global model training efficiency and performance. Under the premise of ensuring data privacy and system security, the method realizes the minimization of system total energy consumption and the satisfaction of delay constraint, which is significantly better than the traditional distributed algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, specifically relating to a method and system for allocating mobile edge computing resources based on blockchain. Background Technology

[0002] In recent years, the rapid development of 5G networks has significantly increased the number of smart terminals connected to mobile networks, leading to a surge in mobile data volume. To address users' growing computing demands, mobile edge computing (MEC) has emerged as a promising solution. MEC is particularly suitable for real-time applications because it enables rapid response times and local decision-making. This is achieved by offloading computationally intensive tasks to MEC servers deployed near mobile devices (MDs).

[0003] However, the distributed nature and limited resources of MEC systems introduce security and privacy risks, such as data tampering and unauthorized computation. Blockchain technology mitigates these problems through its immutability and traceability, but its consensus process generates high energy consumption. Specifically, MDs are often deployed in physically insecure edge locations, making them vulnerable to malicious attacks, including data tampering, privacy breaches, unauthorized computation, and unfair task allocation. Furthermore, traditional MEC systems lack global visibility and traceability, complicating trust management. Blockchain technology effectively addresses these challenges with its immutability and traceability. The consensus mechanism, as a core component of blockchain, is crucial for verifying transactions and ensuring network security. Integrating blockchain into MEC reduces reliance on centralized MEC servers through decentralization.

[0004] Therefore, minimizing energy consumption during the execution of complex tasks in resource-constrained blockchain-based MEC systems remains a key challenge. Summary of the Invention

[0005] To address the issues of high energy consumption, low security, and slow efficiency faced by mobile devices in performing complex tasks, this invention provides a blockchain-based method and system for allocating mobile edge computing resources.

[0006] To achieve the above objectives, the present invention provides a blockchain-based mobile edge computing resource allocation method, comprising:

[0007] The target mobile device collects the remaining computing power data of other devices within the communication range in real time; the edge server initializes a global model and distributes the global model to all target mobile devices.

[0008] The target mobile device issues an action strategy instruction to perform resource allocation based on the remaining computing power data, and calculates the actual latency and energy consumption loss of the action strategy instruction; the blockchain network performs security authentication on the action strategy instruction, and simultaneously calculates the consensus energy consumption loss during the authentication process; the target mobile device uses the actual latency, execution energy consumption loss, and consensus energy consumption loss to evaluate the value of the action strategy instruction; the local global model parameters are updated based on the value evaluation results, and when the training round is reached, the update of the local global model parameters is stopped, and the updated local global model parameters are sent to the edge server.

[0009] The edge server calculates the weights and local evaluation metrics of the latest local global model parameters sent by all target mobile devices; updates the global model parameters based on the weights and local evaluation metrics, and broadcasts the updated global model parameters to all target mobile devices participating in the training; it trains the global model in a loop, and when the training round is reached, a global model that can be allocated resources is obtained.

[0010] Preferably, the global model includes a near-end policy optimization (PPO) algorithm, whereby each target mobile device receives the global model parameters that enable resource allocation and allocates resources to the task to be processed based on the local global model.

[0011] Preferably, the PPO algorithm includes an Acto network and a Critic network; locally on each target mobile device, the Acto network performs forward propagation based on the remaining computing power data, calculates the probability distribution, and selects the action strategy instruction with the highest probability from the probability distribution; the Acto network issues the action strategy instruction to perform resource allocation based on the remaining computing power data, and the Critic network values ​​the action strategy instruction using the actual latency time, execution energy loss, and recognition energy loss.

[0012] Preferably, the blockchain network runs the PBFT algorithm to add the action policy instructions to the distributed ledger in the form of new blocks for security authentication, while simultaneously calculating the consensus energy consumption loss during the authentication process.

[0013] Preferably, the step of updating the global model parameters based on weights and local evaluation metrics specifically includes: the edge server calling the distributed algorithm FDRL with integrated attention mechanism, calculating the similarity score between the local evaluation metric and the maximum preset target metric through dot product, and then normalizing the similarity score to obtain the aggregate weight of each target mobile device; the edge server performing a weighted average based on all aggregate weights to update the global model parameters.

[0014] Preferably, the pending task status includes the data size and maximum tolerable latency of the pending task of the target mobile device; the transmission power status includes the remaining allocable transmission power and maximum transmission power of the mobile device; the computing resource status includes the remaining computing power, remaining battery power, current computing power allocation status of the mobile device, and idle computing power of the edge server; and the wireless channel status includes the available subband set, subband occupancy status, and subband channel gain of the wireless channel.

[0015] Preferably, the task offloading decision is calculated based on the status of the task to be processed and the status of computing resources; the task offloading decision determines whether the target mobile device chooses to process the task locally or offloads the task to an edge server for processing; the transmission power allocation decision only occurs when the task is offloaded, including the target mobile device needing to select a subband with the maximum channel gain that meets the transmission speed requirements and does not exceed the maximum power; the computing resource allocation decision is based on the target mobile device's remaining computing power, remaining battery power, and the status of the task to be processed; the channel selection decision only occurs when the task is offloaded, meaning that the target mobile device selects the subband with the highest channel gain from all available and idle subbands.

[0016] This invention also provides a blockchain-based mobile edge computing resource allocation system, comprising:

[0017] The data preparation module is used to collect the remaining computing power data of other devices within the communication range in real time from the target mobile device; the edge server initializes a global model and distributes the global model to all target mobile devices.

[0018] The local training module is used by the target mobile device to issue action strategy instructions for resource allocation based on the remaining computing power data, and to calculate the actual latency and energy consumption loss of the action strategy instructions. The blockchain network performs security authentication on the action strategy instructions and simultaneously calculates the consensus energy consumption loss during the authentication process. The target mobile device uses the actual latency, execution energy consumption loss, and consensus energy consumption loss to evaluate the value of the action strategy instructions. Based on the value evaluation results, the local global model parameters are updated. When the training round is reached, the updating of the local global model parameters is stopped, and the updated local global model parameters are sent to the edge server.

[0019] The server training module is used by the edge server to calculate the weights and local evaluation metrics of the latest local global model parameters sent by all target mobile devices; update the global model parameters according to the weights and local evaluation metrics, and broadcast the updated global model parameters to all target mobile devices participating in the training; train the global model in a loop, and when the training round is reached, a global model that can be allocated resources is obtained.

[0020] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the steps in the blockchain-based mobile edge computing resource allocation method.

[0021] The present invention also provides a computer-readable storage medium storing a computer program that, when loaded by a processor, can execute any of the steps in the blockchain-based mobile edge computing resource allocation method.

[0022] The blockchain-based mobile edge computing resource allocation method provided by this invention has the following beneficial effects:

[0023] This invention presents a distributed resource management method based on federated reinforcement learning, which combines high efficiency, security, and adaptability. Through a federated learning framework, decision-making and training are performed locally on mobile devices, protecting data privacy while leveraging collective intelligence to optimize global performance. By assigning weights to each mobile device participating in training the global model, high-quality device experience can be dynamically selected, accelerating model convergence. By jointly optimizing the immutability of blockchain and energy consumption, data security and transaction trustworthiness are ensured while effectively controlling the additional overhead of consensus mechanisms. This method, through integrated decision-making on task offloading, communication, and computing resources, precisely minimizes the total system energy consumption under strict latency constraints, improving the security and execution efficiency of mobile devices during complex task execution. Attached Figure Description

[0024] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a flowchart illustrating a blockchain-based mobile edge computing resource allocation method according to an embodiment of the present invention.

[0026] Figure 2 This is a structural diagram of the F-PPO algorithm according to an embodiment of the present invention;

[0027] Figure 3 This is a flowchart illustrating the overall process of the attention mechanism in an embodiment of the present invention.

[0028] Figure 4 This is a comparison chart of reward values ​​for different distributed methods according to embodiments of the present invention;

[0029] Figure 5 This is a comparison chart of the loss values ​​of different distributed methods in embodiments of the present invention;

[0030] Figure 6 This is a comparison chart of the reward values ​​of the F-PPO method under different learning rates according to an embodiment of the present invention;

[0031] Figure 7 This is a comparison chart of the loss values ​​of the F-PPO method in this invention under different numbers of mobile devices;

[0032] Figure 8 This is a comparison chart of reward values ​​for the F-PPO method of this invention at different batch sizes. Detailed Implementation

[0033] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.

[0034] To address this problem, this invention proposes a joint optimization method that integrates Federated Learning (FL) and Deep Reinforcement Learning (DRL) into MEC systems and consensus processes. The main contribution of this invention is that it formulates the joint optimization problem of distributed task offloading and blockchain consensus in mobile edge computing systems as a Markov Decision Process (MDP). The primary objective is to minimize total system energy consumption, including task execution and consensus energy consumption, while strictly adhering to predefined latency constraints. By leveraging the ability of DRL to handle high-dimensional problems, this invention proposes an attention-based aggregation mechanism that accelerates policy learning through dynamic weight allocation in the federated aggregation process. Furthermore, communication overhead is minimized to enhance data privacy. The performance of the proposed scheme is evaluated through extensive simulations and compared with traditional FL combined with other DRL algorithms and non-cooperative multi-agent reinforcement learning methods. The results show that the proposed scheme is more suitable for complex distributed systems.

[0035] In traditional MEC research, most studies focus on optimizing computational offloading to improve Quality of Service (QoS). One proposed QoS optimization model is based on latency and energy consumption, while another is a personalized federated deep reinforcement learning offloading and allocation method for smart communities (PFDRL-OA) to generate customized offloading policies. However, these studies often neglect the security of data transmission and storage during the offloading process. In blockchain-integrated MEC systems, some studies have adopted centralized single-agent offloading schemes, modeling the problem as an MDP and using deep neural networks (DNNs) for function approximation. However, this approach is difficult to scale effectively in distributed MEC-blockchain environments. Alternative solutions employ multi-agent reinforcement learning (MARL). One non-cooperative MARL framework, where MDs make offloading decisions independently, and another work utilizes multi-agent Q-learning for joint offloading and resource allocation. However, non-cooperative MARL often fails to learn cooperative policies, leading to low edge resource utilization and suboptimal offloading performance. Recent FRL research mainly relies on simple aggregation methods, such as the arithmetic mean of model parameters. These methods ignore the heterogeneity of MDs' computational capabilities and the quality of the data they generate, which warrants further investigation. This subsequently leads to suboptimal global model performance, indicating inadequate model capabilities. To address these limitations, embodiments of this invention propose an attention-enhanced FRL method for joint offloading and consensus energy optimization in blockchain-enabled MEC systems. The solution of embodiments of this invention comprehensively addresses offloading decisions, channel selection, transmission power allocation, and resource allocation to minimize total energy consumption.

[0036] This invention provides a blockchain-based method for allocating mobile edge computing resources, specifically as follows: Figure 1 As shown, it includes:

[0037] S1. The target mobile device collects the remaining computing power data of other devices within the communication range in real time; the edge server initializes a global model and distributes the global model to all target mobile devices.

[0038] This invention studies a blockchain-based mobile edge computing (B-MEC) collaborative task offloading and resource allocation system, including Internet of Things (IoT) sensors, data meters (MDs), MEC servers, and a blockchain network. IoT sensors collect various types of real-time data from the physical environment and trigger specific tasks based on the perceived information. A task is formally defined as Mn(t) = {Dn(t), Cn(t), Qn(t)}, where Dn(t) represents the data size of the task, Cn(t) represents the number of CPU cycles required to complete the task, and Qn(t) represents the maximum tolerable latency of the task.

[0039] MDs acquire tasks from nearby IoT sensors within their communication range and determine whether to offload the task to the MEC server and how to allocate resources based on the task Mn(t). MDs have limited computing power, enabling them to process relatively simple or latency-sensitive tasks locally. Furthermore, MDs act as blockchain nodes, storing redundant copies of computational data as transactions to enhance data integrity and system resilience. The blockchain, as a distributed ledger, ensures data integrity and privacy during task offloading due to its immutable and secure nature. Additionally, a Practical Byzantine Fault-Tolerant (PBFT) consensus algorithm is employed to verify and record information related to task offloading and resource allocation onto the blockchain.

[0040] S2. The target mobile device issues an action strategy instruction for resource allocation based on the remaining computing power data, and calculates the actual latency and energy consumption loss of the action strategy instruction. The blockchain network performs security authentication on the action strategy instruction and simultaneously calculates the consensus energy consumption loss during the authentication process. The target mobile device evaluates the value of the action strategy instruction using the actual latency, energy consumption loss, and consensus energy consumption loss. Based on the value evaluation result, the local global model parameters are updated. When the training round is reached, the update of the local global model parameters is stopped, and the updated local global model parameters are sent to the edge server.

[0041] The target mobile device collects remaining computing power data within its unloadable range and trains the received global model locally based on this data. Locally on each target mobile device, the Actor network performs forward propagation based on the remaining computing power data, calculates a probability distribution, and selects the action policy instruction with the highest probability from the distribution to execute resource allocation. The target mobile device calculates the actual latency and energy consumption loss of executing the action policy instruction; the blockchain network runs the PBFT algorithm, adding the action policy instruction to the distributed ledger as a new block for security authentication, while simultaneously calculating the consensus energy consumption loss during the authentication process; the Critic network uses the actual latency, energy consumption loss, and consensus energy consumption loss to evaluate the value of the action policy instruction. The Actor network updates its network parameters based on the value evaluation results, and the Critic network optimizes its parameters based on the score, updating the environmental state parameters of the target mobile device; updates cease when the training round is reached.

[0042] A. Communication model

[0043] Will This is represented as the set of available subbands. In conjunction with subband scheduling, this embodiment of the invention defines a binary variable. As a task unloading strategy, =1 indicates a task originating from a mobile device. via sub-band Unload to the MEC server. =0 Otherwise. Each mobile device in the system is equipped with a single antenna. Let This indicates that mobile devices and MEC servers are in the subband. Uplink channel gain. Let Indicates power allocation, where It is assigned to mobile devices sub-band The power. The data transmission rate of mobile devices is calculated as follows.

[0044] ;

[0045] in , The total frequency bandwidth of the system is evenly divided into Individual bands, therefore This indicates the bandwidth of each subband. This represents the background noise variance, and the second term in the denominator takes into account interference from other mobile users on the same channel.

[0046] B. Computational Model

[0047] In the joint optimization model of task offloading and resource allocation, this invention mainly considers two metrics: latency and energy consumption. The goal of this invention is to make appropriate decisions to minimize overall system energy consumption while satisfying latency requirements as much as possible. Latency mainly includes task processing latency on the local mobile device and the MEC server, as well as transmission latency during offloading. Tasks are run locally on the mobile device. computation delay And on the MEC server after uninstallation They are given as follows:

[0048] ;

[0049] ;

[0050] in The computing resources allocated to mobile devices to perform tasks should not exceed their total computing capacity. Therefore, the computing resource allocation strategy for mobile devices can be defined as follows: . This refers to the computing frequency of the MEC server. Compared to local devices, MEC servers have a much higher computing capacity. And a more stable power supply. Mobile devices upload their task input via uplink. The required time is specified as follows:

[0051] ;

[0052] In short, mobile devices unload their tasks The latency cost is given as

[0053] ;

[0054] In a MEC system, energy consumption primarily comes from the energy consumed during data transfer and local task processing during offload. Since the computing resources of the MEC server far exceed those of mobile devices and it can serve multiple mobile devices simultaneously, the energy consumption of offloading tasks to the MEC server for processing is... Only the energy required for data transmission Related can be represented as:

[0055] ;

[0056] in The energy consumption of local tasks executed on mobile devices can be calculated as follows:

[0057] ;

[0058] in It depends on the energy efficiency coefficient of the chip architecture. Therefore, the energy consumption of MEC... It depends on whether the device has uninstalled it, so it can be expressed as:

[0059] ;

[0060] C. Consensus Model

[0061] In the B-MEC system, the consensus mechanism is a key component of blockchain technology. After mobile devices process data collected from sensors, the data is verified as transactions and packaged into blocks. These blocks are then broadcast to all mobile devices for verification using the PBFT algorithm. System security is ensured when the number of faulty nodes in the network is less than one-third of the total number of nodes. The PBFT consensus process consists of five phases: request, pre-preparation, preparation, commit, and response.

[0062] During the request phase, the client sends a task request to the master node, containing information such as transactions, signatures, and Message Authentication Codes (MACs). The mobile device, acting as a consensus node, collects all transactions, verifies signatures and MACs, and packages the transactions into a block. Indicates in time slot The CPU frequency used to generate new blocks. The energy consumption of a mobile device for generating blocks is given as follows:

[0063] ;

[0064] in This is a binary variable representing the block generated by the mobile device. If the mobile device is in a time slot... Generate blocks =1, otherwise 0. Here Indicates the effective capacitance of the mobile device. This indicates the duration of each time slot.

[0065] During the pre-preparation phase, the master node generates a pre-preparation message (including a signature and MAC) for the request and sends it to all other consensus nodes. These nodes receive and verify the pre-preparation message along with the block content. Upon successful verification, a preparation message is generated and broadcast to all consensus nodes. Once a node receives at least... After different nodes collect a consistent preparation message, it transitions to the commit phase. During the commit phase, all consensus nodes broadcast a commit message, and nodes receive at least... After receiving a consistent commit message, each consensus node confirms its readiness to commit. Finally, in the response phase, each consensus node sends an acknowledgment to the client. When the client receives at least... When a consistent response is received, the transaction is considered to have reached consensus. During these phases, the primary source of energy consumption is block verification energy. And block broadcast energy consumption Because verification and broadcasting are components of each stage, the total energy consumption of these processes is expressed as:

[0066] ;

[0067] ;

[0068] in It is the size of the block. It is the number of CPU cycles required for a mobile device to perform a one-bit computation task. It is the total computing capacity of the mobile device. yes The number of blocks generated in each time slot, This is the maximum output power of the mobile device broadcast block to the MEC server. Then, consensus energy consumption... It consists of three parts: block generation, block verification, and block broadcasting.

[0069] ;

[0070] This invention describes the joint optimization problem of distributed resource allocation and efficient consensus energy in a B-MEC system. This invention proposes using a distributed algorithm, FDRL, with an integrated attention mechanism to solve this problem.

[0071] In a B-MEC system, the optimization objective is to minimize total energy consumption, including offloading and consensus energy consumption, while ensuring compliance with specified latency constraints. The objective function and constraints of this optimization problem are expressed as follows:

[0072] ;

[0073] The above formula represents the system's energy consumption by comparing local execution and offloaded execution. When the energy consumption of offloaded execution is lower than that of local execution, and the latency constraint is also satisfied, the target value should be larger.

[0074] stC1: ;

[0075] C2: ;

[0076] C3: ;

[0077] C4: ;

[0078] C5: ;

[0079] C6: ;

[0080] Constraints C1 and C2 correspond to binary variables indicating whether each task is executed locally or offloaded, and whether a block is generated in a given time slot. Constraint C3 ensures that each mobile device allocates positive resources for computation tasks and the consensus process, without exceeding its total resource budget. Constraint C4 limits the transmission power of each mobile device. Constraint C5 requires that the generated block size exceed the size of the data collected from the mobile device. Constraint C6 guarantees that each task completes within its specified latency threshold.

[0081] The problem is described as MDP to optimize the energy consumption caused by task offloading and resource allocation in the B-MEC system.

[0082] 1) State Space: In a B-MEC system, the environment state includes several components: task state Channel state Transmission power status and resource status .time The overall system state is defined as follows:

[0083] ;

[0084] The task state is defined as follows: ,in This indicates the size of the computing task data on the mobile device. This indicates the number of CPU cycles required to complete the task. This indicates the maximum allowable delay for the task. The channel state is... A vector of sub-channel states, defined as If the sub-channel Mobile devices in time Occupy If the task is executed locally, then Transmission power state is defined as follows: ,express The transmission power of each mobile device meets the requirements. Resource status is defined as follows: ,in This indicates that the mobile device is performing local task computation. and block generation The allocated resources.

[0085] 2) Action Space: Based on state, each mobile device acts as an intelligent agent, selecting an action to perform a task at each time step. The action space comprises four components: offload decision, channel selection, transmission power allocation, and resource allocation. Therefore, the action space of a mobile device is represented as:

[0086] ;

[0087] If the task is performed locally on the mobile device, then If through sub-channel Unload to MEC server Channel selection The mobile device depends on the current channel state. Select the appropriate sub-channel to offload the task; if the task is executed locally, then... Transmission power allocation Indicates that the mobile device is in the sub-channel Power selected for uptransmission task data This is determined based on the task state and channel state. Similarly, resource allocation... Select from a discrete set, based on local task status and consensus requirements.

[0088] 3) Reward function: for each time slot The total reward for the B-MEC system is the sum of the rewards for all mobile devices. Each mobile device is in a certain state. Execute action Receive reward later The reward function is designed to align with the optimization objective and is defined as follows:

[0089] ;

[0090] in This is the penalty for violating constraints. It is worth noting that the penalty for violating constraint C4 (related to maximum latency) is significant because exceeding the latency threshold directly affects the system's task completion rate and consensus progress.

[0091] To address the aforementioned optimization objective, this invention proposes a solution integrating Federated Deep Reinforcement Learning (FDRL) with an attention mechanism to solve this complex and non-convex optimization problem. The Proximal Policy Optimization (PPO) algorithm is used to locally solve the joint optimization problem of task offloading and resource allocation in the B-MEC system, referred to as F-PPO.

[0092] The F-PPO algorithm comprises three main components: local training of offloading and resource allocation strategies, federated model parameter aggregation, and local model updates. First, each mobile device locally learns its offloading and resource allocation strategy using the PPO algorithm. Then, the locally trained model parameters are weighted and aggregated to update the global model. Finally, the updated global model parameters are distributed to each mobile device (MD) for local model updates. Figure 2 As shown.

[0093] Local Model: The PPO algorithm is an optimization method within the actor-critic framework, designed to address the instability and divergence problems of policy gradient methods in high-dimensional, complex state-action spaces. By constraining the magnitude of policy updates, PPO improves training stability and efficiency. Specifically, PPO uses a pruned agent objective function to limit updates during the deviation between the old and new policies. The actor network computes the objective function... Update using the gradient, using the following expression:

[0094] ;

[0095] in It is the probability ratio between the current strategy and the old strategy. It is the advantage function, which represents the quality of a certain action relative to the average action. Will Limited to Within the specified interval, to avoid overly aggressive policy updates that could affect stability. Furthermore, the critic network updates the value function by minimizing the following loss function:

[0096] ;

[0097] in Indicates the current Value function estimation, The objective value function represents the expected reward for the current state. Adjusting the parameters of the critic network... To minimize loss and improve the accuracy of approximating the true value function.

[0098] Global Model: In federated learning, multiple mobile devices participate in model training and share their locally trained model parameters with the server for weighted aggregation. Each mobile device trains a local model based on its local environment. After a fixed period of time, the server aggregates the local model parameters, reducing communication overhead, improving system efficiency, and enhancing data privacy.

[0099] S3. The edge server calculates the weights and local evaluation metrics of the latest local global model parameters sent by all target mobile devices; updates the global model parameters based on the weights and local evaluation metrics, and broadcasts the updated global model parameters to all target mobile devices participating in the training; iteratively trains the global model, and when the training round is reached, a global model capable of resource allocation is obtained.

[0100] The edge server invokes an attention mechanism, which compares the evaluation metrics of each device with an ideal target vector, calculates a similarity score through dot product, and then normalizes it using Softmax to obtain the aggregate weight for each device. The edge server then performs a weighted average based on all aggregate weights to update the global model parameters. The updated global model parameters are then broadcast to all participating mobile devices, and the global model is trained iteratively. When a training epoch is reached, the trained global model is obtained. Each target mobile device allocates resources for its own task based on its trained local global model.

[0101] Given the heterogeneity of mobile devices in terms of computing power, data quality, and model performance, assigning equal weights to all local models during aggregation is suboptimal. Therefore, a weighted federated aggregation method integrating attention mechanisms is proposed, such as... Figure 3 As shown.

[0102] The process is as follows: First, when the server receives the local model parameters, it distributes the global model parameters from the previous round to each mobile device. Next, each mobile device updates its local model and trains it using local data. After training, the mobile devices upload evaluation metrics (e.g., average reward, average loss) and local model parameters to the server. Finally, the server uses an attention mechanism to calculate aggregate weights based on the contribution of each mobile device.

[0103] In this embodiment of the invention, the attention weights are calculated using the following four metrics to reflect the contribution of each mobile device to the global model:

[0104] Average reward: Average reward This indicates model performance. A higher average reward suggests better model effectiveness, while a lower reward may indicate bias. Therefore, Used to evaluate model quality.

[0105] Average loss: the opposite of average reward, a higher average loss This indicates that the model has poor adaptability to the environment, while a lower loss reflects better performance. Therefore, within a specific period... Used to evaluate model quality.

[0106] Mobile device resource status: The resource status of the mobile device It influences task offloading decisions, thus affecting overall system utility. Favorable resource states reduce delays in task completion and consensus processes, thereby affecting model parameters.

[0107] Batch size: Mobile devices with greater computing power can process larger datasets during local training. Therefore, batch size... It affects the contribution of local model parameters to the global model.

[0108] These indicators form the evaluation vector for the equipment. This is used as input to the attention mechanism to measure the device's contribution to the global model. The goal of model training is to maximize reward, minimize loss, optimize resource state, and maximize computational power. Next, the contribution weight of each device is calculated using an attention mechanism:

[0109] ;

[0110] in It's a vector dimension, using dot product to calculate the similarity between the device metrics and the target, and then through... The final weights are obtained after normalization. Finally, the final global parameters are obtained through weighted aggregation:

[0111] ;

[0112] in yes Wheel The device’s local model parameters (including actor and critic network parameters). These are the aggregated global model parameters.

[0113] To verify the effectiveness of the embodiments of the present invention, a MEC simulation environment based on joint optimization of blockchain task offloading and resource allocation was constructed. In the FL simulation, the embodiments of the present invention designed a "Client" class to model a single mobile device, each equipped with a DRL model for local training. Simultaneously, a "Server" class was developed to simulate an edge server, responsible for parameter collection, model aggregation, and broadcasting parameter updates. This configuration together forms the topology of the FRL system. Furthermore, each stage of the consensus process in the blockchain was simulated, including message reception, verification, generation, and transmission, thereby accurately calculating the energy consumption and latency of the entire consensus process. The computational tasks received by the mobile device were simulated by randomly defining the task size, required latency, and required resources. Additionally, reasonable communication and computational latency were set according to references to simulate the computation and consensus processes.

[0114] In this simulation, it is assumed that all data uploaded by IoT sensors is successfully received by mobile devices, and all mobile devices are within the communication range of the MEC server. Furthermore, it is assumed that the MEC server has sufficient computing resources to handle all tasks offloaded by the mobile devices. To evaluate the convergence and effectiveness of the proposed Federated Proximity Policy Optimization (F-PPO) algorithm, this embodiment compares its performance with traditional federated deep reinforcement learning algorithms and centralized methods. These include the traditional federated Actor-Critic (F-AC) method, the traditional federated deep Q-network (F-DQN) method, and non-cooperative methods that do not use federated learning.

[0115] Figure 4 A detailed comparison of rewards from various methods is provided. The proposed F-PPO algorithm consistently outperforms its counterparts, achieving the highest reward value for the selected action in multiple simulated scenarios. This superior performance is characterized by a rapid ascent to the reward maximization stage, reflecting the algorithm's efficiency in policy optimization. These experimental results highlight the robustness of the F-PPO algorithm in handling complex distributed optimization problems. The integration of federated learning not only significantly improves the convergence speed but also preserves model performance, making F-PPO a promising method for distributed systems such as B-MEC.

[0116] like Figure 5 As shown, the integration of federated learning with F-DQN and F-AC algorithms demonstrates a significant improvement in convergence speed compared to decentralized training methods without it. This enhanced convergence is attributed to the collaborative nature of federated learning, which allows local models on distributed devices to contribute to the global model update process, thereby accelerating the optimization trajectory. Despite the faster convergence, the final convergence levels of F-DQN and F-AC are closely consistent with those of decentralized training methods, indicating that the federated framework maintains comparable solution quality while providing improved computational efficiency.

[0117] Figure 6 The performance of the average system reward under different learning rates is demonstrated. The results show that the learning rate significantly affects the learning reward in the training episode. Specifically, a lower learning rate leads to slower learning dynamics, thus reducing the convergence performance of the proposed algorithm. Experiments show that a learning rate of 0.01 produces optimal reward performance while maintaining robust convergence speed, making it the preferred choice for subsequent system simulations and evaluations. Figure 7 The convergence performance of the F-PPO global model is demonstrated with varying numbers of mobile devices. The global model is aggregated using federated learning. As shown, the fastest convergence was achieved with 15 devices, likely due to the increased participation of local models in parameter aggregation, which accelerates global model convergence. Although the convergence speed varies with the number of devices, the final convergence level remains consistent across different numbers of devices.

[0118] In addition, the impact of batch size on the convergence of the F-PPO algorithm was investigated. Figure 8 It has been demonstrated that a larger batch size improves the convergence of the F-PPO algorithm. This is because a larger batch size allows for training with more data instances, enabling the agent to accumulate experience more quickly, leading to faster convergence to the optimal solution. This observation supports using batch size as a contribution metric in the attention mechanism.

[0119] Furthermore, this experiment also analyzed the impact of environmental parameters on rewards. For example, as the task load increased, the relative performance of different methods remained stable. However, increased latency led to a larger penalty, reducing the overall reward. Additionally, as the number of mobile devices increased, model convergence improved, resulting in faster convergence, while the overall reward remained largely unaffected.

[0120] This invention proposes a joint optimization method based on FRL and attention mechanisms to address the challenges of task offloading and resource allocation in B-MEC systems, aiming to minimize total system energy consumption while satisfying latency constraints. By formulating the problem as an MDP, embodiments of this invention develop the F-PPO algorithm, integrating an attention mechanism to dynamically allocate weights to accelerate policy learning and reduce communication overhead to enhance data privacy. Simulation results demonstrate that F-PPO outperforms traditional federated learning algorithms and centralized methods in convergence performance. Furthermore, a larger batch size significantly improves the convergence speed, validating its effectiveness as a contribution metric within the attention mechanism. These findings confirm the effectiveness of the proposed method and its applicability in distributed environments.

[0121] Based on the same inventive concept, this invention also provides a blockchain-based mobile edge computing resource allocation system, comprising:

[0122] The data preparation module is used to collect the remaining computing power data of other devices within the communication range in real time from the target mobile device; the edge server initializes a global model and distributes the global model to all target mobile devices.

[0123] The local training module is used by the target mobile device to issue action strategy instructions for resource allocation based on the remaining computing power data, and to calculate the actual latency and energy consumption loss of the action strategy instructions. The blockchain network performs security authentication on the action strategy instructions and simultaneously calculates the consensus energy consumption loss during the authentication process. The target mobile device uses the actual latency, execution energy consumption loss, and consensus energy consumption loss to evaluate the value of the action strategy instructions. Based on the value evaluation results, the local global model parameters are updated. When the training round is reached, the updating of the local global model parameters is stopped, and the updated local global model parameters are sent to the edge server.

[0124] The server training module is used by the edge server to calculate the weights and local evaluation metrics of the latest local global model parameters sent by all target mobile devices; update the global model parameters according to the weights and local evaluation metrics, and broadcast the updated global model parameters to all target mobile devices participating in the training; train the global model in a loop, and when the training round is reached, a global model that can be allocated resources is obtained.

[0125] This invention also provides a computer device. At the hardware level, the computer device includes a processor, an internal bus, a network interface, memory, and non-volatile storage, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile storage into the memory and then runs it to implement the blockchain-based mobile edge computing resource allocation method provided above.

[0126] The present invention also provides a computer-readable storage medium storing a computer program that can be used to execute the blockchain-based mobile edge computing resource allocation method described above.

[0127] Specific limitations regarding the computing system for the blockchain-based mobile edge computing resource allocation method can be found in the limitations section above, and will not be repeated here. Each module in the aforementioned blockchain-based mobile edge computing resource allocation system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.

[0128] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. Furthermore, the above embodiments only illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for allocating mobile edge computing resources based on blockchain, characterized in that, include: The target mobile device collects the remaining computing power data of other devices within its communication range in real time. The edge server initializes a global model and distributes the global model to all target mobile devices; The target mobile device issues an action strategy instruction to perform resource allocation based on the remaining computing power data, and calculates the actual latency and energy consumption loss of the action strategy instruction; the blockchain network performs security authentication on the action strategy instruction, and simultaneously calculates the consensus energy consumption loss during the authentication process; the target mobile device uses the actual latency, energy consumption loss, and consensus energy consumption loss to evaluate the value of the action strategy instruction; the local global model parameters are updated based on the value evaluation results, and when the training round is reached, the update of the local global model parameters is stopped, and the updated local global model parameters are sent to the edge server; The edge server calculates the weights and local evaluation metrics of the latest local global model parameters sent by all target mobile devices; updates the global model parameters based on the weights and local evaluation metrics, and broadcasts the updated global model parameters to all target mobile devices participating in the training. The global model is trained in a loop. When the training round is reached, a global model that can allocate resources is obtained. It also includes: the global model includes the near-end policy optimization (PPO) algorithm, each target mobile device receives the global model parameters that enable resource allocation, and allocates resources to the task to be processed according to the local global model; The PPO algorithm includes an Actor network and a Critic network. Locally on each target mobile device, the Actor network performs forward propagation based on the remaining computing power data, calculates the probability distribution, and selects the action policy instruction with the highest probability from the probability distribution. The Actor network issues an action policy instruction to allocate execution resources based on the remaining computing power data, and the Critic network evaluates the value of the action policy instruction using the actual latency, execution energy loss, and consensus energy loss. The step of updating the global model parameters based on weights and local evaluation metrics specifically includes: the edge server calling the distributed algorithm FDRL with integrated attention mechanism, calculating the similarity score between the local evaluation metric and the maximum preset target metric through dot product, and then normalizing the similarity score to obtain the aggregate weight of each target mobile device; the edge server performing a weighted average based on all aggregate weights to update the global model parameters.

2. The method for allocating mobile edge computing resources based on blockchain according to claim 1, characterized in that, The blockchain network runs the PBFT algorithm, adding the action policy instructions to the distributed ledger in the form of new blocks for security authentication, while also calculating the consensus energy consumption loss during the authentication process.

3. The method for allocating mobile edge computing resources based on blockchain according to claim 1, characterized in that, The pending task status includes the data size and maximum tolerable latency of the pending task on the target mobile device; the transmission power status includes the remaining allocable transmission power and maximum transmission power of the mobile device; the resource status includes the remaining computing power, remaining battery power, current computing power allocation status of the mobile device, and the idle computing power of the edge server; the wireless channel status includes the available subband set, subband occupancy status, and subband channel gain of the wireless channel.

4. The method for allocating mobile edge computing resources based on blockchain according to claim 1, characterized in that, The task unloading decision is calculated based on the status of the pending task and the status of computing resources. The task unloading decision determines whether the target mobile device chooses to process the task locally or offloads the task to an edge server for processing. The transmission power allocation decision only occurs when unloading a task, including the requirement that the target mobile device selects the sub-band channel with the maximum gain that meets the transmission rate requirements, and the transmission power that does not exceed the maximum power. The computing resource allocation decision is based on the remaining computing power, remaining battery power, and status of the pending task of the target mobile device. Channel selection decision occurs only when the task is offloaded, meaning that the target mobile device selects the subband with the highest channel gain from all available and idle subbands.

5. A system for implementing the blockchain-based mobile edge computing resource allocation method of claim 1, characterized in that, include: The data preparation module is used to collect the remaining computing power data of other devices within the communication range in real time from the target mobile device; The edge server initializes a global model and distributes the global model to all target mobile devices; The local training module is used by the target mobile device to issue action strategy instructions for resource allocation based on the remaining computing power data, and to calculate the actual latency and energy consumption loss of the action strategy instructions; the blockchain network performs security authentication on the action strategy instructions, and simultaneously calculates the consensus energy consumption loss during the authentication process; the target mobile device uses the actual latency, energy consumption loss, and consensus energy consumption loss to evaluate the value of the action strategy instructions; the local global model parameters are updated based on the value evaluation results, and when the training round is reached, the updating of the local global model parameters is stopped, and the updated local global model parameters are sent to the edge server; The server training module is used by the edge server to calculate the weights and local evaluation metrics of the latest local global model parameters sent by all target mobile devices; update the global model parameters according to the weights and local evaluation metrics, and broadcast the updated global model parameters to all target mobile devices participating in the training; train the global model in a loop, and when the training round is reached, a global model that can be allocated resources is obtained.

6. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 4.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is loaded by the processor, it is able to perform the steps of the method according to any one of claims 1 to 4.