Skip to content

How can I write a generated function expression to file? #3910

@asinghvi17

Description

@asinghvi17

Given a System sys, you can obtain a serializable problem expression via:

import ModelingToolkit as MTK
# sys = ...
prob_expr = MTK.ODEProblem{true, MTK.SciMLBase.FullSpecialize}(sys2, [], (0.0, 3000.0); expression = Val{true})

where prob_expr isa Expr. But when I try to write this to file, it also dumps the printed representation of the system as well as some invocation of remake. How can I just get an expr that defines the runtime generated function, that I can write to file, and then load via include without manual edits?

The main reason for this is performance tuning. It is impossible to profile the mathematical operations of a problem at this point, because they don't include line number information (so the profiler refuses to show them). The simple solution is to write them to file (the longer solution involves provenance etc. which is quite tedious to actually do).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions