Disclosure of Invention
The invention aims to make up for the defects of the prior art, and provides an optimization method of a preparation process of an optical fiber preform based on a genetic algorithm and a BP neural network, wherein the technical scheme adopted by the invention is as follows:
an optical fiber perform preparation process optimization method based on a genetic algorithm and a BP neural network comprises the following specific steps:
step 1: collecting original data of optical fiber preform production, collecting gas flow of a blast burner and optical rod quality corresponding to the gas flow when the optical fiber preform is prepared, and respectively using the gas flow as input data and the optical rod quality as output data;
step 2: preprocessing the collected original data, and removing invalid data to obtain a preprocessed data set; the invalid data refers to the data of abnormal production conditions of the optical fiber preform and the quality of the optical fiber preform, and is caused by accidental factors in production;
and step 3: grading the quality of the optical rod, dividing the quality of the optical rod into a plurality of grades according to the optical performance of the optical rod, the transmission performance of the produced optical fiber and the mechanical performance, and grouping the preprocessed data sets according to the grade of the quality of the optical rod;
and 4, step 4: dividing each group of data into a training set and a testing set by adopting a retention method;
and 5: normalizing the training set by using a mapminmax function, normalizing input data and output data of the training set to be between-1 and 1, and outputting normalized input transformation data input train and output transformation data output train;
step 6: constructing an optical fiber preform preparation quality prediction model net based on a BP neural network;
and 7: constructing a Genetic algorithm model, optimizing an initial weight and a threshold of a BP neural network-based optical fiber preform preparation quality prediction model net to obtain an optimal individual x, wherein the optimal individual x comprises the initial weight and the threshold information of the optimized BP neural network;
and 8: assigning the weight value and the threshold value optimized by the genetic algorithm to a BP neural network; extracting an initial weight and a threshold value of the optimized BP neural network from the optimal individual x solved by the genetic algorithm, and assigning a value to the BP neural network after finishing;
and step 9: BP neural network training: setting training parameters, iteration times, learning efficiency and target precision; inputting normalized input transformation data input train and output transformation data output train by using a train function to complete the training of the neural network, namely completing the training of an optical fiber preform preparation quality prediction model based on the BP neural network;
step 10: normalizing the training set by using a mapminmax function, normalizing the input data of the test set and the output data of the test set to be between-1 and 1, and respectively outputting the normalized input test and output test;
step 11: testing an optical fiber preform preparation quality prediction model net based on a BP neural network; using a sim function, bringing the normalized test set input data input test into a trained optical fiber preform preparation quality prediction model net for testing to obtain a coded test result, and recording the coded test result as an; decoding the optical fiber preform, and recording a decoding result as test _ simul, namely a test result of the optical fiber preform quality prediction model;
step 12: the test result test _ simul is differed from the test set output data output test to obtain the test error of the optical fiber preform preparation quality prediction model; adjusting the weight and the threshold of a net model for predicting the preparation quality of the optical fiber preform according to the test error to obtain an optical fiber preform preparation quality prediction model based on the BP neural network;
step 13: storing the trained network data of the quality prediction model prepared by the optical fiber preform based on the BP neural network by using a save net function;
step 14: establishing a genetic algorithm model optimize, optimizing a preparation quality prediction model net of the optical fiber perform of the BP neural network, and searching a predicted optimal individual y of the quality of the optical fiber perform, wherein the optimal individual y comprises input conditions corresponding to the preparation of the optical fiber perform, namely optimal process conditions for preparing the optical fiber perform.
Optionally, in step 14, establishing the genetic algorithm model optisize includes the steps of:
step 14.1: initializing parameters of a genetic algorithm: setting iteration times maxgen2, population size sizepop2, cross probability pcross2 and variation probability pmutation2 of the network, and adjusting according to the data volume and difference;
step 14.2: defining a chromosome length lenchrom2 and a boundary value bound2 according to the number inputnum of BP neural network input data, wherein the chromosome length lenchrom2 is the same as the number inputnum of the BP neural network input data, and the boundary value bound2 is a matrix of rows and columns 2 of the inputnum, wherein the first column is a lower boundary, and the second column is an upper boundary;
step 14.3: population initialization: inputting the chromosome length lenchrom2 and the boundary value bound obtained in the previous step into a function code2, and randomly generating chromosome individuals to form a population individuals 2; defining a population structure, wherein the population individuals2 comprises the fitness of population individuals and the coding information of each chromosome;
step 14.4: calculating the fitness; loading the stored BP neural network optical fiber perform to prepare a quality prediction model net by using a load net function, and inputting individual chromosome information in population individuals2 to obtain information of the quality prediction model prepared by the BP neural network optical fiber perform; inputting the coded individual information of the chromosome and the information of the quality prediction model prepared by the BP neural network optical fiber perform into a fitness calculation function fun2 to obtain corresponding fitness individuals2. fitness2; finding out the chromosome bestchrom2 with the best fitness in each generation and recording the chromosome information, the best fitness value bestfittness 2 and the average fitness avgfittness 2 of the generation;
step 14.5: selecting operation: inputting the population information individuals2 and the population quantity sizpop2 into a selection function select2, and outputting a selected new population individuals 2; the selection mode in the selection function select2 is to determine the probability of selection according to the fitness value of each individual;
step 14.6: and (3) cross operation: inputting the cross probability pcross2, the chromosome length lenchrom2, the chromosome information chrom2 and the population quantity sizepop2 into a cross function cross2, selecting chromosome individuals needing cross operation from a new population individuals2 obtained by selection operation according to the cross operation probability pcross2 by the cross function cross2, randomly pairing every two chromosome individuals, and performing cross exchange on partial genes to obtain the crossed chromosome individuals chrom 2;
step 14.7: mutation operation: inputting the variation probability pmutation2, the chromosome length lenchrom2, the chromosome information chrom2, the population quantity sizepop2, the current iteration num2, the maximum iteration maxgen2 and the boundary bound2 of each individual into a variation function Mutation2, selecting individuals needing variation operation from the crossed chromosome chrom2, mutating certain genes on the individuals, and outputting the chromosome chrom2 after variation; wherein, the chromosome for mutation is randomly selected, and the mutation position is also randomly selected;
step 14.8: and (3) replacement operation: inputting the individual information of the mutated chromosome chrom2 into a fitness function fun2 one by one, and outputting and recording the fitness value individuals2.fitness2 of each individual; finding out chromosomes with minimum fitness and maximum fitness and positions of the chromosomes in the population, and replacing the chromosomes with maximum fitness by the chromosomes with minimum fitness values; recording the best fitness and the average fitness in each generation and the fitness of all individuals in the population;
step 14.9: iterative training: returning to the step 14.5, and carrying out next iteration; when the set maximum iteration times or the calculation result reaches the convergence condition, ending the iterative training of the genetic algorithm, and obtaining the chromosome y with the best fitness;
step 14.10: and outputting a result: and decoding the best chromosome y and outputting the optimal technological parameters for preparing the optical fiber preform.
Optionally, in said step 14.5, the selection in the selection function select2 is roulette.
Optionally, in the step 6, constructing the BP neural network-based optical fiber preform preparation quality prediction model net includes: the three-layer neural network structure comprises an input layer, a hidden layer and an output layer; the input layer to hidden layer transfer function is "tansig" and the hidden layer to output layer transfer function is "purelin"; the number m of the input layer neurons is adapted to the number of the types of gases of the blast burner during the preparation of the optical fiber preform, and the input layer neurons respectively input the gas flow rates corresponding to the input layer neurons; the number of neurons in the output layer is y, and the quality grade of the corresponding optical rod of the neurons in the output layer is; the number of hidden layer neurons is n, according to the number of input layersm and the number of neurons in the output layer y are adjusted by taking m ═ n + y)1/2+ a or m- ㏒2n or m ═ n (nl)1/2A is one of constants between 1 and 10.
Optionally, the number n of hidden layer neurons is determined by the formula (n + y)1/2+a。
Optionally, in step 7, the Genetic algorithm model (Genetic) comprises the steps of:
step 7.1: initializing parameters of a genetic algorithm, and setting parameters of the genetic algorithm according to the data volume of the preprocessed data set, wherein the parameters comprise iteration times maxgen, population scale sizepop, cross probability pcross and variation probability pmutation;
step 7.2: calculating the total number numsum of nodes of the BP neural network optical fiber perform quality prediction model, and adopting a formula numsum which is m + n + n + y; setting a chromosome length lenchrom and a boundary value bound, wherein the length lenchrom of the chromosome is the same as the total number of nodes numsum;
step 7.3: population initialization: inputting the chromosome length lenchrom and the boundary value bound obtained in the previous step into a function code, and randomly generating chromosome individuals to form a population individuals;
step 7.4: calculating the fitness: inputting the information of the chromosome individual into a BP neural network-based optical fiber perform preparation quality prediction model net to obtain the information of the BP neural network optical fiber perform preparation quality prediction model; inputting the coded individual information of the chromosome and the information of the quality prediction model prepared by the BP neural network optical fiber preform into a fitness calculation function fun to obtain corresponding fitness indicvidials. Finding out the chromosome bestchrom with the best fitness in each generation and recording the chromosome information, the best fitness value bestfittness and the average fitness avgfittness of the generation;
step 7.5: selecting operation: inputting the population information individuals and the population quantity sizpop into a selection function select, and outputting the selected new population individuals; the selection mode in the selection function select is to determine the probability of selection according to the fitness value of each individual;
step 7.6: and (3) cross operation: inputting the cross probability pcross, the chromosome length lenchrom, the chromosome information chrom and the population quantity sizepop into a cross function cross, selecting chromosomes needing cross operation from a new population individuals obtained by selection operation according to the cross operation probability pcross, randomly pairing every two chromosomes, and performing cross exchange on partial genes to obtain crossed chromosome individuals chrom;
step 7.7: mutation operation: inputting the variation probability pmutation, the chromosome length lenchrom, the chromosome information chrom, the population quantity sizepop, the current iteration number num, the maximum iteration number maxgen and the individual boundary bound into a variation function Mutation, selecting chromosomes needing variation operation from the crossed chromosomes according to the probability pmutation of the variation operation, then mutating certain genes on the chromosomes, and outputting the chromosome after variation; wherein, the chromosome for mutation is randomly selected, and the mutation position is also randomly selected;
step 7.8: and (3) replacement operation: inputting the chromosome population subjected to mutation operation into a fitness function fun one by one, recalculating fitness, selecting an optimal individual, outputting and recording the fitness value individuals. fittness of the chromosome, finding out the chromosomes with minimum and maximum fitness and the positions of the chromosomes in the population, and replacing the chromosomes with maximum fitness by the chromosomes with minimum fitness; recording the best fitness, the average fitness and the fitness of all chromosomes of the population in each generation;
step 7.9: performing iterative training, returning to the step 7.5, and performing next iteration; when the set maximum iteration times maxgen are reached, ending the iteration training to obtain the chromosome x with the maximum fitness;
step 7.10: and outputting a result: and decoding the best chromosome x, and outputting the optimal initial weight value and the threshold value.
Optionally, said step 7.5, the selection in the selection function select is roulette.
Optionally, in step 4, the ratio of the data amount of the training set to the data amount of the test set is 7 to 3.
Optionally, in step 9, the iteration number maxgen is set to 100, the learning efficiency is set to 0.05, and the target accuracy is set to 0.00001.
The invention has the following advantages:
the method adopts neural network operation, combines the gas flow of the blowtorch for preparing the optical fiber perform as the whole input data, uses the quality of the optical fiber perform as the output data, and constructs the optical fiber perform preparation quality prediction model based on the BP neural network, which can adapt to the nonlinear correlation and linear correlation characteristics of the input data and the output data, and can adapt to the coupling characteristic between the input data, thereby obtaining the prediction model with small deviation with the actual production; the gas flow combination of the blowtorch is integrally used as input data, so that an accurate prediction result can be obtained quickly; then, optimizing an optical fiber preform preparation quality prediction model net of the BP neural network by constructing a genetic algorithm for optimizing input data, and searching a predicted optical fiber preform quality optimal individual to obtain an input condition corresponding to the preparation of the optical fiber preform, namely an optimal process condition for preparing the optical fiber preform; different original data groups are input, different optimal process conditions can be obtained, a table of the optimal process conditions for preparing the optical fiber preform is made, the price of the optical rod prepared by combining the gas flow of the corresponding blowtorch is obtained by combining the price and the using amount of the gas of the blowtorch, the lowest preparation cost of the optical rod is found out, a large amount of labor for carrying out experiments through control variables is replaced, waste of raw materials such as the optical rod and paint is avoided, the cost is saved, and the efficiency is improved.
Detailed Description
In order to make the technical problems, technical solutions and advantageous effects to be solved by the present application clearer, the present application is further described in detail below with reference to the accompanying drawings.
Now, the optimization method of the optical fiber preform preparation process based on the genetic algorithm and the BP neural network is explained. The optimization method of the optical fiber preform preparation process based on the genetic algorithm and the BP neural network is shown in figure 2:
an optical fiber perform preparation process optimization method based on a genetic algorithm and a BP neural network comprises the following specific steps:
step 1: collecting original data of optical fiber preform production, collecting gas flow of a blast burner and optical rod quality corresponding to the gas flow when the optical fiber preform is prepared, and respectively using the gas flow as input data and the optical rod quality as output data;
step 2: preprocessing the collected original data, and removing invalid data to obtain a preprocessed data set; the invalid data refers to the data of abnormal production conditions of the optical fiber preform and the quality of the optical fiber preform, and is caused by accidental factors in production;
and step 3: grading the quality of the optical rod, dividing the quality of the optical rod into a plurality of grades according to the optical performance of the optical rod, the transmission performance of the produced optical fiber and the mechanical performance, and grouping the preprocessed data sets according to the grade of the quality of the optical rod;
and 4, step 4: dividing each group of data into a training set and a testing set by adopting a retention method;
and 5: normalizing the training set by using a mapminmax function, normalizing input data and output data of the training set to be between-1 and 1, and outputting normalized input transformation data input train and output transformation data output train;
step 6: constructing an optical fiber preform preparation quality prediction model net based on a BP neural network;
and 7: constructing a Genetic algorithm model, optimizing an initial weight and a threshold of a BP neural network-based optical fiber preform preparation quality prediction model net to obtain an optimal individual x, wherein the optimal individual x comprises the initial weight and the threshold information of the optimized BP neural network;
and 8: assigning the weight value and the threshold value optimized by the genetic algorithm to a BP neural network; extracting an initial weight and a threshold value of the optimized BP neural network from the optimal individual x solved by the genetic algorithm, and assigning a value to the BP neural network after finishing;
and step 9: BP neural network training: setting training parameters, iteration times, learning efficiency and target precision; inputting normalized input transformation data input train and output transformation data output train by using a train function to complete the training of the neural network, namely completing the training of an optical fiber preform preparation quality prediction model based on the BP neural network;
step 10: normalizing the training set by using a mapminmax function, normalizing the input data of the test set and the output data of the test set to be between-1 and 1, and respectively outputting the normalized input test and output test;
step 11: testing an optical fiber preform preparation quality prediction model net based on a BP neural network; using a sim function, bringing the normalized test set input data input test into a trained optical fiber preform preparation quality prediction model net for testing to obtain a coded test result, and recording the coded test result as an; decoding the optical fiber preform, and recording a decoding result as test _ simul, namely a test result of the optical fiber preform quality prediction model;
step 12: the test result test _ simul is differed from the test set output data output test to obtain the test error of the optical fiber preform preparation quality prediction model; adjusting the weight and the threshold of a net model for predicting the preparation quality of the optical fiber preform according to the test error to obtain an optical fiber preform preparation quality prediction model based on the BP neural network;
step 13: storing the trained network data of the quality prediction model prepared by the optical fiber preform based on the BP neural network by using a save net function;
step 14: establishing a genetic algorithm model optimize, optimizing a preparation quality prediction model net of the optical fiber perform of the BP neural network, and searching a predicted optimal individual y of the quality of the optical fiber perform, wherein the optimal individual y comprises input conditions corresponding to the preparation of the optical fiber perform, namely optimal process conditions for preparing the optical fiber perform.
Step 6, constructing the BP neural network-based optical fiber preform preparation quality prediction model net comprises the following steps: the three-layer neural network structure comprises an input layer, a hidden layer and an output layer; the input layer to hidden layer transfer function is "tansig" and the hidden layer to output layer transfer function is "purelin"; the number m of the input layer neurons is adapted to the number of the types of gases of the blast burner during the preparation of the optical fiber preform, and the input layer neurons respectively input the gas flow rates corresponding to the input layer neurons; the number of neurons in the output layer is y, and the quality grade of the corresponding optical rod of the neurons in the output layer is; the number of hidden layer neurons is n, and is adjusted according to the number m of input layers and the number y of output layer neurons, and one of m ═ n + y)1/2+ a, m ═ ㏒ 2n, and m ═ nl)1/2 is adopted, and a is one of constants between 1 and 10. Preferably, the number n of hidden layer neurons is determined using the formula m ═ n + y 1/2+ a.
Step 7, the Genetic algorithm model (Genetic) comprises the steps of:
step 7.1: initializing parameters of a genetic algorithm, and setting parameters of the genetic algorithm according to the data volume of the preprocessed data set, wherein the parameters comprise iteration times maxgen, population scale sizepop, cross probability pcross and variation probability pmutation;
step 7.2: calculating the total number numsum of nodes of the BP neural network optical fiber perform quality prediction model, and adopting a formula numsum which is m + n + n + y; setting a chromosome length lenchrom and a boundary value bound, wherein the length lenchrom of the chromosome is the same as the total number of nodes numsum;
step 7.3: population initialization: inputting the chromosome length lenchrom and the boundary value bound obtained in the previous step into a function code, and randomly generating chromosome individuals to form a population individuals;
step 7.4: calculating the fitness: inputting the information of the chromosome individual into a BP neural network-based optical fiber perform preparation quality prediction model net to obtain the information of the BP neural network optical fiber perform preparation quality prediction model; inputting the coded individual information of the chromosome and the information of the quality prediction model prepared by the BP neural network optical fiber preform into a fitness calculation function fun to obtain corresponding fitness indicvidials. Finding out the chromosome bestchrom with the best fitness in each generation and recording the chromosome information, the best fitness value bestfittness and the average fitness avgfittness of the generation;
step 7.5: selecting operation: inputting the population information individuals and the population quantity sizpop into a selection function select, and outputting the selected new population individuals; the selection mode in the selection function select is to determine the probability of selection according to the fitness value of each individual;
step 7.6: and (3) cross operation: inputting the cross probability pcross, the chromosome length lenchrom, the chromosome information chrom and the population quantity sizepop into a cross function cross, selecting chromosomes needing cross operation from a new population individuals obtained by selection operation according to the cross operation probability pcross, randomly pairing every two chromosomes, and performing cross exchange on partial genes to obtain crossed chromosome individuals chrom;
step 7.7: mutation operation: inputting the variation probability pmutation, the chromosome length lenchrom, the chromosome information chrom, the population quantity sizepop, the current iteration number num, the maximum iteration number maxgen and the individual boundary bound into a variation function Mutation, selecting chromosomes needing variation operation from the crossed chromosomes according to the probability pmutation of the variation operation, then mutating certain genes on the chromosomes, and outputting the chromosome after variation; wherein, the chromosome for mutation is randomly selected, and the mutation position is also randomly selected;
step 7.8: and (3) replacement operation: inputting the chromosome population subjected to mutation operation into a fitness function fun one by one, recalculating fitness, selecting an optimal individual, outputting and recording the fitness value individuals. fittness of the chromosome, finding out the chromosomes with minimum and maximum fitness and the positions of the chromosomes in the population, and replacing the chromosomes with maximum fitness by the chromosomes with minimum fitness; recording the best fitness, the average fitness and the fitness of all chromosomes of the population in each generation;
step 7.9: performing iterative training, returning to the step 7.5, and performing next iteration; when the set maximum iteration times maxgen are reached, ending the iteration training to obtain the chromosome x with the maximum fitness;
step 7.10: and outputting a result: and decoding the best chromosome x, and outputting the optimal initial weight value and the threshold value.
Step 7.5, the selection in the selection function select is performed by roulette.
Step 14, establishing the genetic algorithm model optime comprises the following steps:
step 14.1: initializing parameters of a genetic algorithm: setting iteration times maxgen2, population size sizepop2, cross probability pcross2 and variation probability pmutation2 of the network, and adjusting according to the data volume and difference;
step 14.2: defining a chromosome length lenchrom2 and a boundary value bound2 according to the number inputnum of BP neural network input data, wherein the chromosome length lenchrom2 is the same as the number inputnum of the BP neural network input data, and the boundary value bound2 is a matrix of rows and columns 2 of the inputnum, wherein the first column is a lower boundary, and the second column is an upper boundary;
step 14.3: population initialization: inputting the chromosome length lenchrom2 and the boundary value bound obtained in the previous step into a function code2, and randomly generating chromosome individuals to form a population individuals 2; defining a population structure, wherein the population individuals2 comprises the fitness of population individuals and the coding information of each chromosome;
step 14.4: calculating the fitness; loading the stored BP neural network optical fiber perform to prepare a quality prediction model net by using a load net function, and inputting individual chromosome information in population individuals2 to obtain information of the quality prediction model prepared by the BP neural network optical fiber perform; inputting the coded individual information of the chromosome and the information of the quality prediction model prepared by the BP neural network optical fiber perform into a fitness calculation function fun2 to obtain corresponding fitness individuals2. fitness2; finding out the chromosome bestchrom2 with the best fitness in each generation and recording the chromosome information, the best fitness value bestfittness 2 and the average fitness avgfittness 2 of the generation;
step 14.5: selecting operation: inputting the population information individuals2 and the population quantity sizpop2 into a selection function select2, and outputting a selected new population individuals 2; the selection mode in the selection function select2 is to determine the probability of selection according to the fitness value of each individual;
step 14.6: and (3) cross operation: inputting the cross probability pcross2, the chromosome length lenchrom2, the chromosome information chrom2 and the population quantity sizepop2 into a cross function cross2, selecting chromosome individuals needing cross operation from a new population individuals2 obtained by selection operation according to the cross operation probability pcross2 by the cross function cross2, randomly pairing every two chromosome individuals, and performing cross exchange on partial genes to obtain the crossed chromosome individuals chrom 2;
step 14.7: mutation operation: inputting the variation probability pmutation2, the chromosome length lenchrom2, the chromosome information chrom2, the population quantity sizepop2, the current iteration num2, the maximum iteration maxgen2 and the boundary bound2 of each individual into a variation function Mutation2, selecting individuals needing variation operation from the crossed chromosome chrom2, mutating certain genes on the individuals, and outputting the chromosome chrom2 after variation; wherein, the chromosome for mutation is randomly selected, and the mutation position is also randomly selected;
step 14.8: and (3) replacement operation: inputting the individual information of the mutated chromosome chrom2 into a fitness function fun2 one by one, and outputting and recording the fitness value individuals2.fitness2 of each individual; finding out chromosomes with minimum fitness and maximum fitness and positions of the chromosomes in the population, and replacing the chromosomes with maximum fitness by the chromosomes with minimum fitness values; recording the best fitness and the average fitness in each generation and the fitness of all individuals in the population;
step 14.9: iterative training: returning to the step 14.5, and carrying out next iteration; when the set maximum iteration times or the calculation result reaches the convergence condition, ending the iterative training of the genetic algorithm, and obtaining the chromosome y with the best fitness;
step 14.10: and outputting a result: and decoding the best chromosome y and outputting the optimal technological parameters for preparing the optical fiber preform.
Step 14.5, the selection in the selection function select2 is roulette.
The present application is described in further detail below with reference to examples, and it should be understood that the specific examples described herein are for purposes of illustration only and are not intended to limit the present application.
Example 1, a flowchart for constructing a model for predicting quality of an optical fiber preform based on a BP neural network is shown in fig. 1, and the following experiment was performed for the optical fiber preform production using the above flowchart.
Firstly, according to the step 1: collecting 100 groups of gas flow of a blast burner and the quality of an optical rod corresponding to the gas flow when the optical fiber preform is prepared, and respectively using the gas flow as input data and the output data as original data;
according to the step 2: preprocessing 100 groups of collected original data, and obtaining a preprocessed data set if invalid data are not found;
according to the step 3: dividing the quality of the optical fiber preform into 5 grades, and grouping the preprocessed data sets according to the grade of the quality of the optical fiber preform;
according to the step 4: dividing five groups of data according to a ratio of 7 to 3 by adopting a retention method, and dividing a training set and a test set;
according to the step 5: normalizing the training set by using a mapminmax function, normalizing input data and output data of the training set to be between-1 and 1, and outputting normalized input transformation data input train and output transformation data output train;
according to the step 6: constructing an optical fiber preform preparation quality prediction model net based on a BP neural network: the device comprises a three-layer neural network structure of an input layer, a hidden layer and an output layer; the input layer to hidden layer transfer function is "tansig" and the hidden layer to output layer transfer function is "purelin"(ii) a The number m of the neurons in the input layer is adapted to the number of the types of gases of the blast burner during the preparation of the optical fiber preform, and the neurons in the input layer respectively input the gas flow corresponding to the neurons; the number of neurons in the output layer is y, and the quality grade of the corresponding optical rod of the neurons in the output layer is; the number of hidden layer neurons is n, the adjustment is performed according to the number m of input layer neurons and the number y of output layer neurons, and m is (n + y)1/2+ a, a is one of constants between 1 and 10; in example 1, m is equal to 7, n is equal to 15, y is 1;
according to the step 7: constructing a Genetic algorithm model, optimizing an initial weight and a threshold of a BP neural network-based optical fiber preform preparation quality prediction model net to obtain an optimal individual x, wherein the optimal individual x comprises the initial weight and the threshold information of the optimized BP neural network;
according to the step 8: extracting an initial weight and a threshold value of the optimized BP neural network from the optimal individual x solved by the genetic algorithm, and assigning a value to the BP neural network after finishing;
according to the step 9: carrying out BP neural network training: setting training parameters, wherein the iteration times are 100, the learning efficiency is 0.05, and the target precision is 0.00001; inputting normalized input transformation data input train and output transformation data output train by using a train function to complete the training of the neural network, namely completing the training of an optical fiber preform preparation quality prediction model based on the BP neural network;
according to the step 10: normalizing the training set by using a mapminmax function, normalizing the input data of the test set and the output data of the test set to be between-1 and 1, and respectively outputting the normalized input test and output test;
according to the step 11: testing an optical fiber preform preparation quality prediction model net based on a BP neural network; using a sim function, bringing the normalized test set input data input test into a trained optical fiber preform preparation quality prediction model net for testing to obtain a coded test result, and recording the coded test result as an; decoding the optical fiber preform, and recording a decoding result as test _ simul, namely a test result of the optical fiber preform quality prediction model;
according to the step 12: the test result test _ simul is differed from the test set output data output test to obtain the test error of the optical fiber preform preparation quality prediction model; adjusting the weight and the threshold of a net model for predicting the preparation quality of the optical fiber preform according to the test error to obtain an optical fiber preform preparation quality prediction model based on the BP neural network;
step 13: and storing the trained network data of the quality prediction model prepared by the optical fiber preform based on the BP neural network by using the save net function.
Finally, under the condition of keeping other production conditions unchanged, changing the gas flow of the blowtorch during the preparation of the optical fiber preform, and randomly generating 16 groups of gas flows of the blowtorch during the preparation of the optical fiber preform for combination; respectively inputting the gas flow of the blowtorch when 16 groups of optical fiber preforms are prepared randomly into the trained BP neural network and used for actual production; recording and comparing the quality of the optical fiber preform obtained by the two modes with the same gas component, and analyzing the accuracy of predicting the preparation quality of the optical fiber preform by the BP neural network. Data from the above experiment are recorded as follows:
TABLE 1 optical fiber preform quality prediction experiment
As can be seen from Table 1, the deviation of the predicted result of the optical fiber preform preparation quality prediction model based on the BP neural network and the production experiment result is not large, only one group of data errors exceed 0.5, and the rest errors are far less than 0.5 and are within an acceptable range; therefore, the optical fiber perform preparation quality prediction model based on the BP neural network can realize accurate prediction of the quality of the optical fiber perform.
Example 2
Embodiment 1 completes the construction and storage of the optical fiber preform preparation quality prediction model based on the BP neural network, as shown in fig. 2, the flowchart of the optical fiber preform preparation process optimization method based on the genetic algorithm and the BP neural network is basically the same as the construction of the optical fiber preform preparation quality prediction model based on the BP neural network in embodiment 1, and the same points are not repeated.
The establishing of the genetic algorithm model optimize comprises the following steps:
step 14.1: initializing parameters of a genetic algorithm: setting iteration times maxgen2, population size sizepop2, cross probability pcross2 and variation probability pmutation2 of the network, and adjusting according to the data volume and difference; in this embodiment, the iteration number maxgen2 is set to 200, the population size sizepop2 is set to 23, the crossover probability pcross2 is set to 0.05, and the mutation probability pmutation2 is set to 0.00001;
step 14.2: defining a chromosome length lenchrom2 and a boundary value bound2 according to the number inputnum of BP neural network input data, wherein the chromosome length lenchrom2 is the same as the number inputnum of the BP neural network input data, and the boundary value bound2 is a matrix of rows and columns 2 of the inputnum, wherein the first column is a lower boundary, and the second column is an upper boundary;
step 14.3: population initialization: inputting the chromosome length lenchrom2 and the boundary value bound obtained in the previous step into a function code2, and randomly generating chromosome individuals to form a population individuals 2; defining a population structure, wherein the population individuals2 comprises the fitness of population individuals and the coding information of each chromosome;
step 14.4: calculating the fitness; loading the stored BP neural network optical fiber perform to prepare a quality prediction model net by using a load net function, and inputting individual chromosome information in population individuals2 to obtain information of the quality prediction model prepared by the BP neural network optical fiber perform; inputting the coded individual information of the chromosome and the information of the quality prediction model prepared by the BP neural network optical fiber perform into a fitness calculation function fun2 to obtain corresponding fitness individuals2. fitness2; finding out the chromosome bestchrom2 with the best fitness in each generation and recording the chromosome information, the best fitness value bestfittness 2 and the average fitness avgfittness 2 of the generation;
step 14.5: selecting operation: inputting the population information individuals2 and the population quantity sizpop2 into a selection function select2, and outputting a selected new population individuals 2; the selection mode in the selection function select2 is to determine the probability of selection according to the fitness value of each individual;
step 14.6: and (3) cross operation: inputting the cross probability pcross2, the chromosome length lenchrom2, the chromosome information chrom2 and the population quantity sizepop2 into a cross function cross2, selecting chromosome individuals needing cross operation from a new population individuals2 obtained by selection operation according to the cross operation probability pcross2 by the cross function cross2, randomly pairing every two chromosome individuals, and performing cross exchange on partial genes to obtain the crossed chromosome individuals chrom 2;
step 14.7: mutation operation: inputting the variation probability pmutation2, the chromosome length lenchrom2, the chromosome information chrom2, the population quantity sizepop2, the current iteration num2, the maximum iteration maxgen2 and the boundary bound2 of each individual into a variation function Mutation2, selecting individuals needing variation operation from the crossed chromosome chrom2, mutating certain genes on the individuals, and outputting the chromosome chrom2 after variation; wherein, the chromosome for mutation is randomly selected, and the mutation position is also randomly selected;
step 14.8: and (3) replacement operation: inputting the individual information of the mutated chromosome chrom2 into a fitness function fun2 one by one, and outputting and recording the fitness value individuals2.fitness2 of each individual; finding out chromosomes with minimum fitness and maximum fitness and positions of the chromosomes in the population, and replacing the chromosomes with maximum fitness by the chromosomes with minimum fitness values; recording the best fitness and the average fitness in each generation and the fitness of all individuals in the population;
step 14.9: iterative training: returning to the step 14.5, and carrying out next iteration; when the set maximum iteration times or the calculation result reaches the convergence condition, ending the iterative training of the genetic algorithm, and obtaining the chromosome y with the best fitness;
step 14.10: and outputting a result: and decoding the best chromosome y and outputting the optimal technological parameters for preparing the optical fiber preform.
Wherein, step 14.5, the selection in the selection function select2 is roulette.
Under the condition of keeping other production conditions unchanged, changing the gas flow of a blast burner when the optical fiber preform is prepared, generating a combination of 23 groups of gas flow of the blast burner when the optical fiber preform is prepared each time, inputting the combination into an optical fiber preform preparation quality prediction model net of a BP (back propagation) neural network for optimizing, and searching a predicted optical fiber preform quality optimal individual y to obtain an optimal process condition for preparing the optical fiber preform; respectively inputting the optimal process parameters of the optical fiber preform rod preparation output each time into the trained BP neural network and using the trained BP neural network for actual production; recording and comparing the quality of the optical fiber preform obtained by using the same gas component in the two modes; data from the above experiment are recorded as follows:
TABLE 2 statistics of optimization results of optical fiber preform process parameters
As can be seen from Table 2, the optimized technological parameters of the optical fiber preform preparation process optimization method based on the genetic algorithm and the BP neural network can produce the high-quality optical fiber preform in a production test; on the basis of the experimental data, the optimized result of the optical fiber preform preparation process optimization method based on the genetic algorithm and the BP neural network is the same as the production experimental result, the corresponding production cost is calculated according to the total amount of the used gas and the unit price of the gas, the gas flow combination with the cost within an acceptable range can be obtained, and the gas flow combination with the lowest production cost can also be obtained.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.