Last active
October 20, 2024 22:02
-
-
Save edxmorgan/196bd746a43b26249a36ee4afe9b9e3b to your computer and use it in GitHub Desktop.
linearize a nonlinear function in casadi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#method 0 | |
def linearize_new(f, x, x0): | |
x_lim = SX.sym('x_lim', x.sparsity()) | |
return substitute(f + jtimes(f, x, x_lim - x0), vertcat(x_lim, x), vertcat(x, x0)) | |
f_linear_new = Function('f_linear_new', [x, x0, u, mu, I_sym], [linearize_new(x_next, x, x0)]) | |
#method 1 | |
F_next_linear = Function('Xnext_linear', [x, x0, u, mu, I_sym], [linearize(x_next, x, x0)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment