A method, system, device and medium for detecting the oil content of an emulsified petroleum product
Patent Information
- Application Number
- CN202311139391.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-05
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-09-05
AI Technical Summary
但每次用ELM求解到的隐含层输出权值不一致,最终影响预测效果,导致ELM模型的输出不稳定
[0055]本发明提供的乳化石油类产品含油率检测方法,通过搭建核极限学习机初始模型,确定适应度函数,并采用改进的北方苍鹰算法对核极限学习机初始模型中的惩罚系数和核参数进行迭代优化,得到核极限学习机优化模型,使其能够根据目标乳化液的中红外光谱数据进行快速、高效和准确的含油率预测,且能够实现批量预测,为复杂条件下石油及石油类产品检测技术的研究提供了实践依据。
Smart Images

Figure CN117191736B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of petroleum and petroleum product testing and analysis, and in particular to a method, system, equipment and medium for detecting the oil content of emulsified petroleum products. Background Technology
[0002] Frequent oil spills cause long-term and serious impacts on the ecological environment and human health. Emulsions of petroleum and petroleum products are difficult to dissipate, making them challenging to effectively treat and recover, and thus posing a more significant threat to the environment. Estimating the oil content of petroleum products at different emulsification stages will help improve the accuracy of crude oil detection on the sea surface, providing optimal parameters for tracing oil spill sources, rapidly determining the nature of pollution, studying spill area and volume, and facilitating the development of effective oil spill pollution prevention and control measures.
[0003] Mid-infrared spectroscopy (MIR) is the absorption spectrum of a substance in the mid-infrared region, with wavenumbers between 4000 and 4000 cm⁻¹. -1 Mid-infrared spectroscopy primarily arises from energy level transitions in molecular vibrations and rotations, with the vibrational frequencies mainly being the fundamental frequency and fingerprint frequency. Fourier transform infrared spectroscopy (FTIR) is based on performing a Fourier transform on the interferometric infrared light. It offers advantages such as high detection sensitivity, fast measurement speed, wide wavelength range, and safety, making it highly advantageous in the identification of material composition and widely used across various industries.
[0004] Extreme Learning Machine (ELM) is a single-hidden-layer feedforward neural network algorithm. The ELM algorithm randomly generates input weights and bias thresholds, and obtains the optimal solution by setting the number of hidden layer neurons and the activation function. Compared to traditional neural networks, ELM improves the network's generalization ability and learning speed, and has strong nonlinear fitting capabilities. However, the output weights of the hidden layer obtained by ELM are inconsistent each time, ultimately affecting the prediction performance and causing the output of the ELM model to be unstable.
[0005] Kernel Extreme Learning Machine (KELM) builds upon ELM by introducing kernel learning methods. It uses kernel functions to map all input samples to a high-dimensional hidden layer feature space. Since the kernel function directly uses the inner product form, it eliminates the need to set the number of hidden layer neurons; only appropriate kernel function parameters need to be set. KELM effectively improves upon the problems of weak generalization ability and unstable recognition rates caused by the random generation of weights and thresholds in ELM.
[0006] Current research on emulsified petroleum and petroleum products focuses primarily on emulsification principles, process simulation, emulsion morphology, hazards, and cleanup strategies. Research on the quantitative assessment of emulsion types and pollution levels is only just beginning. Quantitative assessment of the oil content in emulsions focuses on analyzing the variation of emulsion spectral characteristics with oil content, using features such as peak intensity and peak-to-peak ratio for quantitative estimation. Therefore, establishing a rapid, efficient, and accurate detection technology for determining the oil content of emulsions is of significant value and importance for real-time emulsion damage assessment and emergency response decision-making. Summary of the Invention
[0007] The purpose of this invention is to provide a method, system, equipment, and medium for detecting the oil content of emulsified petroleum products, so as to achieve rapid, efficient, and accurate determination of the oil content of emulsions.
[0008] To achieve the above objectives, the present invention provides the following solution:
[0009] A method for detecting the oil content of emulsified petroleum products, comprising:
[0010] Obtain a sample dataset and the corresponding true oil content; the sample dataset includes mid-infrared spectral data of several sample emulsions with different oil contents;
[0011] An initial model of a kernel extreme learning machine is constructed; the kernel function of the initial model is a radial basis function; the penalty coefficient and kernel parameters of the initial model are randomly selected.
[0012] The fitness function is determined based on the actual oil content and the predicted oil content corresponding to the sample dataset; the predicted oil content corresponding to the sample dataset is obtained by inputting the sample dataset into the initial model of the kernel extreme learning machine for prediction.
[0013] Based on the fitness function, the improved Northern Eagle algorithm is used to iteratively optimize the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine to obtain the optimized kernel extreme learning machine model; after iteratively determining the optimal population using the Northern Eagle algorithm, the improved Northern Eagle algorithm also includes Gaussian perturbation of the optimal population.
[0014] The mid-infrared spectral data of the target emulsion are obtained and input into the kernel limit learning machine optimization model to obtain the predicted oil content of the target emulsion.
[0015] Optionally, obtain the sample dataset and the corresponding true oil content, specifically including:
[0016] Prepare several sample emulsions with different oil contents;
[0017] The mid-infrared spectral data of the sample emulsion were collected to obtain the initial dataset;
[0018] The initial dataset is corrected and normalized to obtain a normalized dataset;
[0019] The KS algorithm is used to divide the normalized dataset into training set, validation set and test set according to a set ratio;
[0020] The training set and the validation set are determined as the sample dataset, and the oil content of the sample emulsion corresponding to the sample dataset is determined as the true oil content corresponding to the sample dataset.
[0021] Optionally, the fitness function is determined based on the actual oil content and predicted oil content corresponding to the sample dataset, specifically including:
[0022] The mean square error of the training set is determined based on the true oil content and predicted oil content corresponding to the training set in the sample dataset.
[0023] The mean square error of the validation set is determined based on the true oil content and predicted oil content corresponding to the validation set in the sample dataset.
[0024] The average of the mean squared error of the training set and the mean squared error of the validation set is used as the fitness function.
[0025] Optionally, based on the fitness function, the improved Northern Eagle algorithm is used to iteratively optimize the penalty coefficient and kernel parameters in the initial kernel extreme learning machine model to obtain an optimized kernel extreme learning machine model, specifically including:
[0026] Set the population size of the Northern Goshawk, the maximum number of iterations, the dimension of the problem to be solved, and the parameter optimization limits;
[0027] Based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization limit, the position of each Northern Goshawk in the solution space is randomly generated; the position of the Northern Goshawk represents the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine.
[0028] The fitness of each Northern Goshawk is calculated based on its location and the fitness function, and the minimum fitness is determined as the optimal fitness. The location of the Northern Goshawk corresponding to the minimum fitness is determined as the optimal population.
[0029] For any iteration of optimization:
[0030] During the identification phase, each Northern Goshawk randomly selects prey to attack, and updates the position and fitness of each Northern Goshawk according to the optimal fitness and the optimal population, thus obtaining the new state of each Northern Goshawk during the identification phase.
[0031] During the development phase, each Northern Goshawk is instructed to capture prey within its hunting radius, and the position and fitness of each Northern Goshawk are updated based on the optimal fitness and the optimal population, resulting in a new state for each Northern Goshawk during the development phase.
[0032] The updated fitness of each Northern Goshawk is calculated based on its new state during the development phase and the fitness function. The minimum updated fitness is determined as the optimal fitness, and the new state of the Northern Goshawk corresponding to the minimum updated fitness is determined as the optimal population.
[0033] The optimal population is subjected to Gaussian perturbation to update the optimal population within the parameter optimization limits, and the optimal fitness is also updated.
[0034] Determine whether the current iteration count has reached the maximum iteration count, and obtain the determination result;
[0035] If the judgment result is negative, return to step "In the identification stage, let each Northern Goshawk randomly select prey to attack, and update the position and fitness of each Northern Goshawk according to the optimal fitness and the optimal population to obtain the new state of each Northern Goshawk in the identification stage".
[0036] If the judgment result is yes, then the optimal penalty coefficient and the optimal kernel parameter are determined according to the optimal population, and the kernel extreme learning machine optimization model is determined according to the optimal penalty coefficient and the optimal kernel parameter.
[0037] Optionally, the optimal population is subjected to Gaussian perturbation to update the optimal population within the parameter optimization bound and to update the optimal fitness, specifically including:
[0038] The optimal population is subjected to Gaussian perturbation to obtain the new state of the optimal population after Gaussian perturbation;
[0039] Determine whether the new state of the optimal population after Gaussian perturbation exceeds the parameter optimization limit, and adjust the position that exceeds the parameter optimization limit to obtain the optimal population within the parameter optimization limit;
[0040] The optimal fitness is updated based on the best population within the parameter optimization limits.
[0041] Optionally, based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization bound, the position of each Northern Goshawk in the solution space is randomly generated, specifically including:
[0042] Based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization limit, the position of each Northern Goshawk in the solution space is randomly generated using the Tent chaotic mapping.
[0043] Optionally, the initial dataset is corrected and normalized to obtain a normalized dataset, specifically including:
[0044] The initial dataset is subjected to multivariate scattering correction processing to obtain the corrected dataset;
[0045] The corrected dataset is subjected to max-min normalization to obtain a normalized dataset.
[0046] A system for detecting the oil content of emulsified petroleum products includes:
[0047] The data acquisition module is used to acquire sample datasets and corresponding true oil content; the sample datasets include mid-infrared spectral data of sample emulsions with different oil contents;
[0048] The model building module is used to build the initial model of the kernel extreme learning machine; the kernel function of the initial model of the kernel extreme learning machine is a radial basis function; the penalty coefficient and kernel parameters of the initial model of the kernel extreme learning machine are randomly selected.
[0049] The fitness function determination module is used to determine the fitness function based on the true oil content and the predicted oil content corresponding to the sample dataset; the predicted oil content corresponding to the sample dataset is obtained by inputting the sample dataset into the initial model of the kernel extreme learning machine for prediction.
[0050] The parameter optimization module is used to iteratively optimize the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine according to the fitness function using the improved Northern Eagle algorithm, so as to obtain the optimized kernel extreme learning machine model; the improved Northern Eagle algorithm also includes Gaussian perturbation of the optimal population after iteratively determining the optimal population using the Northern Eagle algorithm.
[0051] The oil content prediction module is used to acquire the mid-infrared spectral data of the target emulsion and input it into the kernel limit learning machine optimization model to obtain the predicted oil content of the target emulsion.
[0052] An electronic device includes a memory and a processor, the memory storing a computer program, and the processor running the computer program to enable the electronic device to perform the above-described method for detecting the oil content of emulsified petroleum products.
[0053] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for detecting the oil content of emulsified petroleum products.
[0054] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0055] The oil content detection method for emulsified petroleum products provided by this invention establishes an initial model of a kernel extreme learning machine (KELM), determines the fitness function, and uses an improved Northern Eagle algorithm to iteratively optimize the penalty coefficient and kernel parameters in the initial KELM model to obtain an optimized KELM model. This model enables rapid, efficient, and accurate prediction of oil content based on the mid-infrared spectral data of the target emulsion, and also allows for batch prediction. This provides a practical basis for the research of petroleum and petroleum product detection technology under complex conditions. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 A flowchart of the method for detecting the oil content of emulsified petroleum products provided by the present invention;
[0058] Figure 2 This is a schematic diagram of the method for detecting the oil content of emulsified petroleum products provided by the present invention;
[0059] Figure 3 A detailed flowchart of the method for detecting the oil content of emulsified petroleum products provided by the present invention;
[0060] Figure 4 This is a schematic diagram of the scatter point distribution before Tent chaotic mapping in an embodiment of the present invention;
[0061] Figure 5 This is a schematic diagram of the scatter distribution after Tent chaotic mapping according to an embodiment of the present invention.
[0062] Figure 6 This is a fitness change graph of KELM optimized using an improved NGO algorithm in an embodiment of the present invention;
[0063] Figure 7 This is a fitting graph of the actual and predicted values of the oil content of the emulsion in an embodiment of the present invention;
[0064] Figure 8 This is a fitness change graph of KELM optimized using the CSO algorithm in an embodiment of the present invention;
[0065] Figure 9 This is a block diagram of the oil content detection system for emulsified petroleum products provided by the present invention.
[0066] Symbol explanation:
[0067] Data acquisition module-1, model building module-2, fitness function determination module-3, parameter optimization module-4, oil content prediction module-5. Detailed Implementation
[0068] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0069] The purpose of this invention is to provide a method, system, equipment, and medium for detecting the oil content of emulsified petroleum products, so as to achieve rapid, efficient, and accurate determination of the oil content of emulsions.
[0070] In KELM, the penalty coefficient C and the Gaussian kernel parameter σ affect the network's stability and search capability. Typically, without prior knowledge, these parameters are randomly selected based on subjective experience, resulting in significant arbitrariness. The penalty factor C balances structural risk and empirical risk; a larger C indicates a greater emphasis on loss, leading to more precise classification of sample points, but this can result in overfitting. Lower empirical risk results in insufficient model generalization ability. The kernel parameter σ is related to the complexity of the sample feature subspace distribution; a higher dimension of the feature subspace leads to a more complex optimal classification surface and lower empirical risk.
[0071] The Northern Goshawk Optimization (NGO) algorithm is a novel swarm intelligence optimization algorithm, primarily inspired by the northern goshawk's ability to identify and hunt prey. This novel swarm intelligence optimization algorithm exhibits high convergence accuracy and good stability. However, during population initialization, the random generation of individual population positions can potentially lead to a loss of population diversity and cannot guarantee a uniform distribution of individuals in the search space, thus missing potential optimal solutions. Furthermore, the Northern Goshawk algorithm's rapid search speed in the later stages makes it prone to getting trapped in local optima.
[0072] The present invention specifically adopts the following technical measures: First, mid-infrared spectral images of emulsified petroleum products with different oil contents are acquired and preprocessed; then, an initial KELM model is built, and the penalty coefficient C and kernel parameter σ of the initial KELM model are optimized using the improved Northern Eagle algorithm; finally, the optimized KELM model is used to accurately and quickly predict the oil content of emulsified oil data.
[0073] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0074] Example 1
[0075] This invention provides a method for detecting the oil content of emulsified petroleum products. For example... Figure 1 , Figure 2 and Figure 3 As shown, the method includes:
[0076] Step S1: Obtain the sample dataset and the corresponding true oil content; the sample dataset includes mid-infrared spectral data of several sample emulsions with different oil contents.
[0077] Step S1.1: Prepare several sample emulsions with different oil contents.
[0078] The specific experimental materials selected are as follows:
[0079] Experiments were conducted using Sinochem 95 gasoline, aviation kerosene, biodiesel, and 0# diesel.
[0080] Under normal circumstances, as the water content increases, oil-water emulsions cannot maintain a uniform and stable state. Adding an emulsifier allows the water-oil emulsion to remain stable for a certain period. To prepare emulsion samples with different oil contents, i.e., sample emulsions, the lipophilic emulsifier Span80 (HLB value 4.3) and the hydrophilic emulsifier Tween80 (HLB value 15) were selected to emulsify water and oil. To avoid the influence of different emulsifier ratios and amounts on mid-infrared spectroscopy analysis, the total amount of mixed emulsifier used to prepare each emulsion sample was kept constant: the experiment used 0.51g of Span80, 0.1g of Tween80, and the mixed emulsifier had an HLB value of 6.05.
[0081] The formula for calculating the HLB value of the mixed emulsifier is as follows:
[0082]
[0083] In the formula, HLB1 and W1 are the HLB value and mass of the first emulsifier, respectively; HLB2 and W2 are the HLB value and mass of the second emulsifier, respectively; HLB 混 This refers to the HLB value of the mixed emulsifier.
[0084] The formula for calculating oil content is:
[0085]
[0086] In the formula, w 水 It is the mass of water in the emulsion; w 油 It refers to the mass of oil in the emulsion; w 乳 It is the total mass of the emulsifier mixed in the emulsion.
[0087] The experimental instruments and equipment are as follows:
[0088] Tianma Hengji 0.1% electronic balance (JA1003); magnetic stirrer; beaker; glass stirring rod; dropper; plastic dropper.
[0089] The experimental sample configuration process is as follows:
[0090] First, weigh the oil, water, and emulsifier separately using an electronic scale and put them into different small beakers; add Span80 to the oil and stir well; add Tween80 to the water and stir well; then mix the water and oil with the emulsifier added and stir well with a stirrer; set the stirring time to 20 minutes.
[0091] The oil content of the emulsion is selected evenly in 5% intervals between 0% and 95%, specifically: 95%, 90%, 85%, 80%, 75%, 70%, 65%, 60%, 55%, 50%, 45%, 40%, 35%, 30%, 25%, 20%, 15%, 10%, and 5%. Samples with oil contents of 93%, 83%, 13%, 8%, 7%, and 6% are prepared according to requirements. The prepared samples are then emulsified by stirring with a magnetic stirrer for 20 minutes to form an oil-water mixed emulsion.
[0092] Step S1.2: Collect the mid-infrared spectral data of the sample emulsion to obtain the initial dataset.
[0093] The process of acquiring mid-infrared spectra is as follows:
[0094] The mid-infrared spectrum was acquired using a VERTEX 70 Fourier transform infrared spectrometer manufactured by Bruker GmbH, Germany, with OPUS 7.0 software as the accompanying acquisition software, and a resolution set to 4 cm⁻¹. -1 The wavenumber was preserved at 500 cm⁻¹. -1 ~4000cm -1 The emulsion was held in a zinc selenide liquid tank. Three samples were taken for each oil content of each oil product. Each sample was measured twice, and the average of the two measurements was taken as the infrared spectral data of the sample, resulting in a total of 300 spectral data.
[0095] Step S1.3: Correct and normalize the initial dataset to obtain a normalized dataset.
[0096] Preferably, the initial dataset is subjected to multivariate scattering correction processing to obtain a corrected dataset; the corrected dataset is then subjected to max-min normalization processing to obtain a normalized dataset.
[0097] In this embodiment, each sample corresponds to one MIR (Mid Infrared Spectroscopy) spectral data point, incorporating the full spectrum for modeling. The spectral data is preprocessed using MSC (Multiplicative Scatter Correction) to eliminate baseline shifts and drifts between samples.
[0098] To eliminate the adverse effects of excessive data scale differences, the spectral data is further subjected to Min-Max Normalization (MMN) transformation to normalize the spectral data of each sample to within the range [0,1]. The normalization formula is:
[0099]
[0100] Where mscx represents the data after MSC preprocessing; mscx min The minimum value of mscx; mscx max is the maximum value of mscx; mmnx is the spectral data after MMN transformation.
[0101] Step S1.4: Use the KS (Kennard-Stone) algorithm to divide the normalized dataset into a training set, a validation set, and a test set according to a set ratio.
[0102] The training, validation, and test sets are divided in a 3:1:1 ratio. The KS algorithm selects the sample set based on the Euclidean distance between sample spectra, ensuring strong representativeness and reducing the number of similar samples entering the training set. The specific process is as follows: First, calculate the distance between each pair of samples, and add the two samples furthest apart to the training set; then calculate the distance between each remaining sample and the selected samples in the training set, and select the furthest sample from the set of samples closest to the selected samples to add to the training set; this process is repeated until the required number of samples for the training set is met. Sixty spectra are randomly selected as the test set, and the remaining spectral data are then divided into training and validation sets using the KS algorithm; thus, 180 spectral samples are used as the training set, and 60 spectral samples are used as the validation set.
[0103] The KS formula is expressed in terms of d(·):
[0104]
[0105] In the formula, d is the Euclidean distance; (x,y) are points on the coordinate axes, i.e., the absorbance vectors of the two samples; n is the sample number, and for any two samples, x n This represents the absorbance value of sample 1 at the nth wavenumber, y n This represents the absorbance value of sample 2 at the nth wavenumber, and so on for the others.
[0106] Step S1.5: Determine the training set and the validation set as the sample dataset, and determine the oil content of the sample emulsion corresponding to the sample dataset as the true oil content corresponding to the sample dataset.
[0107] Step S2: Build the initial model of the kernel extreme learning machine; the kernel function of the initial model of the kernel extreme learning machine is a radial basis function; the penalty coefficient and kernel parameters of the initial model of the kernel extreme learning machine are randomly selected.
[0108] Kernel learning is defined as: assuming a sample set A function Φ makes the original space R N To Hilbert space Q V The transformation satisfies: R N →Q V and Let K(x,y) = <Φ(x),Φ(y)>, then K(x,y) is defined on R N ×R N The kernel function on Q; <Φ(x),Φ(y)> represents the kernel function on Q. V The inner product of the above.
[0109] The Radial Basis Function (RBF) kernel is chosen as the kernel function for KELM, with a randomly selected penalty coefficient C and kernel parameter σ. The kernel matrix replaces the random matrix in ELM. The kernel function maps all input samples from the N-dimensional space to a high-dimensional hidden layer feature space, thus constructing the initial KELM model. The specific calculations are shown below:
[0110] The RBF kernel function is represented by K(·):
[0111]
[0112] In the formula, x a x b These are two feature vectors.
[0113] In the ELM model, h(x) is the output function of the hidden layer node in the ELM, that is, the hidden layer output h(x) of each sample. i ) is the sample x i A nonlinear mapping function. The hidden layer data matrix H is represented as:
[0114]
[0115] In the formula, N is the number of samples; L is the number of features for each sample.
[0116] Therefore:
[0117]
[0118] In the formula, all are in the form of inner products of h(x), and the constructed kernel function is used to replace HH. T , making HH T (a,b)=K(x a ,x b ).
[0119] Then the following formula can be derived:
[0120]
[0121]
[0122] Therefore, the expression for the output f(x) of the KELM model is:
[0123]
[0124] In the formula, h(x) is the output function of the hidden layer node in ELM; H is the random matrix of the hidden layer in ELM; H T Let (x1, x2, ..., xn) be the generalized inverse matrix of the hidden layer matrix; N Ω represents the normalized feature data; I is a diagonal matrix; C is the penalty factor, also known as the penalty coefficient or regularization coefficient; ELM is the kernel matrix; T is the predicted target vector.
[0125] Step S3: Determine the fitness function based on the actual oil content and predicted oil content corresponding to the sample dataset; the predicted oil content corresponding to the sample dataset is obtained by inputting the sample dataset into the initial model of the kernel extreme learning machine for prediction.
[0126] Specifically, the mean squared error of the training set is determined based on the true oil content and predicted oil content corresponding to the training set in the sample dataset; the mean squared error of the validation set is determined based on the true oil content and predicted oil content corresponding to the validation set in the sample dataset; and the average of the mean squared error of the training set and the mean squared error of the validation set is determined as the fitness function.
[0127] Step S4: Based on the fitness function, the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine are iteratively optimized using the improved Northern Eagle algorithm to obtain the optimized kernel extreme learning machine model; the improved Northern Eagle algorithm further includes Gaussian perturbation of the optimal population after iteratively determining the optimal population using the Northern Eagle algorithm.
[0128] To address the randomness of parameter selection in the KELM algorithm during practical operation and the tendency of the Northern Eagle algorithm to get trapped in local optima, an improved Northern Eagle algorithm is used to optimize the penalty coefficient C and kernel parameter σ of the KELM neural network. The specific steps include:
[0129] Step S4.1: Set the population size of the Northern Goshawk, the maximum number of iterations, the dimension of the problem to be solved, and the parameter optimization limits. The parameter optimization limits include: an upper bound and a lower bound for the initial parameter values.
[0130] Specifically, the population size of the Northern Goshawk is set to Search_Agents = 30, the maximum number of iterations is Max_iter = 20, the dimension of the problem to be solved is dim = 2, and the upper bound of the initial parameter value is set to ub = [2]. 15 ,2 15 ], the lower bound of the initial parameter value lb = [2 -2 ,2 -2 ].
[0131] Step S4.2: Based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization limit, randomly generate the position of each Northern Goshawk in the solution space; the position of the Northern Goshawk represents the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine.
[0132] Preferably, based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization limits, the position of each Northern Goshawk in the solution space is randomly generated using Tent chaotic mapping. See the schematic diagram of the scatter distribution before and after Tent chaotic mapping. Figure 4 and Figure 5 It can be seen that the distribution of scattered points is more uniform after chaotic mapping.
[0133] Specifically, the position (C,σ) of each Northern Goshawk in the solution space is randomly generated, i.e., x', and the position of the population is X':
[0134]
[0135] In the formula, x' i1 ∈[0,1] is the penalty coefficient C; x' i2 ∈[0,1] represents the kernel parameter σ; i represents the number of northern eagles.
[0136] The chaotic sequence generated by the TENT chaotic mapping function is used as the initial position of the population. The chaotic operator has the advantages of randomness and regularity, and can traverse all states without repetition within a certain range.
[0137] The Tent chaos mapping formula is:
[0138]
[0139] In the formula, α∈(0,2] is the chaos parameter; x” i+1 This represents the data after chaotic mapping. In this embodiment, α = 0.5.
[0140] x' i+1 Projection within a limited range:
[0141] x i+1 =lb+x i+1 (ub-lb);
[0142] Therefore, the final position of the Northern Goshawk, initialized by X(·), is:
[0143]
[0144] Step S4.3: Calculate the fitness of each Northern Goshawk based on its location and the fitness function, and determine the minimum fitness as the optimal fitness, and determine the location of the Northern Goshawk corresponding to the minimum fitness as the optimal population.
[0145] Each Northern Goshawk corresponds to a different KELM model. The evaluation metric of the model at this time is used as the fitness of that Northern Goshawk, i.e., the objective function, and the fitness of each population is calculated. The average of the training set and the validation set is used as the evaluation metric, i.e., fitness, for each training session.
[0146] fitness function F i The expression for (·) is as follows:
[0147]
[0148] In the formula, MSE1 is the mean squared error of the training set; MSE2 is the mean squared error of the validation set.
[0149] Mean squared error measures the average squared error between the model's predicted values and the actual values. Its formula is:
[0150]
[0151] In the formula, M is the sample size; Y e This represents the true value of the e-th sample. This is the predicted value for the e-th sample.
[0152] The fitness of the Northern Goshawk population was ranked, and the best fitness in each generation was selected as the optimal fitness F. i and optimal population x best .
[0153] Each iteration of optimization includes steps S4.4-S4.7, as detailed below:
[0154] Step S4.4: In the identification phase, each Northern Goshawk randomly selects prey to attack, and updates the position and fitness of each Northern Goshawk according to the optimal fitness and the optimal population, thus obtaining the new state of each Northern Goshawk in the identification phase.
[0155] The Northern Goshawk randomly selects a prey and attacks it. The behavioral expression for the Northern Goshawk's prey recognition phase is:
[0156]
[0157]
[0158]
[0159] In the formula, P i r is the location of the prey chosen by the i-th northern eagle; r∈[0,1] is a random number; I is a random value of 1 or 2; It is the fitness value; It is its new state in the j-th dimension; It is the mean squared error of the training set under the new state; It is the mean squared error of the validation set in the new state; It is the fitness value in the new state; This is the new state of the i-th Northern Goshawk during the identification phase.
[0160] Step S4.5: During the development phase, each Northern Goshawk is instructed to capture prey within its hunting radius, and the position and fitness of each Northern Goshawk are updated according to the optimal fitness and the optimal population, thus obtaining the new state of each Northern Goshawk during the development phase.
[0161] After a Northern Goshawk attacks its prey, the prey will attempt to escape, but the Northern Goshawk is extremely fast and can capture its prey under any circumstances. The behavioral expression of the Northern Goshawk during its development phase is as follows:
[0162]
[0163]
[0164]
[0165]
[0166] In the formula, R is the hunting radius; t is the current iteration number; and represents the new state of the i-th Northern Goshawk during the hunting phase. It is its new state in the j-th dimension; It is the mean squared error of the training set under the new state; It is the mean squared error of the validation set in the new state; It is the fitness value in the new state; This is the new state of the i-th Northern Goshawk during the hunting phase.
[0167] Step S4.6: Calculate the updated fitness of each Northern Goshawk based on its new state during the development phase and the fitness function, and determine the minimum updated fitness as the optimal fitness. Then, determine the new state of the Northern Goshawk corresponding to the minimum updated fitness as the optimal population.
[0168] Step S4.7: Apply Gaussian perturbation to the optimal population to update the optimal population within the parameter optimization limits and update the optimal fitness.
[0169] Specifically, the optimal population is subjected to Gaussian perturbation to obtain a new state of the optimal population after Gaussian perturbation; it is determined whether the new state of the optimal population after Gaussian perturbation exceeds the parameter optimization limit, and the position exceeding the parameter optimization limit is adjusted to obtain the optimal population within the parameter optimization limit; the optimal fitness is updated based on the optimal population within the parameter optimization limit.
[0170] In the later stages of iteration, the Northern Eagle algorithm tends to concentrate on the optimal individual, leading to a lack of population diversity and premature convergence, making it prone to getting trapped in local optima. The improved Northern Eagle algorithm applies a Gaussian perturbation to the optimal population, as shown in the following formula:
[0171]
[0172]
[0173]
[0174] In the formula, d is the new state after applying a Gaussian perturbation to the optimal state; d follows a pattern with variance c. 2 The expected value is a Gaussian distribution with a mathematical expectation of μ; in this embodiment, c = 1 and μ = 0 is a standard Gaussian distribution.
[0175] Next, it is determined whether the update position exceeds the set limit, and the position that exceeds the limit is adjusted.
[0176] Step S4.9: Determine whether the current iteration count has reached the maximum iteration count, and obtain the determination result.
[0177] Step S4.10: If the judgment result is negative, return to step S4.4.
[0178] Step S4.11: If the judgment result is yes, then determine the optimal penalty coefficient and the optimal kernel parameter according to the optimal population, and determine the kernel extreme learning machine optimization model according to the optimal penalty coefficient and the optimal kernel parameter.
[0179] Specifically, determine whether the maximum number of iterations is met; if it is, output the result F. i The corresponding (x) i1 ,x i2 The optimal penalty coefficient C and the optimal kernel parameter σ are used as the KELM neural network; otherwise, the iteration continues.
[0180] Step S5: Obtain the mid-infrared spectral data of the target emulsion and input it into the kernel limit learning machine optimization model to obtain the predicted oil content of the target emulsion.
[0181] Specifically, the mid-infrared spectral data of the target emulsion are obtained from the test set.
[0182] Furthermore, the model accuracy is evaluated using three metrics: the coefficient of determination R0. 2 ; Test set mean squared error (MSEP); Algorithm running time (t seconds), denoted by t(s).
[0183] R 2 The formula for calculating MSEP is as follows:
[0184]
[0185]
[0186] In the formula, M is the total number of predicted samples; Y e This represents the true value of the e-th sample. This is the predicted value for the e-th sample; This represents the average value of the entire sample.
[0187] The improved NGO algorithm predicts the following results for the samples: Figure 6 and Figure 7 As shown, Figure 6 It is the fitness change curve of the algorithm during the training process. Figure 7 It is the prediction result for the test set samples.
[0188] In addition, a comparison of ELM, KELM, NGO-KELM, and the improved NGO-KELM (INGO-KELM) is shown in Table 1.
[0189] Table 1 shows the mean squared error, coefficient of determination, and algorithm runtime schedule for testing different models.
[0190] MSEP 0.006 0.0021 0.0012 0.00066 <![CDATA[R 2 ]]> 0.90 0.9764 0.9867 0.9928 t(s) 0.242 0.239 13.131 13.683
[0191] As shown in Table 1, compared with ELM, the KELM algorithm can process data more simply and improves convergence speed and classification performance.
[0192] Figure 8 CSO is used to optimize the fitness curve of KELM. Figure 6 and Figure 8 The comparison shows that, compared to the CSO algorithm, the NGO algorithm can quickly iterate to find the optimal target value without subsequent fluctuations. It reached the optimal target value and stabilized in the seventh iteration, indicating that the NGO algorithm has a fast search speed in the later stages, which greatly reduces the number of iterations and running time. It can be seen that the NGO algorithm can quickly determine the optimal target value of the iterative function and iterate, thus improving the accuracy of oil content prediction.
[0193] Table 2 shows a comparison between the predictions of the improved NGO-KELM model and the actual values.
[0194] Table 2 Comparison of Predictions and Actual Values from the Improved NGO-KELM Model
[0195]
[0196]
[0197] As shown in Table 2, the improved NGO-KELM model's prediction results are very close to the actual values. Although its running time is longer than other algorithms, the model has higher accuracy and can better predict emulsions with low oil content. This model has the advantages of being simple, fast, and highly accurate.
[0198] Example 2
[0199] To implement the method corresponding to Embodiment 1 above and achieve the corresponding functions and technical effects, a system for detecting the oil content of emulsified petroleum products is provided below. For example... Figure 9 As shown, the system includes:
[0200] Data acquisition module 1 is used to acquire sample datasets and corresponding true oil content; the sample datasets include mid-infrared spectral data of sample emulsions with different oil contents.
[0201] Model building module 2 is used to build the initial model of the kernel extreme learning machine; the kernel function of the initial model of the kernel extreme learning machine is a radial basis function; the penalty coefficient and kernel parameters of the initial model of the kernel extreme learning machine are randomly selected.
[0202] The fitness function determination module 3 is used to determine the fitness function based on the true oil content and predicted oil content corresponding to the sample dataset; the predicted oil content corresponding to the sample dataset is obtained by inputting the sample dataset into the initial model of the kernel extreme learning machine for prediction.
[0203] The parameter optimization module 4 is used to iteratively optimize the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine according to the fitness function using the improved Northern Eagle algorithm, so as to obtain the optimized kernel extreme learning machine model; the improved Northern Eagle algorithm further includes Gaussian perturbation of the optimal population after iteratively determining the optimal population using the Northern Eagle algorithm.
[0204] The oil content prediction module 5 is used to acquire the mid-infrared spectral data of the target emulsion and input it into the kernel limit learning machine optimization model to obtain the predicted oil content of the target emulsion.
[0205] Example 3
[0206] This invention also provides an electronic device, including a memory and a processor. The memory stores a computer program, and the processor runs the computer program to enable the electronic device to perform the oil content detection method for emulsified petroleum products described in Embodiment 1. The electronic device may be a server.
[0207] In addition, the present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the oil content detection method for emulsified petroleum products in Embodiment 1.
[0208] In summary, compared with existing technologies, due to the complex composition of petroleum and petroleum-related products, it is usually difficult to obtain detailed characteristic component information of petroleum products, and existing methods often need to be used in combination. This invention collects the mid-infrared spectrum of emulsified oil in an objective and scientific manner, which can make full use of spectral data to quickly and in batches predict the oil content of emulsified oil samples. At the same time, the improved NGO-optimized KELM method for concentration prediction of mid-infrared spectral data samples of emulsified oil has advantages such as fast calculation speed and good stability. This provides practical basis for the research of detection technology for petroleum and petroleum-related products under complex conditions.
[0209] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0210] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for detecting the oil content of emulsified petroleum products, characterized in that, include: Obtain a sample dataset and the corresponding true oil content; the sample dataset includes mid-infrared spectral data of several sample emulsions with different oil contents; An initial model of a kernel extreme learning machine is constructed; the kernel function of the initial model is a radial basis function; the penalty coefficient and kernel parameters of the initial model are randomly selected. The fitness function is determined based on the true oil content and predicted oil content corresponding to the sample dataset; specifically, this includes: determining the mean squared error of the training set based on the true oil content and predicted oil content corresponding to the training set in the sample dataset; determining the mean squared error of the validation set based on the true oil content and predicted oil content corresponding to the validation set in the sample dataset; and determining the average of the mean squared errors of the training set and the validation set as the fitness function; the predicted oil content corresponding to the sample dataset is obtained by inputting the sample dataset into the initial model of the kernel extreme learning machine for prediction. Based on the fitness function, an improved Northern Goshawk algorithm is used to iteratively optimize the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine, resulting in an optimized kernel extreme learning machine model. Specifically, this includes: setting the Northern Goshawk population size, maximum number of iterations, problem dimension, and parameter optimization limits; randomly generating the position of each Northern Goshawk in the solution space based on the Northern Goshawk population size, problem dimension, and parameter optimization limits; the position of the Northern Goshawk represents the penalty coefficient and kernel parameters in the initial model of the kernel extreme learning machine; calculating the fitness of each Northern Goshawk based on its position and the fitness function, and determining the minimum fitness as the optimal fitness, and determining the position of the Northern Goshawk corresponding to the minimum fitness as the optimal population; for any iteration optimization: in the recognition phase, each Northern Goshawk randomly selects prey to attack, and updates the position and fitness of each Northern Goshawk based on the optimal fitness and the optimal population, obtaining a new state for each Northern Goshawk in the recognition phase; in the development phase, each Northern Goshawk captures prey within its hunting radius, and based on the... The optimal fitness and the optimal population are used to update the position and fitness of each Northern Goshawk, resulting in a new state for each Northern Goshawk during the development phase. Based on the new state of each Northern Goshawk during the development phase and the fitness function, the updated fitness of each Northern Goshawk is calculated, and the minimum updated fitness is determined as the optimal fitness. The new state of the Northern Goshawk corresponding to the minimum updated fitness during the development phase is determined as the optimal population. The optimal population is subjected to Gaussian perturbation to update the optimal population within the parameter optimization limits, and the optimal fitness is also updated. It is determined whether the current iteration count has reached the maximum iteration count, and a judgment result is obtained. If the judgment result is negative, the process returns to step "In the identification phase, each Northern Goshawk randomly selects prey to attack, and based on the optimal fitness and the optimal population, the position and fitness of each Northern Goshawk are updated, resulting in a new state for each Northern Goshawk during the identification phase." If the judgment result is positive, the optimal penalty coefficient and optimal kernel parameters are determined based on the optimal population, and the kernel extreme learning machine optimization model is determined based on the optimal penalty coefficient and the optimal kernel parameters. The mid-infrared spectral data of the target emulsion are obtained and input into the kernel limit learning machine optimization model to obtain the predicted oil content of the target emulsion.
2. The method for detecting the oil content of emulsified petroleum products according to claim 1, characterized in that, Obtaining the sample dataset and the corresponding true oil content specifically includes: Prepare several sample emulsions with different oil contents; The mid-infrared spectral data of the sample emulsion were collected to obtain the initial dataset; The initial dataset is corrected and normalized to obtain a normalized dataset; The KS algorithm is used to divide the normalized dataset into training set, validation set and test set according to a set ratio; The training set and the validation set are determined as the sample dataset, and the oil content of the sample emulsion corresponding to the sample dataset is determined as the true oil content corresponding to the sample dataset.
3. The method for detecting the oil content of emulsified petroleum products according to claim 1, characterized in that, Applying Gaussian perturbation to the optimal population to update the optimal population within the parameter optimization bounds and updating the optimal fitness specifically includes: The optimal population is subjected to Gaussian perturbation to obtain the new state of the optimal population after Gaussian perturbation; Determine whether the new state of the optimal population after Gaussian perturbation exceeds the parameter optimization limit, and adjust the position that exceeds the parameter optimization limit to obtain the optimal population within the parameter optimization limit; The optimal fitness is updated based on the best population within the parameter optimization limits.
4. The method for detecting the oil content of emulsified petroleum products according to claim 1, characterized in that, Based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization limits, the position of each Northern Goshawk in the solution space is randomly generated, specifically including: Based on the population size of the Northern Goshawk, the dimension of the problem to be solved, and the parameter optimization limit, the position of each Northern Goshawk in the solution space is randomly generated using the Tent chaotic mapping.
5. The method for detecting the oil content of emulsified petroleum products according to claim 2, characterized in that, The initial dataset is corrected and normalized to obtain a normalized dataset, specifically including: The initial dataset is subjected to multivariate scattering correction processing to obtain the corrected dataset; The corrected dataset is subjected to max-min normalization to obtain a normalized dataset.
6. A system for detecting the oil content of emulsified petroleum products, characterized in that, include: The data acquisition module is used to acquire sample datasets and corresponding true oil content; The sample dataset includes mid-infrared spectral data of several sample emulsions with different oil contents; The model building module is used to build the initial model of the kernel extreme learning machine; the kernel function of the initial model of the kernel extreme learning machine is a radial basis function; the penalty coefficient and kernel parameters of the initial model of the kernel extreme learning machine are randomly selected. The fitness function determination module is used to determine the fitness function based on the true oil content and predicted oil content corresponding to the sample dataset. Specifically, it includes: determining the mean squared error of the training set based on the true oil content and predicted oil content corresponding to the training set in the sample dataset; determining the mean squared error of the validation set based on the true oil content and predicted oil content corresponding to the validation set in the sample dataset; determining the average of the mean squared errors of the training set and the validation set as the fitness function; and the predicted oil content corresponding to the sample dataset is obtained by inputting the sample dataset into the initial model of the kernel extreme learning machine for prediction. The parameter optimization module is used to iteratively optimize the penalty coefficients and kernel parameters in the initial model of the kernel extreme learning machine (KEM) based on the fitness function and using an improved Northern Goshawk algorithm, to obtain an optimized KEM model. Specifically, it includes: setting the Northern Goshawk population size, maximum number of iterations, problem dimension, and parameter optimization limits; randomly generating the position of each Northern Goshawk in the solution space based on the Northern Goshawk population size, problem dimension, and parameter optimization limits; the position of the Northern Goshawk represents the penalty coefficients and kernel parameters in the initial KEM model; calculating the fitness of each Northern Goshawk based on its position and the fitness function, determining the minimum fitness as the optimal fitness, and determining the position of the Northern Goshawk corresponding to the minimum fitness as the optimal population; for any iteration optimization: in the recognition phase, each Northern Goshawk randomly selects prey to attack, and updates the position and fitness of each Northern Goshawk based on the optimal fitness and the optimal population, obtaining a new state for each Northern Goshawk in the recognition phase; in the development phase, each Northern Goshawk captures prey within its hunting radius. Based on the optimal fitness and the optimal population, the position and fitness of each Northern Goshawk are updated to obtain the new state of each Northern Goshawk during the development phase. The updated fitness of each Northern Goshawk is calculated based on its new state during the development phase and the fitness function, and the minimum updated fitness is determined as the optimal fitness. The new state of the Northern Goshawk corresponding to the minimum updated fitness is determined as the optimal population. The optimal population is then subjected to Gaussian perturbation to update the optimal population within the parameter optimization limits, and the optimal population is also updated. Fitness; determine whether the current iteration count has reached the maximum iteration count, and obtain the judgment result; if the judgment result is negative, return to step "In the recognition stage, let each Northern Goshawk randomly select prey to attack, and update the position and fitness of each Northern Goshawk according to the optimal fitness and the optimal population, and obtain the new state of each Northern Goshawk in the recognition stage"; if the judgment result is positive, determine the optimal penalty coefficient and the optimal kernel parameter according to the optimal population, and determine the kernel extreme learning machine optimization model according to the optimal penalty coefficient and the optimal kernel parameter. The oil content prediction module is used to acquire the mid-infrared spectral data of the target emulsion and input it into the kernel limit learning machine optimization model to obtain the predicted oil content of the target emulsion.
7. An electronic device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to cause the electronic device to perform the method for detecting the oil content of emulsified petroleum products as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the method for detecting the oil content of emulsified petroleum products as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method for quantitatively analyzing emulsification performance of petroleum crude oil emulsification system and method for determining emulsification performance
CN103940770A
Method for testing water content and oil content in plant seeds and application of method
CN112834546A