Network routing optimization method and device based on particle swarm optimization and simulated annealing
By combining particle swarm optimization and simulated annealing algorithm in network routing optimization, the problem that traditional routing algorithms cannot adjust routing in time when network congestion or failure is solved, efficient and reliable routing strategies in large-scale networks are achieved, and network performance and adaptability are improved.
Patent Information
- Application Number
- CN202411818118.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-25
AI Technical Summary
Traditional shortest path algorithms cannot adjust routes in time when network congestion or node failure, resulting in increased data transmission delay or increased packet loss rate. Traditional optimization algorithms such as genetic algorithms and ant colony algorithms have high computational complexity when dealing with large-scale networks, making them difficult to apply in real time.
Using a network routing optimization method based on particle swarm optimization and simulated annealing, the distributed network is represented as a graph and the delay, bandwidth and packet loss rate are given weights for each edge, multiple particles are created and particle swarms are initialized, and the state of particles is adjusted based on the particle swarm optimization algorithm, and local optimization is performed according to the simulated annealing algorithm.
Improve the diversity and flexibility of routing selection, ensure efficient and reliable routing strategies in complex network environments, significantly improve the performance of distributed networks, and enhance its adaptability and robustness in high dynamic environments.
Smart Images

Figure CN119697079A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of network routing, and in particular to a network routing optimization method based on particle swarm optimization and simulated annealing. Background Art
[0002] With the development of cloud computing and the Internet of Things, the scale and complexity of distributed networks are increasing, resulting in many challenges for traditional routing algorithms in dynamic environments. Traditional technologies usually rely on static routing strategies and cannot effectively cope with changes in network topology and fluctuations in traffic. For example, traditional shortest path algorithms may not be able to adjust routes in time when the network is congested or a node fails, resulting in increased data transmission delays or increased packet loss rates. In addition, traditional optimization algorithms such as genetic algorithms and ant colony algorithms have high computational complexity when dealing with large-scale networks and are difficult to apply in real time. Therefore, they need to be improved. Summary of the invention
[0003] Based on this, it is necessary to provide a network routing optimization method and device based on particle swarm optimization and simulated annealing, in order to solve the problem that the traditional shortest path algorithm may not be able to adjust the route in time when the network is congested or the node fails, resulting in increased data transmission delay or increased packet loss rate. In addition, the traditional optimization algorithms such as genetic algorithms and ant colony algorithms have high computational complexity and are difficult to apply in real time when processing large-scale networks.
[0004] The present invention provides a network routing optimization method based on particle swarm optimization and simulated annealing, the method comprising:
[0005] The distributed network is represented as a graph with network devices as nodes and communication links as edges, and a corresponding weight is assigned to each edge, where the weight represents the parameters of delay, bandwidth and packet loss rate;
[0006] Creating a plurality of particles and initializing a particle swarm, wherein each particle of the particle swarm represents a path combination from a source node to a destination node;
[0007] Adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm;
[0008] The current global best particle is locally optimized according to the simulated annealing algorithm.
[0009] In one embodiment, the distributed network is represented as a graph with network devices as nodes and communication links as edges, and a corresponding weight is assigned to each edge, including:
[0010] Identify all devices on the network and assign a unique identifier to each device;
[0011] For each pair of directly connected devices, create an edge and assign it a weight;
[0012] Store node and edge information according to the graph data structure;
[0013] Obtain real-time monitoring data of network performance indicators and adjust the graph structure and edge weights according to changes in network topology.
[0014] In one embodiment, the method of representing the distributed network as a graph with network devices as nodes and communication links as edges, and assigning a corresponding weight to each edge, further includes:
[0015] The constructed graph is visualized based on graphical tools to intuitively identify network bottlenecks and optimization points.
[0016] In one embodiment, the step of creating a plurality of particles and initializing a particle group includes:
[0017] Creating a plurality of particles, each particle including path information, a position in a search space, a speed, and a fitness value;
[0018] Generate initial paths by random selection or based on existing heuristic algorithms;
[0019] Determine the number of particles based on the size and complexity of the network;
[0020] Assigning each particle a randomly generated path or a path generated by a heuristic algorithm and initializing its velocity to zero, which represents the speed and direction of the particle moving in the search space;
[0021] Evaluate the fitness of each particle's path;
[0022] Array or linked list-based data structures store and manage particle information.
[0023] In one embodiment, the fitness evaluation of the path of each particle includes:
[0024] Determine the total delay of the particle path based on the sum of the delays of each edge in the path;
[0025] Compare the bandwidth values of all edges in the path, and express the minimum bandwidth value in the path as the bandwidth of the path;
[0026] Analyze the historical performance data of each link in the path and calculate the packet loss rate or jitter value of the path to indicate the stability of the path;
[0027] Based on the latency, bandwidth, and stability of each particle, the fitness value of each particle is calculated to evaluate the quality of each particle.
[0028] In one embodiment, the speed and position update rules based on the particle swarm optimization algorithm are used to adjust the state of each particle, including:
[0029] Assume that each particle has a position vector and a velocity vector at the time of initialization, wherein the position vector represents the current solution of the particle in the solution space, and the velocity vector represents the movement of the particle in the next iteration;
[0030] Update the particle's velocity and add the updated velocity to the current position to move the particle to the new position;
[0031] In response to a particle exceeding a preset boundary, limiting the particle position within the boundary, or adjusting the particle position back to within the boundary;
[0032] In response to the fitness value of the current particle being better than its historical best fitness value, updating the historical best position of the particle;
[0033] Based on the historical best positions of all particles, the global best position is updated.
[0034] In one embodiment, the locally optimizing the current global best particle according to the simulated annealing algorithm includes:
[0035] Generate a neighborhood solution based on the current global best particle;
[0036] Calculate the fitness value of the neighborhood solution and compare the fitness value of the neighborhood solution with the fitness value of the current global best particle;
[0037] According to the Metropolis criterion, determine the probability of accepting the neighborhood solution;
[0038] After each iteration, the preset initial temperature is gradually reduced;
[0039] In response to reaching the maximum number of iterations or the temperature dropping to a preset threshold, the particle with the highest fitness is determined as the final routing strategy.
[0040] The present invention also provides a network routing optimization device based on particle swarm optimization and simulated annealing, comprising:
[0041] A graph building module is used to represent the distributed network as a graph with network devices as nodes and communication links as edges, and to assign corresponding weights to each edge, wherein the weights represent parameters of delay, bandwidth, and packet loss rate;
[0042] An initialization module, used to create multiple particles and initialize a particle swarm, each particle of the particle swarm represents a path combination from a source node to a destination node;
[0043] An adjustment module is used to adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm;
[0044] The optimization module is used to locally optimize the current global best particle according to the simulated annealing algorithm.
[0045] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the network routing optimization method based on particle swarm optimization and simulated annealing as described above is implemented.
[0046] The present invention also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the network routing optimization method based on particle swarm optimization and simulated annealing as described above is implemented.
[0047] The above-mentioned network routing optimization method based on particle swarm optimization and simulated annealing solves the local optimal problem and the problem of insufficient adaptability in the existing network routing by combining the hybrid optimization method of particle swarm optimization algorithm and simulated annealing algorithm. At the same time, by introducing the randomness of simulated annealing, the global search capability of particle swarm optimization is enhanced, thereby improving the diversity and flexibility of routing selection. In addition, by comprehensively considering factors such as delay, bandwidth and stability, it ensures the implementation of efficient and reliable routing strategies in complex network environments, significantly improving the performance of distributed networks and enhancing their adaptability and robustness in highly dynamic environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0049] Figure 1 A schematic diagram of a flow chart of a network routing optimization method based on particle swarm optimization and simulated annealing in one embodiment;
[0050] Figure 2 A schematic diagram of a process of representing a distributed network as a graph in one embodiment;
[0051] Figure 3 is a schematic diagram of a process of initializing a particle swarm in an embodiment;
[0052] Figure 4 A schematic diagram of a process of evaluating the fitness of the path of each particle in an embodiment;
[0053] Figure 5 A schematic diagram of a process for adjusting the state of each particle in an embodiment;
[0054] Figure 6 It is a schematic diagram of a process of locally optimizing the current global best particle in one embodiment;
[0055] Figure 7 It is a schematic diagram of the structure of a network routing optimization device based on particle swarm optimization and simulated annealing in one embodiment;
[0056] Figure 8 The figure is a diagram showing the internal structure of an electronic device according to an embodiment. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] Combine the following Figure 1-Figure 8 The present invention describes a network routing optimization method and device based on particle swarm optimization and simulated annealing.
[0059] like Figure 1 As shown, in one embodiment, a network routing optimization method based on particle swarm optimization and simulated annealing includes the following steps:
[0060] Step S100, taking network devices as nodes and communication links as edges, the distributed network is represented as a graph, and a corresponding weight is assigned to each edge, where the weight represents the parameters of delay, bandwidth and packet loss rate.
[0061] It should be noted that the nodes of the graph represent various devices in the network, such as routers, switches, and terminal devices. The constructed network model will provide the necessary basic data for the subsequent particle swarm optimization and simulated annealing algorithms, so that the routing optimization process can be carried out in an accurate network environment.
[0062] Step S200: create multiple particles and initialize a particle swarm, where each particle of the particle swarm represents a path combination from a source node to a destination node.
[0063] Initializing the particle swarm is a key step in the particle swarm optimization algorithm, which aims to provide a diverse starting solution for subsequent routing optimization.
[0064] Step S300, adjusting the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm.
[0065] It should be noted that the position update of a particle is affected by its personal historical best position and the global best position, which makes it convenient to explore the solution space by adjusting the speed and position of the particle.
[0066] Step S400: locally optimize the current global best particle according to the simulated annealing algorithm.
[0067] After each round of particle swarm optimization iteration, the simulated annealing algorithm is used to locally optimize the current global best particle to further improve the quality of the solution. The core idea of the simulated annealing algorithm is to gradually reduce the temperature of the system by simulating the physical annealing process, so that particles can effectively explore the solution space. By controlling the temperature parameter, the simulated annealing algorithm allows a certain degree of "variation" selection to jump out of the local optimum.
[0068] This network routing optimization method based on particle swarm optimization and simulated annealing solves the local optimal problem and insufficient adaptability in existing network routing by combining the hybrid optimization method of particle swarm optimization algorithm and simulated annealing algorithm. At the same time, by introducing the randomness of simulated annealing, the global search capability of particle swarm optimization is enhanced, thereby improving the diversity and flexibility of routing selection. In addition, by comprehensively considering factors such as delay, bandwidth and stability, it ensures the implementation of efficient and reliable routing strategies in complex network environments, significantly improving the performance of distributed networks and enhancing their adaptability and robustness in highly dynamic environments.
[0069] In this embodiment, see Figure 2 , with network devices as nodes and communication links as edges, the distributed network is represented as a graph and each edge is assigned a corresponding weight, including the following steps:
[0070] Step S110, identifying all devices in the network and assigning a unique identifier to each device.
[0071] It should be noted that the attributes of each device (such as type, processing capability, etc.) can also be stored as additional information of the node.
[0072] Step S120: For each pair of directly connected devices, create an edge and assign a weight to it.
[0073] The specific weight calculation formula is as follows:
[0074]
[0075] Among them, w ijrepresents the weight of the edge between device i and device j; α, β, and γ are weight coefficients used to adjust the influence of each factor on the total weight; delay, bandwidth, and packet loss rate represent the communication delay, available bandwidth, and probability of packet loss between devices, respectively.
[0076] Step S130, storing node and edge information according to the graph data structure.
[0077] Graph data structures include adjacency matrices or adjacency lists. The adjacency matrix is suitable for dense graphs, while the adjacency list is more suitable for sparse graphs. Choosing a suitable data structure can improve the efficiency of subsequent algorithms.
[0078] Step S140, obtaining real-time monitoring data of network performance indicators, and adjusting the structure of the graph and the weight of the edges according to changes in the network topology.
[0079] In actual applications, the network topology may change, such as the addition or failure of equipment, link congestion, etc. Therefore, by adjusting the structure of the graph and the weight of the edges according to the real-time monitoring data of network performance indicators, it is convenient to reflect the changes in network status.
[0080] In this embodiment, the distributed network is represented as a graph with network devices as nodes and communication links as edges, and a corresponding weight is assigned to each edge, which also includes:
[0081] Step S150 , visualizing the constructed graph according to a graphical tool to intuitively identify network bottlenecks and optimization points.
[0082] By using graphical tools to visualize the constructed graph, it is easy to understand and analyze the network structure. At the same time, it helps network administrators to intuitively identify network bottlenecks and optimization points.
[0083] The specific examples are as follows:
[0084] Suppose there is a network with 5 devices, namely A, B, C, D and E. First, define these devices as nodes and assign a unique identifier to each device. Next, determine the connection relationship between the devices, such as A is connected to B, B is connected to C, C is connected to D, and D is connected to E. Then, measure the delay, bandwidth and packet loss rate of these links, and assume that the following data is obtained:
[0085] The latency from A to B is 10ms, the bandwidth is 100Mbps, and the packet loss rate is 0.01%;
[0086] The delay from B to C is 20ms, the bandwidth is 50Mbps, and the packet loss rate is 0.05%;
[0087] The latency from C to D is 15ms, the bandwidth is 75Mbps, and the packet loss rate is 0.02%;
[0088] The latency from D to E is 25ms, the bandwidth is 30Mbps, and the packet loss rate is 0.1%.
[0089] According to the above data, the weight coefficients α = 1, β = 0.5, γ = 0.5 are set to calculate the weight of each edge and build a complete network graph. Finally, the network structure is visualized using a graphical tool to facilitate subsequent routing optimization analysis.
[0090] In this embodiment, see Figure 3 , create multiple particles and initialize the particle swarm, including the following steps:
[0091] Step S210, creating multiple particles, each particle including path information, position in the search space, speed, and fitness value.
[0092] It should be noted that each particle can be regarded as a collection of paths, which consists of a series of nodes, indicating the order in which data packets are transmitted in the network.
[0093] Step S220: Generate an initial path by random selection or based on an existing heuristic algorithm.
[0094] Random selection: Generate the initial path by randomly selecting nodes in the network. The specific method is to start from the source node and randomly select adjacent nodes until reaching the destination node. In order to avoid forming a loop, it is necessary to ensure that the selected node has not been visited.
[0095] Heuristic algorithms: such as Dijkstra algorithm or A* algorithm. Dijkstra algorithm is the shortest path algorithm from one vertex to the remaining vertices. It solves the shortest path problem in a weighted graph. The main feature of Dijkstra algorithm is that it starts from the starting point and adopts the strategy of greedy algorithm. Each time, it traverses to the adjacent nodes of the vertex that is closest to the starting point and has not been visited, until it expands to the end point. The A* algorithm is commonly known as the A-star algorithm. As one of the heuristic search algorithms, it is an algorithm that finds the lowest passing cost for a path with multiple nodes on a graph plane. These algorithms can calculate a better path based on the weight of the network (such as delay, bandwidth, etc.). The path generated in this way is usually more feasible and effective.
[0096] Step S230, determining the number of particles according to the network scale and complexity.
[0097] It should be added that the number of particles should be large enough to cover the search space, but not too large to increase the computational burden.
[0098] Step S240, assigning a randomly generated path or a path generated by a heuristic algorithm to each particle, and initializing its speed to zero, where the speed represents the speed and direction of the particle moving in the search space.
[0099] The initialized particle swarm will provide diverse starting solutions for subsequent particle updates and optimizations, ensuring that the algorithm can find better routing strategies in a wide search space.
[0100] Step S250, evaluating the fitness of the path of each particle.
[0101] After initializing the particles, the path of each particle needs to be evaluated for fitness. The fitness function should comprehensively consider factors such as path delay, bandwidth, and stability to provide a basis for subsequent particle updates.
[0102] Step S260, storing and managing particle information based on an array or linked list data structure.
[0103] It should be noted that each particle can be represented by an object, including properties such as path, speed, and fitness.
[0104] The specific examples are as follows:
[0105] Suppose there is a network with source node A and destination node E, and the network contains nodes B, C, and D. We decide to create 10 particles as the initial path.
[0106] 1. Randomly select a path:
[0107] Particle 1: A→B→C→E;
[0108] Particle 2: A→C→D→E;
[0109] Particle 3: A→B→D→E;
[0110] Particle 4: A→B→C→D→E;
[0111] Particle 5: A→C→B→E;
[0112] Particle 6: A→D→E;
[0113] Particle 7: A→B→E;
[0114] Particle 8: A→C→E;
[0115] Particle 9: A→D→C→E;
[0116] Particle 10: A→B→C→D→E.
[0117] 2. Heuristic algorithm generates path:
[0118] Use Dijkstra's algorithm to calculate the shortest path from A to E. Assume that the obtained path is A→B→C→E.
[0119] 3. Initialize particle information:
[0120] Assign an initial velocity of zero to each particle and calculate the fitness value. The fitness value can be calculated by the fitness function, which takes into account the delay, bandwidth and stability of the path.
[0121] The initialization of the particle swarm will provide a solid foundation for subsequent particle updates and optimizations, ensuring that the algorithm can effectively explore the search space and find the optimal solution.
[0122] In this implementation, see Figure 4 , the fitness of each particle's path is evaluated, including the following steps:
[0123] Step S251, determining the total delay of the particle path according to the sum of the delays of each edge in the path.
[0124] Assume that the path is p = (n1, n2, ..., n k ), the specific delay calculation formula is as follows:
[0125]
[0126] Where D(p) represents the delay, which can be calculated by traversing each edge in the path and accumulating its delay value; d(n i ,n i+1 ) represents node n i To node n i+1 of delay.
[0127] Step S252, comparing the bandwidth values of all the edges in the path, and expressing the minimum bandwidth value in the path as the bandwidth of the path.
[0128] The specific expression is as follows:
[0129]
[0130] Where B(p) represents bandwidth, which can be compared by comparing the bandwidth values of all edges in the path and taking the minimum value; i = 1, 2, ..., k-1; b(n i ,n i+1 ) represents node n i To node n i+1 bandwidth.
[0131] Step S253: Analyze the historical performance data of each link in the path, and calculate the packet loss rate or jitter value of the path to indicate the stability of the path.
[0132] For example, the packet loss rate over a period of time is used to indicate stability. The specific calculation formula is as follows:
[0133]
[0134] Among them, S(p) represents stability; the number of packet losses and the total number of transmissions can be collected through network monitoring tools.
[0135] Step S254, based on the delay, bandwidth and stability of each particle, the fitness value of each particle is calculated to evaluate the quality of each particle.
[0136] After calculating the delay, bandwidth, and stability of each particle, these values are substituted into the fitness function to calculate the fitness value of each particle. The higher the fitness value, the better the overall performance of the path.
[0137] The specific fitness function calculation formula is as follows:
[0138]
[0139] Among them, F(p) represents the fitness value of particle p; w1, w2, and w3 are weight coefficients, which are used to adjust the influence of various factors on fitness and need to be set according to the specific application scenario.
[0140] The specific examples are as follows:
[0141] Assume that there is a particle path p = (A, B, C, E), and the following data are known:
[0142] The latency of edge A→B is 10ms, the bandwidth is 100Mbps, and the stability is 0.98;
[0143] The latency of edge B→C is 15ms, the bandwidth is 50Mbps, and the stability is 0.95;
[0144] The latency of edge C→E is 5ms, the bandwidth is 200Mbps, and the stability is 0.99.
[0145] Calculate the delay:
[0146] D(p)=d(A,B)+d(B,C)+d(C,E)=10+15+5=30ms;
[0147] Calculate bandwidth:
[0148] B(p)=min(b(A,B),b(B,C),b(C,E))=min(100,50,200)=50Mbps;
[0149] Calculation stability: Assume that in the past monitoring, the number of packet losses on the link is 2 and the total number of packets sent is 1000, then:
[0150]
[0151] Calculate the fitness value: Assuming the weight coefficients w1 = 0.5, w2 = 0.3, w3 = 0.2, then:
[0152]
[0153] By adopting fitness evaluation, effective feedback will be provided for particle swarm optimization, ensuring that the algorithm can find a better routing strategy in the search space.
[0154] In this embodiment, see Figure 5 , based on the speed and position update rules of the particle swarm optimization algorithm, the state of each particle is adjusted, including the following steps:
[0155] Step S310, setting each particle to have a position vector and a velocity vector at the time of initialization, the position vector represents the current solution of the particle in the solution space, and the velocity vector represents the movement of the particle in the next iteration.
[0156] The initial state expression of the particle is as follows:
[0157] X i =[x i1 ,x i2 ,…,x iD ],
[0158] V i =[v i1 ,v i2 ,…,v iD ],
[0159] Among them, X i Represents a position vector of each particle at initialization, V i Represents a velocity vector that each particle has at initialization, sets the number of particles to N, and the dimension of each particle to D.
[0160] Step S320, updating the velocity of the particle and adding the updated velocity to the current position to move the particle to the new position.
[0161] The particle velocity update formula is:
[0162]
[0163] Among them, w is the inertia weight, which is used to control the degree to which the particle maintains the current direction; c1 and c2 are learning factors, which control the degree to which the particle learns its own optimal position and the global optimal position respectively; r1 and r2 are random numbers in the range of [0,1], which are used to introduce randomness to prevent the algorithm from falling into the local optimum; P i is the best historical position of particle i, and G is the global best position.
[0164] The particle position update formula is:
[0165]
[0166] Step S330, in response to the particle exceeding a preset boundary, limiting the particle position within the boundary, or adjusting the particle position back to within the boundary.
[0167] After updating the position, it is necessary to check whether the particle exceeds the preset boundary. If it exceeds the boundary, the position of the particle is adjusted by adopting the corresponding strategy.
[0168] Step S340 , in response to the fitness value of the current particle being better than its historical best fitness value, updating the historical best position of the particle.
[0169] The specific expression is as follows:
[0170]
[0171] Step S350, updating the global best position based on the historical best positions of all particles.
[0172] The specific expression is as follows:
[0173]
[0174] The specific examples are as follows:
[0175] Suppose there is a particle swarm with 5 particles, each moving in a two-dimensional space. The initial state is as follows:
[0176] Particle positions X1 = [1, 2], X2 = [2, 3], X3 = [3, 1], X4 = [4, 5], X5 = [5, 4];
[0177] Particle speed V1 = [0.5, -0.5], V2 = [0.2, 0.3], V3 = [-0.3, 0.1], V4 = [0.4, -0.2], V5 = [0.1, 0.1];
[0178] The best historical positions are P1 = [1,2], P2 = [2,3], P3 = [3,1], P4 = [4,5], P5 = [5,4];
[0179] The global optimal position G = [4,5].
[0180] 1. Speed update: Assuming w = 0.5, c1 = 1.5, c2 = 1.5, r1 = 0.3, r2 = 0.7, the speed of particle 1 is updated as follows:
[0181]
[0182] Calculated:
[0183]
[0184] 2. Position update: Update the position of particle 1:
[0185]
[0186] In this embodiment, see Figure 6 , local optimization of the current global best particle is performed according to the simulated annealing algorithm, including the following steps:
[0187] Step S410: Generate a neighborhood solution based on the current global best particle.
[0188] The generation of neighborhood solutions can be achieved by making small perturbations to the particle positions, for example:
[0189] G new =G+ΔG,
[0190] Among them, G new represents the domain solution, G is the current global best particle, and ΔG is a random perturbation vector, which is usually randomly generated within a small range.
[0191] Step S420, calculating the fitness value of the neighborhood solution, and comparing the fitness value of the neighborhood solution with the fitness value of the current global best particle.
[0192] By comparing the fitness value of the neighborhood solution with the fitness value of the current global best particle, it is convenient to decide whether to accept the neighborhood solution.
[0193] Step S430: Determine the probability of accepting the neighborhood solution according to the Metropolis criterion.
[0194] The core idea of the Metropolis criterion is that when the system energy decreases, such changes are always accepted; and when the system energy increases, such changes are accepted with a certain probability, rather than being rejected blindly. This idea enables the algorithm to jump out of the local optimal solution during the search process, and thus it is possible to find the global optimal solution.
[0195] The probability of acceptance P is calculated by the following formula:
[0196]
[0197] Where e is the base of the natural logarithm; T is the current temperature; if the fitness of the neighborhood solution is better, it is directly accepted; if it is worse, it is accepted with a certain probability to avoid falling into the local optimum.
[0198] Step S440, after each iteration, gradually lowering the preset initial temperature.
[0199] After each iteration, the temperature T is gradually reduced. The following cooling strategy can be adopted:
[0200] T new =α·T old ,
[0201] Among them, α is the cooling factor, which is usually between 0.8 and 0.99. As the temperature decreases, the probability of accepting a worse solution gradually decreases, and the algorithm gradually converges.
[0202] It should be noted that at the beginning of the algorithm, an initial temperature T0 is set, which determines the range of particle exploration in the solution space. The higher the temperature, the greater the probability that the particle accepts a worse solution, which helps to escape the local optimum.
[0203] The choice of temperature can be determined empirically or experimentally, and can usually be set as a range for the fitness function.
[0204] Step S450, in response to reaching a maximum number of iterations or the temperature dropping to a preset threshold, determining the particle with the highest fitness as the final routing strategy.
[0205] The specific examples are as follows:
[0206] Assume that after a certain particle swarm optimization iteration, the current global best particle G = [4,5], and its fitness value is F(G) = 10. Set the initial temperature T0 = 100 and the cooling factor α = 0.9.
[0207] 1. Neighborhood solution generation: Generate a random perturbation, for example, ΔG = [0.5, -0.3], then the neighborhood solution is:
[0208] G new =[4,5]+[0.5,-0.3]=[4.5,4.7].
[0209] 2. Fitness evaluation: Assume that F(G new )=12.
[0210] 3. Acceptance criteria:
[0211] Since F(G new) > F(G), the acceptance probability needs to be calculated:
[0212]
[0213] Generate a random number r ∈ [0, 1]. If r < P, accept G new , otherwise keep G.
[0214] 4. Temperature update: T new = 0.9 · 100 = 90.
[0215] 5. Iteration: Repeat the above steps until the maximum number of iterations is reached or the temperature drops to a certain threshold. At this time, select the particle with the highest fitness as the final routing strategy.
[0216] In this way, the simulated annealing algorithm can effectively explore the solution space, combined with the global search ability of the particle swarm optimization, significantly improving the effect of routing optimization.
[0217] The following describes the network routing optimization device provided by the present invention based on particle swarm optimization and simulated annealing. The network routing optimization device based on particle swarm optimization and simulated annealing described below can be mutually corresponding and referred to the network routing optimization method based on particle swarm optimization and simulated annealing described above.
[0218] As Figure 7 shown, in one embodiment, a network routing optimization device based on particle swarm optimization and simulated annealing includes a graph construction module 710, an initialization module 720, an adjustment module 730, and an optimization module 740.
[0219] The graph construction module 710 is used to represent the distributed network as a graph with network devices as nodes and communication links as edges, and assign corresponding weights to each edge. The weights represent parameters such as delay, bandwidth, and packet loss rate.
[0220] The initialization module 720 is used to create multiple particles and initialize the particle swarm. Each particle in the particle swarm represents a path combination from the source node to the destination node.
[0221] The adjustment module 730 is used to adjust the state of each particle based on the velocity and position update rules of the particle swarm optimization algorithm.
[0222] The optimization module 740 is used to perform local optimization on the current global best particle according to the simulated annealing algorithm.
[0223] In this embodiment, the graph construction module 710 is specifically used for:
[0224] Identify all devices in the network and assign a unique identifier to each device;
[0225] For each pair of directly connected devices, create an edge and assign it a weight;
[0226] Store node and edge information according to the graph data structure;
[0227] Obtain real-time monitoring data of network performance indicators and adjust the graph structure and edge weights according to changes in network topology.
[0228] In this embodiment, the mapping module 710 is further specifically used for:
[0229] The constructed graph is visualized based on graphical tools to intuitively identify network bottlenecks and optimization points.
[0230] In this embodiment, the initialization module 720 is specifically used for:
[0231] Create multiple particles, each particle contains path information, position in the search space, speed, and fitness value;
[0232] Generate initial paths by random selection or based on existing heuristic algorithms;
[0233] Determine the number of particles based on the size and complexity of the network;
[0234] Assign each particle a randomly generated path or a path generated by a heuristic algorithm and initialize its velocity to zero. The velocity represents the rate and direction of the particle's movement in the search space.
[0235] Evaluate the fitness of each particle's path;
[0236] Array or linked list-based data structures store and manage particle information.
[0237] In this embodiment, the fitness evaluation is performed on the path of each particle, specifically for:
[0238] Determine the total delay of the particle path based on the sum of the delays of each edge in the path;
[0239] Compare the bandwidth values of all edges in the path, and express the minimum bandwidth value in the path as the bandwidth of the path;
[0240] Analyze the historical performance data of each link in the path and calculate the packet loss rate or jitter value of the path to indicate the stability of the path;
[0241] Based on the latency, bandwidth, and stability of each particle, the fitness value of each particle is calculated to evaluate the quality of each particle.
[0242] In this embodiment, the adjustment module 730 is specifically used to:
[0243] Assume that each particle has a position vector and a velocity vector at the time of initialization. The position vector represents the current solution of the particle in the solution space, and the velocity vector represents the movement of the particle in the next iteration.
[0244] Update the particle's velocity and add the updated velocity to the current position to move the particle to the new position;
[0245] In response to a particle exceeding a preset boundary, limiting the particle position within the boundary, or adjusting the particle position back to within the boundary;
[0246] In response to the fitness value of the current particle being better than its historical best fitness value, updating the historical best position of the particle;
[0247] Based on the historical best positions of all particles, the global best position is updated.
[0248] In this embodiment, the optimization module 740 is specifically used for:
[0249] Generate a neighborhood solution based on the current global best particle;
[0250] Calculate the fitness value of the neighborhood solution and compare the fitness value of the neighborhood solution with the fitness value of the current global best particle;
[0251] According to the Metropolis criterion, determine the probability of accepting the neighborhood solution;
[0252] After each iteration, the preset initial temperature is gradually reduced;
[0253] In response to reaching the maximum number of iterations or the temperature dropping to a preset threshold, the particle with the highest fitness is determined as the final routing strategy.
[0254] The network routing optimization device based on particle swarm optimization and simulated annealing solves the local optimal problem and the problem of insufficient adaptability in existing network routing by combining the hybrid optimization method of particle swarm optimization algorithm and simulated annealing algorithm. At the same time, by introducing the randomness of simulated annealing, the global search capability of particle swarm optimization is enhanced, thereby improving the diversity and flexibility of routing selection. In addition, by comprehensively considering factors such as delay, bandwidth and stability, it ensures the implementation of efficient and reliable routing strategies in complex network environments, significantly improving the performance of distributed networks, and enhancing their adaptability and robustness in highly dynamic environments.
[0255] Figure 8 An example of a physical structure diagram of an electronic device is shown. The electronic device may be a smart terminal, and its internal structure diagram may be as follows: Figure 8As shown. The electronic device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a network routing optimization method based on particle swarm optimization and simulated annealing is implemented, and the method includes:
[0256] The distributed network is represented as a graph with network devices as nodes and communication links as edges. Each edge is assigned a corresponding weight, which represents the parameters of delay, bandwidth and packet loss rate.
[0257] Create multiple particles and initialize the particle swarm. Each particle in the particle swarm represents a path combination from the source node to the destination node.
[0258] Adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm;
[0259] The current global best particle is locally optimized according to the simulated annealing algorithm.
[0260] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the electronic device to which the scheme of the present invention is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0261] On the other hand, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, implements a network routing optimization method based on particle swarm optimization and simulated annealing, comprising:
[0262] The distributed network is represented as a graph with network devices as nodes and communication links as edges. Each edge is assigned a corresponding weight, which represents the parameters of delay, bandwidth and packet loss rate.
[0263] Create multiple particles and initialize the particle swarm. Each particle in the particle swarm represents a path combination from the source node to the destination node.
[0264] Adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm;
[0265] The current global best particle is locally optimized according to the simulated annealing algorithm.
[0266] In another aspect, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and when the processor executes the computer instructions, a network routing optimization method based on particle swarm optimization and simulated annealing is implemented, the method comprising:
[0267] The distributed network is represented as a graph with network devices as nodes and communication links as edges. Each edge is assigned a corresponding weight, which represents the parameters of delay, bandwidth and packet loss rate.
[0268] Create multiple particles and initialize the particle swarm. Each particle in the particle swarm represents a path combination from the source node to the destination node.
[0269] Adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm;
[0270] The current global best particle is locally optimized according to the simulated annealing algorithm.
[0271] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory.
[0272] By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0273] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0274] The above-described embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.
Claims
1. A network routing optimization method based on particle swarm optimization and simulated annealing, characterized in that: The method comprises: The distributed network is represented as a graph with network devices as nodes and communication links as edges, and a corresponding weight is assigned to each edge, where the weight represents the parameters of delay, bandwidth and packet loss rate; Creating a plurality of particles and initializing a particle swarm, wherein each particle of the particle swarm represents a path combination from a source node to a destination node; Adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm; The current global best particle is locally optimized according to the simulated annealing algorithm.
2. The network routing optimization method based on particle swarm optimization and simulated annealing according to claim 1, characterized in that: The distributed network is represented as a graph with network devices as nodes and communication links as edges, and a corresponding weight is assigned to each edge, including: Identify all devices on the network and assign a unique identifier to each device; For each pair of directly connected devices, create an edge and assign it a weight; Store node and edge information according to the graph data structure; Obtain real-time monitoring data of network performance indicators and adjust the graph structure and edge weights according to changes in network topology.
3. The network routing optimization method based on particle swarm optimization and simulated annealing according to claim 2, characterized in that: The method uses network devices as nodes and communication links as edges to represent the distributed network as a graph, and assigns a corresponding weight to each edge, and also includes: The constructed graph is visualized based on graphical tools to intuitively identify network bottlenecks and optimization points.
4. The network routing optimization method based on particle swarm optimization and simulated annealing according to claim 3, characterized in that: The step of creating multiple particles and initializing a particle swarm includes: Creating a plurality of particles, each particle including path information, a position in a search space, a speed, and a fitness value; Generate initial paths by random selection or based on existing heuristic algorithms; Determine the number of particles based on the size and complexity of the network; Assigning each particle a randomly generated path or a path generated by a heuristic algorithm and initializing its velocity to zero, which represents the speed and direction of the particle moving in the search space; Evaluate the fitness of each particle's path; Array or linked list-based data structures store and manage particle information.
5. The network routing optimization method based on particle swarm optimization and simulated annealing according to claim 4, characterized in that: The fitness evaluation of the path of each particle includes: Determine the total delay of the particle path based on the sum of the delays of each edge in the path; Compare the bandwidth values of all edges in the path, and express the minimum bandwidth value in the path as the bandwidth of the path; Analyze the historical performance data of each link in the path and calculate the packet loss rate or jitter value of the path to indicate the stability of the path; Based on the latency, bandwidth, and stability of each particle, the fitness value of each particle is calculated to evaluate the quality of each particle.
6. The network routing optimization method based on particle swarm optimization and simulated annealing according to claim 5, characterized in that: The speed and position update rules based on the particle swarm optimization algorithm adjust the state of each particle, including: Assume that each particle has a position vector and a velocity vector at the time of initialization, wherein the position vector represents the current solution of the particle in the solution space, and the velocity vector represents the movement of the particle in the next iteration; Update the particle's velocity and add the updated velocity to the current position to move the particle to the new position; In response to a particle exceeding a preset boundary, limiting the particle position within the boundary, or adjusting the particle position back to within the boundary; In response to the fitness value of the current particle being better than its historical best fitness value, updating the historical best position of the particle; Based on the historical best positions of all particles, the global best position is updated.
7. The network routing optimization method based on particle swarm optimization and simulated annealing according to claim 6, characterized in that: The locally optimizing the current global best particle according to the simulated annealing algorithm includes: Generate a neighborhood solution based on the current global best particle; Calculate the fitness value of the neighborhood solution and compare the fitness value of the neighborhood solution with the fitness value of the current global best particle; According to the Metropolis criterion, determine the probability of accepting the neighborhood solution; After each iteration, the preset initial temperature is gradually reduced; In response to reaching the maximum number of iterations or the temperature dropping to a preset threshold, the particle with the highest fitness is determined as the final routing strategy.
8. A network routing optimization device based on particle swarm optimization and simulated annealing, characterized in that: include: A graph building module is used to represent the distributed network as a graph with network devices as nodes and communication links as edges, and to assign corresponding weights to each edge, wherein the weights represent parameters of delay, bandwidth, and packet loss rate; An initialization module, used to create multiple particles and initialize a particle swarm, each particle of the particle swarm represents a path combination from a source node to a destination node; An adjustment module is used to adjust the state of each particle based on the speed and position update rules of the particle swarm optimization algorithm; The optimization module is used to locally optimize the current global best particle according to the simulated annealing algorithm.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the network routing optimization method based on particle swarm optimization and simulated annealing according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the network routing optimization method based on particle swarm optimization and simulated annealing according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Adaptive routing method of two-dimensional on-chip network based on particle swarm algorithm
CN108183860A
Data center flow scheduling method based on load balancing
CN110891019A
Cited By
Photovoltaic data management method based on ad hoc network and related device
CN120263809A
Credible dynamic load balancing method of data center network based on SDN (Software Defined Network)
CN120512401A
Cloud native assembly type application construction method and device supporting dynamic combination
CN121209864A
Electric meter data acquisition optimization method and system based on CPU occupancy rate
CN121967300A
A CPU occupancy-based power meter data acquisition optimization method and system
CN121967300B