Repository navigation
Read each vertex's isouter when interpreting an Equality cset causally - #5317
Merged
AayushSabharwal merged 1 commit intoOct 30, 2026
Merged
Conversation
The loop that interprets an `Equality` connection set as a causal one checked `cvert.isouter`, where `cvert` is the set's first vertex, so every member was classified with the first member's flag and the root depended on the order of the arguments to `connect`. Read `cset[i].isouter` instead, and test all six orders of an outer output connected to an inner output and an inner input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pankgeorg
marked this pull request as ready for review
October 25, 2026 19:29
AayushSabharwal
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5318.
In
generate_connection_equations_and_stream_connections, the loop that tries to read anEqualityconnection set as a causal one checkscvert.isouterfor every member.cvertis the set's first vertex (cvert = cset[1]at the top of the outer loop), not the vertex being visited. So the outer/inner test uses the first member's flag for all members, and the root of the set depends on the order of the arguments toconnect.Example: a component with an outer
RealOutputnamedoutput, an inner sourcesrc.outputand an inner sinkdst.input, connected in each of the six argument orders:connect(...)argument orderoutput, src.output, dst.inputoutput.u ~ dst.input.u,src.output.u ~ dst.input.uoutput, dst.input, src.outputoutput.u ~ dst.input.u,src.output.u ~ dst.input.usrc.output, output, dst.inputoutput.u ~ src.output.u,dst.input.u ~ src.output.usrc.output, dst.input, outputdst.input.u ~ src.output.u,output.u ~ src.output.udst.input, output, src.outputdst.input.u ~ output.u,src.output.u ~ output.udst.input, src.output, outputdst.input.u ~ src.output.u,output.u ~ src.output.uWith this change the loop reads
cset[i].isouter, and all six orders give... ~ src.output.u. The equations are equivalent either way; what changes is the orientation that #3898 introduced (input ~ output, with the source on the right).#5295 re-enabled the causal root selection (before it, the loop's
=== nothingsentinel comparisons could never succeed, so it always fell back tobase ~ v), which exposed the stale first-vertex lookup.Unblocks: causal
Equalityconnection sets that orient the same way (input ~ output) whatever the order of the arguments toconnect.Tests
A new testset in
lib/ModelingToolkitBase/test/components.jlcovers the six orders above. I checked it on Julia 1.13.2 by running the file's top-level code, its testsets whose names start with "Causal", and the "Serial inductor" and "BLT ordering" testsets, which sit inside the file's top-levelifblock:On master, the first assertion of the existing "Causal connections generate causal equations" testset still fails in both runs. #5298 fixes that one; this PR leaves it alone.
🤖 Generated with Claude Code