Temperature compensation method of novel gas sensor

The least squares support vector machine model is optimized through the whale optimization algorithm and a temperature compensation model is established, which solves the problem that the gas sensor detection results are susceptible to temperature changes, significantly reduces detection errors, and improves the performance and reliability of the sensor.

CN119783859AInactive Publication Date: 2025-04-08HENAN UNIV OF URBAN CONSTR
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510055065.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-04-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The detection results of existing gas sensors are easily affected by temperature changes, resulting in large detection errors.

Method used

The whale optimization algorithm is used to optimize the least squares support vector machine model, establish a temperature compensation model, and reduce the impact of temperature on the detection results by normalizing the training samples and optimization algorithm parameters.

Benefits of technology

It significantly reduces the detection error caused by temperature fluctuations, improves the overall performance and reliability of the sensor, and outputs accurate gas concentration prediction values.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119783859A_ABST
    Figure CN119783859A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of temperature compensation, and discloses a novel temperature compensation method of a gas sensor. According to the temperature compensation method of the novel gas sensor, optimal regularization parameters and kernel function parameters can be found in a multi-dimensional space by setting optimization parameters and generating an initial population, so that the training error of a model is reduced to the maximum extent, and the accuracy of the temperature compensation of the novel gas sensor is improved by normalizing training samples. According to the method, the comparability of data and the convergence speed of the model are improved, the whale optimization algorithm ensures the effectiveness and stability of the optimization process by utilizing a root mean square error in fitness evaluation, and finally, through multiple iterations, the model can accurately capture the influence of temperature change on the output of the gas sensor and can also accurately capture the temperature change of the gas sensor. And an accurate gas concentration prediction value can be output, so that the detection error caused by temperature fluctuation is remarkably reduced, and the overall performance and reliability of the sensor are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of temperature compensation, and in particular to a novel temperature compensation method for a gas sensor. Background Art

[0002] Gas detection sensors mainly include metal oxide semiconductor sensors, electrochemical sensors, etc. These sensors are based on the chemical reaction between the target gas and the sensitive elements of the sensor. The gas concentration is detected by changing the electrical properties of the sensor (resistance, current, etc.). They have the advantages of high sensitivity and easy operation. However, the high sensitivity of these sensors is often at the expense of a high temperature working environment, and they are seriously affected by other non-target gases. Gas sensors based on carbon nanotubes have always been a hot topic for many researchers. Among them, ionization carbon nanotube gas sensors are based on the principle of gas discharge and can overcome the problems of easy saturation and long desorption time of adsorption sensors. They have received widespread attention in recent years. Ionization carbon nanotube gas can be divided into two types of sensors: two-electrode structure sensors and three-electrode structure sensors. The two-electrode structure ionization gas sensor has the advantages of simple structure and easy preparation, and can detect a variety of gases, but the detection results are easily affected by temperature changes, which will lead to large detection errors. Summary of the invention

[0003] 1. Technical issues to be resolved In view of the shortcomings of the prior art, the present invention provides a new temperature compensation method for gas sensors and proposes a temperature compensation model of a whale algorithm optimized least squares support vector machine (WOA-LSSVM) to achieve temperature correction, solve the problem of temperature interference on gas measurement, reduce detection errors, and solve the above problems.

[0004] (II) Technical solution To achieve the above object, the present invention provides the following technical solution: a novel temperature compensation method for a gas sensor, comprising the following steps: S1. Set the population size, maximum number of iterations, individual dimension, and regularization parameter of the whale optimization algorithm and kernel function parameters The selection range; S2, generate the initial population and normalize the training samples; S3. Input the normalized training samples into the least squares support vector machine The model is trained, and the root mean square error between the predicted value of the whale optimization algorithm and the calibrated concentration value of the training sample is used as the fitness value; S4, calculate the fitness value of each individual and determine the position of the best individual in the population; S5. Calculate the convergence factor a and update the parameters A, C and random number P of the whale optimization algorithm; S6, updating the positions of individuals in the population; S7, determine the convergence condition, if the maximum number of iterations or the least squares support vector machine is reached If the model training error is reached, the iteration stops and the process goes to S8, otherwise it returns to S3; S8. Regularization parameters obtained by optimizing the whale optimization algorithm and kernel function parameters Enter the Least Squares Support Vector Machine The model is trained to obtain a temperature compensation model; S9. Predict gas concentration through temperature compensation model and output predicted value Realize temperature compensation for gas sensors.

[0005] Preferably, the formula for normalizing the training samples is as follows: In the formula, represents the normalized training sample data value, represents the original training sample data value, Represents the minimum data value of the original training sample, Indicates the maximum data value of the original training sample.

[0006] Preferably, the fitness value calculation formula is as follows: In the formula, represents the fitness value, represents the total number of training samples, Indicates The actual value of the training sample of the group, Indicates The predicted value of the training sample, Indicates an index subscript.

[0007] Preferably, the convergence factor The calculation formula is as follows: In the formula, represents the convergence factor that decreases linearly from 2 to 0, represents the maximum number of iterations, Indicates the current iteration number.

[0008] Preferably, the whale optimization algorithm parameters The calculation formula is as follows: In the formula, represents the convergence factor that decreases linearly from 2 to 0, express A random number between .

[0009] Preferably, the whale optimization algorithm parameters The calculation formula is as follows: In the formula, express A random number between .

[0010] Preferably, the population individual positions are updated when When , it is updated according to the following formula: In the formula, Indicates that the current individual is in The updated position of the generation, represents the position of a random individual, represents the parameters of the whale optimization algorithm, Indicates the offset between the randomly selected individual and the current individual.

[0011] Preferably, the population individual positions are updated when When , it is updated according to the following formula: In the formula, Indicates that the current individual is in The position of the generation, represents the parameters of the whale optimization algorithm, , represents the distance vector between the current individual and the random individual, Represents a random number, Represents a control factor, which is used to adjust the narrowing of the search range. Indicates that the distribution A random number between .

[0012] Preferably, the pointing is the offset between the randomly selected individual and the current individual The calculation formula is as follows: In the formula, represents the position of a random individual, represents the parameters of the whale optimization algorithm, Indicates that the current individual is in The updated position of the generation.

[0013] Preferably, the distance vector between the current individual and the random individual The calculation formula is as follows: In the formula, The current individual is The position of the generation, Indicates that the current individual is The updated position of the generation.

[0014] Compared with the prior art, the present invention provides a novel temperature compensation method for a gas sensor, which has the following beneficial effects: The present invention sets optimization parameters and generates an initial population. The method can find the optimal regularization parameters and kernel function parameters in a multidimensional space, thereby minimizing the training error of the model. By normalizing the training samples, the method improves the comparability of data and the convergence speed of the model. The whale optimization algorithm uses the root mean square error in fitness evaluation to ensure the effectiveness and stability of the optimization process. Finally, after multiple iterations, the model can not only accurately capture the impact of temperature changes on the output of the gas sensor, but also output accurate gas concentration prediction values, thereby significantly reducing the detection error caused by temperature fluctuations and improving the overall performance and reliability of the sensor. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a schematic diagram of the steps of the method of the present invention; Figure 2 This is the temperature compensation principle diagram of the present invention; Figure 3 It is the algorithm flow chart of the present invention; Figure 4 This is a comparison diagram of gas concentration before and after temperature compensation of the present invention. DETAILED DESCRIPTION

[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0017] In view of the fact that temperature has a great influence on the output of the sensor, which will cause a large detection error, a new temperature compensation method for gas sensors is proposed. Figure 1 , the method comprises the following steps: S1. Set the population size, maximum number of iterations, individual dimension, and regularization parameter of the whale optimization algorithm and kernel function parameters The selection range; In designing the whale optimization algorithm ( ) is used to optimize the least squares support vector machine ( ) When the temperature compensation effect of the model is studied, the following key parameters need to be set scientifically to improve the effectiveness and accuracy of the algorithm. First, the population size is usually set to This ensures that the algorithm has sufficient diversity and coverage during the search process to better explore the solution space. The maximum number of iterations should be set to , which can balance computing resources and accuracy and avoid losing potential optimal solutions when converging prematurely. The individual dimensions need to be The model parameters usually have a dimension of 2 to 5, depending on the selected kernel function and data characteristics. and kernel function parameters The range of the regularization parameter is selected by using the empirical rule. Can be set in , kernel function parameters Can be set in , which can ensure that the model has effective generalization ability during training and effectively avoid overfitting; S2, generate the initial population and normalize the training samples; In implementing the whale optimization algorithm ( ), the first step is to generate the initial population, which involves randomly generating a group of individuals to be optimized from the set parameter space. These individuals represent potential solutions. When selecting the position of the individuals, the corresponding relationship between the individual dimension and the parameters to be optimized should be considered to ensure that each individual can effectively cover different areas of the parameter space. At the same time, in the processing of training samples, data normalization is a crucial technical means. This process usually adopts the minimum-maximum normalization method, that is, the original data is mapped to In scope: In the formula, represents the normalized training sample data value, represents the original training sample data value, Represents the minimum data value of the original training sample, Represents the maximum data value of the original training sample; the above normalization eliminates the dimension effect of the data and ensures that each feature is processed at the same scale, thereby reducing the dominant influence of certain features on the optimization results. At the same time, normalization can accelerate the convergence process and improve the efficiency of model training, because the optimization algorithm is more sensitive to numerical changes in a smaller range. Normalization can also help reduce the complexity of the model and enhance the generalization ability of the model, effectively avoiding overfitting and ensuring good performance on the test sample; S3. Input the normalized training samples into the least squares support vector machine The model is trained, and the root mean square error between the predicted value of the whale optimization algorithm and the calibrated concentration value of the training sample is used as the fitness value; In the whale optimization algorithm ( ), the normalized training samples will be input into the least squares support vector machine ( ) model, which involves using normalized training data to improve the learning efficiency and accuracy of the model. LSSVM can effectively capture the potential patterns in the data by minimizing the training error, and build a nonlinear mapping based on this to achieve accurate prediction of gas concentration. After the training is completed, it will be used The root mean square error between the value predicted by the algorithm and the calibrated concentration value of the training sample is evaluated as the fitness value, which is calculated as follows: In the formula, represents the fitness value, represents the total number of training samples, Indicates The actual value of the training sample of the group, Indicates The predicted value of the training sample, Represents the index subscript; this value can intuitively measure the difference between the model prediction result and the real data. The smaller the error, the higher the fitness value, which means the stronger the prediction ability of the model. This process is not only It provides the optimization direction and ensures the quantitative evaluation of the model performance during the optimization process. In addition, the low fitness value obtained implies that the model can better adapt to the data, thereby improving the accuracy and reliability of the gas sensor when performing temperature compensation; S4, calculate the fitness value of each individual and determine the position of the best individual in the population; After calculating the fitness values ​​of all individuals, the next step is to determine the position of the best individual in the population. This process requires comparing all calculated fitness values ​​and identifying the individual with the smallest fitness value. The position of this individual is the current best solution. In specific implementation, the position of the best individual and the corresponding fitness value are stored and continuously updated in subsequent iterations to guide the algorithm towards a better solution space. In addition, the best individual information is passed to the subsequent search strategy to ensure that the algorithm can give priority to the local optimal solution during the search operation, thereby effectively improving the overall optimization efficiency. S5. Calculate the convergence factor , and update the parameters of the whale optimization algorithm , and random numbers ; In the whale optimization algorithm ( ) is a crucial step in the execution of the algorithm. It directly affects the search behavior of the algorithm and the convergence speed of the solution. The value of the convergence factor usually increases with the number of iterations. The calculation formula is: In the formula, represents the convergence factor that decreases linearly from 2 to 0, represents the maximum number of iterations, Indicates the current iteration number; Through this linear decreasing method, the convergence factor can effectively guide individuals to balance between the exploration and development stages of the search space, ensuring a larger search range in the early stage and focusing on detailed local search when approaching the optimal solution; After calculating the convergence factor, the next step is to update the parameters in the whale optimization algorithm. , And random numbers , the specific update process is as follows: In the formula, represents the convergence factor that decreases linearly from 2 to 0, express A random number between In the formula, express A random number between The random number P plays an important role in choosing the search mode (exploration or exploitation) of the algorithm and is usually Randomly generated within the range, according to The value of determines whether to adopt a global search or a local search strategy, which helps to increase the diversity of the algorithm; By gradually reducing the convergence factor , the algorithm can explore a wider solution space in the early stage of optimization, and in the later stage it can focus on more refined search in the convergence area, so as to achieve the purpose of quickly converging to the optimal solution, and the updated parameters and The adaptability of the whale model at different stages is further enhanced, making it more efficient in dealing with complex multi-peak optimization problems. At the same time, random factors are flexibly introduced. It adds diversity to the algorithm and helps avoid falling into local optimal solutions; S6, updating the positions of individuals in the population; The update of the individual positions of the population is mainly affected by two important parameters: The state of this parameter determines the whale's search strategy and affects whether the individual performs local search or global search. The value of, the formula for updating the individual position is divided into two cases: when When , the algorithm performs a global search, and the update formula for the individual position is: In the formula, Indicates that the current individual is The updated position of the generation, represents the position of a random individual, represents the parameters of the whale optimization algorithm, Indicates the offset between the randomly selected individual and the current individual; when In this case, the algorithm switches to local search and updates according to the following formula: In the formula, Indicates that the current individual is The position of the generation, represents the parameters of the whale optimization algorithm, , represents the distance vector between the current individual and the random individual, Represents a random number, represents the control factor, which is used to adjust the narrowing of the search range. Indicates that the distribution A random number between By dynamically adjusting The whale optimization algorithm can achieve effective exploration and development at different search stages by using different update strategies. For example, in the early stage of search, the larger The value can ensure that the algorithm has a wider search range, and as the iteration progresses, it gradually decreases The value of can make the algorithm focus on the local optimal solution and improve the ability of fine adjustment. Flexible way to update values When faced with complex multi-peak optimization problems, it can effectively avoid early convergence to the local optimum and quickly converge to the global optimal solution at the right time, thereby improving the overall performance and applicability of the algorithm. Through this mechanism, the update of the individual positions of the population not only improves the optimization efficiency, but also enhances the robustness and accuracy of the model; S7, determine the convergence condition, if the maximum number of iterations or the least squares support vector machine is reached If the model training error is reached, the iteration stops and the process goes to S8, otherwise it returns to S3; S8. Regularization parameters obtained by optimizing the whale optimization algorithm and kernel function parameters Enter the Least Squares Support Vector Machine The model is trained to obtain a temperature compensation model; S9. Predict gas concentration through temperature compensation model and output predicted value Realize temperature compensation for gas sensors.

[0018] Through the comprehensive application of the above steps, the model can not only accurately capture the impact of temperature changes on the output of the gas sensor, but also output accurate gas concentration prediction values, thereby significantly reducing the detection error caused by temperature fluctuations and improving the overall performance and reliability of the sensor.

[0019] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A novel temperature compensation method for a gas sensor, characterized in that: The following steps are involved: S1. Set the population size, maximum number of iterations, individual dimension, and regularization parameter of the whale optimization algorithm and kernel function parameters The selection range; S2, generate the initial population and normalize the training samples; S3. Input the normalized training samples into the least squares support vector machine The model is trained, and the root mean square error between the predicted value of the whale optimization algorithm and the calibrated concentration value of the training sample is used as the fitness value; S4, calculate the fitness value of each individual and determine the position of the best individual in the population; S5. Calculate the convergence factor a and update the parameters A, C and random number P of the whale optimization algorithm; S6, updating the positions of individuals in the population; S7, determine the convergence condition, if the maximum number of iterations or the least squares support vector machine is reached If the model training error is reached, the iteration stops and the process goes to S8, otherwise it returns to S3; S8. Regularization parameters obtained by optimizing the whale optimization algorithm and kernel function parameters Enter the least squares support vector machine The model is trained to obtain a temperature compensation model; S9. Predict gas concentration through temperature compensation model and output predicted value Realize temperature compensation for gas sensors.

2. The temperature compensation method of a novel gas sensor according to claim 1 is characterized in that: The formula for normalizing the training samples is as follows: In the formula, represents the normalized training sample data value, represents the original training sample data value, represents the minimum data value of the original training sample, Indicates the maximum data value of the original training sample.

3. The temperature compensation method of a novel gas sensor according to claim 2 is characterized in that: The fitness value calculation formula is as follows: In the formula, represents the fitness value, represents the total number of training samples, Indicates The actual value of the training sample of the group, Indicates The predicted value of the training sample, Indicates an index subscript.

4. The temperature compensation method of a novel gas sensor according to claim 3 is characterized in that: The convergence factor The calculation formula is as follows: In the formula, represents the convergence factor that decreases linearly from 2 to 0, represents the maximum number of iterations, Indicates the current iteration number.

5. The temperature compensation method of a novel gas sensor according to claim 4 is characterized in that: The Whale Optimization Algorithm Parameters The calculation formula is as follows: In the formula, represents the convergence factor that decreases linearly from 2 to 0, express A random number between .

6. The temperature compensation method of a novel gas sensor according to claim 5 is characterized in that: The Whale Optimization Algorithm Parameters The calculation formula is as follows: In the formula, express A random number between .

7. The temperature compensation method of a novel gas sensor according to claim 6 is characterized in that: The individual positions of the population are updated when When , it is updated according to the following formula: In the formula, Indicates that the current individual is in The updated position of the generation, represents the position of a random individual, represents the parameters of the whale optimization algorithm, Indicates the offset between the randomly selected individual and the current individual.

8. The temperature compensation method of a novel gas sensor according to claim 7 is characterized in that: The individual positions of the population are updated when When , it is updated according to the following formula: In the formula, Indicates that the current individual is in The position of the generation, represents the parameters of the whale optimization algorithm, , represents the distance vector between the current individual and the random individual, Represents a random number, Represents a control factor, which is used to adjust the narrowing of the search range. Indicates that the distribution A random number between .

9. The temperature compensation method of a novel gas sensor according to claim 8 is characterized in that: The pointer points to the offset between the randomly selected individual and the current individual The calculation formula is as follows: In the formula, represents the position of a random individual, represents the parameters of the whale optimization algorithm, Indicates that the current individual is in The updated position of the generation.

10. The temperature compensation method of a novel gas sensor according to claim 9 is characterized in that: The distance vector between the current individual and the random individual The calculation formula is as follows: In the formula, The current individual is The position of the generation, Indicates that the current individual is in The updated position of the generation.