Skip to content

Accept inputs represented by time-independent parameters in the initialization system - #5227

Merged
AayushSabharwal merged 1 commit into
masterfrom
mtkbase-parameter-inputs-initialization
Sep 29, 2026
Merged

AayushSabharwal merged 1 commit into
masterfrom
mtkbase-parameter-inputs-initialization

Conversation

@baggepinnen

Copy link
Copy Markdown
Contributor

Split out of #5173.

Summary

generate_initializesystem_timevarying classifies the registered inputs of a system as parameters of the initialization system. It matched Terms only, on the assumption that every input is originally a variable, so a system whose registered inputs are time-independent parameters (System(eqs, t; inputs = [p]) with @parameters p, or a compiled system in which such parameters represent inputs) threw a MatchError when its ODEProblem was constructed. Such inputs are now classified as parameters of the initialization system.

Tests

A regression test constructs ODEProblems for a system with a parameter registered as input, with and without initialization equations.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QBgBrXDidWG1G2KF64gAte

…alization system

`generate_initializesystem_timevarying` matched the registered inputs of a system as
`Term`s only, so a system whose inputs are time-independent parameters threw a
`MatchError` when its `ODEProblem` was constructed. Such inputs are now classified as
parameters of the initialization system.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QBgBrXDidWG1G2KF64gAte
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master e46d3f3... master / e46d3f3...
ODEProblem 3.76 ± 0.076 ms 3.74 ± 0.088 ms 1 ± 0.031
init 0.0497 ± 0.021 ms 0.0498 ± 0.021 ms 0.998 ± 0.59
large_parameter_init/ODEProblem 10 ± 0.68 ms 9.98 ± 0.84 ms 1 ± 0.11
large_parameter_init/init 0.0482 ± 0.0062 ms 0.0488 ± 0.0081 ms 0.988 ± 0.21
mtkcompile 6.5 ± 0.87 ms 6.42 ± 0.89 ms 1.01 ± 0.2
sparse_analytical_jacobian/ODEProblem 12.3 ± 1.5 ms 12.3 ± 1.5 ms 1 ± 0.17
sparse_analytical_jacobian/f_iip 0.05 ± 0 μs 0.05 ± 0 μs 1 ± 0
sparse_analytical_jacobian/f_oop 0.0835 ± 0.012 ms 0.0836 ± 0.013 ms 1 ± 0.21
time_to_load 4.01 ± 0.00095 s 4 ± 0.014 s 1 ± 0.0036
Memory benchmarks
master e46d3f3... master / e46d3f3...
ODEProblem 0.034 M allocs: 1.61 MB 0.034 M allocs: 1.61 MB 1
init 0.475 k allocs: 0.0602 MB 0.475 k allocs: 0.0602 MB 1
large_parameter_init/ODEProblem 0.143 M allocs: 4.79 MB 0.144 M allocs: 4.79 MB 1
large_parameter_init/init 0.757 k allocs: 0.166 MB 0.757 k allocs: 0.166 MB 1
mtkcompile 0.0558 M allocs: 2.63 MB 0.0558 M allocs: 2.64 MB 0.994
sparse_analytical_jacobian/ODEProblem 0.102 M allocs: 4.24 MB 0.102 M allocs: 4.24 MB 1
sparse_analytical_jacobian/f_iip 0 allocs: 0 B 0 allocs: 0 B
sparse_analytical_jacobian/f_oop 0.848 k allocs: 27 kB 0.848 k allocs: 27 kB 1
time_to_load 0.201 k allocs: 12.1 kB 0.201 k allocs: 12.1 kB 1

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia vlts)

Time benchmarks
master e46d3f3... master / e46d3f3...
ODEProblem 7.39 ± 0.25 ms 9.11 ± 0.64 ms 0.812 ± 0.064
init 0.141 ± 0.046 ms 0.147 ± 0.043 ms 0.961 ± 0.42
large_parameter_init/ODEProblem 24.1 ± 1.1 ms 26.2 ± 1.5 ms 0.921 ± 0.068
large_parameter_init/init 0.141 ± 0.027 ms 0.141 ± 0.023 ms 1 ± 0.25
mtkcompile 13.2 ± 0.83 ms 15.7 ± 1.8 ms 0.84 ± 0.11
sparse_analytical_jacobian/ODEProblem 26.9 ± 1 ms 30.1 ± 1.6 ms 0.893 ± 0.057
sparse_analytical_jacobian/f_iip 0.095 ± 0.01 μs 0.107 ± 0.004 μs 0.888 ± 0.099
sparse_analytical_jacobian/f_oop 0.517 ± 0.026 ms 0.53 ± 0.023 ms 0.976 ± 0.065
time_to_load 9.09 ± 0.034 s 9.21 ± 0.3 s 0.986 ± 0.033
Memory benchmarks
master e46d3f3... master / e46d3f3...
ODEProblem 0.0346 M allocs: 1.82 MB 0.0346 M allocs: 1.81 MB 1.01
init 0.508 k allocs: 0.0846 MB 0.508 k allocs: 0.0846 MB 1
large_parameter_init/ODEProblem 0.147 M allocs: 5.54 MB 0.147 M allocs: 5.54 MB 1
large_parameter_init/init 0.64 k allocs: 0.179 MB 0.64 k allocs: 0.179 MB 1
mtkcompile 0.0594 M allocs: 3.37 MB 0.0594 M allocs: 3.37 MB 1
sparse_analytical_jacobian/ODEProblem 0.106 M allocs: 5.33 MB 0.106 M allocs: 5.33 MB 1
sparse_analytical_jacobian/f_iip 0 allocs: 0 B 0 allocs: 0 B
sparse_analytical_jacobian/f_oop 0.634 k allocs: 19.6 kB 0.634 k allocs: 19.6 kB 1
time_to_load 0.153 k allocs: 14.6 kB 0.153 k allocs: 14.6 kB 1

@AayushSabharwal
AayushSabharwal merged commit c2affca into master Sep 29, 2026
101 of 111 checks passed
@AayushSabharwal
AayushSabharwal deleted the mtkbase-parameter-inputs-initialization branch September 29, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants