Skip to content

Conversation

@BenChung
Copy link
Contributor

@BenChung BenChung commented Aug 3, 2024

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

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.

@BenChung BenChung force-pushed the careful-event-affects branch from 8640378 to 9d176cf Compare September 10, 2024 03:57
@BenChung
Copy link
Contributor Author

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).

@BenChung BenChung marked this pull request as draft September 17, 2024 21:38
@AayushSabharwal
Copy link
Member

This looks like a rebase gone wrong 😅

@BenChung
Copy link
Contributor Author

Yep, alas. I'll fix it with a force push

@BenChung BenChung force-pushed the careful-event-affects branch 2 times, most recently from 3653246 to e96ca88 Compare September 24, 2024 07:16
@ChrisRackauckas
Copy link
Member

Rebase.

Copy link
Member

@ChrisRackauckas ChrisRackauckas left a 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

end

output_expr = isscalar ? ts[1] :
(array_type <: Vector ? MakeArray(ts, output_type) : MakeTuple(ts))
Copy link
Contributor

@baggepinnen baggepinnen Oct 24, 2024

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

Copy link
Member

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.

@BenChung
Copy link
Contributor Author

@ChrisRackauckas In terms of simplification, what'd be your thoughts on how to trim this down in that case?

@ChrisRackauckas
Copy link
Member

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 build_explicit_observed_function, and there's ImperativeAffect callback. So it's effectively 3 PRs at once. I think the current merge blocker would be the arguments in build_explicit_observed_function vs build_function.

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?


finalize_affects(cb::SymbolicContinuousCallback) = cb.initialize
function finalize_affects(cbs::Vector{SymbolicContinuousCallback})
mapreduce(finalize_affects, vcat, cbs, init = Equation[])
Copy link
Contributor

@baggepinnen baggepinnen Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(cb, fn) -> begin
function (cb, fn)

anonymous functions can be written this way as well, which maybe looks slightly nicer

Copy link
Member

@AayushSabharwal AayushSabharwal left a 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]>
@ChrisRackauckas ChrisRackauckas merged commit ab97e54 into SciML:master Dec 11, 2024
40 of 42 checks passed
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.

4 participants