Skip to content

Use one function in linearization #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1-Bart-1 opened this issue May 4, 2025 · 2 comments
Closed

Use one function in linearization #199

1-Bart-1 opened this issue May 4, 2025 · 2 comments

Comments

@1-Bart-1
Copy link

1-Bart-1 commented May 4, 2025

Combining the functions f_x!, f_u! and f_d! into one function f_xud! before linearization would reduce the number of function calls needed for linearization, and thus increase performance. This would give one big jacobian, which can be split up into the A, Bu and Bd matrixes.

https://github.com/JuliaControl/ModelPredictiveControl.jl/blob/9e800029610c43f27a9ad915d3ca21797abcbadf/src/model/linearization.jl#L33C1-L35C87

@franckgaga
Copy link
Member

franckgaga commented May 5, 2025

I'm not convinced the increased code complexity and reduced clarity is worth the presumably small performance gain here. There are only two function calls to the state update function solver_f! if you don't have measured disturbances (i.e. f_x! and f_u!).

I'm not even sure that's possible, moreover. The solver_f! is differentiated with respect to a distinct variable on each jacobian! call i.e. with respect to $\mathbf{x}$ for $\mathbf{A}$, and with respect to $\mathbf{u}$ for $\mathbf{B_u}$:

Image

The code right now is consistent with the classical linearization theory: one Jacobian computed for each state-space matrix.

@1-Bart-1
Copy link
Author

1-Bart-1 commented May 5, 2025

Ok, nevermind then!

@1-Bart-1 1-Bart-1 closed this as completed May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants