Skip to content

Support data-valued equations better - #188

Open
BenChung wants to merge 2 commits into
mainfrom
bc/typed-equations
Open

BenChung wants to merge 2 commits into
mainfrom
bc/typed-equations

Conversation

@BenChung

Copy link
Copy Markdown

Struct-valued equations (e.g. struct Foo x y end) beget equations of the form x ~ y where x and y are Foo Instances, which currently neither clock infer properly and error weirdly when MTK tries to put them into 0 ~ x - y form. This instead keeps them intact and makes sure that clock inference recurses through them.

@Shreyas-Ekanathan

Shreyas-Ekanathan commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

I think that part of this (getting x - y to work for structs) was addressed here: SciML/ModelingToolkit.jl#5372

@BenChung

Copy link
Copy Markdown
Author

Looks like it - I'll check against the new main and see.

@BenChung

Copy link
Copy Markdown
Author

Hmm, no, this is still partly needed. The existing fixes cover the x ~ y case but do not cover the residualification piece.

@oscardssmith

Copy link
Copy Markdown
Member

what do you mean by residualification?

@BenChung

Copy link
Copy Markdown
Author

Whoops, sorry, what I mean by residualification is that right now it wants to rewrite x ~ y into 0 ~ x - y really badly, which is not defined for most structures. This avoids the formation of that residual form (which is why I call it that).

@oscardssmith

Copy link
Copy Markdown
Member

The problem with the rewrite being that 0 isn't of compatible shape? I feel like it might be better if we made the 0 it rewrites to be a "structural zero" rather than changing the fundamental way structural equations get simplified fundamentally.

@BenChung

Copy link
Copy Markdown
Author

I don't know what 0 means for non-numerics, though. It might be useful in specific cases (another example is allowing discrete values to take on StructuralEmpty or smth before their first tick), but I'm leery about defining it globally.

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.

3 participants