Design method of glowworm swarm optimization algorithm based on ternary optical computer
By improving the population initialization of the firefly algorithm, introducing dynamic step size and balance over-boundary adjustment, and utilizing the parallelism of a ternary optical computer, the problems of slow convergence speed and easy getting trapped in local optima of the classic firefly algorithm are solved, achieving more efficient solution and faster convergence.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUYANG NORMAL UNIVERSITY
- Filing Date
- 2023-04-19
- Publication Date
- 2026-04-24
AI Technical Summary
The classic firefly algorithm suffers from slow convergence, a tendency to get stuck in local optima, and large solution errors.
The chaotic sequence is generated by the infinite folding iterative chaotic mapping method for population initialization. Adaptive dynamic step size and balance over-boundary adjustment are introduced. The parallelism and bit-assignable property of the ternary optical computer are utilized to improve the parallel strategy and communication method of the firefly algorithm.
It improves the algorithm's optimization ability and convergence speed, reduces the probability of getting trapped in local optima, and enhances solution efficiency and accuracy.
Smart Images

Figure CN116484903B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of firefly algorithms, and more particularly to a design method for firefly algorithms based on ternary optical computers. Background Technology
[0002] The firefly algorithm, inspired by the heuristic optimization algorithm based on the flickering of fireflies at night, was first proposed by Professor Yang of Cambridge University in 2008. In the firefly algorithm, the position of the firefly represents a solution to the objective function. Each firefly moves closer to a relatively brighter firefly to achieve population optimization, thereby finding the optimal solution. The firefly algorithm has seen increasing applications in recent years, and as an emerging biological intelligence algorithm, its research and innovation are pioneering. However, the classic firefly algorithm suffers from drawbacks such as slow convergence speed, susceptibility to getting trapped in local optima, and large solution errors. To address these issues, an improved firefly algorithm was designed and implemented, and this improved algorithm was optimized using a ternary optical computer. Summary of the Invention
[0003] The purpose of this invention is to provide a design method for a firefly algorithm based on a ternary optical computer to solve the above-mentioned technical problems.
[0004] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0005] The method for improving the firefly algorithm includes the following steps:
[0006] 1) The chaotic sequence is generated by the infinite folding iterative chaotic mapping method, as shown in the following formula:
[0007] u m+1 =sin(k / u) m ), k∈(0,+∞);
[0008] Where k is a random number greater than 0;
[0009] The classic firefly algorithm generally uses random number generation to initialize the population. In the improved firefly algorithm, a specific chaotic sequence is used instead of the original method. That is, a large range of random number seeds are used to generate k, and a large number of chaotic random numbers are generated through multiple iterations of the formula. These chaotic random numbers are then superimposed on the search space as the initial position of all fireflies.
[0010] 2) An adaptive dynamic step size is introduced, which adjusts the step size dynamically as the number of iterations increases, as shown in the following formula:
[0011] c n+1 =c n ·(1+e -n );
[0012] Where n is the number of iterations, c n Let c be the step size when the number of iterations is n. As the number of iterations n increases, c... n The coefficient gradually decreases and approaches 1. The increase in step size will gradually level off as the algorithm runs and stabilizes. The whole process can adapt to the environment requirements where the algorithm needs to gradually increase the optimization range from beginning to end and eventually stabilize.
[0013] 3) Introduce an out-of-bounds adjustment for balance, the formula of which is shown below:
[0014]
[0015] Balanced out-of-bounds adjustment not only brings out-of-bounds fireflies back into the effective search space, but also, compared to direct regression to the boundary, this readjustment of individual positions is more uniform and reasonable, optimizing the search conditions for fireflies and improving the algorithm's solution efficiency.
[0016] The design method of the improved firefly algorithm based on ternary optical computer includes using the parallelism of ternary optical computer to improve the running speed and communication method of the algorithm, using different parallel strategies for different stages of the algorithm to allocate resources reasonably. Among them, inter-process communication between processors can also enable individuals in different processors to communicate with each other and mutate and cross-merge on each other's basis.
[0017] Explanation of algorithm identifiers and their abbreviations:
[0018] Firefly Algorithm (FA)
[0019] Modified Firefly Algorithm (MFA);
[0020] Ternary Optical Computer (TOC);
[0021] Firefly Algorithm-Ternary Optical Computer (FA-TOC) based on ternary optical computer optimization;
[0022] This improved Firefly Algorithm (MFA-TOC) is optimized based on a ternary optical computer.
[0023] The beneficial effects of this invention are:
[0024] This invention leverages the gigantic nature, parallelism, and bit-based allocatability of ternary optical computers to improve upon the classic firefly algorithm. The improvement primarily employs randomization of the chaotic mapping of the initial population position, the introduction of an adaptive step size, and balance out-of-bounds adjustments. Experimental results demonstrate that the improved firefly algorithm based on ternary optical computers exhibits enhanced optimization capabilities and increased convergence speed. Attached Figure Description
[0025] Figure 1 The flowchart is shown below for the Firefly algorithm.
[0026] Figure 2 Flowchart of the improved parallel firefly algorithm;
[0027] Figure 3 The graph of the test function;
[0028] Figure 4 The fitness curves of each algorithm in different functions; Detailed Implementation
[0029] To make the technical means, creative features, achieved objectives, and effects of this invention easier to understand, the invention is further described below with reference to specific embodiments and accompanying drawings. However, the following embodiments are merely preferred embodiments of this invention and not all embodiments. Other embodiments obtained by those skilled in the art based on the embodiments described herein without creative effort are all within the protection scope of this invention.
[0030] Specific embodiments of the present invention are described below with reference to the accompanying drawings.
[0031] Explanation of the classic firefly algorithm:
[0032] Assume each firefly has three attributes: position, brightness, and attractiveness. The firefly's position represents a solution to the objective function, and its brightness represents the quality of the objective function value. The attractiveness of a relatively bright firefly to other dimmer fireflies is inversely proportional to the distance between them and directly proportional to the firefly's brightness. This attractiveness causes dimmer fireflies to move towards brighter fireflies, and the distance they move is proportional to the magnitude of the attractiveness. The globally brightest firefly moves randomly.
[0033] The relative brightness of firefly i with respect to firefly j ij for:
[0034]
[0035] Where β is the light absorption constant, h ij Let I be the Euclidean distance between two fireflies. iLet be the absolute brightness of firefly i, which is the objective function value of its position.
[0036] The relative attractiveness α of firefly i to firefly j ij for:
[0037]
[0038] Where α0 is h ij The attraction at which = 0, also known as the maximum attraction, is a constant.
[0039] Firefly j moves towards firefly i because it is attracted to firefly i, and its position is updated accordingly. The formula for updating the position of j is:
[0040] pos j (n+1)=pos j (n)+α ij (pos i (n)-pos j (n))+c(rand-0.5)
[0041] Where n is the number of iterations, pos j (n+1) represents the position of firefly j at the n+1th iteration of the algorithm, c is the step size, which is a constant, and rand is a random number uniformly distributed in the interval [0, 1]. This term serves to introduce randomness and increase diversity, thereby improving the optimization efficiency.
[0042] Please see Figure 1 The classic firefly algorithm execution process is described as follows:
[0043] Step 1: Determine population parameters and perform random population initialization;
[0044] Step 2: Calculate the fitness value of each individual and sort them to obtain the location of the firefly with the highest brightness;
[0045] Step 3: Determine if the iteration has ended, i.e., whether the maximum number of iterations has been reached. If not, proceed to step 4; otherwise, proceed to step 5.
[0046] Step 4: Through The relative brightness of fireflies can be obtained by comparison, and then by... The relative attractiveness of fireflies can be obtained, and then through pos j (n+1)=pos j (n)+α ij (pos i (n)-pos j The position and brightness of the firefly are updated using the formula (n))+c(rand-0.5), and then the process jumps to the second step.
[0047] Step 5: Output the brightness value and position of the brightest firefly to obtain the optimal solution.
[0048] Example 1
[0049] The improvement is based on the classic firefly algorithm, mainly through three aspects: initial population chaos randomization, introduction of dynamic adaptive step size and balance out-of-bounds adjustment.
[0050] ① For initial population chaos randomization:
[0051] Chaotic mapping is often used to generate chaotic sequences, which are random sequences generated by simple deterministic systems. These sequences are characterized by ergodicity, randomness, and sensitivity to initial conditions. In the field of intelligent optimization, chaotic mapping is frequently used to replace traditional random number generation methods. Numerous experiments have demonstrated that using chaotic sequences for population initialization, selection, crossover, and mutation positively impacts the entire algorithm's execution and often yields superior results compared to traditional random number generation.
[0052] Among various chaotic mapping methods, the chaotic sequence generated by the Infinite Folding Iterative Chaotic Mapping (ICMIC) method has the advantages of simple description, fewer restrictions, and strong ergodicity compared to other chaotic sequences. Therefore, the Infinite Folding Iterative Chaotic Mapping (ICMIC) method is selected to generate chaotic sequences, and its formula is shown below:
[0053] u m+1 =sin(k / u) m ),k∈(0,+∞)
[0054] Where k is a random number greater than 0.
[0055] The classic firefly algorithm typically uses random numbers to generate a seed to initialize the population. In MFA, a specific chaotic sequence, u, is used. m+1 =sin(k / u) m The original method is replaced by a random number generator with k ∈ (0, +∞). Specifically, k is first generated using a large-range random number seed, and then... m+1 =sin(k / u) m The formula k∈(0,+∞) generates a large number of chaotic random numbers through multiple iterations. These chaotic random numbers are then superimposed on the search space as the initial positions of all fireflies. Obviously, this initialization method is more ergodic and random, which will make the initial population distribution more uniform and will definitely improve the subsequent firefly optimization situation.
[0056] ② Adaptive dynamic step size:
[0057] Step size is a crucial factor affecting the search capability of an algorithm; in the Firefly algorithm, the step size is expressed as pos. j (n+1)=pos j(n)+α ij (pos i (n)-pos j In the formula (n) + c(rand-0.5), the value of c is a constant in the classic firefly algorithm, meaning the step size is fixed. A fixed step size implies that the search range remains constant throughout the algorithm's execution. However, the algorithm's iteration is a dynamic process; the firefly's position and brightness change as the algorithm progresses, and the optimization conditions for each individual also change. Therefore, using the same search step size as in the initial execution is unreasonable. Based on this, an adaptive dynamic step size is introduced. Since some individuals are prone to getting trapped in local optima and becoming slow as the algorithm executes, this significantly reduces the algorithm's optimization ability. Therefore, the step size should be adjusted to dynamically increase with the number of iterations, as shown in the following formula:
[0058] c n+1 =c n ·(1+e -n )
[0059] In the formula, n is the number of iterations, and c n This is the step size when the number of iterations is n.
[0060] As the number of iterations n increases, c n The coefficient gradually decreases and approaches 1, which means that the increase in step size will gradually level off as the algorithm runs more steadily. The whole process can adapt to the environment where the algorithm needs to gradually increase the optimization range from beginning to end and eventually reach stability.
[0061] ③ Balance over-limit adjustment:
[0062] In the classic firefly algorithm, as the number of iterations increases, some fireflies blindly leave the feasible region, causing the algorithm's search ability to decline. In order to bring them back into the search space, their positions are changed to the boundary values of the search space, as shown in the following formula:
[0063]
[0064] In the formula, pos j pos represents the location of firefly j. max and pos min These represent the upper and lower boundaries of the search space, respectively. While this operation can bring fireflies that have crossed the boundary back into the search space, adjusting all fireflies to the boundary can easily lead to localized convergence, and the search conditions for the returning fireflies are also poor.
[0065] Therefore, a balance-based over-boundary adjustment is introduced, as shown in the following equation:
[0066]
[0067] Balanced out-of-bounds adjustment not only brings out-of-bounds fireflies back into the effective search space, but also, compared to direct regression to the boundary, this readjustment of individual positions is more uniform and reasonable, which to some extent optimizes the search conditions for fireflies and thus improves the algorithm's solution efficiency.
[0068] Example 2
[0069] In this embodiment, a method based on the classic firefly algorithm using a ternary optical computer is proposed. The optical processor of a ternary optical computer has a theoretically huge number of bits and is bit-reconfigurable and bit-allocatable. This means that the optical processor resources can be divided and allocated to the optimization iteration of individual fireflies. This high parallelism solution is different from the traditional fixed-bit electronic processor and will greatly improve the convergence speed of the algorithm.
[0070] FA-TOC will improve the accuracy and convergence speed of the algorithm by utilizing the characteristics of ternary optical computers based on FA. If each initialized firefly in the algorithm is regarded as a separate solution-finding unit, their process of finding the optimal solution is independent and does not interfere with each other. This also means that giving them independent computing power and resources will improve the running efficiency.
[0071] In TOC, the total optical processor can be divided into sub-optical processors and assigned to the algorithm search unit. Since the individuals in the population do not affect each other, the different firefly solving processes can occur simultaneously on multiple sub-optical processors. Ideally, each operator should be assigned a processor.
[0072] Of course, processors that govern different firefly regions can also communicate with each other. This type of inter-population communication can improve the quality of the solution. During each iteration, the fitness value is calculated and sorted. Fireflies with better fitness will eliminate those with poorer fitness. This sorting process uses an additional storage space (recorder) under TOC to store the firefly parameters with the best fitness value. Since the fitness calculation occurs in parallel, it is possible to calculate all fireflies after each iteration in a short time, compare and sort the data, put the best fitness value of each round into the recorder, and finally select the firefly fitness values in the recorder to find the best solution and determine the position of the solution.
[0073] Using the TOC property in FA for parallel improvement, by allocating processor resources to independently enable operators and constructing recorders to quickly collect potential optimal solutions of the algorithm, the time complexity of algorithm iteration will be greatly reduced, the algorithm's solution capability will be improved, the speed at which the algorithm converges to the optimal solution will be accelerated, and the program running time will be reduced.
[0074] Example 3
[0075] In this embodiment, an improved firefly algorithm based on a ternary optical computer is proposed. The MFA algorithm itself has made logical improvements compared to the FA algorithm, mainly focusing on enhancing the algorithm's optimization ability. Therefore, the MFA algorithm can also use the parallelism of TOC to improve the algorithm's running speed and communication method. Moreover, because it has more model optimizations, parallel computing has a greater improvement on it.
[0076] Meanwhile, the existing multiprocessor parallel strategy can be further improved. For example, the first stage of the algorithm can be parallelized using multiple processors, and some populations can be merged in the second stage to reduce processor resource consumption. In other words, different parallel strategies can be used for different stages of the algorithm to allocate resources reasonably. Inter-process communication between processors can also enable individuals in different processors to communicate with each other and carry out mutation, cross-fusion and other measures on each other's basis to further increase population diversity, thereby further optimizing the algorithm.
[0077] To demonstrate that improvements to the classic firefly algorithm and TOC-based re-optimization can enhance algorithm performance, a reasonable control experiment is proposed, and a detailed analysis of the algorithm's performance in functions is conducted. This experiment mainly includes test functions, algorithm simulation experiments, and algorithm performance analysis.
[0078] ① Test function
[0079] To comprehensively evaluate the algorithm's optimization capability under different function conditions, simulation experiments were conducted using six representative standard test functions. The mathematical expressions for these functions are shown below, and their three-dimensional function graphs can be found in [link to graph]. Figure 3 :
[0080] Ackley function:
[0081]
[0082] Quartic function:
[0083]
[0084] Rastrigin function:
[0085]
[0086] Schwefel function:
[0087]
[0088] Sphere function:
[0089]
[0090] Roenbrock function:
[0091]
[0092] ② Algorithm simulation experiment
[0093] The simulation experiment relied on Professor Shen Yunfu's TOC simulation software to simulate the operating environment of the multi-bit TOC prototype system SD16. This platform includes basic operations of MSD numbers and can be used for TOC-based software development. The experimental environment was PyCharm Community Edition 2022.2.4 with a simulation program written in Python, and the Python interpreter version was 3.9.
[0094] Experimental parameters: population size 300, maximum number of iterations 2000, dimension 20;
[0095] These test functions include both single-peak and multi-peak test functions, all of which have a theoretical optimal solution of 0. Some of these functions also have dense local optimum traps, which allows for a good comparison of the ability of different algorithms to capture the global optimum. Next, we will test FA, MFA, FA-TOC, and MFA-TOC several times under the same conditions, record their optimal fitness values, calculate their average optimal fitness values, and plot the graph of the global optimal fitness value as the number of iterations increases.
[0096] Table 1 shows the final fitness values of each algorithm in different functions:
[0097]
[0098] Table 1
[0099] Depend on Figure 4 As shown in Table 1, the convergence speed of the algorithm improved based on TOC is significantly greater than that of the unimproved algorithm, and it is less likely to get trapped in local optima. At the same time, the convergence speed and optimization ability of MFA are better than those of FA. This proves that the improvement of the classic firefly algorithm has indeed improved the performance of the algorithm in all aspects, and the optimization based on TOC has further improved the optimization ability and convergence speed of the algorithm.
[0100] Furthermore, the table of algorithm fitness values reveals that the algorithms are functionally relatively stable, with the deviation between the group average and the optimal value of the entire experimental group not being particularly large. This reflects the precise differences in the capabilities of each algorithm, ruling out underestimation of algorithm capabilities due to accidental errors. However, a small difference can be observed between the optimal fitness value and the average fitness value within the same group of algorithms. This indicates some fluctuation in the algorithm's solution performance, suggesting that the algorithms still have the potential to be further improved to make their optimization capabilities more stable. Additionally, only a few algorithms reached the theoretically optimal solution for the function, highlighting the limitations of algorithms when solving complex functions and implying that there is still room for improvement.
[0101] It is important to note that the experimental data in Table 1 records the optimal fitness values of each algorithm for each function. These recorded optimal fitness values are the minimum fitness values throughout the algorithm's global iterations, occurring in the final stage of the algorithm. Each algorithm underwent multiple parallel experiments under the same conditions for each function. The average optimal fitness value was calculated by dividing the sum of the optimal fitness values obtained from multiple algorithm experiments by the number of effective experiments. For each algorithm, the image with the best fitness value from each experimental group was selected to reflect the algorithm's ability under optimal conditions. This value is uniquely recorded in the optimal fitness value column. The significance of calculating the average optimal fitness value lies in comparing the differences in the algorithms' abilities under general conditions.
[0102] ③ Algorithm performance analysis
[0103] The Ackley function has more small holes and peaks in the outer region, and its optimum near the center is a large hole, resulting in many chaotic local minima. The algorithm searches rapidly towards the center in a large, flat region, but after a certain number of iterations, it falls into a local optimum. Nevertheless, the curve still reflects its ability to find the best-fit value. The Quartic function is a multidimensional, unimodal, flat-bottomed function with random disturbances. Each algorithm exhibits varying degrees of local convergence in the later stages, but graphically, FA and FA-TOC are relatively smooth, while MFA and MFA-TOC show varying degrees of step-like changes, indicating differences in their robustness to disturbances and search capabilities. Although the Rastrigin function has many local minima and is highly multimodal, its minimum distribution is regular, which is favorable for the solutions of MFA and MFA-TOC, making it significantly different from traditional algorithms. The Schwefel and Sphere functions are classic unimodal test functions, possessing both a global minimum and a local minimum equal to the dimension. All four algorithms remained in the solution-finding state even after reaching the maximum number of iterations. Each algorithm achieved a stable optimization speed, possibly due to the mathematical properties of these two function types, making them less prone to getting trapped in local optima. MFA-TOC still converged faster than MFA, although the gap tended to widen in later stages. The Rosenbrock function's global minimum was located at the bottom of a narrow hyperbola. While its convergence trend was clear, finding the optimal solution was still difficult. This explains why the curves of all four algorithms were steep in the first stage but fell into local optima later. However, the TOC-based parallel processing algorithm still maintained a slight lead. Combining experimental results and literature, it was found that within a limited number of iterations, MFA and MFA-TOC exhibited faster convergence speeds and optimization capabilities compared to FA and FA-TOC. FA, due to its stable algorithmic concept, lacked the ability to escape local optima and was more likely to converge prematurely to a poor solution. Combining literature review and experimental results, it can be found that the improved MFA algorithm outperforms the traditional FA in key algorithmic performance metrics. Furthermore, MFA-TOC and FA-TOC, due to their inherited bit-wise allocatability and highly parallel processing capabilities from TOC, outperform their predecessors in terms of function performance. This is also confirmed in the experimental results graphs.
[0104] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely preferred examples and are not intended to limit the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for improving the firefly algorithm, characterized in that, Includes the following steps: 1) The chaotic sequence is generated by the infinite folding iterative chaotic mapping method, as shown in the following formula: in, It is a random number greater than 0; In the improved firefly algorithm, a specific chaotic sequence is used instead of the original method, and a large-scale random number seed is used for generation. A large number of chaotic random numbers are generated through multiple iterations of the formula, and these chaotic random numbers are then superimposed on the search space as the initial positions of all fireflies. 2) An adaptive dynamic step size is introduced, which adjusts the step size dynamically as the number of iterations increases, as shown in the following formula: in, For the number of iterations, For the number of iterations The step size increases with the number of iterations. The increase, The coefficient gradually decreases and approaches 1. The increase in step size will gradually level off as the algorithm runs more steadily. The whole process adapts to the environment requirements of the algorithm to gradually increase the optimization range from beginning to end and eventually reach stability. 3) Introduce an out-of-bounds adjustment for balance, the formula of which is shown below: The balance-based out-of-bounds adjustment brings out-of-bounds fireflies back into the effective search space. Compared to directly reverting them to the boundary, this readjustment of individual positions is more uniform and reasonable, optimizes the search conditions for fireflies, and improves the algorithm's solution efficiency. The parallelism of ternary optical computers is used to improve the running speed and communication method of algorithms. Different parallel strategies are used for different stages of the algorithm to allocate resources reasonably. Inter-process communication between processors can also enable individuals in different processors to communicate with each other and mutate and cross-merge on each other's basis. In TOC, the total optical processor is divided into sub-optical processors and assigned to the algorithm search unit. Since individuals in the population do not affect each other, the different firefly solving processes can occur simultaneously on multiple sub-optical processors, and each operator is assigned a processor.