ModelingToolkit.jl icon indicating copy to clipboard operation
ModelingToolkit.jl copied to clipboard

Improved FunctionalAffect alternative

Open BenChung opened this issue 1 year ago • 3 comments

Checklist

  • [x] 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.
  • [x] 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 avatar Aug 03 '24 01:08 BenChung

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 avatar Sep 10 '24 03:09 BenChung

This looks like a rebase gone wrong 😅

AayushSabharwal avatar Sep 24 '24 05:09 AayushSabharwal

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

BenChung avatar Sep 24 '24 07:09 BenChung

Rebase.

ChrisRackauckas avatar Oct 24 '24 10:10 ChrisRackauckas

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

BenChung avatar Oct 24 '24 10:10 BenChung

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?

ChrisRackauckas avatar Oct 27 '24 14:10 ChrisRackauckas