A method and system for setting PID control parameters based on improved genetic algorithm
By improving the genetic algorithm combined with local optimization and global optimization methods, the PID control parameters are tuned, which solves the problems of cumbersome adjustment process and sensitive to working conditions in the existing technology, and achieves rapid and accurate adjustment of PID control parameters.
Patent Information
- Application Number
- CN202210864808.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-21
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2042-07-21
AI Technical Summary
The existing PID control parameter setting methods are cumbersome and complex, and it is difficult to achieve good setting results in complex working conditions. They are sensitive to changes in working conditions and require frequent re-tuning.
The PID control parameters are tuned by a method based on improved genetic algorithms. The specific steps include local optimization based on the previous generation parameters, obtaining the initial parameters, and then performing global optimization. If the fitness level does not reach the threshold, repeat the above process until the threshold is reached or the evolutionary algebra is terminated.
It realizes the rapid convergence of PID control parameters to the optimal value, improves the efficiency and accuracy of the setting process, and can realize online or offline self-tuning under complex working conditions.
Smart Images

Figure CN115202191B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of industrial motion control and process control, and in particular to a method and system for setting PID control parameters based on an improved genetic algorithm. Background Art
[0002] PID control is widely used in the field of industrial motion control and process control. It has the characteristics of simple algorithm, easy analysis and implementation, good robustness and high reliability. PID control can achieve very good control effect in linear, deterministic and non-time-varying control systems with known mathematical models of control targets. However, the tuning method of PID control parameters is very cumbersome and complicated. For complex actual working conditions, the tuning process is time-consuming, labor-intensive and prone to errors, and it is not easy to achieve good tuning effect. In addition, the performance of PID control is very sensitive to the parameter changes of the control target. Therefore, when the actual working conditions change, the PID control parameters often need to be re-tuned. These situations need to be improved or solved by the self-tuning technology of PID control parameters.
[0003] As an intelligent optimization algorithm, genetic algorithm can search and optimize PID parameters within a specific range, with high efficiency and optimization results, and has been widely used. Although genetic algorithm has good global search ability and will not fall into local optimum, its local search ability is poor. When it reaches the vicinity of global optimum, the search optimization speed slows down and often cannot quickly converge to the true optimal value.
[0004] Therefore, it is necessary to provide an improved technical solution to address the above-mentioned deficiencies in the prior art. Summary of the invention
[0005] The purpose of this application is to provide a method and system for tuning PID control parameters based on an improved genetic algorithm to solve or alleviate the problems existing in the above-mentioned prior art.
[0006] In order to achieve the above objectives, this application provides the following technical solutions:
[0007] The present application provides a method for adjusting PID control parameters based on an improved genetic algorithm, comprising:
[0008] Step S101, according to the n-1th generation PID control parameter, the n-2th generation PID control parameter, and the chromosome fitness corresponding to the n-1th generation PID control parameter and the chromosome fitness corresponding to the n-2th generation PID control parameter, based on a preset optimization model, locally optimize the n-th generation PID control parameter to obtain a first PID control parameter; wherein n represents the evolutionary generation of the genetic algorithm, n≥3, and n is a positive integer;
[0009] Step S102: globally optimizing the first PID control parameter to obtain a second PID control parameter;
[0010] Step S103: if the chromosome fitness of the second PID control parameter does not reach a preset fitness threshold, and n is less than or equal to a preset termination evolution generation, the second PID control parameter is used as the next generation PID control parameter of the genetic algorithm, and steps S101 to S102 are repeatedly executed to perform local optimization and global optimization on the next generation PID control parameter in sequence;
[0011] Step S104: If the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolutionary generation, the adjusted PID control parameter is output and the genetic algorithm is terminated.
[0012] Preferably, the nth generation PID control parameter is locally optimized based on a preset optimization model to obtain the first PID control parameter, which is specifically:
[0013] According to the formula:
[0014]
[0015] Calculating the first PID control parameter;
[0016] In the formula, k n represents the first PID control parameter; k n-1 represents the n-1th generation PID control parameter; k n-2 Indicates the n-2 generation PID control parameters; FIT n-1 FIT represents the chromosome fitness corresponding to the n-1th generation PID control parameters; n-2 represents the chromosome fitness corresponding to the n-2 generation PID control parameter; η is a predefined coefficient.
[0017] Preferably, the first PID control parameter is globally optimized to obtain the second PID control parameter, which is specifically:
[0018] Performing chromosome encoding on the first PID control parameter to obtain a chromosome corresponding to the nth generation PID control parameter;
[0019] The selection, crossover and mutation operations of the genetic algorithm are sequentially performed on the chromosomes corresponding to the n-th generation PID control parameters to obtain the second PID control parameters.
[0020] Preferably, the chromosome encoding of the first PID control parameter to obtain the chromosome corresponding to the n-th generation PID control parameter is specifically:
[0021] According to the first PID control parameter, according to the formula:
[0022]
[0023] Calculating a decimal parameter of the first PID control parameter;
[0024] In the formula, k n(dec) represents the decimal parameter of the first PID control parameter, k nMin represents the minimum value of the value range of the first PID control parameter; k nMax represents the maximum value of the value range of the first PID control parameter; m represents the preset chromosome encoding accuracy;
[0025] The decimal parameter of the first PID control parameter is converted into a binary system to obtain a chromosome corresponding to the nth generation PID control parameter.
[0026] Preferably, the selection, crossover and mutation operations of the genetic algorithm are sequentially performed on the chromosomes corresponding to the n-th generation PID control parameters to obtain the second PID control parameters, specifically:
[0027] Sorting the chromosomes corresponding to the n-th generation PID control parameters, and selecting the chromosomes corresponding to the n-th generation PID control parameters based on a preset selection coefficient to obtain the selected chromosomes;
[0028] Based on a preset crossover coefficient, performing a crossover operation on the selected chromosome to obtain the chromosome after crossover;
[0029] Based on a preset coefficient of variation, performing a mutation operation on the chromosome after the crossover to obtain the mutated chromosome;
[0030] The mutated chromosome is decoded to obtain the second PID control parameter.
[0031] Preferably, if the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolution generation, the adjusted PID control parameter is output and the genetic algorithm is terminated, specifically:
[0032] If the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, the PID control parameter corresponding to the maximum chromosome fitness of the second PID control parameter is selected as the adjusted PID control parameter, and the genetic algorithm is terminated;
[0033] or,
[0034] If n is greater than a preset termination evolutionary generation, the genetic algorithm is terminated, and the PID control parameter corresponding to the maximum chromosome fitness of the second PID control parameter is screened out as the adjusted PID control parameter;
[0035] The adjusted PID control parameters are output.
[0036] Preferably, the method further comprises:
[0037] When n=1, multiple values of the PID control parameter are selected within the value range of the PID control parameter as the second PID control parameter, and step S103 and subsequent steps are executed;
[0038] When n=2, the nth generation PID control parameter is used as the first PID control parameter, and step S102 and subsequent steps are executed.
[0039] The embodiment of the present application also provides a PID control parameter tuning system based on an improved genetic algorithm, comprising:
[0040] The local optimization unit is configured to locally optimize the n-th generation PID control parameter based on the n-1th generation PID control parameter, the n-2th generation PID control parameter, the chromosome fitness corresponding to the n-1th generation PID control parameter, and the chromosome fitness corresponding to the n-2th generation PID control parameter, based on a preset optimization model, to obtain a first PID control parameter; wherein n represents the evolutionary generation of the genetic algorithm, n≥3, and n is a positive integer;
[0041] a global optimization unit, configured to perform global optimization on the first PID control parameter to obtain a second PID control parameter;
[0042] an iteration unit, configured to use the second PID control parameter as the next generation PID control parameter of the genetic algorithm if the chromosome fitness of the second PID control parameter does not reach a preset fitness threshold, and n is less than or equal to a preset termination evolution generation, and repeatedly perform local optimization and global optimization on the next generation PID control parameter by the local optimization unit and the global optimization unit in sequence;
[0043] The output unit is configured to output the adjusted PID control parameter and terminate the genetic algorithm if the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolutionary generation.
[0044] Beneficial effects:
[0045] In the present application, first, according to the n-1th generation PID control parameters, the n-2th generation PID control parameters, and the chromosome fitness corresponding to the n-1th generation PID control parameters and the chromosome fitness corresponding to the n-2th generation PID control parameters, based on a preset optimization model, the n-th generation PID control parameters are locally optimized to obtain the first PID control parameters; in this way, according to the n-1th generation PID control parameters, the n-2th generation PID control parameters and their corresponding chromosome fitnesses, local optimization is performed to obtain the current generation PID control parameters, which can speed up the search optimization speed and enable the genetic algorithm to quickly converge to the optimal value.
[0046] Then, the first PID control parameter is globally optimized to obtain the second PID control parameter; if the chromosome fitness of the second PID control parameter reaches the preset fitness threshold, or n is greater than the preset termination evolution generation, the evolution is terminated and the tuned PID control parameter is output. In this way, the local optimization is combined with the global optimization of the genetic algorithm, so that the tuning process of the PID control parameter has a strong global search optimization capability and a faster local search optimization speed, and the online or offline self-tuning of the PID control parameter is realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. Among them:
[0048] Figure 1 It is the structure diagram of PID control system;
[0049] Figure 2 A flow chart of a method for setting PID control parameters based on an improved genetic algorithm according to some embodiments of the present application;
[0050] Figure 3 A technical logic diagram of a method for tuning PID control parameters based on an improved genetic algorithm according to some embodiments of the present application;
[0051] Figure 4 A schematic diagram of the structure of a tuning system for PID control parameters based on an improved genetic algorithm according to some embodiments of the present application. DETAILED DESCRIPTION
[0052] The present application will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments. Each example is provided by way of explanation of the present application and does not limit the present application. In fact, it will be clear to those skilled in the art that modifications and variations may be made in the present application without departing from the scope or spirit of the present application. For example, a feature shown or described as a part of an embodiment may be used in another embodiment to produce yet another embodiment. Therefore, it is desired that the present application includes such modifications and variations within the scope of the appended claims and their equivalents.
[0053] In order to facilitate the understanding of the present invention, PID control is briefly described as follows:
[0054] PID control refers to the comprehensive control of the proportional, integral and derivative of the deviation. The structure of a conventional PID control system is as follows: Figure 1 As shown, in a continuous system, the PID controller performs proportional, integral, and differential operations on the input error signal e(t) to give a control signal u(t).
[0055] The PID algorithm integrates the past (I), present (P) and future (D) information of the controlled quantity. It does not require much prior knowledge of the dynamic process, has strong robustness, and has satisfactory control effects. It is widely used in industrial processes.
[0056] Depend on Figure 1 The control law of the PID controller is obtained as follows:
[0057]
[0058] Written in the form of a common transfer function:
[0059]
[0060] Where: t represents time; k p is the proportionality coefficient, k i is the integration coefficient, k d is the differential coefficient, and S represents a complex number. From formula (2), we can see that the proportional coefficient k of the PID controller is p As it increases, the controller reacts more sensitively to the deviation; the integral coefficient k i The smaller the value, the more sensitive it is to the accumulated amount of deviation; the differential coefficient k d The larger the value, the more sensitive it is to the change of deviation. Therefore, by adjusting these three quantities in the controller, the expected control purpose can be achieved.
[0061] Genetic algorithms simulate optimization problems into a dynamic optimization process of natural selection of "survival of the fittest". It is a method of searching for optimal solutions by simulating the natural evolution process.
[0062] Since genetic algorithm is a search algorithm derived from evolution and genetics, the commonly used terms are explained below:
[0063] Chromosome: Chromosomes can also be called genotype individuals. A certain number of individuals constitute a population, and the number of individuals in a population is called the population size.
[0064] Gene: Gene is an element in chromosome, which is used to represent the characteristics of an individual. For example, a string of numbers (i.e. chromosome) S=1011, then the four elements 1, 0, 1, and 1 are called genes respectively.
[0065] Fitness: The degree of adaptability of each individual to the environment is called fitness. In order to reflect the adaptability of chromosomes, a function that can measure each chromosome in the problem is introduced, called the fitness function. This function is usually used to calculate the probability of an individual being used in a group.
[0066] In the related art, due to the poor local search capability of genetic algorithms, when reaching the vicinity of the global optimum, the evolution speed is slow and premature convergence is prone to occur, which limits its use in the field of PID control parameter tuning.
[0067] The present invention provides a PID control parameter tuning method based on an improved genetic algorithm, which is used to overcome the slow evolution speed problem existing in the application of traditional genetic algorithms in PID control parameter tuning. Figure 2 A flow chart of a method for setting PID control parameters based on an improved genetic algorithm according to some embodiments of the present application; Figure 3 The technical logic diagram of the method for setting the PID control parameters based on the improved genetic algorithm according to some embodiments of the present application is shown in FIG. Figure 2 , Figure 3 As shown, the method comprises the following steps:
[0068] Step S101, according to the n-1th generation PID control parameters, the n-2th generation PID control parameters, and the chromosome fitness corresponding to the n-1th generation PID control parameters and the chromosome fitness corresponding to the n-2th generation PID control parameters, based on a preset optimization model, locally optimize the n-th generation PID control parameters to obtain first PID control parameters; wherein n represents the evolutionary generation of the genetic algorithm, n≥3, and n is a positive integer.
[0069] In the embodiment of the present application, the PID control parameters may include k p is the proportionality coefficient, k i is the integration coefficient, k dis one or more of the differential coefficients. The specific parameters included in the PID control parameters are determined according to the controlled object: different controlled objects correspond to different PID control methods, resulting in different PID control parameters.
[0070] Specifically, the PID control parameters and their value ranges are determined according to the characteristics and performance requirements of the controlled object.
[0071] It should be noted that the controlled object refers to the actuator or actuator mechanism in the control system, such as control valves, motors, reducers, switching power supplies, etc. These actuators or actuator mechanisms can usually be expressed in the form of transfer functions in the control system.
[0072] The characteristics of the controlled object refer to the mechanical or electrical structure, inherent parameters and inherent characteristics of the controlled object itself, which do not change with the PID controller. For example, in an electromechanical transmission system, if a motor reducer structure is used to output the speed, the rotational inertia of the reducer will increase the order of the transfer function of the entire transmission system; the inherent parameters of the controlled object mainly include the weight of the valve, the rotor rotational inertia of the motor, the winding inductance and resistance, magnetic resistance, permanent magnet flux, the reduction ratio of the reducer, the rotational inertia of the gear, the inductance, capacitance and resistance of the switching power supply. These inherent parameters generally appear in the coefficients of the transfer function of the controlled object and determine the distribution of the zeros and poles of the transfer function on the complex plane; the zero-pole distribution of the above transfer function will further determine the inherent characteristics of the transfer function. Taking the second-order system as an example, its frequency domain characteristics include natural frequency and damping ratio, and its time domain characteristics include rise time, overshoot, adjustment time, etc.
[0073] The performance requirements of PID control refer to the characteristics of the entire system output after adjustment by the PID controller, such as the rise time of the output speed of the motor or reducer, whether there is overshoot in the output voltage of the switching power supply, etc.
[0074] According to the actual requirements of the project and based on different control objectives, the control method can be P control, PI control, PD control, PID control, etc.
[0075] If different control methods are adopted, the structure of the PID controller will change, and the PID control parameters that need to be adjusted also need to be adjusted accordingly. Therefore, the PID control parameters can be determined according to the control method. For example, the parameters contained in the P control only include the proportional coefficient k p , and the parameters contained in PID control include the proportional coefficient k p , integration coefficient k i and the differential coefficient k d .
[0076] In the embodiment of the present application, the value range of the PID control parameter can be determined by using a traditional tuning method, that is, determining the value range of the PID control parameter [k nMin , k nMax ],k n Indicates that each parameter has its own value range, k n ∈[k p , k i , k d ], so the value range is [k nMin , k nMax ] specifically includes the proportionality coefficient k p , integration coefficient k i and the differential coefficient k d The value range is: [k pMin , k pMax ]、[k iMin , k iMax ] or [k dMin , k dMax ].
[0077] In the present application embodiment, PID control parameters are adjusted based on improved genetic algorithm. It should be noted that the genetic algorithm will be repeatedly evolved (also referred to as: iteration) during operation, and each iteration will generate several chromosomes. The chromosome fitness evaluation method is used to determine the scores of all chromosomes in this iteration, to judge the fitness of these chromosomes, and then the chromosomes with low fitness are eliminated, and only the chromosomes with high fitness are retained, so that the quality of the chromosome will be better and better after several iterations.
[0078] During specific implementation, the chromosome fitness evaluation method of the genetic algorithm is determined according to different controlled objects.
[0079] As an implementation method, according to different controlled objects, the basic performance indicators of the control system can be used as the chromosome fitness evaluation method. Among them, the basic performance indicators of the control system include a small step response rise time T r , smaller peak time T p , Smaller adjustment time T s , or one or more of the smaller overshoots.
[0080] In another implementation, according to different controlled objects, the chromosome fitness evaluation method can also use the inverse of the comprehensive performance index of the control system. Among them, the comprehensive performance index includes one or more of the absolute value integral of the deviation IAE, the square integral of the deviation ISE, the time absolute deviation product integral ITAE, and the time deviation square product integral ITSE. Generally, the smaller the comprehensive performance index, the greater the fitness and the better the control effect.
[0081] In order to alleviate the problem of poor local search capability of the genetic algorithm to a certain extent, in the embodiment of the present application, a method combining local optimization with global optimization of the genetic algorithm is adopted to enable the genetic algorithm to converge quickly.
[0082] In an optional embodiment, the method first determines the current evolution generation, and then executes corresponding steps according to different current evolution generations. Specifically: when n=1, multiple PID control parameter values are selected within the value range of the PID control parameter as the second PID control parameter, and step S103 and subsequent steps are executed; when n=2, the nth generation PID control parameter is used as the first PID control parameter, and step S102 and subsequent steps are executed.
[0083] Here, when n=1, that is, when the current evolutionary generation is 1, the genetic algorithm needs to be initialized.
[0084] In practical applications, the genetic algorithm is initialized according to the population size g to determine the initial population, that is, the first generation of PID control parameters.
[0085] Specifically, according to the population size g, in the range of PID control parameters [k nMin , k nMax ] to obtain the primary population, which contains the PID control parameters with a population size of g. At this time, since n=1 corresponds to the primary population, there is no need to perform local optimization and global optimization. The PID control parameters of the current generation can be directly saved, and the chromosome fitness of the primary population can be calculated, and then step S103 and subsequent steps are executed.
[0086] It should be noted that the individuals contained in the population are called chromosomes. In the embodiment of the present application, chromosomes refer to a combination of PID control parameters.
[0087] The population size g indicates that the current generation population in the genetic algorithm contains g individuals; to facilitate the subsequent chromosome crossover, g is preferably an even number.
[0088] Each segment on the chromosome is called a gene. In the embodiment of the present application, the gene refers to each parameter in the PID control parameter, such as the proportional coefficient k p , integration coefficient k i and the differential coefficient k d .
[0089] In the embodiment of the present application, the chromosome encoding accuracy m, population size g, and termination evolution generation l used in the genetic algorithm are determined based on the tuning accuracy requirements and computational cost of the PID control parameters.
[0090] Here, the setting accuracy requirement of PID control parameters mainly refers to the number of significant digits required for PID control parameters. The more significant digits there are, the more chromosome coding accuracy m is required, that is, the more chromosome coding digits there are.
[0091] Here, the computational cost includes space cost and time cost.
[0092] Among them, space cost refers to the storage space occupied by data in the computer system. When a larger chromosome encoding precision m and a larger population size g are used, the storage space occupied by the data will increase. When a computer is used for simulation, the storage space is relatively sufficient, so the space cost may not need to be considered. However, in an actual system, if the storage space of the controller (usually a single-chip microcomputer, ARM chip, DSP chip, etc., and can be externally stored) is limited, then the space cost may need to be considered.
[0093] Time cost refers to the time consumed by the optimization process. When a larger genetic algorithm chromosome encoding accuracy m, a larger population size g, and a larger number of termination evolution generations l are used, the time cost will also increase.
[0094] When n=2, that is, the current evolutionary generation is 2, at this time, since the evolutionary generation is less than 3, it is impossible to perform local optimization. The nth (n=2) generation PID control parameter is used as the first PID control parameter and is globally optimized through a genetic algorithm, that is, executing step S102 and subsequent steps.
[0095] When n≥3, that is, the current evolutionary generation is greater than 3, the nth generation PID control parameters can be locally optimized first. Specifically, according to the penultimate generation (n-1th generation) PID control parameters, the penultimate generation (n-2th generation) PID control parameters, and the chromosome fitness corresponding to the n-1th generation PID control parameters and the chromosome fitness corresponding to the n-2th generation PID control parameters, based on the preset optimization model, the nth generation PID control parameters are locally optimized to obtain the first PID control parameters.
[0096] In some embodiments, based on a preset optimization model, the nth generation PID control parameter is locally optimized to obtain the first PID control parameter, which is specifically:
[0097] According to the formula:
[0098]
[0099] Calculate the first PID control parameter.
[0100] In the formula, k n represents the first PID control parameter; k n-1 represents the n-1th generation PID control parameter; kn-2 Indicates the n-2 generation PID control parameters; FIT n-1 Indicates the chromosome fitness corresponding to the n-1th generation PID control parameters; FIT n-2 represents the chromosome fitness corresponding to the n-2 generation PID control parameters; η is a predefined coefficient.
[0101] In specific implementation, if the first PID control parameter k obtained by local optimization is n Exceeds the value range corresponding to each parameter [k nMin , k nMax ], then according to the formula:
[0102]
[0103] For the first PID control parameter k n Adjust the range so that its value is between [k nMin , k nMax ] within.
[0104] In the formula, k nMin represents the minimum value of the value range of the first PID control parameter; k nMax Indicates the maximum value of the value range of the first PID control parameter.
[0105] In the embodiment of the present application, the PID control parameter value of the current generation is locally optimized based on a preset optimization model, which can improve the local search capability of the genetic algorithm, so that when the PID control parameter reaches the vicinity of the global optimum, the search optimization speed is accelerated, and the real optimal value is quickly converged. Compared with other local optimization methods, the optimization model provided in the embodiment of the present application has a faster iteration speed, can quickly determine the local optimal value, and the model is simple, intuitive, and easy to implement.
[0106] Step S102: globally optimize the first PID control parameter to obtain the second PID control parameter.
[0107] In some embodiments, the first PID control parameter is globally optimized to obtain the second PID control parameter, specifically: the first PID control parameter is chromosome encoded to obtain the chromosome corresponding to the nth generation PID control parameter; the genetic algorithm selection, crossover, and mutation operations are sequentially performed on the chromosome corresponding to the current generation (nth generation) PID control parameter to obtain the second PID control parameter.
[0108] In the present application, the chromosomes composed of PID control parameters are binary encoded.
[0109] Binary coding means that the gene sequence that makes up the chromosome is represented by binary numbers, which has the characteristics of simple and easy encoding / decoding, and easy crossover and mutation program implementation.
[0110] In some embodiments, chromosome encoding is performed on the nth generation (current generation) PID control parameters to obtain the chromosome corresponding to the current generation PID control parameters, specifically:
[0111] According to the first PID control parameter, according to the formula:
[0112]
[0113] Calculate the decimal parameter of the first PID control parameter.
[0114] In the formula, k n(dec) Indicates the decimal parameter of the first PID control parameter, k nMin represents the minimum value of the value range of the first PID control parameter; k nMax represents the maximum value of the value range of the first PID control parameter; m represents the preset chromosome encoding accuracy.
[0115] K n(dec) According to the rounding to the nearest integer; determine the rounded k n(dec) Is it out of the range [0, 2 m -1], if the rounded k n(dec) Out of range [0, 2 m -1], then according to the formula:
[0116]
[0117] K n(dec) Adjust it so that its value is [0, 2 m -1] range.
[0118] The decimal parameter of the first PID control parameter is converted into binary to obtain the chromosome corresponding to the nth generation PID control parameter.
[0119] In the specific implementation, first k n(dec) Convert from decimal to binary, k p(dec) , k i(dec) and k d(dec) Convert to binary k p(bin) , k i(bin) and k d(bin) , then k p(bin) , k i(bin) and k d(bin) Connect them together in order to get a binary value with a length of 3m bits, which is the chromosome code corresponding to the current generation of PID control parameters.
[0120] The use of binary encoding for chromosomes complies with the minimum character set encoding principle, which makes encoding and decoding operations simple and easy, and also facilitates the implementation of subsequent genetic operations such as crossover and mutation.
[0121] In some other embodiments, the selection, crossover, and mutation operations of the genetic algorithm are sequentially performed on the chromosomes corresponding to the n-th generation PID control parameters to obtain the second PID control parameters, specifically: the chromosomes corresponding to the n-th generation PID control parameters are sorted, and the chromosomes corresponding to the n-th generation PID control parameters are selected based on a preset selection coefficient to obtain the selected chromosomes; based on a preset crossover coefficient, a crossover operation is performed on the selected chromosomes to obtain the crossed chromosomes; based on a preset variation coefficient, a mutation operation is performed on the crossed chromosomes to obtain the mutated chromosomes; and the mutated chromosomes are decoded to obtain the second PID control parameters.
[0122] It should be noted that genetic operations include the following three basic genetic operators: selection; crossover; mutation.
[0123] In the embodiment of the present application, the fitness of the chromosomes of the current generation is sorted, and the chromosome codes corresponding to the PID control parameters of the current generation are selected, crossed, and mutated according to the sorting results to obtain the mutated chromosome codes.
[0124] Among them, selection is used to replace chromosomes with poor fitness with chromosomes with better fitness, and to directly pass on the optimized individuals to the next generation or to generate new individuals through pairing and crossover and then pass on to the next generation. The chromosome selection process is as follows:
[0125] Sort the chromosomes by fitness from small to large, and give a selection coefficient P between (0, 0.5g) S , the front P S The chromosome with poor fitness is P S The chromosome with better fitness is replaced, that is, the selected chromosome. Among them, g is the population size.
[0126] Crossover is equivalent to the recombination of biological genes in the process of biological evolution in nature. It is an operation that replaces and recombines parts of the structures of two parent individuals to generate new individuals.
[0127] In the present application example, the chromosome crossover process is as follows:
[0128] When performing chromosome crossover, a crossover coefficient P is given with a value between (0, 1) C , generate a random number X between (0, 1) for the i-th chromosome Cand a random number P between (0, 3m) n , if the cross coefficient P C Greater than X C , then perform crossover, that is, the posterior P of the i-th and i+1-th chromosomes n The units digits are swapped; if the cross coefficient P C Less than or equal to X C , then no crossover is performed; thus the chromosome after crossover is obtained. Where m is the encoding precision; i is an odd number and i is less than or equal to the population size g.
[0129] Mutation is the change of certain gene values of individuals in a group. In the embodiment of the present application, the mutation process of chromosomes is as follows:
[0130] When performing chromosome mutation, basic position mutation can be used, that is, the coefficient of variation P is given a value between (0, 1) M , generate a random number X between (0, 1) for each binary bit of the chromosome M , if the coefficient of variation P M Greater than X M , then mutation is performed, changing the binary bit from 1 to 0 (or from 0 to 1); if the coefficient of variation P M Less than or equal to X M , then no mutation is performed, thus obtaining the mutated chromosome.
[0131] The mutated chromosome is decoded to obtain the second PID control parameter.
[0132] In the embodiment of the present application, decoding can be understood as mapping chromosomes to PID control parameters, and the detailed steps are as follows:
[0133] First, the mutated chromosome code represented by binary and with a length of 3m is divided into three binary numbers k with a length of encoding precision m. m(bin) ; where k m(bin) Corresponding to the binary control parameter k p(bin) , k i(bin) and k d(bin) .
[0134] Then, k p(bin) , k i(bin) and k d(bin) Convert to decimal k p(dec) , k i(dec) and k d(dec) .
[0135] Finally, according to the range of each parameter value [k nMin , k nMax ], according to the formula:
[0136]
[0137] Calculate the second PID control parameter k m .
[0138] Step S103: If the chromosome fitness of the second PID control parameter does not reach the preset fitness threshold, and n is less than or equal to the preset termination evolution generation, the second PID control parameter is used as the next generation PID control parameter of the genetic algorithm, and steps S101 to S102 are repeatedly executed to perform local optimization and global optimization on the next generation PID control parameter in turn.
[0139] In this application example, the chromosome fitness of the PID control parameter of the current evolutionary generation is obtained through simulation or actual measurement of the control system.
[0140] Specifically, a simulation model of the control system is established in the simulation software, which mainly includes a controlled object module, a controller module, and an output feedback module. This process is equivalent to mathematically establishing an ordinary differential equation corresponding to the control system. The current generation of PID control parameters are set to the corresponding parameters of the controller module of the above simulation model. Through simulation, that is, using numerical methods to solve the above ordinary differential equations, the changes in the output of the controlled object over time can be obtained.
[0141] Similar to the simulation model, the actual working control system also includes a controlled object, a controller, and an output detection device. The PID control parameters of the current generation can be set to the corresponding parameters of the controller. During operation, the output detection device is used to measure the change of the output of the controlled object over time, and the control system is simulated or measured to calculate the corresponding chromosome fitness of the current generation.
[0142] If the chromosome fitness of the second PID control parameter does not reach the preset fitness threshold, and n is less than or equal to the preset termination evolutionary generation, it means that the chromosome individual that meets the preset fitness threshold has not been obtained in the current evolutionary generation, and it is necessary to enter the next iteration. At this time, the evolution of the genetic algorithm continues to be performed to further globally optimize the PID control parameters. At this time, the second PID control parameter of the current evolutionary generation is saved, and the second PID control parameter is used as the next generation PID control parameter of the genetic algorithm, and steps S101 to S102 are repeatedly executed, and the next generation PID control parameters are locally optimized and globally optimized in turn, so as to search for chromosomes that are closer to the preset fitness threshold.
[0143] Step S104: If the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolutionary generation, the adjusted PID control parameter is output and the genetic algorithm is terminated.
[0144] In an embodiment of the present application, when the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, it is considered that there is a chromosome individual whose chromosome fitness reaches the preset fitness threshold, that is, the PID control parameter reaches the preset accuracy threshold and can be used in practical applications. At this time, the genetic algorithm terminates and outputs the adjusted PID control parameter.
[0145] Alternatively, for computational cost considerations, when the genetic algorithm evolution generation n is greater than the termination evolution generation, the genetic algorithm evolution must be terminated and the adjusted PID control parameters must be output even if a chromosome individual that meets the preset fitness threshold has not yet been obtained.
[0146] In this way, after local optimization and global optimization, the iteration speed of the genetic algorithm is accelerated, and the PID control parameters that reach the preset accuracy threshold can be quickly obtained.
[0147] In some embodiments, if the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolution generation, the adjusted PID control parameter is output and the genetic algorithm is terminated, specifically: if the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, the PID control parameter corresponding to the maximum chromosome fitness of the second PID control parameter is screened out as the adjusted PID control parameter; or, if n is greater than a preset termination evolution generation, the genetic algorithm is terminated, and the PID control parameter corresponding to the maximum chromosome fitness of the second PID control parameter is screened out as the adjusted PID control parameter; the adjusted PID control parameter is output and the genetic algorithm is terminated.
[0148] In summary, the embodiment of the present application provides a method for tuning PID control parameters based on an improved genetic algorithm, which combines a local optimization algorithm and a genetic algorithm, performs evolutionary iterations through local optimization of PID control parameters, encoding of PID control parameters, chromosome fitness sorting, chromosome selection, crossover, and mutation, and finally obtains the tuned PID control parameters. This method has a strong global search optimization capability and a fast local search optimization speed, and can realize online or offline self-tuning of PID control parameters.
[0149] Exemplary Systems
[0150] The embodiment of the present application provides a PID control parameter tuning system based on an improved genetic algorithm. Figure 4 The structure diagram of the PID control parameter tuning system based on the improved genetic algorithm provided according to some embodiments of the present application is shown in FIG. Figure 4As shown, the system includes: a local optimization unit 401, a global optimization unit 402, an iteration unit 403, and an output unit 404. Among them:
[0151] The local optimization unit 401 is configured to locally optimize the n-th generation PID control parameters based on the n-1th generation PID control parameters, the n-2th generation PID control parameters, the chromosome fitness corresponding to the n-1th generation PID control parameters, and the chromosome fitness corresponding to the n-2th generation PID control parameters, based on a preset optimization model to obtain the first PID control parameters; wherein n represents the evolutionary generation of the genetic algorithm, n≥3, and n is a positive integer.
[0152] The global optimization unit 402 is configured to perform global optimization on the first PID control parameter to obtain a second PID control parameter.
[0153] The iteration unit 403 is configured to use the second PID control parameter as the next-generation PID control parameter of the genetic algorithm if the chromosome fitness of the second PID control parameter does not reach a preset fitness threshold, and n is less than or equal to a preset termination evolution generation, and repeatedly execute the local optimization unit 401 and the global optimization unit 402 to perform local optimization and global optimization on the next-generation PID control parameter in sequence.
[0154] The output unit 404 is configured to output the adjusted PID control parameter and terminate the genetic algorithm if the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolutionary generation.
[0155] A PID control parameter tuning system based on an improved genetic algorithm provided in an embodiment of the present application can implement the steps and processes of any of the above-mentioned PID control parameter tuning methods based on an improved genetic algorithm, and achieve the same technical effects, which will not be repeated here one by one.
[0156] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for setting PID control parameters based on an improved genetic algorithm, characterized in that: include: Step S101, according to the n-1th generation PID control parameter, the n-2th generation PID control parameter, and the chromosome fitness corresponding to the n-1th generation PID control parameter and the chromosome fitness corresponding to the n-2th generation PID control parameter, based on a preset optimization model, locally optimize the n-th generation PID control parameter to obtain a first PID control parameter; wherein n represents the evolutionary generation of the genetic algorithm, n≥3, and n is a positive integer; Step S102, globally optimizing the first PID control parameter to obtain a second PID control parameter; Step S103: if the chromosome fitness of the second PID control parameter does not reach a preset fitness threshold, and n is less than or equal to a preset termination evolution generation, the second PID control parameter is used as the next generation PID control parameter of the genetic algorithm, and steps S101 to S102 are repeatedly performed to perform local optimization and global optimization on the next generation PID control parameter in sequence; Step S104: If the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolution generation, the adjusted PID control parameter is output and the genetic algorithm is terminated; based on the preset optimization model, the nth generation PID control parameter is locally optimized to obtain the first PID control parameter, specifically: According to the formula: Calculating the first PID control parameter; In the formula, k n represents the first PID control parameter; k n-1 represents the n-1th generation PID control parameter; k n-2 represents the n-2 generation PID control parameters; FIT n-1 represents the chromosome fitness corresponding to the n-1th generation PID control parameter; FIT n-2 Indicates the chromosome fitness corresponding to the n-2 generation PID control parameter; η is a predefined coefficient; The first PID control parameter is globally optimized to obtain the second PID control parameter, which is specifically: Performing chromosome encoding on the first PID control parameter to obtain a chromosome corresponding to the nth generation PID control parameter; The selection, crossover and mutation operations of the genetic algorithm are sequentially performed on the chromosomes corresponding to the n-th generation PID control parameters to obtain the second PID control parameters.
2. The method for setting PID control parameters based on improved genetic algorithm according to claim 1 is characterized in that: The chromosome encoding of the first PID control parameter to obtain the chromosome corresponding to the n-th generation PID control parameter is specifically: According to the first PID control parameter, according to the formula: Calculating a decimal parameter of the first PID control parameter; In the formula, k n(dec) represents the decimal parameter of the first PID control parameter, k nMin represents the minimum value of the value range of the first PID control parameter; k nMax represents the maximum value of the value range of the first PID control parameter; m Indicates the preset chromosome encoding accuracy; The decimal parameter of the first PID control parameter is converted into a binary system to obtain a chromosome corresponding to the nth generation PID control parameter.
3. The method for setting PID control parameters based on improved genetic algorithm according to claim 1 is characterized in that: The selection, crossover, and mutation operations of the genetic algorithm are sequentially performed on the chromosomes corresponding to the n-th generation PID control parameters to obtain the second PID control parameters, specifically: Sorting the chromosomes corresponding to the n-th generation PID control parameters, and selecting the chromosomes corresponding to the n-th generation PID control parameters based on a preset selection coefficient to obtain the selected chromosomes; Based on a preset crossover coefficient, performing a crossover operation on the selected chromosome to obtain the chromosome after crossover; Based on a preset coefficient of variation, performing a mutation operation on the chromosome after the crossover to obtain the mutated chromosome; The mutated chromosome is decoded to obtain the second PID control parameter.
4. The method for setting PID control parameters based on improved genetic algorithm according to claim 1, characterized in that: If the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolutionary generation, the adjusted PID control parameter is output and the genetic algorithm is terminated, specifically: If the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, the PID control parameter corresponding to the maximum chromosome fitness of the second PID control parameter is selected as the adjusted PID control parameter, and the genetic algorithm is terminated; or, If n is greater than a preset termination evolutionary generation, the genetic algorithm is terminated, and the PID control parameter corresponding to the maximum chromosome fitness of the second PID control parameter is screened out as the adjusted PID control parameter; The adjusted PID control parameters are output.
5. The method for setting PID control parameters based on an improved genetic algorithm according to any one of claims 1 to 4, characterized in that: The method further comprises: When n=1, multiple values of the PID control parameter are selected within the value range of the PID control parameter as the second PID control parameter, and step S103 and subsequent steps are executed; When n=2, the nth generation PID control parameter is used as the first PID control parameter, and step S102 and subsequent steps are executed.
6. A PID control parameter tuning system based on an improved genetic algorithm, characterized in that: include: The local optimization unit is configured to locally optimize the n-th generation PID control parameter based on the n-1th generation PID control parameter, the n-2th generation PID control parameter, the chromosome fitness corresponding to the n-1th generation PID control parameter, and the chromosome fitness corresponding to the n-2th generation PID control parameter, based on a preset optimization model, to obtain a first PID control parameter; wherein n represents the evolutionary generation of the genetic algorithm, n≥3, and n is a positive integer; a global optimization unit, configured to perform global optimization on the first PID control parameter to obtain a second PID control parameter; an iteration unit, configured to use the second PID control parameter as the next generation PID control parameter of the genetic algorithm if the chromosome fitness of the second PID control parameter does not reach a preset fitness threshold, and n is less than or equal to a preset termination evolution generation, and repeatedly perform local optimization and global optimization on the next generation PID control parameter by the local optimization unit and the global optimization unit in sequence; an output unit, configured to output the adjusted PID control parameter and terminate the genetic algorithm if the chromosome fitness of the second PID control parameter reaches a preset fitness threshold, or n is greater than a preset termination evolutionary generation; The local optimization unit is configured according to the formula: Calculating the first PID control parameter; In the formula, k n represents the first PID control parameter; k n-1 represents the n-1th generation PID control parameter; k n-2 represents the n-2 generation PID control parameters; FIT n-1 represents the chromosome fitness corresponding to the n-1th generation PID control parameter; FIT n-2 Indicates the chromosome fitness corresponding to the n-2 generation PID control parameter; η is a predefined coefficient; The global optimization unit is configured to perform chromosome encoding on the first PID control parameter to obtain the chromosome corresponding to the n-th generation PID control parameter; and sequentially perform the selection, crossover, and mutation operations of the genetic algorithm on the chromosome corresponding to the n-th generation PID control parameter to obtain the second PID control parameter.
Citation Information
Patent Citations
Air pressure self-adaptive online PID setting method based on improved genetic algorithm
CN110609478A
Method and system for planning path of unmanned surface vehicle based on forward / reverse data-driven linear parameter-varying genetic algorithm
WO2021035911A1