Efficient solving algorithm of linear MPC for MBD process

By combining the ADMM algorithm and a compiled language, the problem of real-time solution and embedded deployment of linear MPC in the MBD process is solved, realizing a complete closed loop from simulation to hardware deployment of efficient linear MPC control algorithm, thus improving computational efficiency and real-time performance.

CN122331901APending Publication Date: 2026-07-03TONGJI UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TONGJI UNIV
Filing Date
2026-03-24
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

When developing based on the Model Design Flow (MBD) process, the real-time solution and embedded deployment of Linear Model Predictive Control (MPC) face problems of insufficient computational efficiency and complexity of embedded deployment, making it difficult to meet the real-time requirements of high-frequency control cycles and the migration obstacles of hardware deployment.

Method used

The Alternating Direction Multiplier Method (ADMM) is used to iteratively solve the quadratic programming problem. The algorithm logic and numerical calculations are deployed through a compiled language. By combining an embedded script module and an external code calling module, the MBD tool and the compiled language are efficiently integrated to generate an executable file.

Benefits of technology

It improves the computational efficiency and real-time performance of the linear MPC control algorithm, realizes the complete development process from desktop simulation to actual controller, and enhances the portability and scalability of the algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122331901A_ABST
    Figure CN122331901A_ABST
Patent Text Reader

Abstract

This invention proposes an efficient linear MPC solution algorithm for the MBD process, comprising: Step 1, using ADMM to efficiently solve the quadratic programming (QP) problem and deploying the logic through compiled programming language code; Step 2, uniformly encoding various matrix and vector parameters required for the QP optimization problem into a standard row vector input structure; Step 3, using the external code calling module of the MBD tool and designing interface functions, realizing bidirectional data interaction between the graphical programming module of the MBD tool and the compiled language code of the ADMM algorithm through a pointer passing mechanism; Step 4, compiling the ADMM algorithm code to generate a library file, adding information to the simulation target configuration parameters of the MBD tool, and jointly compiling it with other graphical programming modules of MBD to generate a binary executable file. This invention achieves standardized integration and rapid deployment of linear MPC in the MBD development process, and has the advantages of high computational efficiency, good real-time performance, high portability and scalability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of control engineering and software engineering, and in particular to an efficient solution algorithm for linear model predictive control based on model design flow. Background Technology

[0002] Model-Based Design (MBD) has become an important paradigm for the development of complex control systems, widely used in fields with high requirements for real-time performance and safety, such as automotive electronics, UAV electronics, aerospace, and robotic motion control. This method relies on a graphical modeling environment and toolchain, replacing the traditional pure code development mode with executable visual modules, achieving a closed-loop lifecycle from requirements analysis, algorithm modeling, simulation verification to automatic code generation and final hardware deployment. MBD improves algorithm development efficiency, reduces the error risks introduced by manual programming, and supports engineering processes from rapid prototyping to mass production.

[0003] Linear model predictive control (LMDC), as an optimal control strategy for multi-input multi-output (MIMO) systems, relies on online rolling solutions to constrained quadratic programming problems to compute the optimal control sequence within each control cycle. This method can explicitly handle physical constraints such as actuator saturation and system state safety boundaries, effectively overcoming the limitations of traditional control methods in handling strongly coupled multivariable systems. With its excellent look-ahead predictive capability and closed-loop robustness, LDC has been widely applied in fields such as unmanned aerial vehicles (UAVs) and autonomous vehicles, industrial process control, and energy management systems.

[0004] However, when developing MBD processes using graphical modeling environments, the real-time solution and embedded deployment of linear MPC problems formalized into QP structures face the following challenges: First, the general-purpose optimization solvers built into graphical modeling environments (such as QP solvers based on interpreted languages) typically focus on algorithm functionality verification rather than execution efficiency. In industrial deployment environments with high-frequency control cycles, their computational overhead is significant, and as the prediction time domain increases, the computation time may exceed the real-time requirements of embedded systems.

[0005] Second, the embedded deployment path of existing QP general-purpose solvers is quite complex. Since general-purpose solver computations often rely on specific compiled language runtime environments, converting them into embedded code using automatic code generation tools often faces problems such as lack of support for specific instruction sets, missing dependency libraries, or low code efficiency, making the migration from desktop simulation models to embedded controller binary code difficult.

[0006] In existing technologies, for example, patent CN109139282A discloses a model predictive control system and method for improving computational efficiency. This method uses a quadratic programming solver for online solving. When the solver cannot obtain the optimal solution within a predetermined time, it degenerates into an unconstrained linear quadratic regulator. Although this scheme ensures the time determinism of the control loop through the degradation mechanism, it sacrifices the optimality of control and the strict satisfaction of constraints, failing to solve the problem of solution efficiency from the algorithm itself. Another example is patent CN108334086B, which discloses a path tracking control method based on soft-constraint quadratic programming, improving the solvability of the QP problem by introducing a relaxation factor. However, this method is based on a general optimization solver, mainly focusing on the feasibility of the algorithm, with limited real-time performance, and does not provide a standardized embedded deployment scheme for deep integration with the MBD process.

[0007] In summary, under the current MBD development model, the engineering application of linear MPC faces two main technical bottlenecks: first, the computational efficiency of the general-purpose QP solver is insufficient, making it difficult to meet the high real-time computational requirements of embedded controllers; second, the general-purpose QP solver is heavily dependent on specific operating environments, making it difficult to convert it into efficient, independently executable embedded code through automatic code generation tools, thus hindering the migration of linear MPC algorithms from desktop simulation to hardware deployment. Summary of the Invention

[0008] The purpose of this invention is to overcome the above-mentioned shortcomings and propose an efficient solution algorithm for linear model predictive control (MBC) based on model design flow. This algorithm enables efficient real-time solution and embedded deployment of quadratic programming problems within a linear MPC control framework, thereby improving the engineering performance of MBD-based linear MPC control algorithms from desktop simulation to actual controller deployment.

[0009] Definitions: MBD: Model-Based Design; MPC: Model Predictive Control; ADMM: Alternating Direction Method of Multipliers; QP: Quadratic Programming.

[0010] The technical solution of the present invention is as follows: An efficient linear MPC solution algorithm for MBD processes includes the following steps: Step 1: An efficient solution method for QP problems based on ADMM and its deployment in a compiled language.

[0011] The ADMM algorithm is used to iteratively solve the QP problem, and the algorithm logic and numerical calculations are implemented through compiled programming language code.

[0012] Step 2: Obtain QP optimization problem parameters and deploy embedded script modules.

[0013] The embedded script module in the MBD tool summarizes and concatenates the system matrix, control matrix, weight matrix and constraint vectors required for the QP problem, and encodes them into a unified row vector input structure.

[0014] Step 3: Design and configuration of external code calling module interface functions.

[0015] Design the interface functions required by the external code calling module of the MBD tool, including parameter passing mechanism, data parsing logic and packaging logic, to complete the bidirectional data transfer between the row vector input data described in step 2 and the ADMM algorithm described in step 1, and configure the attributes of the external code calling module to realize the closed-loop interaction between the graphical programming module of the MBD tool and the compiled language code.

[0016] Step 4: Joint compilation and binary file generation.

[0017] The ADMM algorithm is compiled to generate a static library file. The corresponding library information and file information of the interface functions are added to the simulation target configuration parameters of the MBD tool. The external code calling module and other graphical programming modules in the MBD model are jointly compiled to generate a binary executable file.

[0018] Preferably, for a problem formally represented as a constrained optimization problem:

[0019] in It is the objective function of the optimization problem. These are constraints on the optimization problem. These are optimization variables.

[0020] The ADMM algorithm described in step 1 includes: First, the ADMM algorithm introduces an indicator function. :

[0021] Then, constraints will be imposed. By incorporating a "penalty term" into the objective function, the objective function becomes: .

[0022] To separate the objective function into two parts, slack variables are introduced. Construct a new optimization problem: .

[0023] Then, the Lagrange multipliers are introduced. and penalty parameters Construct the augmented Lagrange function: .

[0024] Finally, by iteratively updating the original variable, the relaxed variable, and the dual variable alternately, the... and Optimize to minimize , thus calculating The optimal solution.

[0025] The specific steps for each iteration are as follows: 1) Update the original variables.

[0026] fixed and ,optimization The updated The mathematical form is:

[0027] 2) Slack variable update.

[0028] fixed and ,optimization The updated The mathematical form is:

[0029] In the formula, This indicates a projection operation.

[0030] 3) Dual variable update.

[0031] For Lagrange multipliers Perform gradient ascent, and update The mathematical form is:

[0032] As the iteration progresses, each iteration updates the... , , For the next update , , Ultimately, the ADMM algorithm makes and Gradually converge to equality, and when the tolerance condition is satisfied, obtain... The optimal solution.

[0033] Preferably, the QP problem in step 1 is:

[0034] in, and To optimize variables, To predict the time domain, express index, express index, To predict the time-domain step index, and For single-step optimization variables, for The reference trajectory, also known as the "reference trajectory vector". For the tracking error weight matrix, To control the input weight matrix, For the system matrix, For the control matrix, This is the upper bound for the values ​​of the state variables. This is the lower bound for the values ​​of the state variables. To control the upper limit of the value, To control the lower bound of the value, These are the initial conditions.

[0035] Preferably, when using the ADMM algorithm to iteratively solve the QP problem, the specific steps include: Step 1-1: Introduce indicator functions and and slack variables and The QP problem is transformed into an augmented Lagrangian function form that is easier to solve using the ADMM algorithm:

[0036] Step 1-2: Use the ADMM algorithm to solve the augmented Lagrangian function optimization problem.

[0037] First, the optimized variables are updated using the ADMM original variable update algorithm. and : Optimize variables for the QP problem and The update is formulated as an equality-constrained quadratic programming problem with an LQR structure, which can be solved efficiently by Riccati recursion. The LQR gain matrix involved in this recursion process can be pre-calculated offline. Then, the ADMM slack variable update algorithm is used to update the slack variables corresponding to the optimization variables. and ; Finally, the ADMM dual variable update algorithm is used to update the Lagrange multipliers corresponding to the optimization variables. and .

[0038] Steps 1-3: Repeat steps 1-2 until the tolerance limit is met, then update to this step. and This is the optimal solution to the QP problem.

[0039] The optimal solution is the result of the compiled code calculation. It is called through the interface function of the external code calling module in step 3. At the same time, the ADMM algorithm is implemented in a compiled language and a static link library is generated.

[0040] Preferably, step 2 includes the following steps: Step 2-1: Process the signals calculated or transmitted by other graphical programming modules in the MBD tool to obtain the system state feedback vector for each simulation step; Step 2-2: Perform row vector encoding.

[0041] The system state feedback vector output in step 2-1 As input to the embedded script module, the script code set by the MBD tool is used for programming and concatenated with the matrices and vectors required for the QP problem; The matrices required for the QP problem include: the system matrix. Control matrix Tracking error weight matrix , control input weight matrix ; The vectors required for the QP problem include: the reference trajectory vector. Upper and lower bound constraint vectors of state variables and Upper and lower bound constraint vectors of control input and ; The concatenation is performed in a predetermined order (such as row priority) to obtain a standard row vector containing all parameters of the QP optimization problem.

[0042] The different fields of the standard row vector correspond to specific QP problem parameter types within a predefined index range. This encoding method achieves a unified expression of QP problem parameters within the graphical programming module of the MBD tool and within the compiled language code. This unified expression is... Figure 1 "Row vector encoding" in the context of this.

[0043] Preferably, the interface function called by the external code calling module in step 3 can bridge the MBD graphical modeling environment and the compiled code environment.

[0044] The interface function uses a pointer passing mechanism for input and output. The input parameter is defined as a read-only constant pointer type, which is used to receive the standard row vector (row vector encoding) of the QP problem obtained by concatenation in the MBD model. The output parameter is defined as a writable pointer type, which is used to return the optimal control vector calculated by the ADMM algorithm in contiguous memory.

[0045] The parsing logic of the interface function is as follows: the standard row vector (row vector encoding) from the MBD model pointed to by the input pointer is parsed and decomposed, the parameter matrix and vector information corresponding to each field are extracted, and the extracted data is passed to the ADMM algorithm module in the form of global variables.

[0046] The data packaging logic of the interface function is as follows: receive the optimal control vector obtained by the ADMM algorithm, pass the optimal control vector of the interface function in the form of a global variable, write each element in the vector into the memory space pointed to by the output pointer in sequence, and return the data to other graphical programming modules of MBD.

[0047] Preferably, step 3 specifically includes: Step 3-1: Design and implement the interface function, which uses a data interaction mechanism that combines pointer passing and global variables.

[0048] Inside the function, the pointers to the standard row vectors are first parsed and their fields are decomposed to extract parameter information such as the system matrix, control matrix, weight matrix, constraint vector, and reference trajectory vector, which are then passed to the ADMM algorithm module. Subsequently, the optimal control vector calculated by the ADMM algorithm is packaged into data and returned via an output pointer.

[0049] Step 3-2: Modularly configure the external code calling module, including binding the interface function calls, configuring the input port dimension and the output port dimension.

[0050] Preferably, step 4 specifically includes: Step 4-1: Use a compiler to compile the ADMM algorithm from Step 1 into a static library file.

[0051] Step 4-2: Configure the paths to the static library files and interface function files in the simulation target configuration parameters of the MBD tool.

[0052] Step 4-3: For the entire MBD model, including the external code calling module and other graphical programming modules, use the compilation or code generation commands provided by the MBD environment to compile and finally generate the executable file to be written to the controller.

[0053] Other graphical programming modules and external code calling modules in MBD are all part of the entire MBD algorithm model. Software development based on the MBD model is the MBD (Model-Based Design) process.

[0054] Through the above deployment process, the ADMM algorithm based on a compiled language and the MBD graphical programming environment are efficiently integrated, realizing the complete closed loop of linear MPC control under the MBD process and the efficient deployment and real-time execution of the linear MPC solution process in the embedded controller environment.

[0055] Compared with the prior art, the present invention has the following advantages: I. High computational efficiency and good real-time performance. This invention uses the alternating direction multiplier method to structurally decompose the quadratic programming problem of linear MPC and solves it iteratively. This method effectively reduces the computational complexity of the algorithm while maintaining the required solution accuracy, making it adaptable to the computational resource limitations of embedded controllers and meeting the needs of real-time control.

[0056] Second, the algorithm exhibits excellent portability. This invention constructs a standardized parameter input interface through an embedded script module, bridges the ADMM solution algorithm written in a compiled language using external code calling modules, and supports joint compilation with the MBD tool's graphical modeling environment to generate executable files. This method realizes a complete development process from model simulation to embedded deployment, while eliminating the dependence of general-purpose optimization solvers on the runtime environment, thus improving the algorithm's portability and scalability in engineering applications. Attached Figure Description

[0057] Figure 1 A flowchart illustrating an efficient linear MPC solution algorithm for MBD processes; Figure 2 A flowchart illustrating an implementation example of an efficient linear MPC solution algorithm for MBD processes; Figure 3 This is a schematic diagram of the Simulink model used in an embodiment of the present invention. Figure 4 A comparison chart of the control variables of this method and quadprog in an implementation example of a drone hovering control system; Figure 5 A comparison chart of control errors between this method and quadprog in an implementation example of a drone hovering control system; Figure 6 This is a comparison of the solution time of this method and quadprog in an implementation example of an unmanned aerial vehicle hovering control system. Detailed Implementation

[0058] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. The flowchart of the present invention is shown below. Figure 1 As shown. Clearly, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Other embodiments obtained by those skilled in the art based on the implementation examples of the present invention without creative effort should all fall within the protection scope of the present invention.

[0059] The following is a specific implementation example: In this implementation example, the MBD tool is MATLAB / Simulink, the compiled programming language is C++, the interface function is void my_mpc_step(const double* input_vector_in, double* output), and the compiler used is g++. The embedded scripting module in the MBD tool is MATLAB Function. The external code calling module in the MBD tool is C Caller. The graphical programming modules for the MBD tool are various graphical modules provided by the Simulink library browser.

[0060] In addition, the files containing the interface functions adopt a standardized naming convention, with the corresponding header file being my_mpc_api.cpp, the source file being my_mpc_api.h, and the library file generated by compiling the ADMM algorithm using g++ being QP_ADMM.lib.

[0061] In this implementation example, an efficient linear MPC solution algorithm for MBD processes includes the following steps, such as: Figure 2 As shown: Step 1: An efficient solution method for QP problems based on ADMM and its C++ deployment.

[0062] The ADMM algorithm is used to solve the QP problem iteratively, and the algorithm logic and numerical calculation are implemented in C++ code.

[0063] Step 2: Obtaining QP optimization problem parameters and deploying MATLAB Functions.

[0064] Using MATLAB Functions in Simulink, the system matrix, control matrix, weight matrix, and constraint vectors required for QP problems are summarized and concatenated, and encoded into a unified standard row vector input structure.

[0065] Step 3: Design and configuration of the interface functions of the Simulink C Caller module.

[0066] Design the interface functions to be called by the Simulink C Caller module, including parameter passing mechanism, data parsing logic and packaging logic, to complete the bidirectional data transfer between the row vector input data described in step 2 and the ADMM algorithm described in step 1, and configure the properties of the C Caller module to realize closed-loop interaction from Simulink to C++.

[0067] Step 4: Joint compilation and binary file generation.

[0068] The ADMM algorithm is compiled using g++ to generate a static library file. The corresponding library information and source file and header file information of the interface function in step 3 are added to the Simulink simulation target configuration parameters. The C Caller module and other Simulink modules are jointly compiled to generate a binary executable file.

[0069] In step 1, the ADMM algorithm is specifically as follows: First, the ADMM algorithm introduces an indicator function. :

[0070] Then, constraints will be imposed. By incorporating a "penalty" into the objective function, the objective function becomes... .

[0071] To separate the objective function into two parts, slack variables are introduced. Construct a new optimization problem: .

[0072] Then, the Lagrange multipliers are introduced. and penalty parameters Construct the augmented Lagrange function: .

[0073] Finally, by iteratively updating the original variable, the relaxed variable, and the dual variable alternately, the... and Optimize to minimize , thus calculating The optimal solution.

[0074] The specific steps for each iteration are as follows: 1) Update the original variables.

[0075] fixed and ,optimization The updated The mathematical form is:

[0076] 2) Slack variable update.

[0077] fixed and ,optimization The updated The mathematical form is:

[0078] In the formula, Represents projection operation 3) Dual variable update.

[0079] For Lagrange multipliers Perform gradient ascent, and update The mathematical form is:

[0080] As the iteration progresses, each iteration updates the... , , For the next update , , Ultimately, the ADMM algorithm makes and Gradually converge to equality, and when the tolerance condition is satisfied, obtain... The optimal solution.

[0081] In step 1, the QP problem is specifically as follows:

[0082] in, and To optimize variables, To predict the time domain, express index, express index, To predict the time-domain step index, and For single-step optimization variables, for The reference trajectory, also known as the "reference trajectory vector". For the tracking error weight matrix, To control the input weight matrix, For the system matrix, For the control matrix, This is the upper bound for the values ​​of the state variables. This is the lower bound for the values ​​of the state variables. To control the upper limit of the value, To control the lower bound of the value, These are the initial conditions.

[0083] Step 1 includes the following specific steps: Step 1-1: Introduce indicator functions and and slack variables and The QP problem is transformed into an augmented Lagrangian function form that is easier to solve using the ADMM algorithm:

[0084] Step 1-2: Use the ADMM algorithm to solve the augmented Lagrangian function optimization problem.

[0085] First, the optimized variables are updated using the ADMM original variable update algorithm. and To address the QP problem, optimize the variables. and The update is formulated as an equality-constrained quadratic programming problem with an LQR structure, which can be efficiently solved using Riccati recursion. The LQR gain matrix involved in this recursion process can be pre-calculated offline. Then, the ADMM slack variable update algorithm is used to update the slack variables corresponding to the optimization variables. and Finally, the Lagrange multipliers corresponding to the optimization variables are updated using the ADMM dual variable update algorithm. and .

[0086] Step 1-3: Repeat steps 1-1 and 1-2 until the tolerance limit is met, then update to this step. and This is the optimal solution to the QP problem.

[0087] In step 1, when using the ADMM algorithm to solve the QP problem, in order to improve the real-time solution efficiency and algorithm inference speed of the embedded end, the ADMM solution process is deployed in a structured manner in C++, and the original variable update, relaxation variable update and Lagrange multiplier update operations are executed sequentially in each iteration in the form of a loop structure, and the iteration is repeated until the exit condition is met.

[0088] In step 2, the matrices and vectors required for the QP problem include: System Matrix Control matrix Tracking error weight matrix , control input weight matrix Reference trajectory vector Upper and lower bound constraint vectors of state variables and Upper and lower bound constraint vectors of control input and .

[0089] Step 2 is as follows: Step 2-1: Process the signals calculated or transmitted by other Simulink modules to obtain the system state feedback vector for each simulation step.

[0090] Step 2-2: Perform row vector encoding.

[0091] The system state feedback vector described in step 2-1 is used as input to the MATLAB Function module. In this module, the m-language code set by Simulink is used for programming, and the vectors and matrices required for the QP problem are concatenated. The concatenation is performed in a predetermined order (such as row priority) to finally obtain a standard row vector containing all the parameters of the QP optimization problem.

[0092] Different fields of the standard row vector correspond to specific QP problem parameter types within a predefined index range. This encoding method enables a unified expression of QP problem parameters in both the Simulink and C++ environments.

[0093] In step 3, the C Caller's interface functions enable bridging between the Simulink and C++ environments.

[0094] The function signature of the interface function is: void my_mpc_step(const double* input_vector_in,double* output), A two-pointer passing mechanism is adopted, where the input parameter input_vector_in is a constant pointer type constdouble*, which is used to pass the standard row vector obtained by concatenation in the Simulink model in read-only mode. The output parameter `output` is a writable pointer of type `double*`, used to return the optimal control vector calculated by the ADMM algorithm in contiguous memory. This function achieves data interaction between Simulink and C++ code by directly passing memory addresses, avoiding intermediate data copying and type conversion operations, thereby improving the system's execution efficiency and real-time performance.

[0095] The data parsing logic of the my_mpc_step function is as follows: The input row vector encoded data from Simulink, pointed to by the input_vector_in pointer, is parsed and decomposed to extract the parameter matrices and vector information corresponding to each field, including the system matrix, control matrix, weight matrix, constraint vector, and reference trajectory information. After parsing, the extracted data of each field is passed to the ADMM algorithm as global variables.

[0096] The data packing logic of the my_mpc_step function is as follows: The optimal control vector obtained by solving the QP problem using the ADMM algorithm is returned to the interface function my_mpc_step as a global variable. The interface function uses a for loop to write each element of the optimal control vector into the memory space pointed to by the output pointer output, and then returns output to the Simulink model.

[0097] Step 3 specifically involves: Step 3-1: Design and implement the interface function my_mpc_step for the C Caller module. This function uses a data interaction mechanism that combines pointer passing and global variables.

[0098] Inside the function, the pointers to the standard row vectors are first parsed and their fields are decomposed to extract parameter information such as the system matrix, control matrix, weight matrix, constraint vector, and reference trajectory, which are then passed to the ADMM algorithm solution module. Subsequently, the optimal control vector calculated by the ADMM algorithm is packaged into data and returned via an output pointer.

[0099] Step 3-2: Configure the C Caller module, including binding the interface function my_mpc_step, configuring the input port input_vector_in dimension and the output port output dimension.

[0100] In step 4: First, the static library file generated by compiling the C++ implementation of the ADMM algorithm using g++ is named QP_ADMM.lib and is used to encapsulate the core solution logic of the ADMM algorithm.

[0101] Then configure the Simulink simulation target configuration parameters, including the static library file QP_ADMM.lib, which is used to link the algorithm library during the target code generation process; The header file my_mpc_api.h and the source file my_mpc_api.cpp, which are related to the interface function my_mpc_step, are used to identify the definition and implementation of the interface function called by the C Caller module during the Simulink model compilation process.

[0102] The Simulink model structure described in step 4 is as follows: Figure 3 As shown.

[0103] Step 4 specifically includes: Step 4-1: Use g++ to compile the source code of the ADMM algorithm to generate the static library file QP_ADMM.lib.

[0104] Step 4-2: Configure the library file, header file, and source file in the Simulink simulation target configuration parameters configuration file.

[0105] Step 4-3: For the entire Simulink model, including the CCaller module for solving linear MPC problems based on QP and other Simulink modules, compile it using the MATLAB command rtwbuild to finally generate the executable file.

[0106] In a specific implementation example, a simulation experiment was conducted using UAV hovering control as an example to verify the performance of this method.

[0107] The controller design parameters for the implementation example are as follows: System Matrix : A=[1.0000000,0.0000000,0.0000000,0.0000000,0.0245250,0.0000000,0.0500000,0.0000000,0.0000000,0.0000000,0.0002044,0.0000000; 0.0000000,1.0000000,0.0000000,-0.0245250,0.0000000,0.0000000,0.0000000,0.0500000,0.0000000,-0.0002044,0.0000000,0.0000000; 0.0000000,0.0000000,1.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0500000,0.0000000,0.0000000,0.0000000; 0.0000000,0.0000000,0.0000000,1.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0250000,0.0000000,0.0000000; 0.0000000,0.0000000,0.0000000,0.0000000,1.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0250000,0.0000000; 0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,1.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0250000; 0.0000000,0.0000000,0.0000000,0.0000000,0.9810000,0.0000000,1.0000000,0.0000000,0.0000000,0.0000000,0.0122625,0.0000000; 0.0000000,0.0000000,0.0000000,-0.9810000,0.0000000,0.0000000,0.0000000,1.0000000,0.0000000,-0.0122625,0.0000000,0.0000000; 0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,1.0000000,0.0000000,0.0000000,0.0000000,0.0000000; 0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,1.0000000,0.0000000,0.0000000; 0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,1.0000000,0.0000000; 0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,0.0000000,1.0000000] Control Matrix : B=[-0.0007069,0.0007773,0.0007091,-0.0007795; 0.0007034, 0.0007747, -0.0007042, -0.0007739; 0.0052554, 0.0052554, 0.0052554, 0.0052554; -0.1720966, -0.1895213, 0.1722891, 0.1893288; -0.1729419, 0.1901740, 0.1734809, -0.1907131; 0.0123423, -0.0045148, -0.0174024, 0.0095748; -0.0565520, 0.0621869, 0.0567283, -0.0623632; 0.0562756, 0.0619735, -0.0563386, -0.0619105; 0.2102143,0.2102143,0.2102143,0.2102143; -13.7677303, -15.1617018, 13.7831318, 15.1463003; -13.8353509, 15.2139209, 13.8784751, -15.2570451; [0.9873856, -0.3611820, -1.3921880, 0.7659845] Tracking error weight matrix : Q=diag([100,100,100,4,4,400,4,4,4,2.0408163,2.0408163,4]) Control input weight matrix : R=diag([4,4,4,4]) Reference trajectory vector : y=[0;0;2;0;0;0;0;0;0;0;0;0] Upper and lower bound constraint vectors of state variables and : x max =[5;5;5;5;5;5;5;5;5;5;5;5] x min =[-5;-5;-5;-5;-5;-5;-5;-5;-5;-5;-5;-5] Upper and lower bound constraint vectors of control input and : u max =[0.5;0.5;0.5;0.5] u min =[-0.5;-0.5;-0.5;-0.5] A comparison of the method proposed in this patent with the quadprog method built into MATLAB in terms of control quantity calculation, control error, and solution time.

[0108] Figure 4 and Figure 5 The graphs show a comparison of the control input and control error under the two methods.

[0109] In this embodiment, the control quantity dimension is 4, therefore Figure 4 There are 4 control variables.

[0110] Figure 6 This is a comparison chart of the computation time for the two methods.

[0111] By comparison Figure 4 and Figure 5 It can be seen that the method of this patent performs comparably to quadprog in terms of solution accuracy and error control. (Comparison) Figure 6 It can be seen that the method of this patent effectively reduces the solution time.

[0112] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A linear MPC efficient solving algorithm for MBD process oriented, characterized in that, Includes the following steps: Step 1: Efficient solution method for QP problem based on ADMM and deployment in compiled language: The ADMM algorithm is used to iteratively solve the QP problem, and the algorithm logic and numerical calculation are deployed through compiled programming language code; Step 2: Obtaining QP optimization parameters and deploying embedded script modules: The embedded script module in the MBD tool summarizes and concatenates the system matrix, control matrix, weight matrix and constraint vector required for the QP problem, and encodes them into a unified row vector input structure. Step 3: Design and configuration of the interface function for external code to call the module: Design the interface functions required by the external code calling module of the MBD tool, including parameter passing mechanism, data parsing logic and packaging logic, to complete the bidirectional data transfer between the row vector input structure described in step 2 and the ADMM algorithm described in step 1, and configure the attributes of the external code calling module to realize the closed-loop interaction from other graphical programming modules of MBD to the compiled language code. Step 4, Joint compilation and binary file generation: The ADMM algorithm is compiled to generate a static library file. The corresponding library information and file information of the interface functions are added to the simulation target configuration parameters of the MBD tool. The external code calling module and other graphical programming modules in the MBD model are jointly compiled to generate a binary executable file.

2. The efficient linear MPC solution algorithm for MBD process according to claim 1, characterized in that, For formally represented optimization problems with constraints: ; in It is the objective function of the optimization problem. These are constraints on the optimization problem. These are optimization variables; The ADMM algorithm includes: First, let's introduce the indicator function. : ; Then, constraints will be imposed. By incorporating a penalty term into the objective function, the objective function becomes... ; To separate the objective function into two parts, slack variables are introduced. Construct a new optimization problem: ; Then, the Lagrange multipliers are introduced. and penalty parameters Construct the augmented Lagrange function: ; Finally, by iteratively updating the original variable, the relaxed variable, and the dual variable alternately, the... and Optimize to minimize , thus calculating The optimal solution.

3. The efficient linear MPC solution algorithm for MBD process according to claim 2, characterized in that, The mathematical form of the QP problem is: ; in, and To optimize variables, for Reference trajectory, For the system matrix, For the control matrix, For the tracking error weight matrix, To control the input weight matrix, This is the upper bound for the values ​​of the state variables. This is the lower bound for the values ​​of the state variables. To control the upper limit of the value, To control the lower bound of the value, These are the initial conditions.

4. The efficient linear MPC solution algorithm for MBD process according to claim 1, characterized in that, Step 1 uses the ADMM algorithm to iteratively solve the QP problem, specifically including the following steps: Step 1-1: Introduce indicator functions and and slack variables and The QP problem is transformed into an augmented Lagrangian function form that is easier to solve using the ADMM algorithm. Step 1-2: Solve the augmented Lagrangian function optimization problem using the ADMM algorithm: First, the optimized variables are updated using the ADMM original variable update algorithm. and To address the QP problem, optimize the variables. and The update is formulated as an equality-constrained quadratic programming problem with an LQR structure, which can be efficiently solved using Riccati recursion. The LQR gain matrix involved in this recursion process can be pre-calculated offline. Then, the ADMM slack variable update algorithm is used to update the slack variables corresponding to the optimization variables. and Finally, the ADMM dual variable update algorithm is used to update the Lagrange multipliers corresponding to the optimization variables. and ; Steps 1-3: Repeat steps 1-2 until the tolerance limit is met, then update to this step. and This is the optimal solution to the QP problem.

5. The efficient linear MPC solution algorithm for MBD process according to claim 1, characterized in that, Step 2 includes: Step 2-1: Process the signals calculated or transmitted by other graphical programming modules in the MBD tool to obtain the system state feedback vector for each simulation step; Step 2-2: Perform row vector encoding: The system state feedback vector described in step 2-1 As input to the embedded script module, the script code set by the MBD tool is used to program the code and concatenate it with the matrices and vectors required for the QP problem in a predetermined order, ultimately resulting in a standard row vector containing all the parameters of the QP optimization problem. Different fields of the standard row vector correspond to specific QP problem parameter types within a predefined index range. This encoding method enables a unified expression of QP problem parameters within the graphical programming module of the MBD tool and within the compiled language code.

6. The efficient linear MPC solution algorithm for MBD process according to claim 5, characterized in that, The interface functions called by the external code calling module can bridge the MBD graphical modeling environment and the compiled code environment. The interface function uses a pointer-passing mechanism for input and output. The input parameter is defined as a read-only constant pointer type, which is used to receive the standard row vector obtained by concatenation in the MBD model. The output parameter is defined as a writable pointer type, which is used to return the optimal control vector calculated by the ADMM algorithm in contiguous memory. The data parsing logic of the interface function is as follows: the standard row vector from the MBD model pointed to by the input pointer is parsed and decomposed, the parameter matrix and vector information corresponding to each field are extracted, and the extracted data is passed to the ADMM algorithm module in the form of global variables; The data packaging logic of the interface function is as follows: receive the optimal control vector obtained by the ADMM algorithm, pass the optimal control vector of the interface function in the form of a global variable, write each element in the vector into the memory space pointed to by the output pointer in sequence, and return the data to other graphical programming modules of MBD.

7. The efficient linear MPC solution algorithm for MBD process according to claim 1, characterized in that, Step 3 specifically includes: Step 3-1: Design and implement the interface function, which uses a data interaction mechanism that combines pointer passing and global variables; Inside the function, the pointer to the standard row vector is first parsed and its fields are decomposed to extract parameter information such as the system matrix, control matrix, weight matrix, constraint vector, and reference trajectory, which is then passed to the ADMM algorithm solution module. Subsequently, the optimal control vector calculated by the ADMM algorithm is packaged and returned through the output pointer. Step 3-2: Modularly configure the external code calling module, including binding the interface function calls, configuring the input port dimension and the output port dimension.

8. The efficient linear MPC solution algorithm for MBD process according to claim 1, characterized in that, Step 4 specifically includes: Step 4-1: Use a compiler to compile the source code of the ADMM algorithm to generate a static library file; Step 4-2: Configure the paths to the static library files and interface function files in the simulation target configuration parameters of the MBD tool; Step 4-3: For the entire MBD model, including the external code calling module and other graphical programming modules, use the compilation or code generation commands provided by the MBD environment to compile and finally generate the executable file to be written to the controller.