Skip to content

Question about usage of model.generate() #4046

Answered by valentinsulzer
ottarg asked this question in Q&A
Discussion options

You must be logged in to vote

Once you have generated the code, you have to compile it yourself and then you can call functions from the generated file. See

model.generate("test.c", ["a+b"], input_parameter_order=["p", "q"])
# Compile
subprocess.run(["gcc", "-fPIC", "-shared", "-o", "test.so", "test.c"]) # nosec
# Read the generated functions
x0_fn = casadi.external("x0", "./test.so")
z0_fn = casadi.external("z0", "./test.so")
rhs_fn = casadi.external("rhs_", "./test.so")
alg_fn = casadi.external("alg_", "./test.so")
jac_rhs_fn = casadi.external("jac_rhs", "./test.so")
jac_alg_fn

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@valentinsulzer
Comment options

@ottarg
Comment options

@ottarg
Comment options

@valentinsulzer
Comment options

@ottarg
Comment options

Answer selected by ottarg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants