A similarity retrieval method based on improved particle swarm algorithm
By introducing dynamic weights and adaptive learning factors into the particle swarm algorithm, combined with the KNN algorithm, the problem of local optimality and fixed weights in the similarity retrieval of the traditional particle swarm algorithm is solved, the retrieval efficiency and quality are improved, and the global search is enhanced. Ability to achieve more efficient similar case retrieval.
Patent Information
- Application Number
- CN202210278670.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-03-21
AI Technical Summary
The traditional particle swarm algorithm is prone to falling into local optima during similarity retrieval, and the fixed weights affect the retrieval efficiency when the number of cases increases. The learning factors cannot be adjusted according to iterations, which affects the convergence speed.
The improved particle swarm algorithm is used, dynamic weights and adaptive learning factors are introduced, the learning factors are adjusted through the trigonometric function with changing number of iterations, and the KNN algorithm is combined for weight fitting to improve the global search capability of the algorithm.
It improves the quality and retrieval efficiency of similar cases, enhances the global search capability of the algorithm, increases the probability of finding the optimal solution, and reduces prediction errors.
Smart Images

Figure CN114756568B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of similar case retrieval, and in particular to a similarity retrieval method based on an improved particle swarm algorithm. Background Art
[0002] Case similarity retrieval is to find cases similar to the target case in existing cases based on the target case. Usually, a similarity algorithm is used to retrieve the most similar cases. The particle swarm algorithm is a more commonly used similarity retrieval algorithm. The traditional particle swarm algorithm is prone to fall into local optimality, resulting in poor retrieval efficiency, and the use of fixed weights will affect the similarity retrieval efficiency when the number of cases increases. The weights need to be adjusted according to the case library to have the best fitness for different fitness functions.
[0003] The prior art has the following problems:
[0004] 1) Fixed weights affect retrieval performance;
[0005] 2) The learning factor cannot be changed according to the iteration, which affects the convergence speed. Summary of the invention
[0006] In view of the above problems, the present invention proposes a similarity retrieval method based on an improved particle swarm algorithm.
[0007] The technical solution adopted by the present invention is:
[0008] A similarity retrieval method based on an improved particle swarm algorithm, the method comprising:
[0009] Step S1: Initialize the population particles: Initializing the population particles includes setting the population size N, randomly setting the initial position and initial speed of each particle, and setting the number of iterations k and the maximum number of iterations T of the particle. max , set the particle swarm algorithm inertia coefficient w d Range, randomly select a set of inertia coefficients w d ;
[0010] Step S2: Fitness calculation, calculating the fitness value f(x) of each particle;
[0011] Step S3: Find the optimal individual P of the particle besti and the population optimal g besti , record the individual optimal and population optimal particle positions;
[0012] Step S4: Use the improved particle swarm algorithm to update the particle position and introduce the inertia coefficient w d, update the learning factor, update the particle position, calculate and sort the fitness value of the particles after iteration, and update the individual optimal and group optimal values of the particles. The learning factor adopts a trigonometric function with the number of iterations k as the independent variable, and the weight of the particle swarm algorithm adopts a dynamic weight;
[0013] Step S5: Determine whether the number of iterations k reaches the maximum number of iterations T max ,
[0014] If k is less than T max , then k+1, and repeat step S4;
[0015] If k is equal to T max , then output and save the optimal n particle positions of the population as n similar cases, and record the fitness function value f best (x i );
[0016] Step S6: Parameter fitting, use the KNN algorithm to fit n similar cases and record the weight of the KNN algorithm
[0017] Step S7: Effect evaluation, setting the evaluation threshold. If the evaluation effect meets the evaluation threshold, the process ends. If not, proceed to step S4. The inertia weight w of the particle swarm algorithm in step S4 is d Use the weights of the KNN algorithm in step S6
[0018] Further, the learning factor of the improved particle swarm algorithm in step S4 is set to:
[0019]
[0020]
[0021] Among them, c max =2, c min =1, k is the number of iterations, T max is the maximum number of iterations, c1 and c2 vary between [1, 2].
[0022] Furthermore, the weight of the KNN algorithm in step S6 The calculation is done using the formula:
[0023]
[0024] Among them, D i The distance between the target case and the i-th case, n is the similar case retrieved in step 5, i = {1, 2, ..., n}.
[0025] Furthermore, the fitness calculation method of step S2 and step S4 is set to at least one of the determination coefficient or mean square error, mean absolute percentage error or mean error.
[0026] Furthermore, the process of searching for the optimal individual and population of particles in step S3 and step S4 is as follows:
[0027] Individual optimality, the fitness function value f(x i ) and the best position P calculated previously besti If the current fitness function value f(x i ) is less than the fitness value of the best position, then update the particle position and fitness value f(x i ), update the current position value P besti And the fitness function value f(x i );
[0028] The group is optimal, and the fitness function value f(x i ) and the best position g that all particles pass through besti If the current fitness function value f(x i ) is smaller, then the current particle position and fitness value f(x i ) is updated to the current position value and fitness value f(x i ), record the coordinate value of the dataset at this location.
[0029] The improved particle swarm algorithm uses MAPE, MSE, MAE, R 2 At least one of the four adaptive functions is used for fitness evaluation. For example, the other formula parameters have the same meaning as the MAPE parameters and will not be discussed further.
[0030]
[0031] Where, T max is the maximum number of iterations;
[0032] x forecast (i) Improve the prediction value of particle swarm optimization;
[0033] x real (i) The actual value of the target case to be compared;
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] (1) The improved PSO algorithm uses dynamic weights. Unlike traditional case retrieval, all weights obtained each time a case is retrieved are weights that have been power-fitted after the last case retrieval, which is beneficial to improving the global search capability of the algorithm. Therefore, the quality of similar cases retrieved is also improved accordingly.
[0036] (2) The learning factor in the PSO algorithm is used to adjust the step size of the particle swarm algorithm in the learning process. During the iteration process, c1 represents the extent to which the particle is affected by the "self-cognitive experience", and c2 represents the extent to which the particle is affected by the "group social experience". When c1 is 0, it means that the particle is only affected by social experience; when c2 is 0, it means that the particle is only affected by self-experience. Therefore, the selection of c1 and c2 should not be too large or too small. When c1 and c2 are too large, the optimal solution may be missed; when c1 and c2 are too small, the optimal solution cannot be found. The conventional particle swarm algorithm sets c1 and c2 to fixed values. The particles do not have the ability to self-adjust during the iteration process, and the algorithm effect is not good. The present invention sets the learning factor as a trigonometric function that changes dynamically with the number of iterations. In the early stage of the search, the fitness function value of the particle is small, indicating that the particle is gradually moving toward the optimal solution. At this time, the influence of "group social experience" should be increased, that is, as the learning factor c2 increases, c1 decreases; the fitness function value of the particle increases with the number of iterations, indicating that the particle is gradually moving toward the global optimal solution. At this time, the influence of "self-cognitive experience" should be increased, that is, as the learning factor c2 decreases, c1 increases. Therefore, the probability of the PSO algorithm finding the optimal solution can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 The present invention provides a similarity retrieval method based on an improved particle swarm algorithm;
[0039] Figure 2 Traditional particle swarm algorithm simulation results;
[0040] a) MAPE evaluation results; b) MSE evaluation results; c) MAE evaluation results; d) R2 evaluation results;
[0041] Figure 3 Improved particle swarm algorithm simulation results;
[0042] a) MAPE evaluation results; b) MSE evaluation results; c) MAE evaluation results; d) R2 evaluation results; DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions 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. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0044] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. 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.
[0045] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0046] In the description of the present invention, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance. In addition, the terms "horizontal", "vertical", etc. do not mean that the components are required to be absolutely horizontal or suspended, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", and does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0047] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0048] Reference Figures 1 to 3 Shown
[0049] A similarity retrieval method based on an improved particle swarm algorithm, the method comprising:
[0050] Step S1: Initialize the population particles: Initializing the population particles includes setting the population size N, randomly setting the initial position and initial speed of each particle, and setting the number of iterations k and the maximum number of iterations T of the particle. max , set the particle swarm algorithm inertia coefficient w d The range is 0-0.33333, and a set of weights w is randomly selected in the set inertia coefficient d ;
[0051] Step S2: Fitness calculation, calculating the fitness value f(x) of each particle;
[0052] Step S3: Find the optimal individual P of the particle besti and the population optimal g besti , record the individual optimal and population optimal particle positions;
[0053] Step S4: Use the improved particle swarm algorithm to update the particle position and introduce the inertia coefficient w d , update the learning factor, update the particle position, calculate and sort the fitness value of the particles after iteration, and update the individual optimal and group optimal values of the particles. The learning factor adopts a trigonometric function with the number of iterations k as the independent variable, and the weight of the particle swarm algorithm adopts a dynamic weight;
[0054] Step S5: Determine whether the number of iterations k reaches the maximum number of iterations T max ,
[0055] If k is less than T max , then k+1, and repeat step S4;
[0056] If k is equal to T max , then output and save the optimal n particle positions of the population as n similar cases, and record the fitness function value f best (x i ).
[0057] Step S6: Parameter fitting, use the KNN algorithm to fit n similar cases and record the weight of the KNN algorithm
[0058] Step S7: effect evaluation, setting the evaluation threshold. If the effect evaluation result meets the requirement of setting the evaluation threshold, it ends. If it does not meet the requirement, it is fed back to step S4. In step S4, the inertia coefficient w of the improved particle swarm algorithm is d Use the weights of the KNN algorithm in step S6
[0059] Preferably, the learning factor of the improved particle swarm algorithm in step S4 is set to:
[0060]
[0061]
[0062] Among them, c max =2, c min =1, k is the number of iterations, T max is the maximum number of iterations, c1 and c2 vary between [1, 2].
[0063] Preferably, the weight of the KNN algorithm in step S6 is The calculation is done using the formula:
[0064]
[0065] Among them, D i The distance between the target case and the i-th case, n is the similar case retrieved in step 5, i = {1, 2, ..., n}.
[0066] D i The distance between the target case and the i-th case uses the spatial free decay algorithm, as follows:
[0067]
[0068] Where n is the number of similar cases;
[0069] D i (x t , x i ) The distance between the target case and the i-th case;
[0070] f si The center frequency of the ith case;
[0071] f t The center frequency of the target case;
[0072] l si The difference in level of the ith case;
[0073] l t The difference in level of the target case;
[0074] d si The ratio of the distances of the ith case;
[0075] d t ratio of the distances to the target case;
[0076] w 1d w 2d w 3d Feature weights.
[0077] Preferably, the fitness calculation method of step S2 and step S4 is set to at least one of the determination coefficient or mean square error, mean absolute percentage error or mean error.
[0078] Preferably, the process of searching for the optimal individual particle and the optimal population particle in step S3 and step S4 is as follows:
[0079] Individual optimality, the fitness function value f(x i ) is compared with the fitness value of the best position calculated previously. If the current fitness function value f(x i ) is less than the fitness value of the best position, then update the particle position and fitness value f(x i ), update the current position value and fitness function value f(x i );
[0080] The optimal group, comparing the fitness function value f(x i ) and the fitness value of the best position passed by all particles. If the current fitness function value f(x i ) is smaller, the current particle position and fitness value are updated to the current position value and fitness value f(x i ), record the coordinate value of the dataset at this location.
[0081] Example
[0082] The implementation process of the adaptive knowledge engine technology is simulated. The target case is obtained by processing the data collected by the receiver and analyzing and refining the input information from the receiver. The improved particle swarm algorithm is used to retrieve similar cases in the existing case library, and the retrieved similar cases are output. The actual effect is obtained through result evaluation.
[0083] Preferably, each time a case is retrieved, the weight used is the optimal weight of the last case retrieval. Appropriate weights are conducive to improving the global search capability of the algorithm. The weight values used can change with the dynamic increase of the case library, and the quality of similar cases retrieved is constantly improved.
[0084] It is necessary to randomly select some cases as the data set, and not all the data as the data set, because using all the cases will reduce the reasoning efficiency. This is conducive to improving the retrieval efficiency, and selecting some data sets can reduce the time. When randomly selecting cases, try to select multiple types of cases, so that the interference effect will not be affected by too single cases. When using weights for the first time, a set of weights is randomly generated for calculation. As the number of iterations of the particle swarm algorithm increases, the optimal weight value is finally generated.
[0085] Preferably, the setting parameters in step S6 are power parameters, level, and distance, wherein the interference power is used as the main parameter, and fitting includes the following steps:
[0086] The interference power of n similar cases, i.e., similar case n obtained in step S5, is weighted averaged as the interference power of the interference target case, and the formula is as follows:
[0087]
[0088]
[0089] In the formula, interference power on the target case;
[0090] P i The interference power of the ith similar case;
[0091] The weight of the KNN algorithm is used as the optimal weight and inertia coefficient to participate in the next iteration of the particle swarm algorithm;
[0092] D i The distance between the target case and the i-th case. The target case is the case that needs to be compared and retrieved to be similar to it.
[0093] D i The distance between the target case and the i-th case uses the spatial free decay algorithm, as follows:
[0094]
[0095] Where n is the number of similar cases;
[0096] D i (x t , x i ) The distance between the target case and the i-th case;
[0097] f si The center frequency of the ith case;
[0098] f t The center frequency of the target case;
[0099] l si The difference in level of the ith case;
[0100] l t The difference in level of the target case;
[0101] d si The ratio of the distances of the ith case;
[0102] d tratio of the distances to the target case;
[0103] w 1d w 2d w 3d The feature weights are reasonably allocated based on the inertia weights used in this iteration and the importance of the three parameters frequency, level, and distance in the design.
[0104] The improved particle swarm algorithm adopts adaptive functions MAPE, MSE, MAE, R 2 At least one of the advantages of the improved particle swarm algorithm compared with the conventional particle swarm algorithm is as follows Figure 2 , Figure 3 , the statistics are shown in Table 1.
[0105] Table 1 Traditional PSO algorithm and improved PSO algorithm
[0106] Evaluation Method Traditional PSO algorithm Improved PsO algorithm MAPE 3.83624 3.83618 MSE 146.249 146.151 MAE 7.4263 7.4181 <![CDATA[R 2 ]]> 0.986427 0.986987
[0107] The analysis of the evaluation index results is shown in Table 1. Compared with the traditional PSO algorithm, the smaller the MAPE, MSE and MAE values of the improved PSO algorithm are, the better the prediction effect of the PSO algorithm is. The value range of R2 is [0, 1]. When the value of R2 is larger, the prediction effect is better; the smaller the value of R2 is, the worse the prediction effect is. That is, the larger the value of R2 is, the better the interference power prediction effect is.
[0108] The MAPE index decreased by 0.00006, a decrease of 0.006%; the MSE index decreased by 0.098, a decrease of 9.8%; the MAE index decreased by 0.0082, a decrease of 0.82%; R 2 The index was improved by 0.00056, and the result was as high as 0.056%. It can be clearly seen that the improved PSO algorithm has a better prediction effect.
[0109] Simulation results: In the improved PSO case retrieval algorithm, when T max is 50; the optimal inertia weight coefficient W output d is [0.464160, 0.050000, 0.535840]; f best (x i ) The fitness function value is 146.151, and the simulation results are shown in Figure 2 , Figure 3 .
[0110] In the effect evaluation in step S7, for the adaptive knowledge engine technology cited, successful interference means that the communication receiving module cannot receive the complete electromagnetic signal. By adjusting the inertia weight coefficient according to the evaluation result, the interference rate and time efficiency can be improved.
[0111] Table 2 Simulation results
[0112] Simulation scenario Interference rate Decision time(s) No decision 80.86% 8.23 This article decision engine 93.67% 1.97
[0113] From Table 2, we can see that the interference rate of the decision engine in this paper is 93.67%, the decision time is 1.97s, and the performance
[0114] It is superior to a system without decision-making because the adaptive engine system can make decisions by selecting appropriate parameters based on electromagnetic signals through algorithms, thereby increasing the interference rate and reducing the decision-making time.
[0115] The above is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent change made to the above embodiment according to the technical essence of the invention still falls within the protection scope of the technical solution of the present invention.
Claims
1. A similarity retrieval method based on improved particle swarm algorithm, characterized in that: The method comprises: Step S1: Initialize the population particles: Initializing the population particles includes setting the population size N, randomly setting the initial position and initial speed of each particle, and setting the number of iterations k and the maximum number of iterations T of the particle. max , set the particle swarm algorithm inertia coefficient w d Range, randomly select a set of inertia coefficients w d ; Step S2: Fitness calculation, calculating the fitness value f(x) of each particle; Step S3: Find the optimal individual P of the particle besti and the population optimal g besti , record the individual optimal and population optimal particle positions; Step S4: Use the improved particle swarm algorithm to update the particle position and introduce the inertia coefficient w d , update the learning factor, update the particle position, calculate and sort the fitness values of the particles after iteration, and update the individual optimal and group optimal values of the particles. The learning factor adopts a trigonometric function with the number of iterations k as the independent variable; Step S5: Determine whether the number of iterations k reaches the maximum number of iterations T max , If k is less than T max , then k+1, and repeat step S4; If k is equal to T max , then output and save the optimal n particle positions in the population as n similar cases, and record the fitness function value f best (x i ); Step S6: Parameter fitting: use the KNN algorithm to fit n similar cases and record the weight w of the KNN algorithm. p ; Step S7: effect evaluation, setting the evaluation threshold. If the effect evaluation result meets the requirement of setting the evaluation threshold, it ends. If it does not meet the requirement, it is fed back to step S4. In step S4, the inertia coefficient w of the improved particle swarm algorithm is d Use the weight w of the KNN algorithm in step S6 p ; The learning factor of the improved particle swarm algorithm in step S4 is set to: Among them, c max =2, c min =1, k is the number of iterations, T max is the maximum number of iterations, c1 and c2 vary between [1, 2]; The weight w of the KNN algorithm in step S6 p The calculation is done using the formula: Among them, D i The distance between the target case and the i-th case, n is the similar case retrieved in step 5, i = {1, 2, ..., n}; The interference power of n similar cases, i.e., similar case n obtained in step S5, is weighted averaged as the interference power of the interference target case, and the formula is as follows: Where P t n interference power on the target case; P i The interference power of the ith similar case; w p The weight of the KNN algorithm is used as the optimal weight and inertia coefficient to participate in the next iteration of the particle swarm algorithm; D i The distance between the target case and the i-th case. The target case is the case that needs to be compared and retrieved to be similar to it. D i The distance between the target case and the i-th case uses the spatial free decay algorithm, as follows: Where n is the number of similar cases; D i (x t ,x i ) The distance between the target case and the i-th case; f si The center frequency of the ith case; f t The center frequency of the target case; l si The difference in level of the ith case; l t The difference in level of the target case; d si The ratio of the distances of the ith case; d t ratio of the distances to the target case; w 1d w 2d w 3d The feature weights are reasonably allocated based on the inertia weights used in this iteration and the importance of the three parameters frequency, level, and distance in the design.
2. The similarity retrieval method based on improved particle swarm algorithm according to claim 1, characterized in that: The fitness calculation method in step S2 and step S4 is set to at least one of the determination coefficient, mean square error, mean absolute percentage error or mean error.
3. A similarity retrieval method based on improved particle swarm algorithm according to claim 2, characterized in that: The process of searching for the optimal individual particle and the optimal population particle in step S3 and step S4 is as follows: Individual optimality, the fitness function value f(x i ) and the best position P calculated previously besti If the current fitness function value f(x i ) is less than the fitness value of the best position, then update the particle position and fitness value f(x i ), update the current position value P besti And the fitness function value f(x i ); The group is optimal, and the fitness function value f(x i ) and the best position g that all particles pass through besti If the current fitness function value f(x i ) is smaller, then the current particle position and fitness value f(x i ) is updated to the current position value and fitness value f(x i ), record the data coordinate value at this location.
Citation Information
Patent Citations
A modified particle swarm intelligent optimization method for solving high-dimensional optimization problems of large oil and gas production systems
AU2020103709A4
Self-adaptive particle swarm optimization (PSO)-based particle filter tracking method
CN104036525A
