LQR parameter optimization method based on proportional number two-stage genetic algorithm, electronic equipment and storage medium
By optimizing the Q and R parameters of the LQR control algorithm based on the Lagrange method and a proportional-scalar two-stage genetic algorithm, the problem of low parameter optimization efficiency in the prior art is solved, and the global optimal solution of the LQR control algorithm and the fast response of the system are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUBEI UNIV OF ARTS & SCI
- Filing Date
- 2026-01-16
- Publication Date
- 2026-05-15
AI Technical Summary
In existing technologies, the optimization of Q and R parameters in LQR control algorithms relies on engineers' experience, which is inefficient and makes it difficult to obtain the global optimal solution. This results in a complex optimization problem and makes it impossible to achieve fast system response and trajectory tracking.
A dynamic model based on the Lagrange method is established, and the Q and R parameters are optimized by a proportional two-stage genetic algorithm. The optimization results are evaluated by combining the ITAE index, and the global optimal solution of the LQR control algorithm is achieved.
It improves the optimization efficiency and accuracy of the LQR control algorithm, realizes the system's rapid response and trajectory tracking, avoids over-control, and provides a visual evaluation of the optimization results.
Smart Images

Figure CN122043941A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automatic control technology, and in particular to an LQR parameter optimization method based on a proportional two-stage genetic algorithm, an electronic device, and a storage medium. Background Technology
[0002] The LQR (Linear Quadratic Regulator) control algorithm is a classic optimal control method. This algorithm designs the state feedback control matrix K to minimize the cost function. This control algorithm enables stable system control and is widely used in fields such as wheeled robots, two-wheeled self-balancing robots, and intelligent suspension systems.
[0003] However, the performance of LQR is highly dependent on the parameter selection (parameter tuning) of the weight matrices Q and R in minimizing the cost function. Currently, the parameters of Q and R are mostly determined by trial and error based on engineers' experience, which is inefficient and makes it difficult to obtain the global optimum. In particular, the integral range of the cost function J is from 0 to infinity, which makes the optimization problem complex and cannot be directly applied to conventional optimization algorithms.
[0004] Among existing patents, CN202310168186's LQR controller still relies on manually adjusting the weight matrix, failing to address the issue of automated optimization of Q and R parameters, resulting in time-consuming and labor-intensive processes. While CN202310891982 employs the GA-PSO (Hybrid Genetic Particle Swarm Optimization) algorithm to optimize LQR, it does not address the integral characteristics of the cost function, thus failing to achieve global optimization of LQR and presenting a rather one-sided approach to LQR optimization. None of these patents solve the problem of automated optimization of Q and R parameters.
[0005] Therefore, there is an urgent need for a more comprehensive, automated, and efficient method for optimizing LQR parameters to solve the above problems. Summary of the Invention
[0006] The purpose of this application is to provide an LQR parameter optimization method, electronic device, and storage medium based on a proportional-scalar two-stage genetic algorithm. This technology establishes a dynamic model of the controlled object using the Lagrange method to derive the state-space equations. Based on these equations, an LQR control algorithm model is constructed to obtain the feedback gain weight K and its cost function. The baseline values of the Q and R parameters are optimized using the proportional-scalar two-stage genetic algorithm model. The optimized Q and R parameters are then substituted into the LQR control algorithm model to calculate the feedback gain matrix K and cost function J. The optimization result of the feedback gain matrix K is evaluated using the cost function J, achieving a globally optimal solution for the LQR control algorithm model. This improves the system balance and trajectory tracking of the controlled object. This control algorithm is widely used in wheeled robots, two-wheeled self-balancing robots, intelligent suspension systems, and other fields.
[0007] The technical solution provided in this application is as follows:
[0008] Firstly, a method for optimizing LQR parameters based on a proportional two-stage genetic algorithm:
[0009] S1: Establish a dynamic model of the controlled object based on the Lagrange equation and derive the state-space equation.
[0010] Furthermore, the dynamic model is as follows:
[0011] ;
[0012] in, To unify and simplify variables, Let m be the pitch acceleration of the controlled object, g be the mass of the control object's pendulum, h be the gravitational force, and h be the length of the control object's pendulum. Let M be the initial pitch angle of the control object's lever, and M be the weight of the control object's wheel. The torque of the wheel of the controlled object is denoted as r, and the radius of the wheel of the controlled object is denoted as r.
[0013] Furthermore, the state-space equation expression of the controlled object is as follows:
[0014] ;
[0015] in, The initial pitch angle, Angular velocity, x is the pitch acceleration; x is the distance the pendulum moves. The rotor speed is This refers to the angular acceleration of the pendulum. For the control input; Let A be the spatial state matrix, and a and c be the influence parameters of the spatial state system matrix A. Let B be the spatial state matrix, and b and d be the influence parameters of the spatial state system matrix B.
[0016] The expressions for the influencing parameters a, b, c, and d are as follows:
[0017] ;
[0018] ;
[0019] ;
[0020] ;
[0021] ;
[0022] ;
[0023] Where m is the mass of the pendulum of the controlled object, M is the weight of the wheel of the controlled object, h is the length of the pendulum of the controlled object, r is the radius of the wheel of the controlled object, g is the gravity parameter, and I is the moment of inertia of the pendulum of the controlled object. To unify and simplify variables;
[0024] S2: Construct an LQR control algorithm model based on the state-space equation, and obtain the cost function J of the feedback gain matrix K and the feedback gain weight K.
[0025] S3: Solve the cost function J of the feedback gain weight K using a proportional two-stage genetic algorithm model to obtain the optimized baseline values of the Q and R parameters.
[0026] Further, the Q parameter to be optimized and the R parameter to be optimized are obtained according to the cost function J; and a baseline value for the R parameter is established based on the R parameter.
[0027] The proportional two-stage genetic algorithm model includes a first-stage genetic algorithm and a second-stage genetic algorithm.
[0028] The first-stage genetic algorithm minimizes the fitness function to find the optimal ratio between the Q-parameters initialized after encoding and the baseline values of the R-parameters initialized after encoding; the second-stage initialization population of the Q-parameters in the second-stage genetic algorithm is then optimized based on the optimal ratio.
[0029] The second-stage genetic algorithm minimizes the fitness function, and solves for the optimized Q-parameters and R-parameters based on the second-stage initialized population of the encoded Q-parameters and the baseline value of the encoded initialized R-parameters.
[0030] The Q parameter and the R parameter are encoded with the same dimension size based on the dimensions of the spatial state system matrix A and the spatial state system matrix B of the state space equation.
[0031] The fitness function of the proportional two-stage genetic algorithm model is:
[0032] ;
[0033] in, Let J be the fitness function, ITAE be the ITAE index function, and J be the cost function. The penalty term coefficient of the ITAE index function;
[0034] Both the first-stage genetic algorithm and the second-stage genetic algorithm perform selection, crossover, and mutation on the Q parameters:
[0035] The selections made by the first-stage genetic algorithm and the second-stage genetic algorithm are elite selections;
[0036] The crossover in the first stage genetic algorithm is a binary crossover that introduces adaptive crossover, and the mutation in the first stage genetic algorithm is a basic bit mutation that introduces adaptive mutation;
[0037] The crossover in the second-stage genetic algorithm is a fully disturbed crossover with adaptive crossover; the mutation in the second-stage genetic algorithm is a quantum gate rotation mutation with adaptive mutation.
[0038] The mutation parameters of the adaptive mutation include and , It is 0.1. The value is 0.01; the cross parameters of the adaptive cross include... and , It is 0.8. It is 0.5;
[0039] S4: Substitute the optimized Q and R parameters into the LQR control algorithm model to calculate the optimized feedback gain matrix K; then substitute the optimized Q and R parameters into the cost function J, and evaluate the optimization result of the optimized feedback gain matrix K through the cost function J. If the evaluation result of the cost function J exceeds the threshold, then substitute the optimized feedback gain matrix K into the LQR control algorithm model to achieve system balance or trajectory tracking of the controlled object. If the optimization result does not exceed the threshold, return to step S3 to continue optimizing the Q and R parameters.
[0040] In a second aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, performs an LQR parameter optimization method based on a proportional two-stage genetic algorithm as described in any of the first aspects above.
[0041] Thirdly, a computer device is provided, comprising:
[0042] Memory is used to store instructions.
[0043] A processor is configured to execute the instructions, causing the computer device to perform an LQR parameter optimization method based on a proportional two-stage genetic algorithm as described in any of the first aspects above.
[0044] Compared with the prior art, the beneficial effects achieved by this application are as follows:
[0045] 1. This application optimizes the Q and R values of the LQR controller separately through a two-layer hierarchical strategy. The first layer of optimization obtains the relative proportional relationship between Q and R, and the second layer determines the absolute values of Q and R based on the relative proportional relationship. Through multi-layer optimization, the goal of comprehensively optimizing the Q and R values is achieved, while also avoiding the blindness of traditional methods, thereby improving the accuracy of the control system.
[0046] 2. This application optimizes the numerical characteristics of Q and R values using a two-stage genetic algorithm. This method can perform hierarchical optimization based on numerical characteristics on the basis of comprehensive optimization, thereby improving the optimization efficiency of the genetic algorithm. Compared with the traditional method of parameter tuning, it greatly improves the optimization efficiency and achieves the goal of rapid response of the control system in various scenarios.
[0047] 3. This application uses the ITAE (Integral Time Absolute Error) index for optimization, which can balance control effect and energy consumption during the genetic algorithm optimization of Q and R values, so as to prevent over-control and further improve the optimization results. At the same time, the ITAE index can also be used as an evaluation index to visualize the Q and R value optimization results of the genetic algorithm, and provide data support for optimization efficiency and optimization results from a numerical perspective. Attached Figure Description
[0048] Figure 1 This is a flowchart of the method provided in this application.
[0049] Figure 2 This is a flowchart of the algorithm optimization for the first and second genetic algorithms in this application.
[0050] Figure 3 This is a diagram showing the results of the first genetic algorithm optimization of the wheeled legged robot proposed in this application. Figure 3 Figure (a) in the middle shows the fitness optimization results of the first genetic algorithm. Figure 3 Figure (b) shows the convergence distance result of the first genetic algorithm parameter optimization.
[0051] Figure 4 This is a diagram showing the optimization results of the second genetic algorithm ITAE for the wheeled leg robot in this application.
[0052] Figure 5 This is a diagram showing the results of the second genetic algorithm optimization of the wheeled legged robot in this application. Figure 5 Figure (a) in the middle shows the fitness optimization results of the second genetic algorithm. Figure 5 Figure (b) shows the convergence distance result of the second genetic algorithm parameter optimization.
[0053] Figure 6 This is an example diagram of the LQR control algorithm model for the wheeled legged robot of this application.
[0054] Figure 7 This is an example diagram of the wheeled robot of this application.
[0055] Figure 8 This is a Simulink simulation image of the wheeled robot of this application. Detailed Implementation
[0056] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this application or its application or use.
[0057] Example 1:
[0058] This embodiment introduces an LQR parameter optimization method based on a proportional two-stage genetic algorithm. The controlled object in this embodiment is a wheeled-legged robot as an example. The wheeled-legged robot includes the following physical parameters: pendulum mass m, pendulum length h, pendulum moment of inertia I=m*(h^2), gravity parameter g, wheel radius r, and wheel weight M. (Refer to...) Figure 1 The process is divided into four steps, as detailed below:
[0059] S1: Establish a dynamic model of the wheeled robot based on the Lagrange equations and derive the state-space equations:
[0060] S1.1 Solve for the Lagrangian quantities based on the total kinetic energy and center of mass height of the wheeled robot.
[0061] The expression for the total kinetic energy T of the wheeled robot:
[0062] ;
[0063] This refers to the kinetic energy gained by the wheels of a wheel-legged robot as they rotate. This refers to the kinetic energy gained by the pendulum of the wheeled robot as it rotates with the wheels. This refers to the kinetic energy obtained by the pendulum parallel to the direction of movement of the wheeled robot when it moves by its wheels;
[0064] in M represents the weight of the wheel of the wheeled robot. The rotational speed of the wheels of the wheeled robot;
[0065] I represents the moment of inertia of the lever of the wheeled robot. Let I be the angular velocity of the pendulum of the wheeled robot, where I = m * (h^2), m is the mass of the pendulum of the wheeled robot, and h is the length of the pendulum of the wheeled robot.
[0066] m is the mass of the lever of the wheeled robot. The rotational speed of the wheels of the wheeled robot;
[0067] The velocity of the center of mass is calculated by considering the angle, length, and distance traveled by the swing arm of the wheeled robot. :
[0068] By analyzing the horizontal and vertical movement distances of the wheeled robot's pendulum using trigonometric functions, we can obtain:
[0069] ;
[0070] h represents the length of the lever of the wheeled robot, and x represents the distance the wheeled robot travels. Let be the initial pitch angle of the lever arm of the wheeled robot. This represents the horizontal distance traveled by the lever of the wheeled robot. denoted as , where is the vertical distance the lever of the wheeled robot moves; sin is the sine function, and cos is the cosine function.
[0071] Differentiating the horizontal and vertical distances 'a' and 'b' after analysis, the velocity of the center of mass is obtained. The analytical formula obtained through trigonometric functions is:
[0072] ;
[0073] h is the length of the lever of the wheeled robot. Let be the initial pitch angle of the lever arm of the wheeled robot. For the angular velocity of the lever of the wheeled robot, The rotational speed of the wheels of the wheeled robot. This represents the horizontal distance the lever of the wheeled robot travels. Let be the vertical distance the pendulum of the wheeled robot moves; sin is the sine function, cos is the cosine function; therefore, the velocity of the pendulum's center of mass is... Squaring, and Substituting the values, we get the formula:
[0074] ;
[0075] in, This represents the horizontal distance the lever of the wheeled robot travels. This represents the vertical distance the lever of the wheeled robot travels. Let be the rotational speed of the wheeled robot's wheels, and h be the length of the robot's lever. Let be the initial pitch angle of the lever arm of the wheeled robot. For the angular velocity of the lever of the wheeled robot, The rotational speed of the wheels of the wheeled robot;
[0076] The velocity of the center of mass The square of , and Substitute the total kinetic energy Simplifying, we get:
[0077] ;
[0078] Where M is the weight of the wheel of the wheeled robot, and m is the mass of the swing arm of the wheeled robot. Let be the rotational speed of the wheel of the wheeled robot, I be the moment of inertia of the pendulum of the wheeled robot, and h be the length of the pendulum of the wheeled robot. Let be the initial pitch angle of the lever arm of the wheeled robot. Let be the angular velocity of the lever of the wheeled robot, and cos be the cosine function;
[0079] The Lagrangian quantity L of the wheel-legged robot is calculated based on the total kinetic energy and the height of the center of mass:
[0080] ;
[0081] For total kinetic energy, Let M be the height of the center of mass, M be the weight of the wheel of the wheeled robot, and m be the mass of the pendulum of the wheeled robot. Let be the rotational speed of the wheel of the wheeled robot, I be the moment of inertia of the pendulum of the wheeled robot, and h be the length of the pendulum of the wheeled robot. Let be the initial pitch angle of the lever arm of the wheeled robot. Let be the angular velocity of the pendulum of the wheel-legged robot, g be the gravitational parameter, and cos be the cosine function; where is the height of the pendulum's center of mass. The change is as follows: m is the mass of the lever of the wheeled robot, and g is the gravity parameter. Let be the initial pitch angle of the lever of the wheeled robot, and cos be the cosine function;
[0082] S1.2 Substitute the Lagrange quantities into the Lagrange equations to establish a dynamic model.
[0083] The Lagrange equation is:
[0084] ;
[0085] in, Let i be the i-th generalized coordinate. For the i-th generalized velocity based on the i-th generalized coordinate, For the i-th generalized force based on the i-th generalized coordinate, Let be the number of constraint equations in the Lagrange equations. The symbol for differential calculation, The sign of the partial derivative. For Lagrange quantities;
[0086] According to the Lagrange equation, the Lagrange quantity Taking partial derivatives, the Lagrange equation is:
[0087] ;
[0088] in, Let i be the i-th generalized coordinate. For the i-th generalized velocity based on the i-th generalized coordinate, For the i-th generalized force based on the i-th generalized coordinate, Let be the number of constraint equations in the Lagrange equations. The symbol for differential calculation, The sign of the partial derivative. For Lagrange quantities;
[0089] The parameters in the Lagrange equations for wheeled robots are as follows:
[0090] Generalized coordinates = Generalized force = ;
[0091] in, and These are the first and second generalized coordinates, respectively, where x represents the distance traveled by the wheeled robot. The initial pitch angle of the lever arm of the wheeled robot; and For the first generalized force based on the first generalized coordinate and the second generalized force based on the second generalized coordinate, To apply force to the wheeled robot;
[0092] Due to the generalized coordinates of wheeled robots Let be the initial pitch angle of the lever arm of the wheeled robot. Since the lever arm has no force at the pitch angle, therefore... Force F and torque The relationship is Where r is the wheel radius;
[0093] Will Substituting the first generalized coordinate and the first generalized force into the Lagrange equation, we get: The next step is to calculate the first generalized coordinate using partial derivatives. Intermediate quantity:
[0094] First, the rotational speed of the wheeled robot... Find the partial derivative:
[0095] ;
[0096] in, For Lagrange units, Let M be the rotational speed of the wheel of the wheeled robot, M be the weight of the wheel of the wheeled robot, and m be the mass of the pendulum of the wheeled robot. Let be the rotational speed of the wheeled robot's wheels, and h be the length of the robot's lever. For the angular velocity of the lever of the wheeled robot, Let be the initial pitch angle of the lever of the wheeled robot, and cos be the cosine function. The sign of the partial derivative;
[0097] Again By taking the differential, we can obtain: ;
[0098] in, The symbol for differential calculation, The sign of the partial derivative. Let M be a Lagrangian quantity, where M is the weight of the wheel of the wheeled robot, and m is the mass of the lever of the wheeled robot. Let denoted as ω0, where ω is the angular acceleration of the lever of the wheeled robot, and h is the length of the lever of the wheeled robot. For the pitch acceleration of the wheeled robot, For the angular velocity of the lever of the wheeled robot, Let be the initial pitch angle of the lever of the wheeled robot, sin be the sine function, and cos be the cosine function;
[0099] Continue taking the partial derivative with respect to the distance x traveled by the wheeled robot: ; For Lagrange units, The sign of the partial derivative;
[0100] Will and Substitute into the Lagrange equation Simplification yields the first generalized coordinate. equation:
[0101] ;
[0102] Where M is the weight of the wheel of the wheeled robot, m is the mass of the pendulum of the wheeled robot, and h is the length of the pendulum of the wheeled robot. For the pitch acceleration of the wheeled robot, For the angular velocity of the lever of the wheeled robot, Let be the initial pitch angle of the lever arm of the wheeled robot, where sin is the sine function and cos is the cosine function. Let r be the wheel torque of the wheeled robot, and r be the wheel radius.
[0103] With the first generalized coordinate Similarly, the second generalized coordinate is calculated using partial derivatives. Intermediate quantity:
[0104] First, the angular velocity of the swing arm of the wheeled robot... Find the partial derivative:
[0105] ;
[0106] in, Let I be the Lagrangian quantity, and let I be the moment of inertia of the lever of the wheeled robot. Let be the rotational speed of the wheel of the wheeled robot, and m be the mass of the pendulum of the wheeled robot. Let be the rotational speed of the wheeled robot's wheels, and h be the length of the robot's lever. For the angular velocity of the lever of the wheeled robot, Let be the initial pitch angle of the lever of the wheeled robot, and cos be the cosine function. The sign of the partial derivative;
[0107] Again By taking the differential, we can obtain: ;
[0108] in, The symbol for differential calculation, Let I be a Lagrangian quantity, I be the moment of inertia of the lever of the wheeled robot, and m be the mass of the lever of the wheeled robot. For the angular acceleration of the pendulum of the wheeled robot, Let be the rotational speed of the wheeled robot's wheels, and h be the length of the robot's lever. For the pitch acceleration of the wheeled robot, For the angular velocity of the lever of the wheeled robot, Let be the initial pitch angle of the lever arm of the wheeled robot, where sin is the sine function and cos is the cosine function. The sign of the partial derivative;
[0109] Continue to calculate the initial pitch angle of the wheeled robot's lever according to the Lagrange equation. Find the partial derivative:
[0110] ;
[0111] in, For Lagrange units, Let be the partial derivative sign, m be the mass of the pendulum of the wheeled robot, h be the length of the pendulum of the wheeled robot, g be the gravity parameter, and sin be the sine function. For the angular velocity of the lever of the wheeled robot, The rotational speed of the wheels of the wheeled robot;
[0112] Furthermore, and Substituting into the Lagrange equation and simplifying, we obtain the second generalized coordinate. The equation:
[0113] ;
[0114] Where I is the moment of inertia of the pendulum of the wheeled robot, m is the mass of the pendulum of the wheeled robot, and h is the length of the pendulum of the wheeled robot. For the angular acceleration of the pendulum of the wheeled robot, Let g be the initial pitch angle of the lever of the wheeled robot, g be the gravity parameter, sin be the sine function, and cos be the cosine function;
[0115] If the initial pitch angle of the wheeled robot's swing arm Within a small angle range , sin is the sine function, cos is the cosine function; therefore, the first generalized coordinate... and the second generalized coordinate The equation can be further simplified to:
[0116] ; ;
[0117] Where M is the weight of the wheel of the wheeled robot, and m is the mass of the pendulum of the wheeled robot. Let denoted as ω0, where ω is the angular acceleration of the lever of the wheeled robot, and h is the length of the lever of the wheeled robot. For the pitch acceleration of the wheeled robot, For the angular velocity of the lever of the wheeled robot, Let be the initial pitch angle of the lever arm of the wheeled robot. Let be the wheel torque of the wheeled robot, r be the wheel radius of the wheeled robot, and I be the moment of inertia of the lever of the wheeled robot. Let g be the angular acceleration of the pendulum of the wheeled robot, and g be the gravitational parameter.
[0118] The first generalized coordinate The equation is transformed to obtain:
[0119] ;
[0120] in, Let M be the angular acceleration of the pendulum of the wheeled robot, M be the weight of the wheel of the wheeled robot, and m be the mass of the pendulum of the wheeled robot. Let be the wheel torque of the wheeled robot, r be the wheel radius of the wheeled robot, and h be the length of the lever of the wheeled robot. The pitch acceleration of the wheeled robot;
[0121] The first generalized after the change Substituting the equation into the second generalized coordinate The equation, simplified and expanded, yields:
[0122] ;
[0123] Where I is the moment of inertia of the pendulum of the wheeled robot, m is the mass of the pendulum of the wheeled robot, and h is the length of the pendulum of the wheeled robot. For the pitch acceleration of the wheeled robot, Let M be the wheel torque of the wheeled robot, M be the wheel weight of the wheeled robot, r be the wheel radius of the wheeled robot, and g be the gravity parameter. The initial pitch angle of the lever arm of the wheeled robot;
[0124] Will Pitch acceleration of a mid-wheeled legged robot Combine like terms and... The irrelevant terms stand independently on the left side of the equation, resulting in:
[0125] ;
[0126] Let the variables be unified and simplified. , M is the weight of the wheel of the wheeled robot, m is the mass of the pendulum of the wheeled robot, h is the length of the pendulum of the wheeled robot, and I is the moment of inertia of the pendulum of the wheeled robot.
[0127] Will Substitution We can obtain:
[0128] ;
[0129] in, To unify and simplify variables, Let be the pitch acceleration of the wheeled robot, m be the mass of the wheeled robot's lever, g be the gravitational parameter, and h be the length of the wheeled robot's lever. Let M be the initial pitch angle of the lever of the wheeled robot, and M be the weight of the wheel of the wheeled robot. Let be the wheel torque of the wheeled robot, and r be the wheel radius of the wheeled robot;
[0130] Will Dividing both sides by D simplifies to:
[0131] ;
[0132] Will Substitution Simplifying, we get:
[0133] ;
[0134] Finally and Simplifying, we get:
[0135] ;
[0136] in, To unify and simplify variables, Let be the pitch acceleration of the wheeled robot, m be the mass of the wheeled robot's lever, g be the gravitational parameter, and h be the length of the wheeled robot's lever. Let M be the initial pitch angle of the lever of the wheeled robot, and M be the weight of the wheel of the wheeled robot. Let be the wheel torque of the wheeled robot, and r be the wheel radius of the wheeled robot;
[0137] At this point, the pitch acceleration and angular acceleration of the pendulum Both can be determined by the initial pitch angle of the wheeled robot's lever. Wheel torque of wheel-legged robots It is stated that a dynamic model of the wheeled robot has been established.
[0138] S1.3 The state-space equation of the wheeled robot is obtained by calculating based on the dynamic model.
[0139] State space model of the wheeled robot , For state vectors, To control the input vector, A is The spatial state system matrix, B is... The spatial state system matrix;
[0140] Let the control input vector be... , , Let be the wheel torque of the wheeled robot; let the system state vector of the wheeled robot be... , ; Let be the initial pitch angle of the lever arm of the wheeled robot. Let ω be the angular velocity of the lever of the wheeled robot, and x be the distance the wheeled robot travels. The rotational speed of the wheels of the wheeled robot;
[0141] Assuming the system state vector is 0, the rate of change of the inverted pendulum state of the wheel-legged robot with time is obtained through differential equations. Differentiating the state vector yields... , State vector of the wheeled robot Differential variable, For the angular velocity of the lever of the wheeled robot, For the pitch acceleration of the wheeled robot, The rotational speed of the wheels of the wheeled robot. For the angular acceleration of the lever of the wheeled robot;
[0142] Dynamic model, system state vector Control input vector and system state vector derivative Substitute into Further transformation and simplification yield:
[0143] ;
[0144] ; ; ; ;
[0145] ; ;
[0146] in, To unify and simplify variables, Let be the pitch acceleration of the wheeled robot, m be the mass of the wheeled robot's lever, g be the gravitational parameter, and h be the length of the wheeled robot's lever. Let M be the initial pitch angle of the lever of the wheeled robot, and M be the weight of the wheel of the wheeled robot. Let be the wheel torque of the wheeled robot, and r be the wheel radius of the wheeled robot. Let be the initial pitch angle of the lever arm of the wheeled robot. For the angular velocity of the lever of the wheeled robot, Let x be the pitch acceleration of the wheeled robot, and x be the distance the wheeled robot travels. The rotational speed of the wheels of the wheeled robot. The angular acceleration of the pendulum of the wheeled robot.
[0147] After conversion Basis Rearranging the form into matrix form, we get:
[0148] ;
[0149] in, The initial pitch angle, Angular velocity, x is the pitch acceleration; x is the distance the pendulum moves. The rotor speed is This refers to the angular acceleration of the pendulum. This refers to the wheel torque; Let A be the spatial state matrix, and a and c be the influence parameters of the spatial state system matrix A. Let B be the spatial state matrix, and b and d be the influence parameters of the spatial state system matrix B.
[0150] S2: Construct an LQR control algorithm model based on the state-space equation, and obtain the cost function J of the feedback gain matrix K and the feedback gain weight K.
[0151] Through state-space equations Construct an LQR control algorithm model, referring to... Figure 6 As shown, read the system state vector Adjusting the control input vector , State vector of the wheeled robot Differential variable, for The integral of the system state vector, where the system state vector is... The spatial state system matrix A represents the system's own evolution law, without a control input vector. Intervention, control of input vector The spatial state system matrix B is the control input vector. The impact of intervention on the system; the K matrix is the feedback gain matrix;
[0152] The cost function J is obtained through the LQR control algorithm model. Obtain the Q and R parameters; Let cost function be This is the control input vector for the system state feedback loop. The system state vector is the system state feedback loop. for The transpose function, for The transpose function of , where Q is the Q parameter representing the control weight of the feedback gain matrix K, and R is the R parameter representing the power consumption effect of the feedback gain matrix K;
[0153] S3 solves the cost function J of the feedback gain weight K using a proportional two-stage genetic algorithm model, and obtains the optimized baseline values of the Q and R parameters.
[0154] Further, the Q parameter to be optimized and the R parameter to be optimized are obtained according to the cost function J; and a baseline value for the R parameter is established based on the R parameter.
[0155] The proportional two-stage genetic algorithm model includes a first-stage genetic algorithm and a second-stage genetic algorithm.
[0156] The first-stage genetic algorithm minimizes the fitness function to find the optimal ratio between the Q-parameters initialized after encoding and the baseline values of the R-parameters initialized after encoding; the second-stage initialization population of the Q-parameters in the second-stage genetic algorithm is then optimized based on the optimal ratio.
[0157] The second-stage genetic algorithm minimizes the fitness function, and solves for the optimized Q-parameters and R-parameters based on the second-stage initialized population of the encoded Q-parameters and the baseline value of the encoded initialized R-parameters.
[0158] The Q parameter and the R parameter are encoded with the same dimension size based on the dimensions of the spatial state system matrix A and the spatial state system matrix B of the state space equation.
[0159] The fitness function of the proportional two-stage genetic algorithm model is:
[0160] ;
[0161] in, Let J be the fitness function, ITAE be the ITAE index function, and J be the cost function. The penalty term coefficient of the ITAE index function;
[0162] Both the first-stage genetic algorithm and the second-stage genetic algorithm perform selection, crossover, and mutation on the Q parameters:
[0163] The selections made by the first-stage genetic algorithm and the second-stage genetic algorithm are elite selections;
[0164] The crossover in the first stage genetic algorithm is a binary crossover that introduces adaptive crossover, and the mutation in the first stage genetic algorithm is a basic bit mutation that introduces adaptive mutation;
[0165] The crossover in the second-stage genetic algorithm is a fully disturbed crossover with adaptive crossover; the mutation in the second-stage genetic algorithm is a quantum gate rotation mutation with adaptive mutation.
[0166] The mutation parameters of the adaptive mutation include and , It is 0.1. The value is 0.01; the cross parameters of the adaptive cross include... and , It is 0.8. It is 0.5;
[0167] The following describes the optimization process of the first-stage genetic algorithm and the second-stage genetic algorithm, referring to... Figure 2 As shown:
[0168] S3.1: Initialize the population:
[0169] Process description:
[0170] Generate an initial parameter population, where each individual represents a set of baseline values for candidate Q and R parameters. The Q parameters are the state weight matrix (diagonal matrix), and the R parameters are the control weight matrix (scalar or diagonal matrix).
[0171] Input: parameter range (e.g., diagonal elements q1~q4 of Q parameter ∈ [0.1, 1000], R parameter ∈ [0, 20]), population size (e.g., 100 individuals);
[0172] Process: The population is generated using random initialization or chaotic mapping (such as Logistic mapping);
[0173] Each individual is encoded as a vector, for example, individual = [q1, q2, q3, q4, R]; q1, q2, q3, and q4 are the diagonal elements of the Q parameters, and R is the R parameter;
[0174] Output: Initial population (e.g., 100 individuals). Key points: Population size affects global search capability; the initialization range must cover potentially optimal solutions to avoid premature convergence.
[0175] S3.2 encoding:
[0176] Process description:
[0177] The parameters (the values of Q and R) are converted into chromosomes that can be manipulated by the genetic algorithm.
[0178] Optionally, the encoding method may include binary encoding, real number encoding, or quantum encoding.
[0179] Binary encoding: Convert each parameter value into a binary string. For example, if the diagonal element q1 of the Q parameter is ∈ [0.1, 1000] and the precision requirement is 0.000001, then the chromosome length m satisfies 2m−1<(1000−0.1)×104≤2m-1, which calculates to m≈20 bits.
[0180] Real number encoding: directly using the real values of the parameters as genes.
[0181] Quantum encoding: The gene is represented by a pair of complex numbers, such as [α, β], where |α|² + |β|² = 1, in order to improve search efficiency.
[0182] Output: Encoded chromosome population.
[0183] During the encoding process, the Q parameter and the R parameter adopt the same encoding dimension based on the dimension size of the spatial state system matrix A and the spatial state system matrix B;
[0184] Combining the model: Given spatial state system matrix A and spatial state system matrix B, the LQR cost function is... During encoding, it is necessary to ensure that the dimensions of the Q and R parameters match those of the spatial state system matrix A and spatial state system matrix B (for example, if A is a 4×4 matrix, Q should be a 4×4 diagonal matrix, and R should be a scalar). This is to ensure that the optimization calculation results will not be affected by the data dimensions, thus preventing the optimization results from failing to match.
[0185] S3.3 Fitness Function Calculation:
[0186] Process description:
[0187] The fitness value of each individual is evaluated, indicating better parameter performance. This process employs a two-step genetic algorithm: the first uses the cost function J as the fitness function, and the second uses ITAE as the fitness function.
[0188] Fitness function design:
[0189] First-stage genetic algorithm: , Let J be the fitness function expression for the first stage of the genetic algorithm, where J is the cost function.
[0190] Second-stage genetic algorithm:
[0191] Introduce ITAE as a comprehensive indicator; , , where e(t) is the systematic error (e.g., lateral error, heading error). This is the fitness expression for the second-stage genetic algorithm. For ITAE index functions, The penalty term coefficient of the ITAE index function is... For the systematic error point, This is the total error. This is the integral quantity.
[0192] Calculation process:
[0193] Individuals are decoded into Q parameters and R parameters.
[0194] Solving the Riccati equation We obtain matrix P, where P is the solution to the Riccati algebraic equation and the feedback control matrix. Q is the Q parameter. Let A be the inverse matrix of the R parameters, A be the spatial state system matrix A, and B be the spatial state matrix B. Let A be the transpose of the spatial state system matrix A. Let be the transpose of the spatial state system matrix B.
[0195] Calculate feedback gain and optimal control law , This is the control input vector for the system state feedback loop. This is the system state vector of the system state feedback loop.
[0196] Simulate the system response and calculate the ITAE index or cost function J.
[0197] Output: Fitness value for each individual.
[0198] S3.4 Selection Steps:
[0199] Process description: Select superior individuals based on fitness to enter the next generation, simulating "survival of the fittest".
[0200] Specifically, this involves calculating the selection probability for each individual. , Let be the probability of the i-th choice, where Let N be the fitness of individual i, and N be the total number of individuals; calculate the cumulative probability. , Let be the cumulative probability of k individuals. Choose the probability for the j-th individual. Generate random numbers for the total number of individuals. Choose one that satisfies The individual; the output is the set of selected individuals.
[0201] Optionally, the selection method includes several variations, such as:
[0202] Elite retention: The individual with the highest fitness is directly retained to the next generation.
[0203] Sort selection: Sort by fitness, and the selection probability is related to the ranking.
[0204] In this embodiment, the selection in the first stage of the genetic algorithm is elite selection; the selection in the second stage of the genetic algorithm is elite selection.
[0205] Output: The set of selected individuals.
[0206] S3.5 Cross Steps:
[0207] Process description: New individuals are generated by exchanging chromosome segments to increase diversity. Single-point crossover or full-interference crossover are commonly used.
[0208] Alternatively, the crossover can be performed using any of the following methods:
[0209] Binary crossover: A crossover point is randomly selected, and parent genes are exchanged. For example, parent A = [a1, a2, a3, a4], B = [b1, b2, b3, b4]; a1, a2, a3, and a4 are the parent gene elements of A; b1, b2, b3, and b4 are the parent gene elements of B. The crossover results in offspring A' = [a1, a2, b3, b4] and B' = [b1, b2, a3, a4]. A' is the offspring of parent A, and B' is the offspring of parent B.
[0210] Full interference crossover: Recombining the population along the diagonal. For example, after arranging the individual matrix by rows, exchanging genes along the diagonal achieves global mixing.
[0211] Adaptive crossover probability :definition , and Here, f is the crossover probability parameter, and f is the individual fitness. For average fitness, For maximum fitness.
[0212] The crossover in the first-stage genetic algorithm is a binary crossover with adaptive crossover; the crossover in the second-stage genetic algorithm is a full-disturbance crossover with adaptive crossover; the crossover parameters of the adaptive crossover include... and , Set to 0.8, Set to 0.5;
[0213] Output: The new population after crossover.
[0214] Key point: Set the crossover probability to 0.8. Too high a probability will destroy the superior genes, while too low a probability will result in slow convergence.
[0215] S3.6 Mutation Operation:
[0216] Process description: Randomly change gene values with a small probability to escape local optima. Common methods include basic bit mutation or quantum rotation gate mutation.
[0217] Mutation can be performed using any of the following methods:
[0218] Basic locus variation: Randomly select gene loci, with probability Perturb its value. For example, in real number encoding, q1→q1+δ, where q1 is the encoded element and δ is a random small quantity.
[0219] Quantum rotation gate mutation: used for quantum encoding, updating qubits to... , and Let be the two binary-coded chromosomes of the i-th qubit, and t be the mutation time. For rotation Angle-angled revolving door, in which For a revolving door, sin is the sine function and cos is the cosine function. For rotation angle, Determined by fitness.
[0220] The adaptive mutation expression is:
[0221] ;
[0222] in For adaptive mutation probability, and Here, f is the variation parameter, and f is the individual fitness. For average fitness, For maximum fitness;
[0223] The mutation in the first-stage genetic algorithm is a basic bit mutation that introduces adaptive mutation; the mutation in the second-stage genetic algorithm is a quantum gate rotation mutation that introduces adaptive mutation; the mutation parameters of the adaptive mutation include... and , Set to 0.1, Set to 0.01;
[0224] Output: The new population after mutation.
[0225] Key point: The mutation probability should be set between 0.01 and 0.1. Too high a probability can lead to random walks, while too low a probability can lead to premature convergence.
[0226] S3.7 Termination Condition Check
[0227] Process description: Determine whether to end the iteration. Common conditions include:
[0228] Maximum number of iterations (e.g., 200 generations).
[0229] Fitness convergence (e.g., the optimal fitness changes less than the threshold 1e-6 over N consecutive generations).
[0230] To achieve the preset performance (e.g., ITAE < threshold), the threshold is set by the relevant technical personnel.
[0231] Output: If the conditions are met, output the optimal individual (i.e., the optimal values of Q and R); otherwise, return to the (3) fitness function calculation loop.
[0232] S4 substitutes the optimized Q and R parameters into the LQR control algorithm model to calculate the optimized feedback gain matrix K; then substitutes the optimized Q and R parameters into the cost function J, and evaluates the optimization result of the optimized feedback gain matrix K through the cost function J. If the evaluation result of the cost function J exceeds the threshold, the optimized feedback gain matrix K is substituted into the LQR control algorithm model to achieve system balance or trajectory tracking of the controlled object. If the optimization result does not exceed the threshold, the process returns to step S3 to continue optimizing the Q and R parameters.
[0233] Example 2:
[0234] This embodiment is a numerical simulation of the first-stage and second-stage genetic algorithms in the process of the wheeled-legged robot based on Embodiment 1. The wheeled-legged robot refers to... Figure 7 As shown, the specific values are as follows:
[0235] The physical parameters of the wheeled robot are: arm mass m = 6.25 kg, arm length h = 0.13 m, arm moment of inertia I = m * (h^2), gravity g = 9.8 m / (s^2), wheel radius r = 0.07 m, wheel weight M = 3.7 kg; initial pitch angle is... =0.3 rad;
[0236] In this embodiment, MATLAB is used for algorithm calculation and Simulink is used for simulation of the wheeled robot. The simulation diagram is shown below. Figure 8 As shown;
[0237] First GA optimization algorithm:
[0238] The first GA focused on determining the optimal ratio between Q and R, fixing R=5 as the baseline, and optimizing only the diagonal elements of the Q matrix; the cost function J adopted the standard quadratic form. ; Let cost function be This is the control input vector for the system state feedback loop. The system state vector is the system state feedback loop. for The transpose function, for The transpose function of , where Q is the Q parameter representing the control weights of the feedback gain matrix K, and R is the R parameter representing the power consumption effect of the feedback gain matrix K. As the unit of integration, This represents an infinite upper limit for integration;
[0239] The first GA used the following GA parameters: population size: 100 individuals; maximum number of generations: 200 generations; variable range: qᵢ ∈ [0.1, 1000] (wide range covering possible optimal solutions); selection strategy: elite selection (retaining the top 10% of optimal individuals); crossover and mutation: simulated binary crossover (SBX) and polynomial mutation;
[0240] The code result is as follows:
[0241] Exit flag: 1 (1 = convergence, 0 = hyperalgebra, -1 = interruption).
[0242] Optimal Q-diagonal elements: [0.100000, 0.100066, 0.100000, 0.100000].
[0243] Minimum J value: 6.432495.
[0244] Total function evaluation times: 6680.
[0245] After one GA optimization, the optimized Q = [0.100000, 0.100066, 0.100000, 0.100000], and the J value decreased from the initial 10.2 to 6.43; (See results for reference.) Figure 3 As shown; Figure 3 (a) shows the fitness convergence result, with the vertical axis representing the fitness value and the horizontal axis representing the number of iterations, including the best fitness and the mean fitness. Figure 3 (b) shows the convergence distance results for parameter optimization, with the vertical axis representing the average distance (Avengerdistance) and the horizontal axis representing the number of iterations (Generation). Average Distance Between Individuals represents the average distance accuracy between parameters after optimization; convergence of all data indicates a good result.
[0246] Through GA optimization, we obtained the optimal scaling relationship of the Q matrix. Typical results show that different diagonal elements of Q exhibit specific scaling characteristics, reflecting the relative importance of each state variable in the control system.
[0247] The first GA implementation achieved QR scaling optimization based on cost function J, with key achievements including:
[0248] A complete theoretical framework and mathematical foundation were established. An efficient GA optimization algorithm and its engineering implementation were developed. Physically meaningful optimal proportional relationships were obtained. The effectiveness and superiority of the method were verified.
[0249] Second GA optimization algorithm:
[0250] The first GA optimization successfully determined the optimal ratio between Q and R, but the absolute performance of the controller still needs fine-tuning. The ratio only solves the problem of the relative weight between parameters, while the magnitude of the absolute values directly affects the dynamic response characteristics of the controller, such as overshoot, settling time, and steady-state error.
[0251] Set the ITAE metric; , For ITAE metrics, For the systematic error point, For the total error, As an integral measure, ITAE has the following advantages compared to other performance metrics (such as ISE and IAE):
[0252] 1. Time-weighted characteristics: Emphasizes later-stage errors, promoting rapid system stabilization;
[0253] 2. Comprehensive performance evaluation: Considering both response speed and steady-state accuracy;
[0254] 3. Engineering practicality: It has been widely verified as an effective control indicator.
[0255] The second GA optimization employs a hierarchical strategy, optimizing absolute values based on a fixed proportional relationship. The core principle is: based on the Q-ratio obtained from the first GA, a fine-tuning is performed using ITAE as the fitness function within an adaptive search range of ±50%, with ±50% set based on the experience of technical personnel.
[0256] Optimize the process:
[0257] Input the reference Q value from the first GA result; automatically generate the search range: lower limit = Q × 0.50, upper limit = Q × 1.50; GA optimizes the absolute value of Q, with R = 5 fixed; output the optimal Q matrix and the minimum ITAE value;
[0258] Based on the experience from the first GA, we further optimized the GA parameters:
[0259] Population size: 100 individuals (reduces computational cost and maintains diversity); Maximum generations: 200 generations (expected to converge faster); Search strategy: a combination of elite selection and adaptive mutation; Convergence condition: function tolerance 1e-7 to improve optimization accuracy; Automatically generated search range: lower limit = Q×0.50, upper limit = Q×1.50; To ensure comparability of results, we standardized the experimental conditions: initial tilt angle: 0.3 rad (17.2°), adjusted based on stability analysis; Simulation time: 10 seconds, covering the complete dynamic response;
[0260] After the second GA optimization, the optimal Q = [0.050040, 0.150000, 0.126613, 0.050355], ITAE = 1.23, compared to 3.15 without optimization; results are referenced. Figure 4 and Figure 5 As shown; Figure 4 The ITAE system responses were all lower than the target values, indicating that the optimization results were relatively good. Figure 3 (a) Similarly, Figure 5 Figure (a) shows the fitness optimization results of the second genetic algorithm, including the vertical axis representing the fitness value, and the horizontal axis representing the number of iterations, the best fitness, and the average fitness. Figure 3 (b) Similarly, Figure 5 Figure (b) shows the convergence distance results of the second genetic algorithm parameter optimization, including the average distance on the vertical axis, the number of iterations on the horizontal axis, and the average distance accuracy between parameters after optimization; convergence of all data indicates a good result.
[0261] The code result is as follows:
[0262] Exit flag: 1 (1 = convergence, 0 = hyperalgebra).
[0263] Optimal Q values: [0.050040, 0.150000, 0.126613, 0.050355].
[0264] Minimum ITAE value: 2.374137.
[0265] Function evaluation count: 5960.
[0266] Total number of iterations: 65.
[0267] Improved fitness: ITAE value improved by approximately 60% compared to the initial value.
[0268] Population diversity: The adaptive search range effectively maintains population diversity.
[0269] The robustness of the method was verified by testing different reference Q values: the change in the optimization result was less than 10% when the reference Q changed by ±50%, indicating that the method has good stability.
[0270] Compared to traditional methods, it offers significant advantages: Performance improvement: ITAE metric improved by 35%, and tuning time reduced by 40%. Adaptability: Adaptive search range is more efficient than fixed range. Practicality: The comprehensive penalty term avoids the limitations of a single metric.
[0271] The second GA achieved the following main results:
[0272] Methodological innovation: It realizes absolute numerical optimization based on ITAE and combines it with an adaptive search strategy.
[0273] Performance improvement: The dynamic performance of the controller is significantly improved, and the ITAE index is optimized by more than 60%.
[0274] Practical application in engineering: A complete optimization process and code architecture have been established.
[0275] Robustness verification: The effectiveness of the method was verified in multiple scenarios.
[0276] The two-step GA method has the following innovations: Systematic scaling optimization: explicitly defining the scaling relationship as an independent optimization stage. Fixed R-value strategy: simplifying the optimization problem and improving convergence efficiency.
[0277] Technical contributions: A hierarchical optimization strategy was proposed, employing a proportional-to-numerical optimization paradigm. A comprehensive ITAE fitness function was developed to balance multiple performance metrics. Adaptive search range generation was implemented, improving optimization efficiency.
[0278] Performance comparison: After optimization, the robot's pitch angle stabilizes to within 0.1 rad within 2 seconds, while the traditional LQR takes 5 seconds. The parameter tuning time is reduced by 60% compared to the traditional method. Moreover, the Q and R parameters are tuned by the genetic algorithm throughout the process without the need for manual parameter intervention. This not only improves the optimization time efficiency but also greatly enhances the applicability of the method in practical applications.
[0279] Example 3:
[0280] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a lightweight edge-end vehicle undercarriage hazard identification method as described in any of Embodiment 1.
[0281] Example 4:
[0282] A computer device, comprising:
[0283] Memory is used to store instructions.
[0284] A processor is configured to execute the instructions, causing the computer device to perform operations of a lightweight edge-end vehicle undercarriage hazard identification method as described in any of Embodiment 1.
[0285] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for optimizing LQR parameters based on a proportional two-stage genetic algorithm, characterized in that, include: S1: Establish a dynamic model of the controlled object based on the Lagrange equations and derive the state-space equations; S2: Construct the LQR control algorithm model based on the state-space equation, and obtain the cost function J of the feedback gain matrix K and the feedback gain weight K; S3: Solve the cost function J of the feedback gain weight K using a proportional two-stage genetic algorithm model to obtain the optimized baseline values of the Q and R parameters; S4: Substitute the optimized Q and R parameters into the LQR control algorithm model to calculate the optimized feedback gain matrix K; then substitute the optimized Q and R parameters into the cost function J, and evaluate the optimization result of the optimized feedback gain matrix K through the cost function J. If the evaluation result of the cost function J exceeds the threshold, then substitute the optimized feedback gain matrix K into the LQR control algorithm model to achieve system balance or trajectory tracking of the controlled object. If the optimization result does not exceed the threshold, return to step S3 to continue optimizing the Q and R parameters.
2. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 1, characterized in that: The dynamic model is as follows: ; in, To unify and simplify variables, Let m be the pitch acceleration of the controlled object, g be the mass of the control object's pendulum, h be the gravitational force, and h be the length of the control object's pendulum. Let M be the initial pitch angle of the control object's lever, and M be the weight of the control object's wheel. Let r be the wheel torque of the controlled object, and r be the wheel radius of the controlled object.
3. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 1, characterized in that: The state-space equation expression of the controlled object is as follows: ; in, The initial pitch angle, Angular velocity, x is the pitch acceleration; x is the distance the pendulum moves. The rotor speed is This refers to the angular acceleration of the pendulum. For the control input; Let A be the spatial state matrix, and a and c be the influence parameters of the spatial state system matrix A. Let B be the spatial state matrix, and b and d be the influence parameters of the spatial state system matrix B.
4. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 3, characterized in that: The expressions for the influencing parameters a, b, c, and d are as follows: ; ; ; ; ; ; Where m is the mass of the pendulum of the controlled object, M is the weight of the wheel of the controlled object, h is the length of the pendulum of the controlled object, r is the radius of the wheel of the controlled object, g is the gravity parameter, and I is the moment of inertia of the pendulum of the controlled object. To unify and simplify variables.
5. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 1, characterized in that: The cost function J of the feedback gain weight K is solved by a proportional two-stage genetic algorithm model, and the optimized baseline values of the Q and R parameters are obtained as follows: The Q-parameters and R-parameters to be optimized are obtained based on the cost function J; a baseline value for the R-parameters is established based on the R-parameters. The proportional two-stage genetic algorithm model includes a first-stage genetic algorithm and a second-stage genetic algorithm. The first-stage genetic algorithm minimizes the fitness function to find the optimal ratio between the Q-parameters initialized after encoding and the baseline values of the R-parameters initialized after encoding; the second-stage initialization population of the Q-parameters in the second-stage genetic algorithm is then optimized based on the optimal ratio. The second-stage genetic algorithm minimizes the fitness function and solves for the optimized Q-parameters and R-parameters based on the second-stage initialized population of the encoded Q-parameters and the baseline value of the encoded initialized R-parameters.
6. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 5, characterized in that: During the encoding process, the Q parameter and the R parameter adopt the same encoding dimension based on the dimensions of the spatial state system matrix A and the spatial state system matrix B of the state space equation.
7. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 5, characterized in that: The fitness function of the proportional two-stage genetic algorithm model is: ; in, Let J be the fitness function, ITAE be the ITAE index function, and J be the cost function. The penalty term coefficient of the ITAE index function.
8. The LQR parameter optimization method based on a proportional two-stage genetic algorithm according to claim 5, characterized in that: Both the first-stage genetic algorithm and the second-stage genetic algorithm perform selection, crossover, and mutation on the Q parameters: The selections made by the first-stage genetic algorithm and the second-stage genetic algorithm are elite selections; The crossover in the first stage genetic algorithm is a binary crossover that introduces adaptive crossover, and the mutation in the first stage genetic algorithm is a basic bit mutation that introduces adaptive mutation; The crossover in the second-stage genetic algorithm is a fully disturbed crossover with adaptive crossover; the mutation in the second-stage genetic algorithm is a quantum gate rotation mutation with adaptive mutation. The mutation parameters of the adaptive mutation include and , It is 0.
1. The value is 0.01; the cross parameters of the adaptive cross include... and , It is 0.
8. It is 0.
5.
9. A computer-readable storage medium, characterized in that: It stores a computer program that, when executed by a processor, implements an LQR parameter optimization method based on a proportional two-stage genetic algorithm as described in any one of claims 1-8.
10. A computer device, characterized in that: include: Memory, used to store instructions; A processor for executing the instructions, causing the computer device to perform an LQR parameter optimization method based on a proportional two-stage genetic algorithm as described in any one of claims 1-8.