SciML / ModelingToolkit.jl

An acausal modeling framework for automatically parallelized scientific machine learning (SciML) in Julia. A computer algebra system for integrated symbolics for physics-informed machine learning and automated transformations of differential equations
https://mtk.sciml.ai/dev/
Other
1.38k stars 196 forks source link

Allow variable array length for parameters in `@mtkmodel` #2453

Open ven-k opened 5 months ago

ven-k commented 5 months ago

Is your feature request related to a problem? Please describe.

Parameters and variables arrays in @mtkmodel allows the length to be defined while defining the MTKModel. While doesn't allow user to specify/modify the length.

Describe the solution you’d like

@mtkmodel A begin
    @parameters begin
        a[1:N] = 10, [description = ""]
     end
end

Should add N as a kwarg.

@mtkmodel A begin
    @structural_parameters begin
        N = 5
    end
    @parameters begin
        a[1:N] = 10, [description = ""]
     end
end

Should create a of length 5, while allowing user to override with N.

Additional context

X-ref: https://discourse.julialang.org/t/modelingtoolkit-change-parameter-vector-size-based-on-structural-parameter/109914

ChrisRackauckas commented 3 weeks ago

This is simply not possible given how the graph algorithms and the codegen works. In theory JuliaSim Compiler could be able to do something though.