Tension and compression spring design method and device based on Bayesian optimization algorithm and medium

By applying Bayesian optimization algorithm in the design of tension springs, combining Gaussian process regression model and constraint expectations to improve the acquisition function, the problem of low computational efficiency of genetic algorithms is solved, and more efficient design optimization is achieved.

CN119558000APending Publication Date: 2025-03-04SOUTHWEST JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411615654.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In the prior art, genetic algorithms have low calculation efficiency in the design of tension springs and many iterations, resulting in slow convergence speed and long calculation time.

Method used

Using the Bayesian optimization algorithm design method, the Gaussian process regression model and constraint expectations are improved, the acquisition function is nested, the method of optimization is generated, and the design parameters are optimized.

Benefits of technology

The calculation accuracy and efficiency are significantly improved, the convergence time is shortened, population diversity is ensured, premature convergence is avoided, and the optimal solution is searched for fewer function evaluations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119558000A_ABST
    Figure CN119558000A_ABST
Patent Text Reader

Abstract

The invention relates to the field of mechanical design, in particular to a tension-compression spring design method and device based on a Bayesian optimization algorithm and a medium. The optimization method comprises the following steps: establishing a tension-compression spring design problem model, randomly generating a population, constructing a Gaussian process regression model of a target function, a Gaussian process regression model of a constraint function vector and other related functions in a Bayesian optimization algorithm, generating new sample points, and performing iterative optimization. And selecting part of variables from more variables by using a nested optimization method, and optimizing the variables to generate new sample points. The calculation precision and efficiency can be remarkably improved, and the convergence speed is increased. And premature convergence can be avoided while population diversity is ensured. Under the framework of Bayesian optimization, an acquisition function is improved by selecting a Gaussian process and constraint expectation, and the optimal solution of the spring design parameters can be effectively searched under the condition that the number of function evaluation times is small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of mechanical design, and in particular to a tension and compression spring design method, equipment and medium based on a Bayesian optimization algorithm. Background Art

[0002] In the typical engineering optimization problem of tension and compression spring design, engineering designers need to face the problem of minimizing the weight or cost of the spring by optimizing design parameters while meeting certain working conditions and performance requirements, while ensuring its reliability and durability during use.

[0003] Prior art: Genetic algorithm is a heuristic search algorithm that simulates the biological evolution process. It optimizes the solution of the problem by simulating biological mechanisms such as natural selection, inheritance, crossover and mutation. In the design of tension and compression springs, genetic algorithm can handle nonlinear optimization problems with complex constraints.

[0004] However, genetic algorithms have the disadvantage of low computational efficiency. Genetic algorithms usually require a large number of iterations to find the optimal solution, which may lead to low computational efficiency, especially when dealing with large-scale or complex problems. The algorithm converges slowly and requires a long computational time to reach a satisfactory solution. Summary of the invention

[0005] The present invention provides a tension and compression spring design method, device and medium based on a Bayesian optimization algorithm to solve the problem of low calculation efficiency in the prior art.

[0006] The technical solution adopted by the present invention is:

[0007] A tension and compression spring design method based on a Bayesian optimization algorithm comprises the following steps:

[0008] Step S1: Establish a tension and compression spring design problem model, determine the objective function f(x) and m constraint functions of the tension and compression spring design, expressed as:

[0009] [g1(x),...,g i (x), ..., g m (x)].

[0010] Where x is a sample point, and each sample point includes w variables, expressed as:

[0011] x=[x1,...,x i , ..., x w ].

[0012] Among them, x i is the i-th variable. 1≤i≤w. g i (x) is the i-th constraint function, 1≤i≤m.

[0013] Step S2: Sampling the sample points in step S1, randomly generating a population Q, wherein the population Q includes n sample points, which can be expressed as:

[0014] Q=[x1,...,x i , ..., x n ].

[0015] Among them, x i is the i-th sample point, 1≤i≤n.

[0016] Step S3: Using the population Q generated in step S2, construct a Gaussian process regression model of the objective function f(x) and a constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] is the prediction error function.

[0017] Step S4: Using the Gaussian process regression model of the objective function f(x) in the Bayesian optimization algorithm constructed in step S3, the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] constructs the acquisition function CEI(x) and generates a new sample point x * .

[0018] Step S5: The new sample point x generated in step S4 * The objective function f(x) and the constraint functions [g1(x), ..., g i (x), ..., g m(x)], and update the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] and the acquisition function CEI(x) constructed in step S4.

[0019] Step S6: Repeat steps S3 to S5 until a preset number of iterations v is reached.

[0020] Furthermore, the step S2 uses a Latin hypercube sampling method to sample the sample points in the step S1 to randomly generate a population Q.

[0021] Furthermore, in step S3, the population Q generated in step S2 is used to construct a Gaussian process regression model of the objective function f(x) and a constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the following steps are performed:

[0022] Step S31: First, use the step S2 to randomly generate a population Q, calculate the mean function μ(x) and the kernel function k(x) a , x b ), and then construct the Gaussian process regression model in the Bayesian optimization algorithm of the objective function f(x), which is expressed as:

[0023] f(x)~GP(μ(x),k(x) a , x b )).

[0024] Among them, x a , x bare any two sample points in the population Q in step S2.

[0025] Kernel function k(x a , x b ) is expressed as:

[0026]

[0027] s 2 is the variance parameter of the kernel function, which controls the scale of the kernel function values.

[0028] l is a hyperparameter of the kernel function.

[0029] and They are x a and x b The variable of the i-th step S1.

[0030] Step S32: Using the Gaussian process regression model in the Bayesian optimization algorithm of the objective function f(x) constructed in step S31, construct a prediction function of the objective function f(x) and a prediction error function of the objective function f(x) in step S3.

[0031] The prediction function of the objective function f(x) is Expressed as:

[0032]

[0033] The prediction error function of the objective function f(x) is Expressed as:

[0034]

[0035] in, and σ 2 is the maximum likelihood estimate of the mean and error of the Gaussian process model, l is the new sample point x * and the covariance vector between n sample points,

[0036] C is a covariance matrix, expressed as:

[0037]

[0038] Among them, C ij Expressed as:

[0039]

[0040] x (i) and x (j) For any two sample points, and x (i) and x (j) The kth variable of , 1≤k≤w. c is an n-dimensional vector, c i =Corr(x * , x (i) ),

[0041] in,

[0042] y=[f (1) , ..., f (i) , ..., f (n) ] T is the function value of the observed n sample points.

[0043] f (i) is the value of f(x) calculated by substituting the i-th sample point into the objective function f(x).

[0044] I is an n-dimensional unit vector.

[0045] Step S33: Using the methods of step S31 and step S32, construct a constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model in the Bayesian optimization algorithm, the constraint function [g1(x), ..., g i (x), ..., g m (x)] and the constraint function [g1(x), ..., g i (x), ..., g m (x)] is the prediction error function.

[0046] Furthermore, in step S4, the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] constructs the acquisition function CEI(x) and generates a new sample point x * When the system is running, perform the following steps:

[0047] Step S41: Using the prediction function and constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m The prediction error function of CEI(x)] constructs the acquisition function CEI(x), which is the constrained expectation improvement acquisition function, expressed as:

[0048]

[0049] in,

[0050] EI(x) is the expected improvement function without considering constraints, which is used to select points with higher expected improvement values. j (x)≤0) is the constraint function [g1(x), ..., g i (x), ..., g m (x)], 1≤j≤m.

[0051] f min is the minimum value of the current objective function f(x).

[0052] is the standard deviation of the prediction error function of the objective function f(x) at x.

[0053] is the jth constraint function at x [g1(x),...,g i (x), ..., g m (x)] prediction function.

[0054] is the jth constraint function at x [g1(x),...,g i (x), ..., g m (x)] is the prediction error function.

[0055] Φ and They are the standard Gaussian cumulative distribution function and probability density function, respectively, expressed as:

[0056]

[0057]

[0058] Among them, o is a standard normal variable, that is, For the standard Gaussian distribution, μ = 0 and σ = 1, c is expressed as Inside the square brackets erf is the error function, expressed as:

[0059]

[0060] where t is the integration variable.

[0061] is the probability of satisfying all constraints.

[0062] Step S42: Use the nested optimization method to generate a new sample point x * , and the specific process is as follows:

[0063] First, use the mixed-integer optimizer of the genetic algorithm to perform variable optimization under the acquisition function CEI(x) constructed in the step S41. The first layer of the mixed-integer optimizer of the genetic algorithm obtains the dimensions [z1,..., z i ,..., z d of d variables to be optimized, where d is a preset value, 0 < d < w, expressed as:

[0064] [z1,..., z i ,..., z d = argmax CEI(x).

[0065] where z i is the dimension of the i-th variable to be optimized. argmax CEI(x) is to find the value of x that makes CEI(x) reach the maximum value.

[0066] Then, use the genetic algorithm optimizer to optimize the [z1,..., z i ,..., z d under the acquisition function CEI(x) constructed in the step S41. The second layer of the genetic algorithm optimizer obtains the corresponding optimized variable x, expressed as:

[0067]

[0068] where, is the z i -th optimized variable.

[0069] Finally, replace the corresponding d variables in the current optimal solution, that is, use to replace to generate the new sample point x * , where, is the z i -th variable before optimization.

[0070] Furthermore, in step S5, the new sample point x generated in step S4 is * The objective function f(x) and the constraint functions [g1(x), ..., g m (x)], and update the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m When the prediction error function of CEI(x)] and the acquisition function CEI(x) constructed in step S4 are used, the following steps are specifically performed:

[0071] Step S51: The new sample point x generated in step S4 is * Evaluate the objective function f(x) to obtain a new objective function, wherein the new objective function is the minimum value f of the current objective function f(x) in step S41. min , f min To minimize the mass of the spring. And output f min .

[0072] Step S52: The new sample point x generated in step S4 is * Substitute the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] and calculate the corresponding new function values.

[0073] Step S53: The new sample point x generated in step S4 is * Substitute the acquisition function CEI(x) and calculate a new acquisition function to prepare for the next iteration.

[0074] Furthermore, the preset number of iterations v in step S6 is not less than 80 times.

[0075] Furthermore, the expression of the objective function f(x) of the tension and compression spring design in step S1 is:

[0076] f(x)=x1 2 x2(x3+2).

[0077] Among them, x1, x2, x3 are the variables in step S1, x1 is the diameter of the spring wire, x2 is the average diameter of the spring coil, and x3 is the number of effective coils of the spring. x1, x2, x3 form a variable vector, which is expressed as:

[0078] x=[x1,x2,x3].

[0079] And each of the variables satisfies the inequality constraints, which are expressed as:

[0080] 0.05≤x1≤2.00.

[0081] 0.25≤x2≤1.30.

[0082] 2.00≤x3≤15.0.

[0083] Furthermore, the constraint function [g1(x), ..., g i (x), ..., g m The expression of (x)] is:

[0084] [g(x), g2(x), g3(x), g4(x)].

[0085] Among them, g1(x), g2(x), g3(x), g4(x) are: minimum deflection, shear stress, oscillation frequency and outer diameter limit, respectively. The four constraint functions are expressed as constraint inequalities, respectively:

[0086]

[0087] Based on the same inventive concept, the present invention also provides a computer device, including: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the above-mentioned tension and compression spring design method based on the Bayesian optimization algorithm by executing the computer instructions.

[0088] Based on the same inventive concept, the present invention also provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the above-mentioned tension and compression spring design method based on the Bayesian optimization algorithm.

[0089] The beneficial effects of the present invention are:

[0090] The present invention utilizes a nested optimization method to select some variables from a larger number of variables, optimize these variables, and generate new sample points, which can significantly improve the accuracy and efficiency of calculations, increase the convergence speed, and ensure population diversity while avoiding premature convergence.

[0091] The present invention can effectively search for the optimal solution of spring design parameters under the framework of Bayesian optimization by selecting Gaussian process and constraint expectation improvement acquisition function with fewer function evaluation times. This method can not only significantly improve the accuracy and efficiency of design, but also take into account more performance indicators and constraints in the design process, thereby realizing the optimization of spring design. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0093] Figure 1 The figure is a flow chart of the method.

[0094] Figure 2 This is the spring structure diagram.

[0095] Figure 3 Iterative graph of optimization results for tension and compression spring design. DETAILED DESCRIPTION

[0096] The present invention provides a tension and compression spring design method, device and medium based on a Bayesian optimization algorithm to solve the problem of low calculation efficiency in the prior art.

[0097] The following disclosure provides examples which are not intended to limit the present invention.

[0098] The embodiments of the invention are described in detail below with reference to the accompanying drawings:

[0099] A design method for tension and compression springs based on Bayesian optimization algorithm. The process is as follows: Figure 1 Said, comprising the following steps:

[0100] Step S1: Establish a tension and compression spring design problem model, determine the objective function f(x) and m constraint functions of the tension and compression spring design, expressed as:

[0101] [g1(x),...,g i(x), ..., g m (x)].

[0102] Where x is a sample point, and each sample point includes w variables, expressed as:

[0103] x=[x1,...,x i , ..., x w ].

[0104] Among them, x i is the i-th variable. 1≤i≤w. g i (x) is the i-th constraint function, 1≤i≤m.

[0105] In this embodiment, each of the sample points includes three variables, which are expressed as:

[0106] x=[x1,x2,x3].

[0107] In this embodiment, the expression of f(x) is:

[0108] f(x)=x1 2 x2(x3+2).

[0109] Among them, x1, x2, x3 are the variables mentioned in step S1, x1 is the diameter of the spring wire, x2 is the average diameter of the spring coil, and x3 is the number of effective coils of the spring.

[0110] And each of the variables satisfies the inequality constraints, which are expressed as:

[0111] 0.05≤x1≤2.00;

[0112] 0.25≤x2≤1.30;

[0113] 2.00≤x3≤15.0.

[0114] In this embodiment, the constraint function of the tension and compression spring design [g1(x), ..., g i (x), ..., g m The expression of (x)] is:

[0115] [g(x), g2(x), g3(x), g4(x)].

[0116] Among them, g1(x), g2(x), g3(x), g4(x) are: minimum deflection, shear stress, oscillation frequency and outer diameter limit, respectively. The four constraint functions are expressed as constraint inequalities, respectively:

[0117]

[0118] Among them, x1, x2, x3 are the variables mentioned in step S1, x1 is the diameter of the spring wire, x2 is the average diameter of the spring coil, and x3 is the number of effective coils of the spring.

[0119] Step S2: Sample the sample points in step S1 using the Latin hypercube sampling method to randomly generate a population Q, where the population Q includes n sample points, expressed as:

[0120] Q=[x1,...,x i , ..., x n ].

[0121] Among them, x i is the i-th sample point, 1≤i≤n.

[0122] In this embodiment, the population Q includes 20 sample points, which can be expressed as:

[0123] Q=[x1,...,x 20 ].

[0124] Among them, 1≤i≤20.

[0125] Step S3: Using the population Q generated in step S2, construct the Gaussian process regression model of the objective function f(x), the Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction function of the objective function f(x), the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), and the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)]. In step S3, the Gaussian process regression model is part of the Bayesian optimization algorithm and is a probability-based non-parametric regression method that models data uncertainty by assuming that data points are generated by a Gaussian process. A Gaussian process is a random process in which the joint distribution of any finite set of data points is a Gaussian distribution. In regression analysis, the Gaussian process is used to simulate the prior distribution of the function, and then this distribution is updated according to the observed data to obtain the posterior distribution of the function.

[0126] Step S4: Using the Gaussian process regression model of the objective function f(x) in the Bayesian optimization algorithm constructed in step S3, the Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction function of the objective function f(x), the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), and the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the acquisition function CEI(x) is constructed, and a new sample point x is generated. * .

[0127] Step S5: The new sample point x generated in step S4 * The objective function f(x) and the constraint functions [g(x), g2(x), g3(x), g4(x)] are evaluated at the step S3, and the Gaussian process regression model of the objective function f(x), the Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction function of the objective function f(x), the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)] and the acquisition function CEI(x) constructed in the step S4 are updated.

[0128] Step S6: Repeat the steps S3 to S5 until the preset number of iterations of 80 in this embodiment is reached.

[0129] Further, in step S3, using the population Q generated in step S2, to construct a Gaussian process regression model of the objective function f(x), a Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], a prediction function of the objective function f(x), a prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], a prediction error function of the objective function f(x), and a prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)] in the Bayesian optimization algorithm, the following steps are specifically performed:

[0130] Step S31: First, use the step S2 to randomly generate a population Q, calculate the mean function μ(x) and the kernel function k(x) a , x b ), and then construct the Gaussian process regression model in the Bayesian optimization algorithm of the objective function f(x), which is expressed as:

[0131] f(x)~GP(μ(x),k(x)a , x b )).

[0132] Among them, x a , x b are any two sample points in the population Q in step S2.

[0133] Kernel function k(x a , x b ) is expressed as:

[0134]

[0135] s 2 is the variance parameter of the kernel function, which controls the scale of the kernel function values.

[0136] l is a hyperparameter of the kernel function.

[0137] and They are x a and x b The variable of the i-th step S1.

[0138] Step S32: Using the Gaussian process regression model in the Bayesian optimization algorithm of the objective function f(x) constructed in step S31, construct a prediction function of the objective function f(x) and a prediction error function of the objective function f(x) in step S3.

[0139] The prediction function of the objective function f(x) Expressed as:

[0140]

[0141] The prediction error function of the objective function f(x) is Expressed as:

[0142]

[0143] in, and σ 2 is the maximum likelihood estimate of the mean and error of the Gaussian process model, l is the new sample point x * and the covariance vector between n sample points. In this embodiment, n=20.

[0144] C is a covariance matrix, expressed as:

[0145]

[0146] Among them, C ij Expressed as:

[0147]

[0148] x (i) and x (j) For any two sample points, and x (i) and x (j) The kth variable of , 1≤k≤3. c is a 20-dimensional vector, c i =Corr(x * , x (i) ),

[0149] in,

[0150] y=[f (1) , ..., f (i) , ..., f (20) ] T is the function value of the 20 observed sample points, 1≤i≤20.

[0151] f (i) is the value of f(x) calculated by substituting the i-th sample point into the objective function f(x).

[0152] I is a 20-dimensional unit vector.

[0153] Step S33: Using the methods of step S31 and step S32, construct a Gaussian process regression model in the Bayesian optimization algorithm of the constraint function [g(x), g2(x), g3(x), g4(x)], a prediction function of the constraint function [g(x), g2(x), g3(x), g4(x)] and a prediction error function of the constraint function [g(x), g2(x), g3(x), g4(x)].

[0154] Further, the step S4 uses the Gaussian process regression model of the objective function f(x) in the Bayesian optimization algorithm constructed in the step S3, the Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction function of the objective function f(x), the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), and the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)] to construct the acquisition function CEI(x), and generate a new sample point x * When the system is running, perform the following steps:

[0155] Step S41: Construct an acquisition function CEI(x) using the prediction function of the objective function f(x) constructed in step S3, the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), and the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)]. The acquisition function CEI(x) is a constrained expectation improvement acquisition function, which is expressed as:

[0156]

[0157] in,

[0158] EI(x) is the expected improvement function without considering constraints, which is used to select points with higher expected improvement values. j (x)≤0) is the probability of the jth constraint function in the constraint functions [g(x), g2(x), g3(x), g4(x)], 1≤j≤4.

[0159] f min is the minimum value of the current objective function f(x).

[0160] is the standard deviation of the prediction error function of the objective function f(x) at x.

[0161] is the prediction function of the jth constraint function [g(x), g2(x), g3(x), g4(x)] at x.

[0162] is the prediction error function of the jth constraint function [g(x), g2(x), g3(x), g4(x)] at x.

[0163] Φ and They are the standard Gaussian cumulative distribution function and probability density function, respectively, expressed as:

[0164]

[0165] Among them, o is a standard normal variable, that is, For the standard Gaussian distribution, μ = 0 and σ = 1, c is expressed as In brackets Erf is the error function, expressed as:

[0166]

[0167] Where t is the integration variable. is the probability of satisfying all constraints.

[0168] In the step S41, the expected improvement (EI(x)) criterion is selected as the acquisition function to be optimized in the subspace. The EI criterion can provide a good balance between global search and local search. Since there are engineering constraints in the design optimization of tension and compression springs, the constraints can be directly taken into account when maximizing the EI(x) function, and the problem of selecting update points is changed from unconstrained optimization of the EI function to constrained optimization of the EI function, i.e., CEI(x).

[0169] Step S42: Generate new sample points x using the nested optimization method * The specific process is as follows: first, a mixed integer optimizer of a genetic algorithm is used to perform variable optimization under the acquisition function CEI(x) condition constructed in step S41. The first layer of the mixed integer optimizer of the genetic algorithm obtains the dimensions of d variables to be optimized [z1, ..., z i , ..., z d ], where d is a preset value, 0<d<3, in this embodiment d=2, expressed as:

[0170] [z1, z2] = argmax CEI(x).

[0171] Wherein, z1 is the dimension of the first variable to be optimized, and z2 is the dimension of the second variable to be optimized. argmax CEI(x) is to find the value of x so that CEI(x) reaches the maximum value.

[0172] Then, the genetic algorithm optimizer is used to optimize the [z1, z2] under the acquisition function CEI(x) constructed in step S41, and the second layer of the genetic algorithm optimizer obtains the corresponding optimization variable x, which is expressed as:

[0173]

[0174] in, is the z1th optimization variable, is the z2th optimization variable.

[0175] Finally, replace the two variables corresponding to the current optimal solution, that is, use replace Generate the new sample point x * ,in, is the variable before the z1th optimization, is the variable before the z2th optimization. In this embodiment, the step S42 is implemented using the ga optimizer provided by MATLAB.

[0176] Furthermore, in step S5, the new sample point x generated in step S4 is *When evaluating the objective function f(x) and the constraint functions [g(x), g2(x), g3(x), g4(x)], and updating the Gaussian process regression model of the objective function f(x) in the Bayesian optimization algorithm constructed in step S3, the Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction function of the objective function f(x), the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)] and the acquisition function CEI(x) constructed in step S4, the following steps are specifically performed:

[0177] Step S51: The new sample point x generated in step S4 is * Evaluate the objective function f(x) to obtain a new objective function, wherein the new objective function is the minimum value f of the current objective function f(x) in step S41. min , f min To minimize the mass of the spring. And output f min .

[0178] By the attached Figure 3 It can be seen from the iteration curve of the optimization results of the tension and compression spring design that Nest-B0 has a certain degree of optimization for the initial value of the objective function. It can be found that under multiple design variables and multiple engineering constraints, Nest-B0 has good optimization results for the optimization of the tension and compression spring design problem, and the convergence speed is also relatively fast.

[0179] Step S52: The new sample point x generated in step S4 is * Substitute the Gaussian process regression model of the objective function f(x), the Gaussian process regression model of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction function of the objective function f(x), the prediction function of the constraint functions [g(x), g2(x), g3(x), g4(x)], the prediction error function of the objective function f(x), and the prediction error function of the constraint functions [g(x), g2(x), g3(x), g4(x)] into the Bayesian optimization algorithm constructed in step S3, and calculate new corresponding function values ​​respectively.

[0180] Step S53: The new sample point x generated in step S4 is * Substitute the acquisition function CEI(x) and calculate a new acquisition function to prepare for the next iteration.

[0181] Based on the same inventive concept, this embodiment also provides a computer device, including: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the above-mentioned tension and compression spring design method based on the Bayesian optimization algorithm by executing the computer instructions.

[0182] Based on the same inventive concept, this embodiment also provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the above-mentioned tension and compression spring design method based on the Bayesian optimization algorithm.

Claims

1. A tension and compression spring design method based on Bayesian optimization algorithm, characterized in that: The method comprises the following steps: Step S1: establishing a tension and compression spring design problem model, determining the objective function f(x) and m constraint functions of the tension and compression spring design, expressed as: [g1(x),...,g i (x),...,g m (x)]; Where x is a sample point, and each sample point includes w variables, expressed as: x=[x1,...,x i ,...,x w ]; Among them, x i is the i-th variable; 1≤i≤w; g i (x) is the i-th constraint function, 1≤i≤m. Step S2: Sampling the sample points in step S1, randomly generating a population Q, wherein the population Q includes n sample points, which can be expressed as: Q=[x1,...,x i ,...,x n ]; Among them, x i is the i-th sample point, 1≤i≤n; Step S3: Using the population Q generated in step S2, construct a Gaussian process regression model of the objective function f(x) and a constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] prediction error function; Step S4: Using the Gaussian process regression model of the objective function f(x) in the Bayesian optimization algorithm constructed in step S3, the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] constructs the acquisition function CEI(x) and generates a new sample point x * ; Step S5: The new sample point x generated in step S4 * The objective function f(x) and the constraint functions [g1(x), ..., g i (x), ..., g m (x)], and update the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] and the acquisition function CEI(x) constructed in step S4; Step S6: Repeat steps S3 to S5 until a preset number of iterations v is reached.

2. A tension and compression spring design method based on Bayesian optimization algorithm according to claim 1, characterized in that: The step S2 uses the Latin hypercube sampling method to sample the sample points in the step S1 to randomly generate a population Q.

3. A tension and compression spring design method based on Bayesian optimization algorithm according to claim 2, characterized in that: In step S3, the population Q generated in step S2 is used to construct a Gaussian process regression model of the objective function f(x) and a constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the following steps are performed: Step S31: First, use the step S2 to randomly generate a population Q, calculate the mean function μ(x) and the kernel function k(x) a , x b ), and then construct the Gaussian process regression model in the Bayesian optimization algorithm of the objective function f(x), which is expressed as: f(x)~GP(μ(x),k(x a ,x b )); Among them, x a , x b are any two sample points in the population Q in step S2; Kernel function k(x a , x b ) is expressed as: s 2 is the variance parameter of the kernel function, which controls the scale of the kernel function value; l is the hyperparameter of the kernel function; and They are x a and x b The variable of step S1 in the i-th step; Step S32: using the Gaussian process regression model in the Bayesian optimization algorithm of the objective function f(x) constructed in step S31, constructing a prediction function of the objective function f(x) and a prediction error function of the objective function f(x) in step S3; The prediction function of the objective function f(x) Expressed as: The prediction error function of the objective function f(x) is Expressed as: in, and σ 2 is the maximum likelihood estimate of the mean and error of the Gaussian process model, l is the new sample point x * and the covariance vector between n sample points, C is a covariance matrix, expressed as: Among them, C ij Expressed as: x (i) and x (j) For any two sample points, and x (i) and x (j) The kth variable of , 1≤k≤w; c is an n-dimensional vector, c i =Corr(x * , x (i) ), in, y=[f (1) , ..., f (i) , ..., f (n) ] T is the function value of the observed n sample points; f (i) is the value of f(x) calculated by substituting the i-th sample point into the objective function f(x); I is an n-dimensional unit vector; Step S33: Using the methods of step S31 and step S32, construct a constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model in the Bayesian optimization algorithm, the constraint function [g1(x), ..., g i (x), ..., g m (x)] and the constraint function [g1(x), ..., g i (x), ..., g m (x)] is the prediction error function.

4. A tension and compression spring design method based on Bayesian optimization algorithm according to claim 3, characterized in that: The step S4 uses the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)] constructs the acquisition function CEI(x) and generates a new sample point x * When the system is running, perform the following steps: Step S41: Using the prediction function and constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m The prediction error function of CEI(x)] constructs the acquisition function CEI(x), which is the constrained expectation improvement acquisition function, expressed as: in, EI(x) is the expected improvement function without considering constraints, which is used to select points with higher expected improvement values; P(g j (x)≤0) is the constraint function [g1(x), ..., g i (x), ..., g m The probability of the jth constraint function in (x)], 1≤j≤m; f min is the minimum value of the current objective function f(x); is the standard deviation of the prediction error function of the objective function f(x) at x; is the jth constraint function at x [g1(x),...,g i (x), ..., g m (x)] prediction function; is the jth constraint function at x [g1(x),...,g i (x), ..., g m (x)] prediction error function; Φ and They are the standard Gaussian cumulative distribution function and probability density function, respectively, expressed as: Among them, o is a standard normal variable, that is, For the standard Gaussian distribution, ρ = 0 and σ = 1, c is expressed as In brackets Erf is the error function, expressed as: Where, t is the integral variable; is the probability of satisfying all constraints; Step S42: Generate new sample points x using the nested optimization method * , the specific process is: First, a mixed integer optimizer of a genetic algorithm is used to perform variable optimization under the acquisition function CEI(x) condition constructed in step S41. The first layer of the mixed integer optimizer of the genetic algorithm obtains the dimensions [z1, ..., z2] of the variables to be optimized. i , ..., z d ], where d is the preset value, 0<d<w, expressed as: [z1,...,z i ,...,from d ]=argmax CEI(x); Among them, z i is the dimension of the i-th variable to be optimized; argmax CEI(x) is to find the value of x so that CEI(x) reaches the maximum value; Then, the genetic algorithm optimizer is used to optimize the [z1, ..., z i , ..., z d ] is optimized, and the second layer of the genetic algorithm optimizer obtains the corresponding optimization variable x, which is expressed as: in, For the zth i the optimization variables; Finally, replace the corresponding d variables in the current optimal solution, that is, use replace Generate the new sample point x * ,in, For the zth i Variables before optimization.

5. A tension and compression spring design method based on Bayesian optimization algorithm according to claim 4, characterized in that: In step S5, the new sample point x generated in step S4 is * The objective function f(x) and the constraint functions [g1(x), ..., g m (x)], and update the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m When the prediction error function of CEI(x)] and the acquisition function CEI(x) constructed in step S4 are used, the following steps are specifically performed: Step S51: The new sample point x generated in step S4 is * Evaluate the objective function f(x) to obtain a new objective function, wherein the new objective function is the minimum value f of the current objective function f(x) in step S41. min , f min To minimize the mass of the spring; and output f min ; Step S52: The new sample point x generated in step S4 is * Substitute the Gaussian process regression model of the objective function f(x) and the constraint function [g1(x), ..., g i (x), ..., g m (x)], the Gaussian process regression model of the objective function f(x), the prediction function of the constraint function [g1(x), ..., g i (x), ..., g m (x)], the prediction function of the objective function f(x), and the constraint function [g1(x), ..., g i (x), ..., g m (x)], and calculate the corresponding new function values ​​respectively; Step S53: The new sample point x generated in step S4 is * Substitute the acquisition function CEI(x) and calculate a new acquisition function to prepare for the next iteration.

6. A tension and compression spring design method based on Bayesian optimization algorithm according to claim 5, characterized in that: The preset number of iterations v in step S6 is no less than 80 times.

7. The tension and compression spring design method based on Bayesian optimization algorithm according to claim 1 is characterized in that: The expression of the objective function f(x) of the tension and compression spring design in step S1 is: f(x)=x1 2 x2(x3+2); Among them, x1, x2, x3 are the variables in step S1, x1 is the diameter of the spring wire, x2 is the average diameter of the spring coil, and x3 is the number of effective coils of the spring; x1, x2, x3 form a variable vector, which is expressed as: x = [x1, x2, x3]; And each of the variables satisfies the inequality constraints, which are expressed as: 0.05≤x1≤2.00; 0.25≤x2≤1.30; 2.00≤x3≤15.0。 8. The tension and compression spring design method based on Bayesian optimization algorithm according to claim 1 is characterized in that: The constraint function of the tension and compression spring design [g1(x), ..., g i (x), ..., g m The expression of (x)] is: [g(x), g2(x), g3(x), g4(x)]; Among them, g1(x), g2(x), g3(x), g4(x) are: minimum deflection, shear stress, oscillation frequency and outer diameter limit, respectively. The four constraint functions are expressed as constraint inequalities, respectively:

9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the tension and compression spring design method based on the Bayesian optimization algorithm as described in any one of claims 1 to 8 by executing the computer instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute a tension and compression spring design method based on a Bayesian optimization algorithm as described in any one of claims 1 to 8.