Computing resource allocation method and device, terminal equipment and storage medium
By combining local and global update mechanisms, the improved Firefly Algorithm solves the problem that traditional algorithms are prone to getting trapped in local optima in distributed computing environments, achieving globally optimal allocation of computing resources and improving task execution efficiency and security.
Patent Information
- Application Number
- CN202511316692.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2025-12-30
AI Technical Summary
Traditional optimization algorithms are prone to getting trapped in local optima in distributed computing environments, resulting in poor allocation of computing resources and difficulty in coping with dynamic changes and malicious attacks, thus failing to achieve globally optimal allocation.
An improved firefly algorithm is adopted, which combines local and global two-stage update mechanisms. Through an iterative process that combines local and global updates, the global optimal solution for computing resources is found, and malicious attack detection is performed before allocation.
It achieves globally optimal allocation of computing resources, improves the execution efficiency and reliability of distributed computing tasks, and reduces resource consumption and the impact of malicious attacks.
Smart Images

Figure CN121233299A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computing resource allocation technology, and in particular relates to a computing resource allocation method, apparatus, terminal equipment and storage medium. Background Technology
[0002] With the rapid development of IoT technology, distributed computing, as a new computing model, effectively reduces data transmission latency and improves system response speed by offloading some computing tasks from the cloud to the network edge, thus providing better quality of service for IoT applications. In distributed computing environments, especially edge computing environments, the rational allocation of computing resources is of great significance for improving system performance and reducing task processing latency.
[0003] In related technologies, some solutions employ traditional optimization algorithms to schedule computing resources. These algorithms, due to their simplicity and effectiveness, can achieve efficient allocation of computing resources. However, in distributed computing scenarios, multi-task collaborative scheduling is influenced by various factors and is highly complex. Traditional optimization algorithms are prone to getting trapped in local optima when dealing with such problems, resulting in suboptimal allocation of computing resources. Summary of the Invention
[0004] This application provides a computing resource allocation method, a computing resource allocation device, a terminal device, a computer-readable storage medium, and a computer program product. It not only overcomes the shortcomings of traditional intelligent optimization algorithms that are prone to premature convergence in dynamic distributed computing environments, but also balances local fine-grained exploration and global breadth-based optimization through a two-stage search strategy, quickly achieving the global optimal allocation of computing resources and significantly improving the efficiency and reliability of distributed computing task execution.
[0005] A first aspect of this application provides a method for allocating computing resources, including:
[0006] Obtain task information for the computing tasks to be unloaded;
[0007] Based on the task information, several allocation schemes for computing resources to perform computing tasks are initially generated;
[0008] Multiple allocation schemes are used as the initial firefly population. The firefly algorithm is used to perform multiple rounds of iterative update operations on the positions of the fireflies until the end of the update condition is met. Each round of iterative update operation includes local update sub-operations and global update sub-operations executed sequentially, so that the fireflies first move to the light source fireflies in the neighborhood, and then move to at least one central position of the firefly population.
[0009] The first historical position of the first firefly is determined based on the first brightness value of each historical position of the firefly population in multiple rounds of iterative update operations, wherein the second brightness value of the first firefly at the first historical position is greater than at least a portion of the first brightness value.
[0010] According to the allocation scheme corresponding to the first firefly at the first historical position, computing resources are allocated to perform computing tasks.
[0011] In one implementation, before performing multiple rounds of iterative updates on the firefly's position using the firefly algorithm, the method further includes:
[0012] The initial firefly population is clustered to obtain k firefly subgroups, where k is a positive integer greater than 1;
[0013] The firefly algorithm is used to perform multiple rounds of iterative updates on the firefly's position, including:
[0014] During each round of iterative update operations, when the global update sub-operation is started, the subgroup center position of each firefly subgroup is determined based on the historical best position of each firefly in each firefly subgroup, resulting in k subgroup center positions, where the brightness value of the firefly at the historical best position is greater than the brightness value of the firefly at other historical positions.
[0015] For each firefly
[0016] Determine the proposed update positions for the firefly to move to the center of each of the k subgroups, and obtain the k proposed update positions;
[0017] Based on the brightness value of the firefly at the k positions to be updated, determine the global update position of the firefly in the current iteration update process.
[0018] In one implementation, the method of performing multiple rounds of iterative updates on the firefly's position using the firefly algorithm further includes:
[0019] During each round of iterative updates, when the local update sub-operation is started, the light source fireflies in the neighborhood of each firefly are determined;
[0020] Make each firefly move toward its respective light source firefly and update its position;
[0021] After each position update, determine whether the condition for ending the partial update is met.
[0022] If so, then end the partial update;
[0023] If not, update the light source fireflies in the neighborhood of each firefly and perform a new local update sub-operation until it is determined that the current condition for ending the local update is met.
[0024] In one implementation, determining whether the current condition for ending the local update is met includes:
[0025] If, after performing a preset number of consecutive local update sub-operations, the brightness value of at least one firefly does not increase, then the condition for ending the local update is determined to be met; and / or
[0026] If the number of local update sub-operations is greater than or equal to the number threshold, it is determined that the current condition for ending the local update is met.
[0027] In one implementation, determining the subgroup center position of each firefly subgroup based on the historical best positions of each firefly within each subgroup includes:
[0028] For each firefly subgroup, the subgroup center is determined using the following formula:
[0029]
[0030] in, Let d represent the positional component of the subgroup center of the firefly subgroup, and n represent the number of fireflies in the subgroup. The position component in dimension d represents the historical best position of the i-th firefly in the firefly subgroup.
[0031] In one implementation, determining the proposed update positions for the firefly to move towards the center positions of k subgroups includes:
[0032] For each subgroup center, the proposed update position for the firefly to move towards that subgroup center is determined using the following formula:
[0033]
[0034] Where, x id x represents the d-th dimension position component of the firefly's location before it moved to the center of the subgroup. id ' represents the d-th dimension of the position component of the proposed updated position of the firefly as it moves toward the center of the subgroup. This indicates the attractiveness of the center of the subgroup to the firefly. ε represents the d-th dimension position component of the center position of this subgroup. i Let α represent the random perturbation term associated with the firefly, and let α represent the coefficient.
[0035] In one implementation, obtaining task information of the computing task to be unloaded includes:
[0036] Receive data packets uploaded by various terminal devices;
[0037] Each data packet is identified and classified according to its task identifier, resulting in multiple task data packets corresponding to multiple computing tasks.
[0038] The attribute values of each task data packet are normalized.
[0039] For each task data packet
[0040] Based on the normalized attribute values of the task data packet, perform malicious attack task detection on the task data packet;
[0041] If the detection results indicate that the computation task corresponding to the task data packet is a malicious attack task, delete the task data packet.
[0042] If the detection results indicate that the computing task corresponding to the task data packet is a normal task, then the computing task corresponding to the task data packet is identified as a computing task to be uninstalled.
[0043] A second aspect of this application provides a computing resource allocation apparatus, comprising:
[0044] The acquisition module is used to obtain task information of the computing tasks to be unloaded;
[0045] The preliminary allocation module is used to generate multiple allocation schemes for computing resources to perform computing tasks based on task information.
[0046] The iterative update module is used to take multiple allocation schemes as the initial firefly population and use the firefly algorithm to perform multiple rounds of iterative update operations on the position of the fireflies until the end update condition is met. Each round of iterative update operation includes local update sub-operations and global update sub-operations executed sequentially, so that the fireflies first move to the light source fireflies in the neighborhood, and then move to at least one central position of the firefly population.
[0047] The first historical position determination module is used to determine the first historical position of the first firefly based on the first brightness value of each historical position of the firefly population in multiple rounds of iterative update operations, wherein the second brightness value of the first firefly at the first historical position is greater than at least a portion of the first brightness value.
[0048] The computing allocation module is used to allocate computing resources to perform computing tasks according to the allocation scheme corresponding to the first firefly at the first historical position.
[0049] A third aspect of this application provides a terminal device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described computing resource allocation method.
[0050] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described computing resource allocation method.
[0051] The fifth aspect of this application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps in the above-described computing resource allocation method.
[0052] The computing resource allocation method provided in the first aspect of this application first generates multiple allocation schemes for computing resources used to execute the computing tasks based on the data packets of the computing tasks to be unloaded. Then, the multiple allocation schemes are used as the initial firefly population, and the positions of the fireflies are updated in multiple rounds using an improved firefly algorithm until the end of the update condition is met. The first historical position of the first firefly with the highest brightness value during the multiple rounds of iterative updates is accurately determined. Finally, computing resources are allocated to execute the computing tasks according to the allocation scheme corresponding to the first firefly at its first historical position. Since the multiple rounds of iterative update operations include local update sub-operations and global update sub-operations executed sequentially, this scheme innovatively integrates a local and global dual-stage update mechanism in the firefly algorithm: in the local update stage, fireflies move to high-brightness individuals in the neighborhood, quickly converging to a local optimal solution; in the global update stage, the population is guided to gather towards the central position, promptly escaping the stagnation of local optimization, and accurately and efficiently searching for the global optimal solution. Finally, through dynamic comparison of brightness values in multiple rounds of iterative updates, the allocation scheme corresponding to the historical optimal position of the firefly can be efficiently and accurately located. This scheme not only overcomes the premature convergence defect of traditional intelligent optimization algorithms in dynamic distributed computing environments, but also balances local fine-grained exploration and global breadth-based optimization through a two-stage search strategy, quickly achieving the globally optimal allocation of computing resources and significantly improving the efficiency and reliability of distributed computing task execution. Thus, it effectively solves the high complexity problem of collaborative scheduling of computing tasks in IoT distributed computing scenarios.
[0053] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0055] Figure 1 This is a flowchart illustrating a computing resource allocation method provided in one embodiment of this application;
[0056] Figure 2 This is a schematic diagram illustrating the implementation principle of a computing resource allocation method provided in one embodiment of this application;
[0057] Figure 3 This is a partial flowchart of a computing resource allocation method provided in another embodiment of this application;
[0058] Figure 4 This is a second partial flowchart of a computing resource allocation method provided in another embodiment of this application;
[0059] Figure 5 This is a schematic diagram of the structure of a computing resource allocation device provided in one embodiment of this application;
[0060] Figure 6 This is a schematic diagram of the structure of a terminal device provided in one embodiment of this application. Detailed Implementation
[0061] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0062] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0063] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0064] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0065] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0066] As mentioned earlier, traditional optimization algorithms are used in related technologies to schedule computing resources in distributed computing environments. However, traditional optimization algorithms are prone to getting trapped in local optima when dealing with this type of problem, resulting in poor performance in allocating computing resources.
[0067] Specifically, some solutions utilize traditional optimization algorithms such as genetic algorithms, particle swarm optimization, and ant colony optimization to achieve collaborative scheduling of IoT edge computing tasks. For example, optimization is performed with minimizing latency as the objective function.
[0068] However, research has revealed that the latency of computing resource scheduling in distributed computing environments (such as edge computing environments) is affected by various factors, including the type of IoT tasks and device capabilities. IoT edge computing task collaborative scheduling exhibits high-dimensionality and nonlinear characteristics. Specifically, the interplay of factors such as differences in task types, heterogeneity of device computing power, and network state fluctuations leads to a large number of local extrema in the search space. Traditional optimization algorithms, typically based on population search or heuristic rules, are suitable for handling low-dimensional, linear problems. In dynamically changing edge environments, they struggle to effectively explore the global optimum, prematurely converging to suboptimal solutions. This makes them ill-suited to the high demands of dynamic global resource allocation in edge computing task collaborative scheduling, resulting in suboptimal computing resource allocation.
[0069] Furthermore, research indicates that the computing resource allocation schemes in related technologies also suffer from drawbacks such as slow resource deployment, high energy consumption, and inability to effectively identify malicious attack tasks, making it difficult to meet the high standards for data processing latency and energy consumption in scenarios with a large number of connected devices.
[0070] To at least partially address the aforementioned problems, this application first provides a method for allocating computing resources. This method can be applied to various technical fields requiring computing resource allocation, including but not limited to the Internet of Things (IoT), intelligent manufacturing, smart cities, vehicle-to-everything (V2X) systems, and telemedicine. For example, in the field of intelligent manufacturing, the method can optimize resource allocation for real-time control and status monitoring of industrial equipment; in the field of smart cities, it can support dynamic scheduling for traffic flow analysis and public safety monitoring; in the field of V2X systems, it enables low-latency computation for autonomous driving decision-making and real-time navigation; and in the field of telemedicine, it enables efficient collaboration between remote diagnosis and image processing.
[0071] It should be noted that the computing resource allocation method of this application embodiment is applicable to computing resource scheduling in various distributed computing environments. It is suitable for task collaborative scheduling in pure edge computing scenarios as well as cross-layer computing task collaborative scheduling in edge-cloud collaborative architectures. For example, in a pure edge computing scenario, the computing resource allocation method of this application embodiment can be executed by an edge server or a regional center. In an edge-cloud collaborative architecture, the computing resource allocation method of this application embodiment can be executed by an edge computing management platform in a cloud server. Specifically, the edge computing management platform can first receive data packets of computing tasks uploaded by local terminal devices, and then, based on global resource monitoring and multi-objective optimization strategies, allocate the most suitable edge nodes to each computing task. This achieves global optimized allocation and dynamic balancing of cross-node resources.
[0072] like Figure 1 As shown, the computing resource allocation method provided in this application embodiment includes the following steps S110, S120, S130, S140 and S150.
[0073] Step S110: Obtain the task information of the computing task to be unloaded.
[0074] In this embodiment, the task information of the computing task to be uninstalled can be determined based on the data packets of the computing task to be uninstalled uploaded by the terminal device. Specifically, it can be the task metadata (such as task type, data volume, device identifier, timestamp, etc.) extracted from these data packets.
[0075] The data packets of computing tasks to be unloaded can be data packets of computing tasks uploaded by terminal devices trusted by the edge server. For example, after receiving the data packets of computing tasks uploaded by each terminal device, the edge server can first perform malicious attack task detection (i.e., DDoS detection) on these data packets. Data packets detected as malicious attack tasks are then deleted, and only data packets of normal tasks are retained as the data packets of the computing tasks to be unloaded.
[0076] For example, in a cross-layer computing task collaborative scheduling scenario of an edge-cloud collaborative architecture, the computing tasks to be unloaded from the edge server can be computing tasks with high real-time requirements. For example, AR rendering tasks, device control tasks, etc.
[0077] In a specific example, the edge server can receive data packets of computing tasks uploaded by terminal devices (such as industrial sensors or AR glasses) via a wireless interface. A protocol parsing module can then extract the task metadata corresponding to each data packet. Exemplarily, the edge server or regional center (where the edge server sends the task metadata) can employ various suitable DDoS detection methods to detect malicious attack tasks, filter out malicious attack task data packets, and store the data packets of normal tasks as data packets to be offloaded computing tasks in the edge server's local cache queue.
[0078] Step S120: Based on the task information, generate a number of allocation schemes for computing resources used to perform computing tasks.
[0079] The various allocation schemes generated in this step can be initial allocation schemes. These initial allocation schemes can be randomly generated or generated according to a preset allocation method. In this embodiment, the same computing task can be assigned to the same edge node or to different edge nodes. For different computing tasks, they can be assigned to the same edge node or to different edge nodes for execution.
[0080] By way of example, but not limitation, the regional center can first obtain the task metadata of each computing task and the real-time resource status of each edge node (such as CPU utilization, remaining memory, and network bandwidth). Then, it can generate an initial allocation scheme through exhaustive search or random sampling. This can form an initial firefly population (each firefly corresponds to one resource allocation combination scheme). Each firefly can correspond to a multi-dimensional resource combination scheme.
[0081] Specifically, each individual firefly can be represented using a combination of a task allocation matrix and a resource allocation matrix. For example, the task allocation matrix can be a task-node mapping matrix A. The resource allocation matrix can be a task-resource type and quantity mapping matrix B (such as CPU cores, memory size, network bandwidth, etc.). The position of each firefly can be represented by a position vector C obtained by flattening and concatenating matrices A and B.
[0082] Step S130: Using multiple allocation schemes as the initial firefly population, the firefly algorithm is used to perform multiple rounds of iterative update operations on the positions of the fireflies until the end update condition is met. Each round of iterative update operations includes local update sub-operations and global update sub-operations executed sequentially, so that the fireflies first move to the light source fireflies in the neighborhood, and then move to at least one central position of the firefly population.
[0083] The Firefly Algorithm is an optimization algorithm inspired by the bioluminescent behavior of fireflies. It establishes an attraction mechanism between different fireflies to find the optimal solution in a search space. The brighter the firefly's fluorescence, the stronger its attraction to other fireflies. Through this bioluminescent attraction mechanism, all feasible solutions in the search space are moved to find the optimal solution. The entire population has a positive feedback mechanism, which accelerates algorithm convergence, increases the probability of finding the optimal solution, and exhibits strong robustness, making it suitable for finding the best allocation results.
[0084] It is understandable that in the traditional firefly algorithm, each iteration update of the population usually corresponds to a position update of the firefly in its neighborhood (i.e., a local update sub-operation). The iteration update ends when the optimal solution of the population in the local space is found.
[0085] In this embodiment, an improved firefly algorithm is used to find the optimal solution globally. It is important to note that in this embodiment, each iteration of the firefly population includes sequential local update sub-operations and global update sub-operations. That is, in each iteration, the fireflies first seek a relatively optimal solution locally, and then seek a relatively optimal solution globally. This not only avoids getting stuck in local optima during the optimization process, but also efficiently explores the global optimum, improving both efficiency and accuracy.
[0086] In this embodiment, each iteration update operation of the firefly population includes at least one local update sub-operation and at least one global update sub-operation. Optionally, each iteration update operation of the firefly population includes one local update sub-operation and one global update sub-operation. Alternatively, each iteration update operation of the firefly population includes multiple local update sub-operations and one global update sub-operation.
[0087] In this embodiment, a single local update sub-operation corresponds to one iterative update of the firefly population in the traditional firefly algorithm. A low-brightness firefly moves once towards the brightest firefly within its field of vision (neighborhood) (e.g., a neighboring light source firefly). Meanwhile, the brightest firefly in its neighborhood (i.e., a neighboring light source firefly) moves randomly once.
[0088] In one example, the attraction between fireflies can be determined using the following formula (a):
[0089]
[0090] Where β represents the attraction of firefly j, a light source within the neighborhood of firefly i, to firefly i. β0 is the attraction of firefly j, a light source within its neighborhood, to fireflies located at the same position. The magnitude of β0 is positively correlated with the brightness of firefly j. ij This represents the distance between firefly i and the light source firefly j. γ is the light absorption coefficient, usually a constant. It can be understood that the attraction between two fireflies is negatively correlated with the distance between them.
[0091] In one example, the position of a non-light source firefly can be updated using the following formula:
[0092] c' i =c i +β(c j -c i )+αε
[0093] ...Formula (II)
[0094] Among them, c i c represents the position of firefly i before it moved. j c' indicates the position of the light source, firefly j. i This represents the position of firefly i after moving towards the light source firefly j. α is the step size factor, which can be a constant within the interval [0,1]. ε is a random factor, following a uniform distribution. By setting a random perturbation term, the problem of prematurely falling into local optima can be mitigated.
[0095] In one example, for the case where the firefly is a light source firefly within its own neighborhood, the position of the light source firefly can be updated using the following formula:
[0096] c' i =c i +αε
[0097] ...Formula (3)
[0098] Among them, c i c' represents the position of firefly i before it moves.i This represents the position of the light source firefly i after it has moved randomly.
[0099] In this embodiment, the brightness of the firefly can be determined based on the value of an evaluation metric for the resource allocation scheme. This evaluation metric can be set according to actual needs. Exemplarily, but not limitingly, the evaluation metric for the resource allocation scheme may include latency, energy consumption, and load balancing. Exemplarily, latency can be the task completion latency corresponding to the resource allocation scheme, specifically the total time required from the arrival of the computing task at the edge node to the completion of the task. Energy consumption can be the total energy consumption corresponding to the resource allocation scheme, that is, the total energy consumed by the edge node during the execution of the computing task, including the edge node's computing energy consumption, communication energy consumption, and cooling energy consumption. Load balancing can be the node load balancing degree corresponding to the resource allocation scheme, characterizing the degree of difference in resource utilization among the edge nodes, and used to measure the balance of resource allocation.
[0100] For example, the brightness f of a firefly can be calculated using the following formula (iv):
[0101] f = w1 × La + w2 × E + w3 × Lb
[0102] ...Formula (IV)
[0103] Where La represents latency, E represents energy consumption, Lb represents load balancing, and w1, w2, and w3 represent the weighting coefficients of each evaluation indicator. The weighting coefficients can be dynamically adjusted according to the edge scenario.
[0104] Specifically, for each firefly, the brightness of each firefly within its neighborhood can be determined using formula (iv) above, thereby identifying the light source firefly. Then, if the firefly is a light source firefly, its position can be updated according to formula (iii). If the firefly is not a light source firefly, its position can be updated according to formulas (i) and (ii) above.
[0105] In this embodiment, during each iteration of updating the firefly population, after completing at least one local update sub-operation, a global update sub-operation for the firefly population can be performed. Specifically, before performing the global update sub-operation, at least one central position of the firefly population can be determined or updated. In one example, at least one central position of the firefly population can be determined based on the current instantaneous position of each firefly in the current firefly population. For example, if the number of central positions is 1, the central position corresponds to the center of the instantaneous positions of all fireflies. Alternatively, if the number of central positions is greater than 1, each central position corresponds to the center of the instantaneous positions of a subset of fireflies. In another example, at least one central position of the firefly population can also be determined based on the historical positions of the firefly population. For example, it can be determined based on the current historical best position of each firefly. The brightness value of each firefly at its historical best position can be greater than the brightness value of that firefly at other historical positions. For example, for each firefly, each time it moves, its brightness value at the new position can be compared with the brightness value at the previously recorded historical best position. If the brightness value increases, the new position is updated to the historical best position; if the brightness value remains unchanged or decreases, the original historical best position can be retained. In this example, the center position of the firefly population can correspond to the center of the historical best position of all fireflies, or it can correspond to the center of the historical best position of some fireflies.
[0106] In this embodiment, during each iteration of the firefly population update, after a firefly has moved once or multiple times to a neighboring, better firefly, it can continue to move towards at least one central location within the firefly population. This not only significantly improves the convergence speed of the firefly algorithm but also enhances its ability to escape local optima.
[0107] In a specific example, during each iteration of updating the firefly population, after completing at least one local update sub-operation, at least one central position of the population can be calculated using various suitable methods (such as centroid-based algorithms or K-means clustering). Then, the fireflies are guided to move towards at least one central position. For example, the central position of the firefly population can be considered as the global light source firefly for each firefly (e.g., referred to as the global light source firefly), and the attraction of the global light source firefly to each firefly can be determined according to the methods described in Formulas (I), (II), (III), and (IV) above, thus determining the intended update position for each firefly to move towards the global light source firefly.
[0108] In one example, if the number of center locations for a firefly population is one, the firefly populations can gather towards one global light source firefly. A proposed update location can be determined for each firefly. This proposed update location can then be used as the global update location for the firefly. In another example, if the number of center locations for a firefly population is greater than one, the firefly populations can gather towards multiple global light source fireflies. Multiple proposed update locations can be determined for each firefly. Then, from these multiple proposed update locations, one corresponding to a relatively optimal resource allocation scheme can be selected as the global update location for the firefly.
[0109] After each iteration, the last determined global update position of the firefly population can be used as the starting point for the next iteration. This process is repeated until the conditions for ending the update are met.
[0110] In this embodiment, the end-of-update condition can be the iteration termination condition for the firefly population. The iteration termination condition can be set according to actual needs.
[0111] For example, the iteration termination condition may include at least one of the following:
[0112] The maximum number of iterations has been reached.
[0113] The brightness value of the firefly population reaches the convergence threshold (e.g., the brightness change of the firefly population is less than 0.1% after two consecutive rounds of iteration updates).
[0114] Step S140: Determine the first historical position of the first firefly based on the first brightness value of each historical position of the firefly population in multiple rounds of iterative update operations, wherein the second brightness value of the first firefly at the first historical position is greater than at least a portion of the first brightness value.
[0115] In one example, the brightness value sequence of the historical position of the firefly population in each round can be recorded iteratively using the firefly algorithm, and a memory pool is used to store and update the better solutions. After the iteration update ends, one of the last updated better solutions can be selected as the final solution (i.e., the first historical position of the first firefly).
[0116] For example, after each iteration, the historical best position of each firefly is stored and updated. After the iteration ends, the firefly with the highest brightness value at its historical best position can be selected as the first firefly, and the historical best position of the first firefly can be used as the first historical position.
[0117] Step S150: Allocate computing resources to perform computing tasks according to the allocation scheme corresponding to the first firefly at the first historical position.
[0118] For example, the task allocation matrix and resource allocation matrix corresponding to the first firefly at its first historical position can be parsed to obtain the edge nodes executing the computing tasks and allocation scheme parameters (such as CPU core allocation, memory block partitioning, and network bandwidth reservation). Resource allocation instructions can then be issued through a regional center or edge computing management platform to dynamically configure the computing resources of the edge nodes.
[0119] For example, during the execution of computing tasks at each edge node, actual performance indicators such as actual latency and node load can be monitored in real time, and resource allocation schemes can be dynamically optimized based on these performance indicators. This forms a closed-loop feedback optimization mechanism, enabling resource allocation schemes to adapt to the dynamic changes in the edge environment.
[0120] The computing resource allocation method provided in the first aspect of this application first generates multiple allocation schemes for computing resources used to execute the computing tasks based on the data packets of the computing tasks to be unloaded. Then, the multiple allocation schemes are used as the initial firefly population, and the positions of the fireflies are updated in multiple rounds using an improved firefly algorithm until the end of the update condition is met. The first historical position of the first firefly with the highest brightness value during the multiple rounds of iterative updates is accurately determined. Finally, computing resources are allocated to execute the computing tasks according to the allocation scheme corresponding to the first firefly at its first historical position. Since the multiple rounds of iterative update operations include local update sub-operations and global update sub-operations executed sequentially, this scheme innovatively integrates a local and global dual-stage update mechanism in the firefly algorithm: in the local update stage, fireflies move to high-brightness individuals in the neighborhood, quickly converging to a local optimal solution; in the global update stage, the population is guided to gather towards the central position, promptly escaping the stagnation of local optimization, and accurately and efficiently searching for the global optimal solution. Finally, through dynamic comparison of brightness values in multiple rounds of iterative updates, the allocation scheme corresponding to the historical optimal position of the firefly can be efficiently and accurately located. This scheme not only overcomes the shortcomings of traditional intelligent optimization algorithms that are prone to premature convergence in dynamic edge environments, but also balances local fine-grained exploration and global breadth-based optimization through a two-stage search strategy, quickly achieving the globally optimal allocation of computing resources and significantly improving the efficiency and reliability of edge computing task execution. Thus, it effectively solves the high complexity problem of collaborative scheduling of computing tasks in IoT edge computing scenarios.
[0121] In one implementation, step S110 obtains task information of the computing task to be unloaded, including the following steps:
[0122] Step S111: Receive data packets uploaded by each terminal device;
[0123] Step S112: Identify each data packet and classify them according to the task identifier to obtain multiple task data packets corresponding to multiple computing tasks respectively;
[0124] Step S113: Normalize the attribute values of each task data packet;
[0125] Step S114: For each task data packet, perform malicious attack task detection on the task data packet based on the normalized attribute value of the task data packet.
[0126] Step S115: If the detection result indicates that the computation task corresponding to the task data packet is a malicious attack task, delete the task data packet.
[0127] Step S116: If the detection result indicates that the computing task corresponding to the task data packet is a normal task, then the computing task corresponding to the task data packet is identified as a computing task to be uninstalled.
[0128] It is understandable that, due to the flexible accessibility and high heterogeneity of edge networks, terminal devices are more vulnerable to DDoS attacks, which can lead to malicious traffic being offloaded as normal computing tasks to edge servers, resulting in a huge consumption of edge server resources. Therefore, in this embodiment, the edge server (or regional center) can also perform DDoS detection on the computing tasks offloaded by the terminal devices to reduce malicious offloading.
[0129] For example, at the terminal device level, the edge server (or regional center) can also generate the trust level of the terminal device based on the detection results of the computing task, so that the terminal device with a high trust level can complete the computing offloading at a relatively low cost, while the terminal device with a low trust level can only complete the computing offloading at a relatively high cost, thereby improving the security of the computing offloading process in the edge network.
[0130] The following example uses an edge server to perform DDoS detection, referring to Tables 1 and 2 below. Figure 2 The specific implementation methods of steps S111 to S116 above will be explained.
[0131] First, in step S111, within the time window of traffic capture by the edge server, there will be one or more data packets of computing tasks in the communication link, each data packet having its own corresponding task identifier (such as parameter I in Table 1). Figure 2 As shown, in step S112, the edge server can classify the mixed data packets according to the task identifier carried by the received data packets. The data packets of each computing task are combined together until all N data packets of the task are collected.
[0132] Table 1
[0133]
[0134]
[0135] Then, the edge server can extract the attribute values of each data packet, as shown in Table 1. Each data packet has f attributes. Data packet attributes can include protocol type, timestamp, total forward packets, etc. As shown in Table 2, the extracted attribute values of each computation task's data packet can be stored as an N×f matrix. N rows represent N data packets, each row represents all attribute values of the data packet, and f columns represent the f distinct attributes of each data packet.
[0136] Table 2
[0137]
[0138] In step S113, the edge server can normalize the attribute values of the data packets for each computing task. Specifically, rows with null values can be removed, and the attribute values of the remaining rows can be normalized to [0,1]. Each row's array (1×f) corresponds to a single sample. When using the detection model for DDoS attack detection later, each row's array can be used as input to the model.
[0139] In step S114, the attribute value array obtained by normalizing the attribute values of the data packets of each computing task can be input into the detection model to detect malicious attack tasks for each task data packet. In step S115, if the detection result indicates that the computing task corresponding to the task data packet is a malicious attack task, the task data packet is deleted. In step S116, if the detection result indicates that the computing task corresponding to the task data packet is a normal task, the computing task corresponding to the task data packet is determined as a computing task to be unloaded. For example, a computing task detected as a normal unloading task has an attribute value of 1, and the computing unloading can be completed according to the unloading decision. A computing task detected as malicious traffic unloading has an attribute value of 0, and the computing operation is not performed and the computing task is discarded.
[0140] The above scheme receives data packets uploaded by terminal devices, categorizes them by task identifier, normalizes the attribute values of the task data packets, and then performs DDoS attack detection. If a malicious attack task is detected, the data packet is deleted; otherwise, it is designated as a task to be offloaded. This scheme reduces the likelihood of malicious traffic being treated as normal computing tasks and offloaded to edge servers, thus lowering resource consumption. Furthermore, it generates terminal device trust levels based on detection results, improving the security of the computing offloading process. Therefore, it can improve the efficiency and security of computing resource allocation.
[0141] In one implementation, step S130 uses the firefly algorithm to perform multiple rounds of iterative update operations on the position of the firefly, and also includes the following steps S131 to S135.
[0142] Step S131: In each round of iterative update, when the local update sub-operation is started, determine the light source fireflies in the neighborhood of each firefly.
[0143] For example, the brightness of each firefly in the neighborhood of a firefly at its current location can be calculated, and the firefly with the highest brightness value can be identified as the light source firefly.
[0144] Step S132: Move each firefly toward its respective light source firefly and update its position.
[0145] Step S133: After each position update, determine whether the current condition for ending the local update is met.
[0146] The conditions for ending a partial update can be set according to actual needs.
[0147] In one example, the conditions for ending a local update can include at least one of the following:
[0148] The brightness of the fireflies increased to the threshold level.
[0149] The brightness fluctuation of the fireflies is within the preset range;
[0150] The number of times the partial update sub-operation has been executed has reached the threshold.
[0151] The density of fireflies at the location has reached the density threshold;
[0152] During this iteration, the local update time reached the time threshold.
[0153] Step S134: If yes, then end the partial update.
[0154] Step S135: If not, update the light source fireflies in the neighborhood of each firefly and perform a new local update sub-operation until it is determined that the current condition for ending the local update is met.
[0155] In the above scheme, when using the firefly algorithm for multi-round iterative updates, each round of local update sub-operation first determines the light source fireflies in the neighborhood of each firefly, causing the fireflies to move towards the light source and update their positions. Then, it further checks whether the condition for ending the local update is met. If it is met, the local update stops, and a global update is performed. If not, the light source fireflies are updated, and local updates continue. In this way, by dynamically adjusting the number of local updates for fireflies in each round of iteration, the search for local optima can be more accurate, and the risk of getting trapped in local optima can be effectively reduced. Therefore, the algorithm's performance and solution quality can be effectively improved, increasing the efficiency and accuracy of finding local optima, and further improving the optimization efficiency and accuracy of the computational resource allocation scheme.
[0156] In one implementation, step S133 determines whether the conditions for ending the local update are met, including the following steps S1331 and / or S1332.
[0157] Step S1331: If, after performing a preset number of consecutive local update sub-operations, the brightness value of at least one firefly does not increase, it is determined that the current condition for ending the local update is met.
[0158] The preset number of attempts can be set according to actual needs. For example, the preset number of attempts is 2. If, after performing two consecutive local update sub-operations, the brightness value of at least one firefly does not increase (i.e., the brightness of a firefly does not improve after moving to a neighboring light source firefly three times), then it can be determined that the condition for ending the local update is met.
[0159] Step S1332: If the number of local update sub-operations is greater than or equal to the number threshold, determine that the current condition for ending the local update is met.
[0160] The number of moves threshold can also be set according to actual needs. For example, the number of moves threshold can be 5. For example, if the firefly population moves to the fireflies near the light source more than 5 times, regardless of how the brightness of the fireflies changes, the local update will end and a global update sub-operation will be executed instead.
[0161] In the above scheme, on the one hand, during each round of iterative updates to the firefly population, if the brightness value of any firefly does not increase after performing a preset number of local update sub-operations, the local update is terminated. This reduces invalid updates and saves computational resources. On the other hand, the local update is terminated when the number of local update sub-operations reaches a threshold. This improves the efficiency of iterative updates. Combining these two termination conditions considers both algorithm convergence and sets an upper limit on the number of updates, ensuring that local updates stop within a reasonable timeframe, thus improving the iterative update efficiency of the firefly population and enhancing the effectiveness and controllability of the local update process in the firefly algorithm.
[0162] In one embodiment, before step S130, which uses the firefly algorithm to perform multiple rounds of iterative update operations on the position of the firefly, the computing resource allocation method of this application embodiment further includes step S1301.
[0163] Step S1301 involves clustering the initial firefly population to obtain k firefly subgroups, where k is a positive integer greater than 1. The number of firefly subgroups k can be set according to actual needs. The following explanation uses k=5 as an example. Various clustering methods can be used; the following explanation uses the K-Means clustering algorithm as an example.
[0164] Step S130 uses the firefly algorithm to perform multiple rounds of iterative updates on the firefly's position, including the following steps:
[0165] Step S136: During each round of iterative update operation, when the global update sub-operation is started, the subgroup center position of each firefly subgroup is determined according to the historical best position of each firefly in each firefly subgroup, and k subgroup center positions are obtained, where the brightness value of the firefly at the historical best position is greater than the brightness value of the firefly at other historical positions.
[0166] Step S137: For each firefly, determine the proposed update position for the firefly to move to the center position of each of the k subgroups, and obtain the k proposed update positions.
[0167] Step S138: Determine the global update position of the firefly in the current iteration update process based on the brightness value of the firefly at the k positions to be updated.
[0168] In this embodiment, the K-Means clustering algorithm can be integrated into the firefly algorithm to increase population information exchange and enhance the algorithm's global search capability. For example, the clustering process in step S1301 can be performed during the firefly algorithm's population initialization process. Taking k=5 as an example, in step S1301, the entire firefly population can be clustered into 5 firefly subgroups. Clustering can be performed based on one or more dimensions of the firefly position vector. For example, clustering can be performed based on execution nodes; resource allocation schemes for similar task execution nodes can correspond to a firefly subgroup. Alternatively, clustering can be performed based on resource allocation parameters; allocation schemes with similar resource allocation parameters can correspond to a firefly subgroup.
[0169] For example, we can define an initial firefly population dataset X = {x1, x2, ..., x...} n}, where xi=(x i1 ,x i2 ,…,x idLet be a d-dimensional vector. Then, according to the principle of minimizing the sum of the squares of all data points in each cluster to the cluster center, the dataset X is divided into 5 clusters, each corresponding to a cluster center (i.e., the initial center position of the firefly population). The 5 cluster centers form a set C = {c1, c2, ..., c5}, where ci = (c i1 ,c i2 ,…,c id ), is also a d-dimensional vector. For example, after completing the firefly subgroup division, multiple rounds of iterative updates to the firefly population can begin.
[0170] In step S136, during each round of iterative update, when the global update sub-operation begins (e.g., after the local update ends), the subgroup center position of each firefly subgroup can be determined based on the historical best position of each firefly in each subgroup (i.e., the cluster center of each cluster is updated). For example, the center positions of the five firefly subgroups can be determined. For example, the five center positions are denoted as x. (GCP,j) , where j∈(1,2,…,5).
[0171] In one implementation, step S136 determines the subgroup center position of each firefly subgroup based on the historical best position of each firefly in each subgroup, including the following step S1361.
[0172] Step S1361: For each firefly subgroup, determine the subgroup center position using the following formula (v):
[0173]
[0174] in, Let d represent the positional component of the subgroup center of the firefly subgroup, and n represent the number of fireflies in the subgroup. The position component in dimension d represents the historical best position of the i-th firefly in the firefly subgroup.
[0175] In the above scheme, the subgroup center position is calculated based on the historical best position of each firefly within the subgroup. This fully utilizes existing optimization information and more accurately reflects the overall characteristics of the subgroup. Furthermore, the subgroup center position comprehensively considers the historical best position of each firefly within the subgroup, making the determination of the center position more reasonable and better reflecting the globally optimal solution. This scheme helps to better guide the search direction in the firefly algorithm, improving the algorithm's convergence speed and accuracy, thereby finding the globally optimal allocation scheme more efficiently.
[0176] Furthermore, in step S137, for each firefly, the proposed update positions for moving to the centers of k subgroups can be determined, resulting in k proposed update positions. For example, each subgroup center can be considered as a global light source firefly for each firefly. Following the aforementioned method for determining the update positions for moving fireflies to neighboring light source fireflies, five proposed update positions obtained by moving fireflies to each global light source firefly can be determined. This movement strategy, guided by group historical information, not only significantly improves the convergence speed of the algorithm but also enhances its ability to escape local optima.
[0177] In one implementation, step S137 determines the proposed update position for the firefly to move to the center position of each of the k subgroups, including the following step S1371.
[0178] Step S1371: For each subgroup center position, determine the proposed update position for the firefly to move towards that subgroup center position using the following formula (vi):
[0179]
[0180] Where, x id x represents the d-th dimension position component of the firefly's location before it moved to the center of the subgroup. id ' represents the d-th dimension of the position component of the proposed updated position of the firefly as it moves toward the center of the subgroup. This indicates the attractiveness of the center of the subgroup to the firefly. ε represents the d-th dimension position component of the center position of this subgroup. i Let α represent the random perturbation term associated with the firefly, and let α represent the coefficient.
[0181] In the above scheme, the center position of each subgroup is used as a reference, and parameters such as attraction are employed to accurately determine the proposed update position for fireflies to move towards the center position of each subgroup. This scheme considers both the guiding effect of the subgroup as a whole, enabling fireflies to move towards more promising areas, and introduces a random perturbation term to increase the diversity of the search and further reduce the problem of getting trapped in local optima. This scheme balances the convergence and global search capabilities of the algorithm, helping fireflies to explore the solution space more efficiently and improving the efficiency and accuracy of the algorithm in finding the optimal solution.
[0182] Step S138: Determine the global update position of the firefly in the current iteration update process based on the brightness value of the firefly at the k positions to be updated.
[0183] For example, formula (vi) above can be used to calculate the five proposed update positions obtained by moving each firefly to one of the five proposed update positions. These five proposed update positions correspond one-to-one with the five subgroup center positions. For example, the proposed update position corresponding to the j-th subgroup center position is denoted as... Where j∈(1,2,…,5). Then, the brightness value corresponding to each position to be updated can be calculated. Five brightness values can be obtained.
[0184] In step S138, the global update position of the firefly in the current iteration update process can be determined based on at least the comparison results of the k brightness values that correspond one-to-one with the k positions to be updated.
[0185] In one implementation, the first proposed update position corresponding to the highest brightness value can be selected from k proposed update positions and used as the global update position of the firefly in the current iteration update process.
[0186] In another embodiment, the brightness values corresponding to the k proposed update positions and the positions of the firefly before it moves to the center of the k subgroups (e.g., denoted as the positions to be updated) can be compared. The second proposed update position with the highest brightness value is selected from the k proposed update positions and the position to be updated, and is used as the global update position of the firefly in the current iteration update process.
[0187] For example, the second position to be updated can be determined using the following formula (vii):
[0188]
[0189] Where, x i Indicates the position of the firefly to be updated, x i ' represents the second proposed update position for the firefly, f(x) i ') represents the brightness value of the firefly at the second position to be updated.
[0190] In the above scheme, the initial firefly population is first clustered into multiple firefly subgroups, which facilitates regional optimization. In each iteration of the firefly population update, after updating the local positions of fireflies towards neighboring light sources, the center position of each subgroup is updated first. This provides a precise reference for the global position update of the fireflies, making the search direction more accurate. This quickly and accurately determines multiple proposed update positions for the fireflies to move towards the centers of each subgroup. Finally, based on the brightness values corresponding to each proposed update position, the global update position of the fireflies is determined. This approach fully utilizes local information while comprehensively considering the global situation. Through this combination of local and global methods, the breadth and depth of the search are effectively balanced, significantly improving the efficiency of finding high-quality solutions, thereby significantly improving the efficiency and accuracy of computational resource allocation.
[0191] The following is combined with Figure 3 and Figure 4 The flow of a computing resource allocation method according to a specific embodiment of this application will be described. For example... Figure 3 As shown, firstly, the edge server acquires the data packets of computing tasks unloaded from each terminal device. Then, it identifies and classifies the data packets for each task. Specifically, it can classify them according to task type (such as image processing, data computation, etc.). It then extracts the attribute values of each classified task data packet. The attribute values are then normalized, mapping data of different dimensions to the [0,1] interval. Next, based on the normalized attribute values, a DDoS test is performed on each computing task. The test results determine whether each computing task is normal. If not, the abnormal computing tasks are discarded. If so, the normal computing tasks are unloaded, and the following steps are executed: Figure 4 The edge layer resource allocation process is shown.
[0192] Specifically, such as Figure 4As shown, an improved firefly algorithm can be used to allocate resources at the edge layer. First, several resource allocation schemes can be randomly generated, each corresponding to a firefly, to initialize the firefly population's positions. Then, the K-Means clustering algorithm can be used to divide the firefly population into K subgroups. Based on the brightness of each firefly, the visible light source fireflies within the neighborhood of each firefly in each subgroup are determined. Each firefly then moves towards the light source firefly, updating its position. In other words, fireflies move to the better individuals within their local range based on brightness, achieving local search. After each move, it can be determined whether the local optimization termination condition is met. If not, the positions of the light source fireflies in the neighborhood of each firefly (the moved firefly) can be updated, and each firefly continues to move towards the updated light source firefly, updating its position. This continues until the local optimization termination condition is met. If the local optimization termination condition is met, the global search process begins. Specifically, for each subgroup, the position of the generalized center particle (GCP) of each subgroup can be determined based on the historical best position of each firefly (i.e., the historical position corresponding to the highest brightness). Specifically, the GCP can correspond to the center of the historical best position of each firefly in the subgroup. Then, each firefly can move towards the GCP of its respective subgroup, resulting in K possible positions to be updated. Afterwards, the final position of each firefly in this iteration can be determined based on the brightness values corresponding to the K positions to be updated. This final position can correspond to the position to be updated with the highest brightness value (e.g., the shortest delay). The firefly is then moved to this final position. It is then determined whether the current iteration termination condition is met. If not, a new iteration begins based on the firefly's current position (i.e., the final position). In the new iteration, the light source fireflies in the neighboring fireflies are updated, causing the firefly to move towards the light source fireflies to achieve local optimization. If the local optimization termination condition is met, the GCP of each subgroup can be updated. The fireflies are then moved towards the updated GCP to obtain their final position in the next iteration. The iteration continues until the termination condition is met, at which point it ends. The brightness values corresponding to the historical best positions of each firefly are calculated and compared. Based on the resource allocation scheme corresponding to the historical best position of the firefly with the highest brightness value, the final resource allocation scheme is determined, and the allocation is completed.
[0193] Once the allocation is complete, the computing tasks are executed according to the allocated edge layer resources. That is, specific computing tasks can be executed based on the optimized resource scheme (such as the number of CPU cores, bandwidth, execution nodes, etc.).
[0194] In the above scheme, firstly, the computing tasks offloaded from terminal devices are classified and detected at the edge server, and computing tasks caused by DDoS attacks are specifically eliminated, thereby enabling the edge server to handle normal computing tasks more efficiently. Secondly, the Firefly algorithm, which combines local and global location optimization, is used to quickly and accurately allocate computing resources to each computing task. This scheme significantly reduces the time complexity of the algorithm and improves the convergence speed and search accuracy of the optimization algorithm.
[0195] This application also provides a computing resource allocation device. For example... Figure 5 As shown, the computing resource allocation device 500 of this application embodiment includes:
[0196] The acquisition module 510 is used to acquire task information of the computing tasks to be unloaded;
[0197] The preliminary allocation module 520 is used to generate multiple allocation schemes for computing resources to perform computing tasks based on task information.
[0198] The iterative update module 530 is used to take multiple allocation schemes as the initial firefly population and use the firefly algorithm to perform multiple rounds of iterative update operations on the position of the fireflies until the end update condition is met. Each round of iterative update operation includes local update sub-operations and global update sub-operations executed sequentially, so that the fireflies first move to the light source fireflies in the neighborhood and then move to at least one central position of the firefly population.
[0199] The first historical position determination module 540 is used to determine the first historical position of the first firefly based on the first brightness value of each historical position of the firefly population in multiple rounds of iterative update operations, wherein the second brightness value of the first firefly at the first historical position is greater than at least a portion of the first brightness value.
[0200] The allocation computing module 550 is used to allocate computing resources to perform computing tasks according to the allocation scheme corresponding to the first firefly at the first historical position.
[0201] In one embodiment, the computing resource allocation device 500 of this application further includes:
[0202] The clustering module is used to cluster the initial firefly population before the iterative update module 530 performs multiple rounds of iterative update operations on the firefly positions using the firefly algorithm, to obtain k firefly subgroups, where k is a positive integer greater than 1.
[0203] Iterative update module 530 includes:
[0204] The subgroup center position determination unit is used to determine the subgroup center position of each firefly subgroup based on the historical best position of each firefly in each firefly subgroup during each round of iterative update operation, when the global update sub-operation is started, and obtain k subgroup center positions, where the brightness value of the firefly at the historical best position is greater than the brightness value of the firefly at other historical positions.
[0205] The proposed update position determination unit is used to determine, for each firefly, the proposed update position to be moved to the center position of each of the k subgroups, and obtain the k proposed update positions;
[0206] The global update position determination unit is used to determine the global update position of each firefly in the current iteration update process based on the brightness value of the firefly at the k proposed update positions.
[0207] In one implementation, the iterative update module 530 further includes:
[0208] The light source firefly determination unit is used to determine the light source fireflies in the neighborhood of each firefly during each round of iterative update, when the local update sub-operation is started.
[0209] The local position update unit is used to move each firefly toward its respective light source firefly and update its position.
[0210] The judgment unit is used to determine whether the condition for ending the local update is met after each position update.
[0211] End the local update unit; if so, the local update will end.
[0212] The light source firefly update unit is used to update the light source fireflies in the neighborhood of each firefly if no, and to perform a new local update sub-operation until it is determined that the current condition for ending the local update is met.
[0213] In one embodiment, the determining unit includes:
[0214] The first determining subunit is configured to determine that the condition for ending the local update is met if, after performing a preset number of consecutive local update sub-operations, the brightness value of at least one firefly has not increased; and / or
[0215] The second determining subunit is used to determine whether the current condition for ending the local update is met when the number of local update sub-operations is greater than or equal to the number threshold.
[0216] In one implementation, the subgroup center location determination unit is further configured to:
[0217] For each firefly subgroup, the subgroup center is determined using the following formula:
[0218]
[0219] in, Let d represent the positional component of the subgroup center of the firefly subgroup, and n represent the number of fireflies in the subgroup. The position component in dimension d represents the historical best position of the i-th firefly in the firefly subgroup.
[0220] In one implementation, the proposed update position determination unit is further configured to:
[0221] For each subgroup center, the proposed update position for the firefly to move towards that subgroup center is determined using the following formula:
[0222]
[0223] Where, x id x represents the d-th dimension position component of the firefly's location before it moved to the center of the subgroup. id ' represents the d-th dimension of the position component of the proposed updated position of the firefly as it moves toward the center of the subgroup. This indicates the attractiveness of the center of the subgroup to the firefly. ε represents the d-th dimension position component of the center position of this subgroup. i Let α represent the random perturbation term associated with the firefly, and let α represent the coefficient.
[0224] In one implementation, the acquisition module 510 includes:
[0225] The receiving unit is used to receive data packets uploaded by each terminal device;
[0226] The classification unit is used to identify each data packet and classify them according to the task identifier, so as to obtain multiple task data packets corresponding to multiple computing tasks respectively;
[0227] The normalization unit is used to normalize the attribute values of each task data packet;
[0228] The detection unit is used to detect malicious attack tasks for each task data packet based on the normalized attribute values of the task data packet.
[0229] The deletion unit is used to delete each task data packet if the detection result indicates that the computation task corresponding to the task data packet is a malicious attack task.
[0230] The computation task determination unit is used to determine the computation task corresponding to each task data packet as a computation task to be unloaded if the detection result indicates that the computation task corresponding to the task data packet is a normal task.
[0231] This application also provides a terminal device. For example... Figure 6 As shown, the terminal device 600 of this application embodiment includes: at least one processor 610 ( Figure 6 The diagram shows only one processor, memory 620, and computer program 630 stored in memory 620 and executable on at least one processor 610. When processor 610 executes computer program 630, it implements the steps of the above-described computing resource allocation method.
[0232] In this embodiment, the terminal device may include, but is not limited to, a processor and a memory. Figure 6 This is merely an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than illustrated, or combine certain components, or use different components. The processor may be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0233] It should be noted that the information interaction and execution process between the above-mentioned devices / modules are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0234] Those skilled in the art will understand that, for the sake of convenience and brevity, the above-described division of functional modules is merely an example. In practical applications, the functions described above can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The functional modules in the embodiments can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules can be implemented in hardware or as software functional modules. Furthermore, the specific names of the functional modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0235] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described computing resource allocation method.
[0236] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps in the above-described computing resource allocation method.
[0237] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method of allocating computing resources, characterized by, The method comprises: obtaining task information of a computing task to be unloaded; generating a plurality of allocation schemes of computing resources for executing the computing task according to the task information; performing a plurality of rounds of iterative updating operations on the positions of the fireflies by using the glowworm swarm optimization algorithm, until an ending updating condition is met, wherein each round of the iterative updating operation comprises a local updating sub-operation and a global updating sub-operation performed in sequence, so that the fireflies first move to a light source firefly in a neighborhood and then move to at least one center position of the firefly swarm; determining a first historical position of a first firefly according to first brightness values of each historical position of the firefly swarm in the plurality of rounds of the iterative updating operation, wherein a second brightness value of the first firefly at the first historical position is greater than at least part of the first brightness values; allocating computing resources to execute the computing task according to an allocation scheme corresponding to the first firefly at the first historical position.
2. The method of allocating computing resources as recited in claim 1, wherein, Before the plurality of rounds of iterative updating operations on the positions of the fireflies by using the glowworm swarm optimization algorithm, the method further comprises: performing clustering processing on the initial firefly swarm to obtain k firefly sub-swarms, wherein k is a positive integer greater than 1; the plurality of rounds of iterative updating operations on the positions of the fireflies by using the glowworm swarm optimization algorithm comprises: in each round of the iterative updating operation, when the global updating sub-operation is started to be performed, determining a sub-swarm center position of each of the firefly sub-swarms according to a historical best position of each of the fireflies in each of the firefly sub-swarms, to obtain k sub-swarm center positions, wherein a brightness value of the firefly at the historical best position is greater than brightness values of the firefly at other historical positions; for each of the fireflies, determining k tentative updated positions of the firefly moving to the k sub-swarm center positions respectively, to obtain the k tentative updated positions; determining a global updated position of the firefly in the current round of iterative updating according to brightness values of the firefly at the k tentative updated positions.
3. The method of allocating computing resources as recited in claim 2, wherein, the plurality of rounds of iterative updating operations on the positions of the fireflies by using the glowworm swarm optimization algorithm further comprises: in each round of iterative updating, when the local updating sub-operation is started to be performed, determining a light source firefly in a neighborhood of each of the fireflies; making each of the fireflies move to and update the position of the light source firefly; after each update of the position, determining whether an ending local updating condition is met; if yes, ending the local updating; if no, updating the light source firefly in the neighborhood of each of the fireflies and performing a new local updating sub-operation until it is determined that the ending local updating condition is met.
4. The method of allocating computing resources as recited in claim 3, wherein, the determination of whether the ending local updating condition is met comprises: after performing the local updating sub-operation for a preset number of consecutive times, if brightness values of at least one of the fireflies have not increased all the time, it is determined that the ending local updating condition is met; and / or In a case where a number of the local update sub-operations is greater than or equal to a number threshold, it is determined that the ending local update condition is currently satisfied.
5. The method of allocating computing resources as recited in claim 2, wherein, The determining of the sub-population center position of each of the glowworm sub-populations according to the historical optimal position of each of the glowworms in the glowworm sub-population comprises: For each of the glowworm sub-populations, the sub-population center position of the glowworm sub-population is determined by using the following formula: wherein, represents the d-th dimensional position component of the position of the center of the sub swarm of the firefly sub swarm, and n represents the number of fireflies in the firefly sub swarm, represents the d-th dimensional position component of the historical best position of the i-th firefly in the firefly sub swarm.
6. The method of allocating computing resources as recited in claim 2, wherein, The determining of the pseudo-updated position of the glowworm to the k sub-population center positions respectively comprises: For each of the sub-population center positions, the pseudo-updated position of the glowworm to the sub-population center position is determined by using the following formula: wherein x id represents the d-th dimensional position component of the position of the firefly before moving to the position of the center of the subswarm, x id represents the d-th dimensional position component of the tentative updated position of the tentative position of the firefly moving to the position of the center of the subswarm, represents the degree of attraction of the position of the center of the subswarm to the firefly, represents the d-th dimensional position component of the position of the center of the subswarm, ε i represents a random perturbation term associated with the firefly, and α represents a coefficient.
7. The method of allocating computing resources according to any of claims 1-6, wherein, The task information of the to-be-offloaded computing task comprises: Receiving data packets uploaded by each terminal device; Identifying each of the data packets and classifying them according to task identifiers to obtain a plurality of task data packets respectively corresponding to a plurality of the computing tasks; Normalizing attribute values of each of the task data packets; For each of the task data packets, According to the normalized attribute values of the task data packet, detecting the task data packet for malicious attack tasks; In a case where the detection result indicates that the computing task corresponding to the task data packet is a malicious attack task, deleting the task data packet; In a case where the detection result indicates that the computing task corresponding to the task data packet is a normal task, determining the computing task corresponding to the task data packet as the to-be-offloaded computing task.
8. A computing resource allocation device, characterized in that, Comprise: An acquisition module configured to acquire task information of a to-be-offloaded computing task; A preliminary allocation module configured to preliminarily generate a plurality of allocation schemes of computing resources for executing the computing task according to the task information; An iterative update module configured to take the plurality of allocation schemes as initial glowworm populations, perform a plurality of rounds of iterative update operations on positions of the glowworms by using a glowworm algorithm until an ending update condition is satisfied, wherein each round of the iterative update operation comprises sequentially performed local update sub-operations and global update sub-operations, so that the glowworms first move to light source glowworms in a neighborhood and then move to at least one center position of the glowworm populations; A first historical position determination module configured to determine a first historical position of a first glowworm according to first luminance values of each historical position of the glowworm populations in the plurality of rounds of the iterative update operations, wherein a second luminance value of the first glowworm at the first historical position is greater than at least part of the first luminance values; An allocation calculation module configured to allocate computing resources to execute the computing task according to an allocation scheme corresponding to the first glowworm at the first historical position.
9. A terminal device, comprising: Comprise: A memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the computing resource allocation method according to any one of claims 1-7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the computing resource allocation method according to any one of claims 1-7.
