-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
Improved FunctionalAffect alternative #2922
Improved FunctionalAffect alternative #2922
Conversation
8640378
to
9d176cf
Compare
I'm increasingly happy with this implementation; the main caveat to that statement is that the use of ComponentArrays for MutatingFunctionalAffects means that the values passed in and out are homogenously typed (that is they're all float64s, which is not great). |
This looks like a rebase gone wrong 😅 |
Yep, alas. I'll fix it with a force push |
3653246
to
e96ca88
Compare
…amedTuples for heterotyped operation support.
Rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super happy with the implementation, I think it seems a bit more complicated than maybe it could be, but I'm willing to see how this goes because it's marked as experimental
src/systems/diffeqs/odesystem.jl
Outdated
@@ -564,12 +589,12 @@ function build_explicit_observed_function(sys, ts; | |||
oop_mtkp_wrapper = mtkparams_wrapper | |||
end | |||
|
|||
output_expr = isscalar ? ts[1] : | |||
(array_type <: Vector ? MakeArray(ts, output_type) : MakeTuple(ts)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I pass StaticVector{Float64, 3}
here, I still get a Vector
right? Seems slightly confusing, although the docstring is rather clear on what options are available.
There is an option to get static arrays out from build_function
, would it make sense to follow this same interface for build_explicit_observed_function
?
https://github.com/JuliaSymbolics/Symbolics.jl/blob/10a61ee505038f4faaf9e1edbcda1caeed8d4cc7/src/build_function.jl#L285
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would make sense to do the same thing here.
@ChrisRackauckas In terms of simplification, what'd be your thoughts on how to trim this down in that case? |
It's just hard to review because there's multiple things going on here. There's an extension to SymbolicContinuousCallback, there's changing options in Also, since the ImperativeAffect is marked as experimental, it should all be isolated to a file so that if it's removed it can be done cleanly. It seems like there are utils for ImperativeAffect that are mixed in with the other callbacks? |
src/systems/callbacks.jl
Outdated
if has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing | ||
initialize = handle_optional_setup_fn( | ||
map( | ||
(cb, fn) -> begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(cb, fn) -> begin | |
function (cb, fn) |
anonymous functions can be written this way as well, which maybe looks slightly nicer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor doc thing I found
Co-authored-by: Aayush Sabharwal <[email protected]>
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
This introduces
MutatingFunctionalAffect
(better name suggestions much appreciated) which presents a higher level interface when compared to FunctionalAffect. In particular, it decouples the inputs and outputs to the affect from the precise problem structure post-simplification.This isn't quite complete yet; I need to implement it marking unknowns mutating by affects irreducible so that they're always there come runtime. Close, however.