PLC adaptive control method and system based on artificial intelligence
By constructing a balanced data set and optimizing individual position update methods, the data imbalance and search balance problems in PLC adaptive control are solved, and the performance and accuracy of the model are improved.
Patent Information
- Application Number
- CN202311537002.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-17
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2043-11-17
AI Technical Summary
In the existing PLC adaptive control method, the balanced data set method causes the boundaries of most and few classes at the sample boundaries to be blurred, and noise and redundant information are introduced, which cannot solve the problem of data imbalance; the individual location initialization of traditional models is uneven, and the search locations are diverse. Weakness in nature, low convergence accuracy, and the inability to balance local and global searches.
The boundary sample set is constructed based on the nearest neighbor samples, the sum of the proportions and distributions of most samples is calculated, and new samples are generated using three new sample generation methods to build an equilibrium data set; the individual position is initialized through sinusoidal chaos mapping, combining water wave dynamic factors and golden segmentation The coefficients are position updated and the model is constructed based on the maximum number of iterations and fitness thresholds.
It improves the accuracy of the model in distinguishing between majority and minority samples, controls noise and redundant information, enhances the diversity of individual locations, balances local and global search capabilities, and improves model performance.
Smart Images

Figure CN117348419B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of PLC control, and specifically refers to a PLC adaptive control method and system based on artificial intelligence. Background Art
[0002] PLC adaptive control is to automatically adjust the parameters of industrial processes, adapt to system changes, and improve the stability and performance of the control system. However, the existing balanced data set method has the problem that the newly generated samples are at the sample boundary, making the boundary between the majority class and the minority class increasingly blurred and difficult to distinguish, and introducing too much noise or redundant information when generating new samples, resulting in the inability to solve the problem of data imbalance; the traditional PLC adaptive control model has the problem of uneven individual position initialization, weak search position diversity, low convergence accuracy, and inability to find a balance between local search and global search. Summary of the invention
[0003] In view of the above situation, in order to overcome the defects of the prior art, the present invention provides a PLC adaptive control method and system based on artificial intelligence. In view of the existing balanced data set method, the newly generated samples are at the sample boundary, which makes the boundary between the majority class and the minority class more and more blurred and difficult to distinguish, and introduces too much noise or redundant information when generating new samples, resulting in the inability to solve the problem of data imbalance. This scheme constructs a boundary sample set based on the nearest neighbor sample, calculates the proportion and distribution sum of the majority samples in the nearest neighbor sample, obtains the number of samples required to be synthesized for each minority sample, and uses three new sample generation methods defined based on the sample generation area to generate new samples to construct a balanced data set. The newly generated samples will be closer to the boundary, which is helpful for the model to be more accurate. Accurately distinguish majority and minority samples, and control noise and redundant information, thereby improving model performance; In view of the problems of uneven individual position initialization, weak search position diversity, low convergence accuracy, and inability to find a balance between local search and global search in traditional PLC adaptive control models, this scheme initializes individual positions based on sinusoidal chaos mapping, uses water wave dynamic factors and dynamic inertia weights for the first position update, uses the golden section coefficient for the second position update, and completes the model construction based on the maximum number of iterations and fitness threshold, enriching the diversity of individual positions, improving global search performance, balancing the capabilities of local search and global search, and improving the defect of easily falling into local optimality during the search process, thereby improving model performance.
[0004] The technical solution adopted by the present invention is as follows: The PLC adaptive control method based on artificial intelligence provided by the present invention comprises the following steps:
[0005] Step S1: data collection, collecting historical industrial process data and control operation instructions;
[0006] Step S2: data preprocessing, data cleaning and data normalization processing of the collected data;
[0007] Step S3: Balance the historical data set, construct a boundary sample set based on the nearest neighbor samples, calculate the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtain the number of samples required to synthesize each minority sample, and use three new sample generation methods defined based on the sample generation area to generate new samples to construct a balanced data set;
[0008] Step S4: Establish a PLC adaptive control model, initialize individual positions based on sinusoidal chaos mapping, use water wave dynamic factors and dynamic inertia weights to perform the first position update, use the golden section coefficient to perform the second position update, and complete the model construction based on the maximum number of iterations and fitness threshold;
[0009] Step S5: PLC adaptive control, adjusting the parameters of the industrial process according to the control operation instructions predicted by the PLC adaptive control model to achieve PLC adaptive control.
[0010] Furthermore, in step S1, the data collection is to collect historical industrial process data and control operation instructions, the industrial process data includes sensor measurement data and industrial process status data, and the control operation instructions are used as prediction labels.
[0011] Furthermore, in step S2, the data preprocessing is to perform data cleaning on the collected historical industrial process data, the data cleaning includes using interpolation methods to fill missing values, delete outliers and data smoothing operations, and perform data normalization on the collected historical industrial process data, and construct a historical data set based on the historical industrial process data after data cleaning and data normalization.
[0012] Furthermore, in step S3, the balancing of the historical data set specifically includes the following steps:
[0013] Step S31: Calculate the nearest neighbor samples. For each minority sample, calculate the distance between it and other samples, sort them according to the size of the distance, and find the K samples closest to the minority sample as the K nearest neighbor samples of the minority sample. The formula used is as follows:
[0014] ;
[0015] Where M and F are two different minority samples in the historical dataset, m l and f l are the feature vectors of minority samples M and minority samples F in the lth dimension, d(M, F) is the distance between minority samples M and minority samples F, l is the feature dimension index, and A2 is the feature dimension;
[0016] Step S32: construct a boundary sample set, calculate the number of samples of the majority class and the number of samples of the minority class in the K nearest neighbor samples of the minority sample, if the number of samples of the majority class is greater than the number of samples of the minority class, then add the minority sample to the boundary sample set;
[0017] Step S33: Calculate the total number of samples to be synthesized, using the following formula:
[0018] S=(LM aj -LM in )×rand(0,1);
[0019] In the formula, S is the total number of samples to be synthesized, LM aj is the number of samples of the majority class in the historical dataset, LM in is the number of samples of the minority class in the historical data set, rand() is the random number generation function;
[0020] Step S34: Calculate the sum of proportion and distribution. For the boundary sample set (M1, M2, M3, ..., M n ), we label each minority sample in i , calculate the M i The number of majority samples among the K nearest neighbor samples, and the sum of the proportion and distribution of the majority samples of the K nearest neighbor samples are calculated. The formula used is as follows:
[0021] ;
[0022] Z=V1+V2+…+V n ;
[0023] Where V i is a minority sample M i The proportion of the majority samples of the K nearest neighbor samples, I i is a minority sample M i The number of majority samples in the K nearest neighbor samples, Z is the sum of the distributions of majority samples in the boundary sample set, and n is the number of minority samples in the boundary sample set;
[0024] Step S35: Calculate the number of samples required to synthesize each minority sample, using the following formula:
[0025] ;
[0026] a i =h i ×S;
[0027] In the formula, a i is a minority sample M i The number of samples to be synthesized, hi is the ratio of the number of samples that need to be synthesized for each minority sample Mi;
[0028] Step S36: Generate new samples, pre-set the size of the sample generation area η and 0<η<1, and select a small number of samples M i Randomly select two samples from the K nearest neighbor samples, denoted as k1 and k2, and interpolate between k1 and k2 to generate a temporary sample M v , then in M i With M v Interpolate between them to generate new samples M new And put them into the minority sample set. If k1 and k2 are both samples of the majority class, the first new sample generation method in step S361 is used to generate a new sample; if k1 is a sample of the minority class and k2 is a sample of the majority class, the second new sample generation method in step S362 is used to generate a new sample; if k1 and k2 are both samples of the minority class, the second new sample generation method in step S363 is used to generate a new sample. The steps are as follows:
[0029] Step S361: The first new sample generation method uses the following formula:
[0030] M1 v =k1+rand(0,1)×(k2-k1);
[0031] M1 new =M1 v +rand(0,η)×(M1 v -M i );
[0032] Where, M1 v is a temporary sample generated by the first new sample generation method, M1 new It is a new sample generated by the first new sample generation method;
[0033] Step S362: The second new sample generation method uses the following formula:
[0034] M2 v =k1+rand(0, η)×(k2-k1);
[0035] M2 new =M2 v +rand(0,1)×(M2 v -M i );
[0036] Where, M2 v is a temporary sample generated by the second new sample generation method, M2 newIt is a new sample generated by the second new sample generation method;
[0037] Step S363: The third new sample generation method uses the following formula:
[0038] M3 v =k1+rand(0,1)×(k2-k1);
[0039] M3 new =M3 v +rand(0,1)×(M3 v -M i );
[0040] Where, M3 v is a temporary sample generated by the third new sample generation method, M3 new It is a new sample generated by the third new sample generation method;
[0041] Step S37: construct a balanced data set based on the industrial process data after the new samples are generated.
[0042] Further, in step S4, the establishment of the PLC adaptive control model specifically includes the following steps:
[0043] Step S41: construct a training data set and a test data set, randomly select 70% of the sample data from the balanced data set as the training data set, and the remaining 30% of the sample data as the test data set;
[0044] Step S42: Initialize individual positions, use model parameters to represent individual positions, randomly generate the first individual position Q1 based on the individual search space, and initialize the 2nd-Nth individual positions Q2. o The formula used for the individual position is as follows:
[0045] ;
[0046] In the formula, Q c+1 is the position of the c+1th individual, Q c is the position of the cth individual, e is a constant in the range (0, 4], c is the individual index, N o is the total number of individuals;
[0047] Step S43: training the model, using Python to import the sklearn library to call the SVM function based on the model parameters, and training the PLC adaptive control model based on the training data set;
[0048] Step S44: Calculate the global optimal position, take the PLC adaptive control model performance established based on the model parameters as the individual fitness value, and take the individual position with the highest fitness value as the global optimal position Q best ;
[0049] Step S45: First location update, the steps are as follows:
[0050] Step S451: Calculate the water wave dynamic factor, using the following formula:
[0051] ;
[0052] Where U(t) is the water wave dynamic factor at the tth iteration, t is the iteration index, T is the maximum iteration number, b is a random integer and b∈[-1,1], r1 is a random number and r1∈[0,1], g is the control factor and g∈[1,3];
[0053] Step S452: Calculate the dynamic inertia weight using the following formula:
[0054] ;
[0055] Where E(t) is the dynamic inertia weight at the tth iteration, p is a random value that changes dynamically around the value 1, E0 is the minimum value of the dynamic inertia weight, and E1 is the maximum value of the dynamic inertia weight;
[0056] Step S453: Perform the first position update based on the water wave dynamic factor and the dynamic inertia weight. The formula used is as follows:
[0057] ;
[0058] Where Q1 c (t+1) is the position of the cth individual after the first position update, r2 and r3 are two different random numbers and r2, r3∈[0,1], Q best (t) is the global optimal position at the tth iteration, Q c (t) is the position of the cth individual at the tth iteration;
[0059] Step S46: The second location update, the steps are as follows:
[0060] Step S461: Calculate the golden section coefficient, the formula used is as follows:
[0061] s1=ε(1-δ)+γ×δ;
[0062] s2=ε×δ+γ×(1-δ);
[0063] Where s1 is the first golden section coefficient, s2 is the second golden section coefficient, δ is the golden section ratio, ε and γ are two different search intervals;
[0064] Step S462: Perform a second position update based on the golden section coefficient, using the following formula:
[0065] ;
[0066] Where, Q2 c (t+1) is the position of the cth individual after the second position update, Q1 best (t+1) is the global optimal position after the first position update, R1 and R2 are the two direction control factors of the position update, R1∈[0, 2π], R2∈[0, π];
[0067] Step S47: Determine the model parameters, pre-set the fitness value threshold β, update the global optimal position, and when the fitness value corresponding to the global optimal position is higher than the fitness value threshold β, build a PLC adaptive control model based on the current model parameters; otherwise, if the maximum number of iterations T is reached, go to step S42; otherwise, go to step S45.
[0068] Furthermore, in step S5, the PLC adaptive control collects real-time industrial process data, and after preprocessing the data, inputs the data into the PLC adaptive control model for prediction, inputs the predicted control operation instructions into the PLC as a reference signal, and adjusts the parameters of the industrial process according to the predicted control operation instructions to realize the adaptive control of the PLC.
[0069] The artificial intelligence-based PLC adaptive control system provided by the present invention comprises a data acquisition module, a data preprocessing module, a historical data set balancing module, a PLC adaptive control model building module and a PLC adaptive control module;
[0070] The data acquisition module collects historical industrial process data and control operation instructions, and sends the data to the data preprocessing module;
[0071] The data preprocessing module performs data cleaning and data normalization on the collected data, and sends the data to the balanced historical data set module;
[0072] The balanced historical data set module constructs a boundary sample set based on the nearest neighbor samples, calculates the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtains the number of samples required to synthesize each minority sample, and generates new samples using three new sample generation methods defined based on the sample generation area, constructs a balanced data set, and sends the data to the PLC adaptive control model establishment module;
[0073] The PLC adaptive control model module is constructed by initializing individual positions based on sinusoidal chaos mapping, using water wave dynamic factors and dynamic inertia weights to perform the first position update, using the golden section coefficient to perform the second position update, completing the model construction based on the maximum number of iterations and fitness threshold, and sending the data to the PLC adaptive control module;
[0074] The PLC adaptive control module adjusts the parameters of the industrial process according to the control operation instructions predicted by the PLC adaptive control model to achieve adaptive control of the PLC.
[0075] The beneficial effects achieved by the present invention using the above scheme are as follows:
[0076] (1) In view of the fact that the existing balanced dataset methods have newly generated samples at the sample boundary, the boundary between the majority class and the minority class becomes increasingly blurred and difficult to distinguish, and too much noise or redundant information is introduced when generating new samples, resulting in the inability to solve the problem of data imbalance. This scheme constructs a boundary sample set based on the nearest neighbor samples, calculates the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtains the number of samples required to synthesize each minority sample, and uses three new sample generation methods defined based on the sample generation area to generate new samples to construct a balanced dataset. The newly generated samples will be closer to the boundary, which helps the model to more accurately distinguish between majority and minority samples, and control noise and redundant information, thereby improving model performance.
[0077] (2) In view of the problems of uneven individual position initialization, weak search position diversity, low convergence accuracy, and inability to find a balance between local search and global search in traditional PLC adaptive control models, this scheme initializes individual positions based on sinusoidal chaos mapping, uses water wave dynamic factors and dynamic inertia weights for the first position update, and uses the golden section coefficient for the second position update. The model is constructed based on the maximum number of iterations and fitness threshold, which enriches the diversity of individual positions, improves global search performance, balances the capabilities of local search and global search, and improves the defect of easily falling into local optimality during the search process, thereby improving model performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 A schematic diagram of the process flow of the PLC adaptive control method based on artificial intelligence provided by the present invention;
[0079] Figure 2 A schematic diagram of the artificial intelligence-based PLC adaptive control system provided by the present invention;
[0080] Figure 3 is a schematic flow chart of step S3;
[0081] Figure 4It is a schematic diagram of the process of step S4.
[0082] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention. DETAILED DESCRIPTION
[0083] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0084] In the description of the present invention, it should be understood that terms such as “upper”, “lower”, “front”, “back”, “left”, “right”, “top”, “bottom”, “inside” and “outside” indicating directions or positional relationships are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as limiting the present invention.
[0085] Example 1, see Figure 1 The present invention provides a PLC adaptive control method based on artificial intelligence, which comprises the following steps:
[0086] Step S1: data collection, collecting historical industrial process data and control operation instructions;
[0087] Step S2: data preprocessing, data cleaning and data normalization processing of the collected data;
[0088] Step S3: Balance the historical data set, construct a boundary sample set based on the nearest neighbor samples, calculate the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtain the number of samples required to synthesize each minority sample, and use three new sample generation methods defined based on the sample generation area to generate new samples to construct a balanced data set;
[0089] Step S4: Establish a PLC adaptive control model, initialize individual positions based on sinusoidal chaos mapping, use water wave dynamic factors and dynamic inertia weights to perform the first position update, use the golden section coefficient to perform the second position update, and complete the model construction based on the maximum number of iterations and fitness threshold;
[0090] Step S5: PLC adaptive control, adjusting the parameters of the industrial process according to the control operation instructions predicted by the PLC adaptive control model to achieve PLC adaptive control.
[0091] Example 2, see Figure 1 ,This embodiment is based on the above embodiment. In step S1, data collection is to collect historical industrial process data and control operation instructions. The industrial process data includes sensor measurement data and industrial process status data, and the control operation instructions are used as prediction labels.
[0092] Example 3, see Figure 1 This embodiment is based on the above embodiment. In step S2, data preprocessing is to perform data cleaning on the collected historical industrial process data. The data cleaning includes using interpolation methods to fill missing values, delete outliers and perform data smoothing operations, and perform data normalization on the collected historical industrial process data. A historical data set is constructed based on the historical industrial process data after data cleaning and data normalization.
[0093] Example 4, see Figure 1 and Figure 3 This embodiment is based on the above embodiment. In step S3, balancing the historical data set specifically includes the following steps:
[0094] Step S31: Calculate the nearest neighbor samples. For each minority sample, calculate the distance between it and other samples, sort them according to the size of the distance, and find the K samples closest to the minority sample as the K nearest neighbor samples of the minority sample. The formula used is as follows:
[0095] ;
[0096] Where M and F are two different minority samples in the historical dataset, m l and f l are the feature vectors of minority samples M and minority samples F in the lth dimension, d(M, F) is the distance between minority samples M and minority samples F, l is the feature dimension index, and A2 is the feature dimension;
[0097] Step S32: construct a boundary sample set, calculate the number of samples of the majority class and the number of samples of the minority class in the K nearest neighbor samples of the minority sample, if the number of samples of the majority class is greater than the number of samples of the minority class, then add the minority sample to the boundary sample set;
[0098] Step S33: Calculate the total number of samples to be synthesized, using the following formula:
[0099] S=(LM aj -LM in )×rand(0,1);
[0100] In the formula, S is the total number of samples to be synthesized, LM aj is the number of samples of the majority class in the historical dataset, LMin is the number of samples of the minority class in the historical data set, rand() is the random number generation function;
[0101] Step S34: Calculate the sum of proportion and distribution. For the boundary sample set (M1, M2, M3, ..., M n ), we label each minority sample in i , calculate the M i The number of majority samples among the K nearest neighbor samples, and the sum of the proportion and distribution of the majority samples of the K nearest neighbor samples are calculated. The formula used is as follows:
[0102] ;
[0103] Z=V1+V2+…+V n ;
[0104] Where V i is a minority sample M i The proportion of the majority samples of the K nearest neighbor samples, I i is a minority sample M i The number of majority samples in the K nearest neighbor samples, Z is the sum of the distributions of majority samples in the boundary sample set, and n is the number of minority samples in the boundary sample set;
[0105] Step S35: Calculate the number of samples required to synthesize each minority sample, using the following formula:
[0106] ;
[0107] a i =h i ×S;
[0108] In the formula, a i is a minority sample M i The number of samples to be synthesized, h i is the ratio of the number of samples that need to be synthesized for each minority sample Mi;
[0109] Step S36: Generate new samples, pre-set the size of the sample generation area η and 0<η<1, and select a small number of samples M i Randomly select two samples from the K nearest neighbor samples, denoted as k1 and k2, and interpolate between k1 and k2 to generate a temporary sample M v , then in M i With M v Interpolate between them to generate new samples M newAnd put them into the minority sample set. If k1 and k2 are both samples of the majority class, the first new sample generation method in step S361 is used to generate a new sample; if k1 is a sample of the minority class and k2 is a sample of the majority class, the second new sample generation method in step S362 is used to generate a new sample; if k1 and k2 are both samples of the minority class, the second new sample generation method in step S363 is used to generate a new sample. The steps are as follows:
[0110] Step S361: The first new sample generation method uses the following formula:
[0111] M1 v =k1+rand(0,1)×(k2-k1);
[0112] M1 new =M1 v +rand(0,η)×(M1 v -M i );
[0113] Where, M1 v is a temporary sample generated by the first new sample generation method, M1 new It is a new sample generated by the first new sample generation method;
[0114] Step S362: The second new sample generation method uses the following formula:
[0115] M2 v =k1+rand(0, η)×(k2-k1);
[0116] M2 new =M2 v +rand(0,1)×(M2 v -M i );
[0117] Where, M2 v is a temporary sample generated by the second new sample generation method, M2 new It is a new sample generated by the second new sample generation method;
[0118] Step S363: The third new sample generation method uses the following formula:
[0119] M3 v =k1+rand(0,1)×(k2-k1);
[0120] M3 new =M3 v +rand(0,1)×(M3 v -M i );
[0121] Where, M3 v is a temporary sample generated by the third new sample generation method, M3 new It is a new sample generated by the third new sample generation method;
[0122] Step S37: construct a balanced data set based on the industrial process data after the new samples are generated.
[0123] By performing the above operations, the existing balanced data set method has newly generated samples at the sample boundary, which makes the boundary between the majority class and the minority class more and more blurred and difficult to distinguish, and introduces too much noise or redundant information when generating new samples, resulting in the inability to solve the problem of data imbalance. This scheme constructs a boundary sample set based on the nearest neighbor samples, calculates the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtains the number of samples required to synthesize each minority sample, and uses three new sample generation methods defined based on the sample generation area to generate new samples to construct a balanced data set. The newly generated samples will be closer to the boundary, which will help the model to more accurately distinguish between majority and minority samples, and control noise and redundant information, thereby improving model performance.
[0124] Example 5, see Figure 1 and Figure 4 This embodiment is based on the above embodiment. In step S4, establishing a PLC adaptive control model specifically includes the following steps:
[0125] Step S41: construct a training data set and a test data set, randomly select 70% of the sample data from the balanced data set as the training data set, and the remaining 30% of the sample data as the test data set;
[0126] Step S42: Initialize individual positions, use model parameters to represent individual positions, randomly generate the first individual position Q1 based on the individual search space, and initialize the 2nd-Nth individual positions Q2. o The formula used for the individual position is as follows:
[0127] ;
[0128] In the formula, Q c+1 is the position of the c+1th individual, Q c is the position of the cth individual, e is a constant in the range (0, 4], c is the individual index, N o is the total number of individuals;
[0129] Step S43: training the model, using Python to import the sklearn library to call the SVM function based on the model parameters, and training the PLC adaptive control model based on the training data set;
[0130] Step S44: Calculate the global optimal position, take the PLC adaptive control model performance established based on the model parameters as the individual fitness value, and take the individual position with the highest fitness value as the global optimal position Q best ;
[0131] Step S45: First location update, the steps are as follows:
[0132] Step S451: Calculate the water wave dynamic factor, using the following formula:
[0133] ;
[0134] Where U(t) is the water wave dynamic factor at the tth iteration, t is the iteration index, T is the maximum iteration number, b is a random integer and b∈[-1,1], r1 is a random number and r1∈[0,1], g is the control factor and g∈[1,3];
[0135] Step S452: Calculate the dynamic inertia weight using the following formula:
[0136] ;
[0137] Where E(t) is the dynamic inertia weight at the tth iteration, p is a random value that changes dynamically around the value 1, E0 is the minimum value of the dynamic inertia weight, and E1 is the maximum value of the dynamic inertia weight;
[0138] Step S453: Perform the first position update based on the water wave dynamic factor and the dynamic inertia weight. The formula used is as follows:
[0139] ;
[0140] Where Q1 c (t+1) is the position of the cth individual after the first position update, r2 and r3 are two different random numbers and r2, r3∈[0,1], Q best (t) is the global optimal position at the tth iteration, Q c (t) is the position of the cth individual at the tth iteration;
[0141] Step S46: The second location update, the steps are as follows:
[0142] Step S461: Calculate the golden section coefficient, the formula used is as follows:
[0143] s1=ε(1-δ)+γ×δ;
[0144] s2=ε×δ+γ×(1-δ);
[0145] Where s1 is the first golden section coefficient, s2 is the second golden section coefficient, δ is the golden section ratio, ε and γ are two different search intervals;
[0146] Step S462: Perform a second position update based on the golden section coefficient, using the following formula:
[0147] ;
[0148] Where, Q2 c (t+1) is the position of the cth individual after the second position update, Q1 best (t+1) is the global optimal position after the first position update, R1 and R2 are the two direction control factors of the position update, R1∈[0, 2π], R2∈[0, π];
[0149] Step S47: Determine the model parameters, pre-set the fitness value threshold β, update the global optimal position, and when the fitness value corresponding to the global optimal position is higher than the fitness value threshold β, build a PLC adaptive control model based on the current model parameters; otherwise, if the maximum number of iterations T is reached, go to step S42; otherwise, go to step S45.
[0150] By performing the above operations, in view of the problems of uneven individual position initialization, weak search position diversity, low convergence accuracy, and inability to find a balance between local search and global search in the traditional PLC adaptive control model, this scheme initializes the individual position based on sinusoidal chaos mapping, uses water wave dynamic factors and dynamic inertia weights for the first position update, uses the golden section coefficient for the second position update, and completes the model construction based on the maximum number of iterations and fitness threshold, which enriches the diversity of individual positions, improves the global search performance, balances the capabilities of local search and global search, and improves the defect of easily falling into local optimality during the search process, thereby improving the model performance.
[0151] Example 6, see Figure 1 This embodiment is based on the above embodiment. In step S5, the PLC adaptive control collects real-time industrial process data. After preprocessing the data, the data is input into the PLC adaptive control model for prediction. The predicted control operation instruction is input into the PLC as a reference signal. The parameters of the industrial process are adjusted according to the predicted control operation instruction to realize the adaptive control of the PLC.
[0152] Embodiment 7, see Figure 2 , this embodiment is based on the above embodiment, the artificial intelligence-based PLC adaptive control system provided by the present invention includes a data acquisition module, a data preprocessing module, a balance historical data set module, a PLC adaptive control model establishment module and a PLC adaptive control module;
[0153] The data acquisition module collects historical industrial process data and control operation instructions, and sends the data to the data preprocessing module;
[0154] The data preprocessing module performs data cleaning and data normalization on the collected data, and sends the data to the balanced historical data set module;
[0155] The balanced historical data set module constructs a boundary sample set based on the nearest neighbor samples, calculates the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtains the number of samples required to synthesize each minority sample, and generates new samples using three new sample generation methods defined based on the sample generation area, constructs a balanced data set, and sends the data to the PLC adaptive control model establishment module;
[0156] The PLC adaptive control model module is constructed by initializing individual positions based on sinusoidal chaos mapping, using water wave dynamic factors and dynamic inertia weights to perform the first position update, using the golden section coefficient to perform the second position update, completing the model construction based on the maximum number of iterations and fitness threshold, and sending the data to the PLC adaptive control module;
[0157] The PLC adaptive control module adjusts the parameters of the industrial process according to the control operation instructions predicted by the PLC adaptive control model to achieve adaptive control of the PLC.
[0158] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0159] 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.
[0160] The present invention and its embodiments are described above, and such description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.
Claims
1. PLC adaptive control method based on artificial intelligence, Features: The method comprises the following steps: Step S1: data collection, collecting historical industrial process data and control operation instructions; Step S2: data preprocessing, data cleaning and data normalization processing of the collected data; Step S3: Balance the historical data set, construct a boundary sample set based on the nearest neighbor samples, calculate the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtain the number of samples required to synthesize each minority sample, and use three new sample generation methods defined based on the sample generation area to generate new samples to construct a balanced data set; Step S4: Establish a PLC adaptive control model, initialize individual positions based on sinusoidal chaos mapping, use water wave dynamic factors and dynamic inertia weights to perform the first position update, use the golden section coefficient to perform the second position update, and complete the model construction based on the maximum number of iterations and fitness threshold; Step S5: PLC adaptive control, adjusting the parameters of the industrial process according to the control operation instructions predicted by the PLC adaptive control model to achieve PLC adaptive control; In step S4, the establishment of the PLC adaptive control model specifically includes the following steps: Step S41: construct a training data set and a test data set, randomly select 70% of the sample data from the balanced data set as the training data set, and the remaining 30% of the sample data as the test data set; Step S42: Initialize the individual position, use the model parameters to represent the individual position, and randomly generate the first individual position Q based on the individual search space 1 , initialize the 2-N o The formula used for the individual position is as follows: ; In the formula, Q c+1 is the position of the c+1th individual, Q c is the position of the cth individual, e is a constant in the range (0, 4], c is the individual index, N o is the total number of individuals; Step S43: training the model, using Python to import the sklearn library to call the SVM function based on the model parameters, and training the PLC adaptive control model based on the training data set; Step S44: Calculate the global optimal position, take the PLC adaptive control model performance established based on the model parameters as the individual fitness value, and take the individual position with the highest fitness value as the global optimal position Q best ; Step S45: First location update, the steps are as follows: Step S451: Calculate the water wave dynamic factor, using the following formula: ; Where U(t) is the water wave dynamic factor at the tth iteration, t is the iteration index, T is the maximum number of iterations, b is a random integer and b∈[-1,1], r 1 is a random number and r 1 ∈[0,1], g is the control factor and g∈[1,3]; Step S452: Calculate the dynamic inertia weight using the following formula: ; Where E(t) is the dynamic inertia weight at the tth iteration, p is a random value that changes dynamically around value 1, and E 0 is the minimum value of the dynamic inertia weight, E 1 is the maximum value of the dynamic inertia weight; Step S453: Perform the first position update based on the water wave dynamic factor and the dynamic inertia weight. The formula used is as follows: ; Where, Q1 c (t+1) is the position of the cth individual after the first position update, r 2 and r 3 are two different random numbers and r 2 、r 3 ∈[0, 1], Q best (t) is the global optimal position at the tth iteration, Q c (t) is the position of the cth individual at the tth iteration; Step S46: The second location update, the steps are as follows: Step S461: Calculate the golden section coefficient, the formula used is as follows: s 1 =ε(1-δ)+γ×δ; s 2 =ε×δ+γ×(1-δ); In the formula, s 1 is the first golden ratio coefficient, s 2 is the second golden section coefficient, δ is the golden section ratio, ε and γ are two different search intervals; Step S462: Perform a second position update based on the golden section coefficient, using the following formula: ; Where, Q2 c (t+1) is the position of the cth individual after the second position update, Q1 best (t+1) is the global optimal position after the first position update, R 1 and R 2 are the two directional control factors for position update, R 1 ∈[0, 2π], R 2 ∈[0,π]; Step S47: Determine the model parameters, pre-set the fitness value threshold β, update the global optimal position, and when the fitness value corresponding to the global optimal position is higher than the fitness value threshold β, construct the PLC adaptive control model based on the current model parameters; otherwise, if the maximum number of iterations T is reached, go to step S42; otherwise, go to step S45; In step S3, the balancing of the historical data set specifically includes the following steps: Step S31: Calculate the nearest neighbor samples. For each minority sample, calculate the distance between it and other samples, sort them according to the size of the distance, and find the K samples closest to the minority sample as the K nearest neighbor samples of the minority sample. The formula used is as follows: ; Where M and F are two different minority samples in the historical dataset, m l and f l are the feature vectors of minority samples M and minority samples F in the lth dimension, d(M, F) is the distance between minority samples M and minority samples F, l is the feature dimension index, and A2 is the feature dimension; Step S32: construct a boundary sample set, calculate the number of samples of the majority class and the number of samples of the minority class in the K nearest neighbor samples of the minority sample, if the number of samples of the majority class is greater than the number of samples of the minority class, then add the minority sample to the boundary sample set; Step S33: Calculate the total number of samples to be synthesized, using the following formula: S=(LM aj -LM in )×rand(0,1); In the formula, S is the total number of samples to be synthesized, LM aj is the number of samples of the majority class in the historical dataset, LM in is the number of samples of the minority class in the historical data set, rand() is the random number generation function; Step S34: Calculate the sum of the proportion and distribution. For the boundary sample set (M 1 , M 2 , M 3 , …, M n ), we label each minority sample in i , calculate the M i The number of majority samples among the K nearest neighbor samples, and the sum of the proportion and distribution of the majority samples of the K nearest neighbor samples are calculated. The formula used is as follows: ; Z=V 1 +V 2 +…+V n ; Where V i is a minority sample M i The proportion of the majority samples of the K nearest neighbor samples, I i is a minority sample M i The number of majority samples in the K nearest neighbor samples, Z is the sum of the distributions of majority samples in the boundary sample set, and n is the number of minority samples in the boundary sample set; Step S35: Calculate the number of samples required to synthesize each minority sample, using the following formula: ; a i =h i ×S; In the formula, a i is a minority sample M i The number of samples to be synthesized, h i is the ratio of the number of samples that need to be synthesized for each minority sample Mi; Step S36: Generate new samples, pre-set the size of the sample generation area η and 0<η<1, and select a small number of samples M i Two samples are randomly selected from the K nearest neighbor samples, denoted as k 1 and k 2 , in k 1 With k 2 Interpolate between to generate temporary samples M v , then in M i With M v Interpolate between them to generate new samples M new And put it into a minority sample set, if k 1 and k 2 are all samples of the majority class, then the first new sample generation method in step S361 is used to generate new samples; if k 1 is the sample of the minority class, k 2 is a sample of the majority class, then the second new sample generation method in step S362 is used to generate a new sample; if k 1 and k 2 If all of them are samples of the minority class, the second new sample generation method in step S363 is used to generate new samples, and the steps are as follows: Step S361: The first new sample generation method uses the following formula: M1 v =k 1 +rand(0,1)×(k 2 -k 1 ); M1 new =M1 v +rand(0,η)×(M1 v -M i ); Where, M1 v is a temporary sample generated by the first new sample generation method, M1 new It is a new sample generated by the first new sample generation method; Step S362: The second new sample generation method uses the following formula: M2 v =k 1 +rand(0,η)×(k 2 -k 1 ); <h2 style=";text-align:left;direction:ltr">M2<h2 style=";text-align:left;direction:ltr"> new <h2 style=";text-align:left;direction:ltr"> =M2<h2 style=";text-align:left;direction:ltr"> v <h2 style=";text-align:left;direction:ltr"> +rand(0,1)×(M2)<h2 style=";text-align:left;direction:ltr"> v <h2 style=";text-align:left;direction:ltr"> -M<h2 style=";text-align:left;direction:ltr"> i <h2 style=";text-align:left;direction:ltr"> ); Where, M2 v is a temporary sample generated by the second new sample generation method, M2 new It is a new sample generated by the second new sample generation method; Step S363: The third new sample generation method uses the following formula: M3 v =k 1 +border(0,1)×(k 2 -k 1 ); <h2 style=";text-align:left;direction:ltr">M3<h2 style=";text-align:left;direction:ltr"> new <h2 style=";text-align:left;direction:ltr"> =M3<h2 style=";text-align:left;direction:ltr"> v <h2 style=";text-align:left;direction:ltr"> +rand(0,1)×(M3)<h2 style=";text-align:left;direction:ltr"> v <h2 style=";text-align:left;direction:ltr"> -M<h2 style=";text-align:left;direction:ltr"> i <h2 style=";text-align:left;direction:ltr"> ); Where, M3 v is a temporary sample generated by the third new sample generation method, M3 new It is a new sample generated by the third new sample generation method; Step S37: construct a balanced data set based on the industrial process data after the new samples are generated.
2. According to the artificial intelligence-based PLC adaptive control method of claim 1, Features: In step S1, the data collection is to collect historical industrial process data and control operation instructions, the industrial process data includes sensor measurement data and industrial process status data, and the control operation instructions are used as prediction labels.
3. The PLC adaptive control method based on artificial intelligence according to claim 1, Features: In step S2, the data preprocessing is to perform data cleaning on the collected historical industrial process data, and the data cleaning includes using interpolation methods to fill missing values, delete outliers and perform data smoothing operations, and perform data normalization on the collected historical industrial process data, and construct a historical data set based on the historical industrial process data after data cleaning and data normalization.
4. The PLC adaptive control method based on artificial intelligence according to claim 1, Features: In step S5, the PLC adaptive control collects real-time industrial process data, and after preprocessing the data, inputs the data into the PLC adaptive control model for prediction, inputs the predicted control operation instructions into the PLC as reference signals, and adjusts the parameters of the industrial process according to the predicted control operation instructions to realize the adaptive control of the PLC.
5. A PLC adaptive control system based on artificial intelligence, used to implement the PLC adaptive control method based on artificial intelligence as described in any one of claims 1 to 4, Features: It includes a data acquisition module, a data preprocessing module, a historical data set balance module, a PLC adaptive control model building module and a PLC adaptive control module.
6. The artificial intelligence-based PLC adaptive control system according to claim 5, Features: The data acquisition module collects historical industrial process data and control operation instructions, and sends the data to the data preprocessing module; The data preprocessing module performs data cleaning and data normalization on the collected data, and sends the data to the balanced historical data set module; The balanced historical data set module constructs a boundary sample set based on the nearest neighbor samples, calculates the proportion and distribution sum of the majority samples in the nearest neighbor samples, obtains the number of samples required to synthesize each minority sample, and generates new samples using three new sample generation methods defined based on the sample generation area, constructs a balanced data set, and sends the data to the PLC adaptive control model establishment module; The PLC adaptive control model module is constructed by initializing individual positions based on sinusoidal chaos mapping, using water wave dynamic factors and dynamic inertia weights to perform the first position update, using the golden section coefficient to perform the second position update, completing the model construction based on the maximum number of iterations and fitness threshold, and sending the data to the PLC adaptive control module; The PLC adaptive control module adjusts the parameters of the industrial process according to the control operation instructions predicted by the PLC adaptive control model to achieve adaptive control of the PLC.
