Skip to content

BREAKING: v10 release #3563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 235 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
235 commits
Select commit Hold shift + click to select a range
452727e
chore!: bump MAJOR version
AayushSabharwal Apr 14, 2025
08075ce
ci: run workflows on PR to v10 branch
AayushSabharwal Apr 14, 2025
970b2f3
docs: bump MTK compat
AayushSabharwal Apr 14, 2025
1b22715
TEMP COMMIT: use branch of MTKStdlib
AayushSabharwal Apr 14, 2025
3f9f5b7
feat: make `@named` always wrap arguments in `ParentScope`
AayushSabharwal Apr 3, 2025
3e66574
test: test `@named` always wrapping in `ParentScope`
AayushSabharwal Apr 14, 2025
94f1c05
refactor: remove `DelayParentScope`
AayushSabharwal Apr 14, 2025
9bf44a7
refactor: remove `time_varying_as_func`
AayushSabharwal Apr 14, 2025
6e902e0
test: update tests with removed `time_varying_as_func`
AayushSabharwal Apr 14, 2025
e050e5e
refactor: remove input_idxs output
vyudu Apr 18, 2025
8c0fa25
refactor: use new `structural_simplify` in linearization
vyudu Apr 21, 2025
082cd5d
fix: fix linearization tests
vyudu Apr 22, 2025
3d98862
test: test updates
vyudu Apr 24, 2025
c66e604
fix input output tests
vyudu Apr 24, 2025
6ca9b12
more test fixes
vyudu Apr 25, 2025
1edc7f1
fix: fix sort_eqs and check distrubances in markio
vyudu Apr 28, 2025
07b8cde
test: fix usage of old `structural_simplify` io syntax
AayushSabharwal May 7, 2025
8a7259e
fix: fix usage of `structural_simplify` with inputs
AayushSabharwal May 9, 2025
c477a33
feat: add new affect semantics, reorganize callback code
vyudu Mar 1, 2025
f504824
build: update Project.toml
vyudu Mar 17, 2025
e1f2776
refactor: reorganize `include`s, export `Pre`
vyudu Mar 3, 2025
0bc4166
docs: update NEWS.md
vyudu Apr 21, 2025
b507cfc
docs: document new `AffectSystem`/`Pre` semantics
AayushSabharwal May 9, 2025
7fc26d0
docs: update docs to account for new `Pre` semantics
vyudu Apr 1, 2025
bacfd6c
fix: fix `reinitializealg` usage in FMIExt
vyudu Mar 22, 2025
e28af63
fix: do not distribute shifts inside `Pre` and `Initial`
vyudu Mar 20, 2025
7ff1dda
test: update tests to account for new `Pre` semantics
vyudu Mar 11, 2025
1c19071
refactor: update symbolic event parsing in system constructors
vyudu Mar 5, 2025
f96227e
feat: implement `==` for `DiscreteSystem`
AayushSabharwal May 9, 2025
9de14e8
feat: implement `==` for `ImplicitDiscreteSystem`
AayushSabharwal May 9, 2025
540f3fb
feat: allow passing `cachesyms` to `ImplicitDiscreteFunction` codegen
AayushSabharwal May 9, 2025
57716f0
fix: update error checking for `ImplicitDiscreteProblem` initial cond…
AayushSabharwal May 9, 2025
104450f
feat: add `resid_prototype` for `ImplicitDiscreteFunction`
AayushSabharwal May 9, 2025
aa2b5df
fix: fix discrete variable detection in `IndexCache`
vyudu Mar 11, 2025
d4e4d4d
fix: update callback and jump codegen in JumpProblem
vyudu Mar 12, 2025
07f16a3
refactor: update `@mtkmodel` to account for new callback syntax
vyudu Mar 24, 2025
d12abee
fix: do not error when simplifying implicit `DiscreteSystem`s
AayushSabharwal May 9, 2025
5120296
fix: propagate events when simplifying `SDESystem`
AayushSabharwal May 9, 2025
1e9c8f2
fix: unwrap `discrete_parameters` in `make_affect`
AayushSabharwal May 9, 2025
43bc659
fix: implement `tovar(::Arr)`
AayushSabharwal May 9, 2025
805b23d
fix: fix propagation of `reinitializealg` in `SymbolicDiscreteCallback`
AayushSabharwal May 12, 2025
dff62b0
fix: FMI ME state management callback shouldn't ever trigger or reini…
AayushSabharwal May 12, 2025
48be180
refactor: remove old `System` function
AayushSabharwal Apr 14, 2025
509643c
refactor: remove `odesystem.jl`
AayushSabharwal May 14, 2025
a69b403
refactor: add `_eq_unordered` to `utils.jl`
AayushSabharwal Apr 20, 2025
66255d0
refactor: move `flatten_equations` to `utils.jl`
AayushSabharwal May 14, 2025
3e6f7f8
refactor: remove `sdesystem.jl`
AayushSabharwal Apr 20, 2025
e486b27
refactor: move `__num_isdiag_noise`, `get_num_diag_noise` to location…
AayushSabharwal Apr 20, 2025
1113524
refactor: remove `discrete_system.jl`
AayushSabharwal Apr 20, 2025
3436067
refactor: remove `implicit_discrete_system.jl`
AayushSabharwal Apr 20, 2025
6e5801d
remove jumpsystem.jl
AayushSabharwal May 14, 2025
23093ae
refactor: move `JumpType` definition to `utils.jl`
AayushSabharwal Apr 22, 2025
5b4e80d
refactor: remove `nonlinearsystem.jl`
AayushSabharwal Apr 20, 2025
a58d3d3
refactor: remove `optimizationsystem.jl`
AayushSabharwal Apr 21, 2025
5eb6a1c
refactor: remove `constraints_system.jl`
AayushSabharwal Apr 21, 2025
adfb917
remove abstractodesystem.jl
AayushSabharwal May 14, 2025
1dcc454
refactor: do not rely on `ArrayPartition` when unit-checking jumps
AayushSabharwal May 14, 2025
74a2153
feat: add unified `System` type
AayushSabharwal May 14, 2025
c146dd0
feat: add getters for new `System` fields
AayushSabharwal Apr 14, 2025
0da70f3
feat: add hierarchical aggregator functions for jumps, brownians and …
AayushSabharwal Apr 14, 2025
d15f60e
refactor: move `constraints` to `abstractsystem.jl`
AayushSabharwal Apr 21, 2025
e5bad1e
refactor: don't warn about system supertype for `System`
AayushSabharwal Apr 14, 2025
acc4f31
refactor: port `stochastic_integral_transform` and `Girsanov_transform`
AayushSabharwal Apr 20, 2025
a0dbe7f
refactor: move `eval_or_rgf` to `codegen_utils.jl`
AayushSabharwal Apr 27, 2025
b938241
feat: allow `GeneratedFunctionWrapper` to compile functions and build…
AayushSabharwal Apr 27, 2025
84d69bc
feat: add `maybe_compile_function`
AayushSabharwal Apr 28, 2025
c8e4be5
refactor: fix and document `delay_to_function`, implement it for `Sys…
AayushSabharwal Apr 15, 2025
e96e76b
feat: add initial codegen for `System`
AayushSabharwal Apr 13, 2025
b174f03
refactor: port `build_explicit_observed_function` to `codegen.jl`
AayushSabharwal Apr 20, 2025
6008eba
feat: add `@fallback_iip_specialize`
AayushSabharwal Apr 14, 2025
67a598b
feat: add `check_compatible_system`
AayushSabharwal Apr 14, 2025
4a96614
feat: implement `generate_initializesystem` for `System`
AayushSabharwal Apr 14, 2025
97a6cad
refactor: remove `generate_factorized_W`
AayushSabharwal Apr 16, 2025
5ee21c3
fix: fix `remake` for `IntervalNonlinearProblem`
AayushSabharwal Apr 16, 2025
304f640
feat: add `replace` kwarg to `add_toterms!`
AayushSabharwal May 14, 2025
4decfa8
refactor: centralize problem kwargs handling
AayushSabharwal May 14, 2025
8d313bf
refactor: move `filter_kwargs` and `SymbolicTstops` to `problem_utils…
AayushSabharwal Apr 21, 2025
d469f7c
feat: support returning `Expr` from `SymbolicTstops` and `ObservedFun…
AayushSabharwal Apr 28, 2025
8b9cb5a
refactor: pass `u0` and `p` as kwargs in `process_SciMLProblem`
AayushSabharwal May 14, 2025
4c5841a
feat: add `maybe_codegen_scimlfn` and `maybe_codegen_scimlproblem`
AayushSabharwal Apr 28, 2025
9d5ebda
feat: implement `ODEProblem` and `ODEFunction` for `System`
AayushSabharwal Apr 14, 2025
556c0a7
feat: implement `DDEFunction`, `DDEProblem` for `System`
AayushSabharwal May 14, 2025
78b2f1c
feat: implement `DAEProblem` and `DAEFunction` for `System`
AayushSabharwal May 14, 2025
fa7f1f7
feat: implement `SDEProblem` and `SDEFunction` for `System`
AayushSabharwal May 14, 2025
f3433db
feat: implement `SDDEProblem`, `SDDEFunction` for `System`
AayushSabharwal Apr 16, 2025
aeb2316
feat: implement `NonlinearProblem`, `NonlinearFunction` for `System`
AayushSabharwal May 14, 2025
575e302
feat: implement `IntervalNonlinearProblem`, `IntervalNonlinearFunctio…
AayushSabharwal Apr 16, 2025
90baa3d
feat: implement `ImplicitDiscreteProblem` `ImplicitDiscreteFunction` …
AayushSabharwal May 14, 2025
025e319
feat: implement `DiscreteProblem` and `DiscreteFunction` for `System`
AayushSabharwal May 14, 2025
cd19b84
feat: allow manually choosing time-independent initialization
AayushSabharwal Apr 17, 2025
3d5e4c0
feat: implement `OptimizationProblem` and `OptimizationFunction` for …
AayushSabharwal May 14, 2025
b875120
feat: implement `JumpProblem` for `System`
AayushSabharwal May 14, 2025
e973971
feat: add `InitializationProblem`
AayushSabharwal May 14, 2025
b4aa4b0
feat: implement `NonlinearLeastSquaresProblem` for `System`
AayushSabharwal Apr 20, 2025
c3034b3
refactor: port `SCCNonlinearProblem` to separate file
AayushSabharwal Apr 20, 2025
6a5d841
feat: implement `BVProblem` for `System`
AayushSabharwal May 14, 2025
4e52917
feat: implement `SteadyStateProblem` for `System`
AayushSabharwal Apr 21, 2025
37d7f6a
fix: fix `toexpr(::AbstractSystem)`
AayushSabharwal Apr 21, 2025
60d73b9
fix: fix `extend(::AbstractSystem)`
AayushSabharwal Apr 21, 2025
81e8c98
fix: fix `substitute(::AbstractSystem, _...)`
AayushSabharwal Apr 21, 2025
3f5428a
fix: construct `System` in `@mtkmodel`
AayushSabharwal Apr 21, 2025
8556dee
docs: fix docstring of `process_SciMLProblem`
AayushSabharwal Apr 21, 2025
1048557
refactor: allow real values in `costs`
AayushSabharwal Apr 25, 2025
fcc9142
refactor: remove old clock handling code, retain error messages
AayushSabharwal Apr 21, 2025
1b1ea3d
fix: allow simplifying systems with noise
AayushSabharwal Apr 21, 2025
2396646
refactor: remove `schedule(sys)`
AayushSabharwal Apr 21, 2025
001f2b7
feat: set system scheduling information in `structural_simplify`
AayushSabharwal Apr 21, 2025
260d2b1
refactor: remove references to `ODESystem` in source code
AayushSabharwal Apr 21, 2025
28999f3
refactor: remove `__structural_simplify(::JumpSystem)`
AayushSabharwal Apr 21, 2025
330d0e7
refactor: remove references to `SDESystem` in source code
AayushSabharwal Apr 21, 2025
35b0ae3
refactor: remove references to `NonlinearSystem`
AayushSabharwal Apr 21, 2025
2580861
refactor: remove references to `DiscreteSystem`
AayushSabharwal Apr 21, 2025
aa7961e
refactor: do not use `sys.substitutions`
AayushSabharwal Apr 22, 2025
8348908
test: replace `ODESystem` with `System`
AayushSabharwal May 14, 2025
e027e93
test: replace `NonlinearSystem` with `System`
AayushSabharwal Apr 22, 2025
a0c1394
test: replace `ImplicitDiscreteSystem` with `System`
AayushSabharwal Apr 22, 2025
36d0c76
test: replace `DiscreteSystem` with `System`
AayushSabharwal Apr 22, 2025
dfd16e5
fix: ensure equations are `Vector{Equation}` in `generate_initializes…
AayushSabharwal Apr 25, 2025
9b35a00
test: fix usage of array equations in test
AayushSabharwal Apr 25, 2025
56741c9
test: ensure equations passed to system are `Vector{Equation}`
AayushSabharwal Apr 25, 2025
5ea5f81
refactor: remove `process_equations`
AayushSabharwal Apr 25, 2025
8a277f4
docs: document `collect_var!`
AayushSabharwal Apr 25, 2025
7678ffc
refactor: change default operator in `collect_vars!` to `Symbolics.Op…
AayushSabharwal Apr 25, 2025
1b77666
feat: add `validate_operator`
AayushSabharwal Apr 25, 2025
a2b712a
refactor: document `collect_vars!` and use `validate_operator`
AayushSabharwal Apr 25, 2025
d5ee287
feat: add `is_floatingpoint_symtype`
AayushSabharwal Apr 25, 2025
f7dfb96
refactor: use `is_floatingpoint_symtype` in `is_variable_floatingpoint`
AayushSabharwal Apr 25, 2025
b7258df
test: don't pass dvs/ps to `ODEFunction`
AayushSabharwal Apr 25, 2025
43f32bd
test: fix shadowing of `System` in tests
AayushSabharwal Apr 25, 2025
1aaa64b
test: pass `u0map` and `tspan` to `ODEProblem`
AayushSabharwal Apr 25, 2025
268947d
test: create `JumpProblem` directly
AayushSabharwal Apr 25, 2025
ddeeee1
test: pass `Vector{Equation}` to `System`
AayushSabharwal Apr 25, 2025
6b5dab8
refactor: remove `build_torn_function`, `tearing_assignments`
AayushSabharwal Apr 27, 2025
14d8d40
refactor: remove `get_substitutions`, `has_substitutions` field getters
AayushSabharwal Apr 27, 2025
a7f7ae6
refactor: implement `empty_substitutions` and `get_substitutions` usi…
AayushSabharwal Apr 27, 2025
c6a1501
refactor: remove `get_substitutions_and_solved_unknowns`
AayushSabharwal Apr 27, 2025
26b3304
refactor: update `tearing_substitute_expr`, `full_equations` to use `…
AayushSabharwal Apr 27, 2025
b07c935
refactor: do not use `get_substitutions` in `get_cmap`
AayushSabharwal Apr 27, 2025
a6f889a
test: fix mass matrix tests
AayushSabharwal Apr 27, 2025
b7d4890
test: fix odesystem tests
AayushSabharwal Apr 27, 2025
9ec0721
refactor: rename `generate_function` to `generate_rhs`
AayushSabharwal Apr 27, 2025
23ac3d8
fix: fix type-piracy of `Symbolics.rename`
AayushSabharwal Apr 29, 2025
9b1617f
refactor: remove `systems/diffeqs/modelingtoolkitize.jl`
AayushSabharwal Apr 29, 2025
c6d20ee
feat: add `modelingtoolkitize` for `ODEProblem`
AayushSabharwal Apr 29, 2025
0425dc2
feat: add `modelingtoolkitize` for `SDEProblem`
AayushSabharwal Apr 29, 2025
cee2a6d
feat: add `add_accumulations`
AayushSabharwal Apr 29, 2025
1e4cb23
test: fix `odesystem` tests
AayushSabharwal Apr 29, 2025
a815755
fix: validate that `Sample` operates on unknowns
AayushSabharwal Apr 29, 2025
c7d37e5
test: fix `test/structural_transformation/utils.jl`
AayushSabharwal Apr 29, 2025
2b7124b
test: simplify test for metadata retention in `complete`
AayushSabharwal Apr 29, 2025
22a175f
test: improve readability of dependency graph tests
AayushSabharwal Apr 29, 2025
f82ff93
test: fix usage of `ODEProblemExpr` in lowering test
AayushSabharwal Apr 29, 2025
b55e28f
test: remove test for specifying type of system in `@mtkmodel`
AayushSabharwal Apr 29, 2025
d5fd328
test: fix parameter dependencies test
AayushSabharwal Apr 29, 2025
ce50a4d
test: fix symbolic events test
AayushSabharwal Apr 29, 2025
9788f3e
test: fix modelingtoolkitize test
AayushSabharwal Apr 29, 2025
e2a94aa
test: remove outdated test
AayushSabharwal May 1, 2025
63feb39
refactor: remove old `modelingtoolkitize(::OptimizationProblem)`
AayushSabharwal May 1, 2025
a706150
feat: add `modelingtoolkitize(::OptimizationProblem)`
AayushSabharwal May 1, 2025
72fd930
refactor: remove old `modelingtoolkitize(::NonlinearProblem)`
AayushSabharwal May 1, 2025
e7a96b6
feat: add `modelingtoolkitize(::NonlinearProblem)`
AayushSabharwal May 1, 2025
3974550
refactor: remove old `modelingtoolkitize(::ODEProblem)` and `::SDEPro…
AayushSabharwal May 1, 2025
153aa73
feat: add `structural_simplify` for optimization systems
AayushSabharwal May 2, 2025
9602a81
fix: change default `consolidate` to `default_consolidate` in `@mtkmo…
AayushSabharwal May 7, 2025
9d8df2a
fix: handle `Shift`s in `is_diff_equation`
AayushSabharwal May 8, 2025
f19daed
feat: implement `calculate_hessian` and `hessian_sparsity` for `System`
AayushSabharwal May 8, 2025
c656c33
feat: make delay processing more modular in `build_function_wrapper`
AayushSabharwal May 8, 2025
7102e48
fix: fix `generate_cost` for time-dependent (BV) systems
AayushSabharwal May 8, 2025
a654f5e
fix: default `build_initializeprob` to `supports_initialization(sys)`
AayushSabharwal May 8, 2025
7cad5fe
fix: disallow simplification of jump systems
AayushSabharwal May 8, 2025
7f6456a
fix: remove usage of `is_scalar_noise` kwarg
AayushSabharwal May 8, 2025
be1d04b
feat: inspect jumps in `collect_scoped_vars!`
AayushSabharwal May 8, 2025
854a340
test: comment out jac/tgrad caching test
AayushSabharwal May 8, 2025
de3b7e8
test: update BVProblem tests to new semantics
AayushSabharwal May 8, 2025
45b3d59
test: update DDE tests to new semantics
AayushSabharwal May 8, 2025
f5fffbb
test: make debugging tests more reproducible
AayushSabharwal May 8, 2025
a77d685
test: update discrete system tests to new semantics
AayushSabharwal May 8, 2025
f021791
test: update implicit discrete system tests to new semantics
AayushSabharwal May 8, 2025
efbe0c8
test: remove redundant initial values tests
AayushSabharwal May 8, 2025
33da82f
test: update initialization system tests to new semantics
AayushSabharwal May 8, 2025
5849d34
test: fix jump system tests
AayushSabharwal May 8, 2025
3c53941
test: remove redundant namespacing tests
AayushSabharwal May 8, 2025
eb53edd
fix: fix `independent_variables`
AayushSabharwal May 8, 2025
e2f1422
feat: export newly added functions
AayushSabharwal May 8, 2025
4a39883
feat: add `noise_to_brownians`
AayushSabharwal May 14, 2025
bfcae72
feat: add `convert_system_indepvar`
AayushSabharwal May 14, 2025
d94e88b
fix: fix structural simplification for SDEs
AayushSabharwal May 14, 2025
3cfba7f
refactor: remove `convert_system`
AayushSabharwal May 14, 2025
4bea746
test: fix nonlinearsystem tests
AayushSabharwal May 14, 2025
966ccea
test: fix optimizationsystem tests
AayushSabharwal May 14, 2025
24a56f9
test: fix sdesystem tests
AayushSabharwal May 14, 2025
c871e52
fix: unwrap in `add_toterms!`, don't override existing values
AayushSabharwal May 14, 2025
192dff7
fix: unwrap `varmap` and add toterms in `better_varmap_to_vars`
AayushSabharwal May 14, 2025
1e10954
test: update mtkparameters tests
AayushSabharwal May 14, 2025
c2f0424
test: update serialization tests
AayushSabharwal May 14, 2025
cf61fe3
test: fix symbolic indexing interface tests
AayushSabharwal May 14, 2025
573146e
fix: fix `Pre` parameter discovery for `AffectSystem`
AayushSabharwal May 14, 2025
f3d6288
fix: fix `compile_condition`, respect `eval_expression` and `eval_mod…
AayushSabharwal May 14, 2025
0d8fcb8
fix: respect `eval_expression`, `eval_module` in `compile_equational_…
AayushSabharwal May 14, 2025
3a7a54e
test: fix symbolic event tests
AayushSabharwal May 14, 2025
e5223b8
fix: update CasADi extension to new semantics
AayushSabharwal May 15, 2025
96e3d81
fix: update InfiniteOpt extension to new semantics
AayushSabharwal May 15, 2025
23ff019
fix: update `optimal_control_interface.jl` to new semantics
AayushSabharwal May 15, 2025
17caec8
fix: recognize delayed derivatives in `isdelay`
AayushSabharwal May 15, 2025
c1c8746
fix: use 2-argument `consolidate` in dynamic optimization tests
AayushSabharwal May 15, 2025
995b8ae
build: bump CasADi compat
AayushSabharwal May 16, 2025
229e8c2
fix: fix homotopy continuation
AayushSabharwal May 20, 2025
71dd1ca
fix: fix AD on `default_consolidate`
AayushSabharwal May 20, 2025
545616f
test: fix labelledarrays test
AayushSabharwal May 20, 2025
a9e5df5
fix: fix `define_params` in `LabelledArraysExt`
AayushSabharwal May 20, 2025
130f98f
fix: fix BifurcationKitExt
AayushSabharwal May 20, 2025
98de7ec
refactor: remove `ode_order_lowering` and `dae_order_lowering`
AayushSabharwal May 20, 2025
abc6abe
refactor: remove code related to parsing and substitution of constants
AayushSabharwal May 19, 2025
9278139
refactor: make `@constants` create non-tunable parameters
AayushSabharwal May 19, 2025
2b140de
refactor: update `@constants` parsing in `@mtkmodel`
AayushSabharwal May 19, 2025
9f39e28
test: account for new `@constants` behavior in tests
AayushSabharwal May 19, 2025
21baf12
fix: don't `toparam` inside `Initial`
AayushSabharwal Apr 4, 2025
811196b
feat: reduce reliance on metadata in `structural_simplify`
AayushSabharwal Apr 4, 2025
3c09dea
fix: fix `linearization_function` with analysis points mutating the s…
AayushSabharwal May 19, 2025
348287f
fix: properly handle array equations during variable discovery in `Sy…
AayushSabharwal May 19, 2025
6d99420
test: fix broken tearing test
AayushSabharwal May 19, 2025
9fc141a
test: fix missing subcomponent in components test
AayushSabharwal May 19, 2025
59e5ad6
fix: fix incorrect default in DDE test
AayushSabharwal May 19, 2025
678d98f
fix: fix parameter not passed to `System` in units test
AayushSabharwal May 19, 2025
bd15dfd
fix: fix parameter not passed to system in error handling test
AayushSabharwal May 19, 2025
9bd3a06
test: update test with new simplification result
AayushSabharwal May 19, 2025
abfb41b
test: fix variable not passed to `System` in odesystem test
AayushSabharwal May 19, 2025
0dedfe9
refactor: don't check `isparameter` in `check_variables` and `check_p…
AayushSabharwal May 20, 2025
501dc7f
fix: don't use `isparameter` in `find_eq_solvables!`
AayushSabharwal May 20, 2025
21d9cb8
fix: don't use `isparameter` in `generate_initializesystem`
AayushSabharwal May 20, 2025
77a3f51
test: test simplification independent of metadata
AayushSabharwal May 20, 2025
6aa6039
fix: unwrap brownians in `noise_to_brownians`
AayushSabharwal May 21, 2025
0723b71
test: pass `@constants` parameter to `System` constructor
AayushSabharwal May 21, 2025
92e3686
test: pass brownians to `System` constructor
AayushSabharwal May 21, 2025
7bceb7a
fix: unhack observed when compiling callbacks
AayushSabharwal May 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- v10
tags: '*'
pull_request:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- 'master'
- v10
tags: '*'
pull_request:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- 'release-'
- v10
paths-ignore:
- 'docs/**'
push:
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# ModelingToolkit v10 Release Notes

### Callbacks

Callback semantics have changed.

- There is a new `Pre` operator that is used to specify which values are before the callback.
For example, the affect `A ~ A + 1` should now be written as `A ~ Pre(A) + 1`. This is
**required** to be specified - `A ~ A + 1` will now be interpreted as an equation to be
satisfied after the callback (and will thus error since it is unsatisfiable).

- All parameters that are changed by a callback must be declared as discrete parameters to
the callback constructor, using the `discrete_parameters` keyword argument.

```julia
event = SymbolicDiscreteCallback(
[t == 1] => [p ~ Pre(p) + 1], discrete_parameters = [p])
```

# ModelingToolkit v9 Release Notes

### Upgrade guide
Expand Down
15 changes: 12 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
version = "9.80.1"
version = "10.0.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -31,6 +31,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e"
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
ImplicitDiscreteSolve = "3263718b-31ed-49cf-8a0f-35a466e8af96"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
JumpProcesses = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5"
Expand All @@ -43,6 +44,7 @@ NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down Expand Up @@ -87,7 +89,7 @@ BifurcationKit = "0.4"
BlockArrays = "1.1"
BoundaryValueDiffEqAscher = "1.6.0"
BoundaryValueDiffEqMIRK = "1.7.0"
CasADi = "1.0.6"
CasADi = "1.0.7"
ChainRulesCore = "1"
Combinatorics = "1"
CommonSolve = "0.2.4"
Expand Down Expand Up @@ -115,6 +117,7 @@ ForwardDiff = "0.10.3"
FunctionWrappers = "1.1"
FunctionWrappersWrappers = "0.1"
Graphs = "1.5.2"
ImplicitDiscreteSolve = "0.1.2"
InfiniteOpt = "0.5"
InteractiveUtils = "1"
JuliaFormatter = "1.0.47, 2"
Expand Down Expand Up @@ -176,6 +179,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
ModelingToolkitStandardLibrary = "16a59e39-deab-5bd0-87e4-056b12336739"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationBase = "bca83a33-5cc9-4baa-983d-23429ab6bcbb"
OptimizationMOI = "fd9f6733-72f4-499f-8506-86b2bdd0dea1"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand All @@ -195,5 +199,10 @@ StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
ModelingToolkitStandardLibrary = { url = "https://github.com/SciML/ModelingToolkitStandardLibrary.jl/", rev = "mtk-v10" }
OptimizationBase = { url = "https://github.com/AayushSabharwal/OptimizationBase.jl", rev = "as/mtk-v10" }
OptimizationMOI = { url = "https://github.com/AayushSabharwal/Optimization.jl", subdir = "lib/OptimizationMOI", rev = "as/mtk-v10" }

[targets]
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqCore", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq", "Pkg", "JET", "OrdinaryDiffEqNonlinearSolve", "Logging"]
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqCore", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq", "Pkg", "JET", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase"]
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Documenter = "1"
DynamicQuantities = "^0.11.2, 0.12, 1"
FMI = "0.14"
FMIZoo = "1"
ModelingToolkit = "8.33, 9"
ModelingToolkit = "10"
ModelingToolkitStandardLibrary = "2.19"
NonlinearSolve = "3, 4"
Optim = "1.7"
Expand Down
20 changes: 6 additions & 14 deletions docs/src/basics/Composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,42 +135,34 @@ sys.y = u * 1.1
In a hierarchical system, variables of the subsystem get namespaced by the name of the system they are in. This prevents naming clashes, but also enforces that every unknown and parameter is local to the subsystem it is used in. In some cases it might be desirable to have variables and parameters that are shared between subsystems, or even global. This can be accomplished as follows.

```julia
@parameters a b c d e f
@parameters a b c d

# a is a local variable
b = ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
c = ParentScope(ParentScope(c)) # ParentScope can be nested
d = DelayParentScope(d) # skips one level before applying ParentScope
e = DelayParentScope(e, 2) # second argument allows skipping N levels
f = GlobalScope(f)
d = GlobalScope(d)

p = [a, b, c, d, e, f]
p = [a, b, c, d]

level0 = ODESystem(Equation[], t, [], p; name = :level0)
level1 = ODESystem(Equation[], t, [], []; name = :level1) level0
parameters(level1)
#level0₊a
#b
#c
#level0₊d
#level0₊e
#f
#d
level2 = ODESystem(Equation[], t, [], []; name = :level2) level1
parameters(level2)
#level1₊level0₊a
#level1₊b
#c
#level0₊d
#level1₊level0₊e
#f
#d
level3 = ODESystem(Equation[], t, [], []; name = :level3) level2
parameters(level3)
#level2₊level1₊level0₊a
#level2₊level1₊b
#level2₊c
#level2₊level0₊d
#level1₊level0₊e
#f
#d
```

## Structural Simplify
Expand Down
108 changes: 87 additions & 21 deletions docs/src/basics/Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,67 @@ the event occurs). These can both be specified symbolically, but a more [general
functional affect](@ref func_affects) representation is also allowed, as described
below.

## Symbolic Callback Semantics

In callbacks, there is a distinction between values of the unknowns and parameters
*before* the callback, and the desired values *after* the callback. In MTK, this
is provided by the `Pre` operator. For example, if we would like to add 1 to an
unknown `x` in a callback, the equation would look like the following:

```julia
x ~ Pre(x) + 1
```

Non `Pre`-d values will be interpreted as values *after* the callback. As such,
writing

```julia
x ~ x + 1
```

will be interpreted as an algebraic equation to be satisfied after the callback.
Since this equation obviously cannot be satisfied, an error will result.

Callbacks must maintain the consistency of DAEs, meaning that they must satisfy
all the algebraic equations of the system after their update. However, the affect
equations often do not fully specify which unknowns/parameters should be modified
to maintain consistency. To make this clear, MTK uses the following rules:

1. All unknowns are treated as modifiable by the callback. In order to enforce that an unknown `x` remains the same, one can add `x ~ Pre(x)` to the affect equations.
2. All parameters are treated as un-modifiable, *unless* they are declared as `discrete_parameters` to the callback. In order to be a discrete parameter, the parameter must be time-dependent (the terminology *discretes* here means [discrete variables](@ref save_discretes)).

For example, consider the following system.

```julia
@variables x(t) y(t)
@parameters p(t)
@mtkbuild sys = ODESystem([x * y ~ p, D(x) ~ 0], t)
event = [t == 1] => [x ~ Pre(x) + 1]
```

By default what will happen is that `x` will increase by 1, `p` will remain constant,
and `y` will change in order to compensate the increase in `x`. But what if we
wanted to keep `y` constant and change `p` instead? We could use the callback
constructor as follows:

```julia
event = SymbolicDiscreteCallback(
[t == 1] => [x ~ Pre(x) + 1, y ~ Pre(y)], discrete_parameters = [p])
```

This way, we enforce that `y` will remain the same, and `p` will change.

!!! warning

Symbolic affects come with the guarantee that the state after the callback
will be consistent. However, when using [general functional affects](@ref func_affects)
or [imperative affects](@ref imp_affects) one must be more careful. In
particular, one can pass in `reinitializealg` as a keyword arg to the
callback constructor to re-initialize the system. This will default to
`SciMLBase.NoInit()` in the case of symbolic affects and `SciMLBase.CheckInit()`
in the case of functional affects. This keyword should *not* be provided
if the affect is purely symbolic.

## Continuous Events

The basic purely symbolic continuous event interface to encode *one* continuous
Expand Down Expand Up @@ -91,7 +152,7 @@ like this
@variables x(t)=1 v(t)=0

root_eqs = [x ~ 0] # the event happens at the ground x(t) = 0
affect = [v ~ -v] # the effect is that the velocity changes sign
affect = [v ~ -Pre(v)] # the effect is that the velocity changes sign

@mtkbuild ball = ODESystem([D(x) ~ v
D(v) ~ -9.8], t; continuous_events = root_eqs => affect) # equation => affect
Expand All @@ -110,8 +171,8 @@ Multiple events? No problem! This example models a bouncing ball in 2D that is e
```@example events
@variables x(t)=1 y(t)=0 vx(t)=0 vy(t)=2

continuous_events = [[x ~ 0] => [vx ~ -vx]
[y ~ -1.5, y ~ 1.5] => [vy ~ -vy]]
continuous_events = [[x ~ 0] => [vx ~ -Pre(vx)]
[y ~ -1.5, y ~ 1.5] => [vy ~ -Pre(vy)]]

@mtkbuild ball = ODESystem(
[
Expand Down Expand Up @@ -204,7 +265,7 @@ bb_sol = solve(bb_prob, Tsit5())
plot(bb_sol)
```

## Discrete events support
## Discrete Events

In addition to continuous events, discrete events are also supported. The
general interface to represent a collection of discrete events is
Expand All @@ -227,13 +288,13 @@ Suppose we have a population of `N(t)` cells that can grow and die, and at time
`t1` we want to inject `M` more cells into the population. We can model this by

```@example events
@parameters M tinject α
@parameters M tinject α(t)
@variables N(t)
Dₜ = Differential(t)
eqs = [Dₜ(N) ~ α - N]

# at time tinject we inject M cells
injection = (t == tinject) => [N ~ N + M]
injection = (t == tinject) => [N ~ Pre(N) + M]

u0 = [N => 0.0]
tspan = (0.0, 20.0)
Expand All @@ -255,7 +316,7 @@ its steady-state value (which is 100). We can encode this by modifying the event
to

```@example events
injection = ((t == tinject) & (N < 50)) => [N ~ N + M]
injection = ((t == tinject) & (N < 50)) => [N ~ Pre(N) + M]

@mtkbuild osys = ODESystem(eqs, t, [N], [M, tinject, α]; discrete_events = injection)
oprob = ODEProblem(osys, u0, tspan, p)
Expand All @@ -269,16 +330,18 @@ event time, the event condition now returns false. Here we used logical and,
cannot be used within symbolic expressions.

Let's now also add a drug at time `tkill` that turns off production of new
cells, modeled by setting `α = 0.0`
cells, modeled by setting `α = 0.0`. Since this is a parameter we must explicitly
set it as `discrete_parameters`.

```@example events
@parameters tkill

# we reset the first event to just occur at tinject
injection = (t == tinject) => [N ~ N + M]
injection = (t == tinject) => [N ~ Pre(N) + M]

# at time tkill we turn off production of cells
killing = (t == tkill) => [α ~ 0.0]
killing = ModelingToolkit.SymbolicDiscreteCallback(
(t == tkill) => [α ~ 0.0]; discrete_parameters = α, iv = t)

tspan = (0.0, 30.0)
p = [α => 100.0, tinject => 10.0, M => 50, tkill => 20.0]
Expand All @@ -298,16 +361,17 @@ A preset-time event is triggered at specific set times, which can be
passed in a vector like

```julia
discrete_events = [[1.0, 4.0] => [v ~ -v]]
discrete_events = [[1.0, 4.0] => [v ~ -Pre(v)]]
```

This will change the sign of `v` *only* at `t = 1.0` and `t = 4.0`.

As such, our last example with treatment and killing could instead be modeled by

```@example events
injection = [10.0] => [N ~ N + M]
killing = [20.0] => [α ~ 0.0]
injection = [10.0] => [N ~ Pre(N) + M]
killing = ModelingToolkit.SymbolicDiscreteCallback(
[20.0] => [α ~ 0.0], discrete_parameters = α, iv = t)

p = [α => 100.0, M => 50]
@mtkbuild osys = ODESystem(eqs, t, [N], [α, M];
Expand All @@ -325,7 +389,7 @@ specify a periodic interval, pass the interval as the condition for the event.
For example,

```julia
discrete_events = [1.0 => [v ~ -v]]
discrete_events = [1.0 => [v ~ -Pre(v)]]
```

will change the sign of `v` at `t = 1.0`, `2.0`, ...
Expand All @@ -334,10 +398,10 @@ Finally, we note that to specify an event at precisely one time, say 2.0 below,
one must still use a vector

```julia
discrete_events = [[2.0] => [v ~ -v]]
discrete_events = [[2.0] => [v ~ -Pre(v)]]
```

## Saving discrete values
## [Saving discrete values](@id save_discretes)

Time-dependent parameters which are updated in callbacks are termed as discrete variables.
ModelingToolkit enables automatically saving the timeseries of these discrete variables,
Expand All @@ -348,8 +412,10 @@ example:
@variables x(t)
@parameters c(t)

ev = ModelingToolkit.SymbolicDiscreteCallback(
1.0 => [c ~ Pre(c) + 1], discrete_parameters = c, iv = t)
@mtkbuild sys = ODESystem(
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [1.0 => [c ~ c + 1]])
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [ev])

prob = ODEProblem(sys, [x => 0.0], (0.0, 2pi), [c => 1.0])
sol = solve(prob, Tsit5())
Expand All @@ -362,15 +428,15 @@ The solution object can also be interpolated with the discrete variables
sol([1.0, 2.0], idxs = [c, c * cos(x)])
```

Note that only time-dependent parameters will be saved. If we repeat the above example with
this change:
Note that only time-dependent parameters that are explicitly passed as `discrete_parameters`
will be saved. If we repeat the above example with `c` not a `discrete_parameter`:

```@example events
@variables x(t)
@parameters c
@parameters c(t)

@mtkbuild sys = ODESystem(
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [1.0 => [c ~ c + 1]])
D(x) ~ c * cos(x), t, [x], [c]; discrete_events = [1.0 => [c ~ Pre(c) + 1]])

prob = ODEProblem(sys, [x => 0.0], (0.0, 2pi), [c => 1.0])
sol = solve(prob, Tsit5())
Expand Down
Loading
Loading