Runtime Generated Functions

Blockquote nlsys_func = generate_function(ns, [x,y,z], [a,b,c], expression=Val{false})[2]

Generates :
(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##MTIIPVar#873"), Symbol("##MTKArg#870"), Symbol("##MTKArg#871")),ModelingToolkit.var"#_RGF_ModTag",(0xe85d4d5a, 0xc9aaedcf, 0x24c24ac9, 0xb7dd2fb4, 0xc6ba2717)}) (generic function with 1 method)

Can someone please guide how to overcome this issue

Thaks in advance

What’s the issue?

1 Like

(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##MTIIPVar#873"), Symbol("##MTKArg#870"), Symbol("##MTKArg#871")),ModelingToolkit.var"#_RGF_ModTag",(0xe85d4d5a, 0xc9aaedcf, 0x24c24ac9, 0xb7dd2fb4, 0xc6ba2717)}) (generic function with 1 method)

Unable to understand this generated output

That’s just the name of the function. It could print something else, but in general functions don’t print something too interesting to most people.

1 Like

So is there any other way to generate Runtime Generated Functions?

Following is my code sample which I followed from Tutorial

using ModelingToolkit, GeneralizedGenerated

@variables x y z
@parameters a b c

##Define a nonlinear system
eqs = [0 ~ - y - (z+20),
0 ~ x + a * y,
0 ~ b + (z+20) * (x - c)]
ns = NonlinearSystem(eqs, [x,y,z], [a,b,c])
nlsys_func = generate_function(ns)[2] # second is the inplace version

rossler = ModelingToolkit.eval(nlsys_func)
du = zeros(3); u = ones(3)
params = (0.2,0.2,5.7)

j_func2 = generate_jacobian(ns)[2] # second is in-place
j2! = ModelingToolkit.eval(j_func2)

using NLsolve
nlsolve((out, x) -> rossler(out, x, params), (out, x) -> j2!(out, x, params), ones(3))

nlsys_func = generate_function(ns, [x,y,z], [a,b,c], expression=Val{false})[2] # runtime generated function

You can directly use GitHub - SciML/RuntimeGeneratedFunctions.jl: Functions generated at runtime without world-age issues or overhead

Even using RuntimeGeneratedFunctions.jl the output remains the same but I would really like to know if its just a function name which is generated as output then, whats the use of line:

nlsys_func = generate_function(ns, [x,y,z], [a,b,c], expression=Val{false})[2] # runtime generated function

What can be concluded with the output of this line of code generated?

It’s just the hash of the function body.

So is Runtime generated functions is made to generate hash value of the function body? Can i conclude the use of RuntimeGeneratedFunctions.jl like that?

It’s just a function.

Okay, thank you