Skip to content

Commit cac927e

Browse files
authored
Improve overconstrained connection handling (#10768)
- Remove redundant breakable branches before building the connection graph. - Generate equalityConstraint equations when they are needed, instead of generating all possible equalityConstraint equations at the start and then discarding the unused ones. Fixes #10717
1 parent 3414854 commit cac927e

File tree

7 files changed

+370
-256
lines changed

7 files changed

+370
-256
lines changed

OMCompiler/Compiler/NFFrontEnd/NFConnectionSets.mo

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,15 @@ package ConnectionSets
124124
input BrokenEdges broken;
125125
output Boolean b = false;
126126
protected
127-
ComponentRef lhs, rhs, cr1, cr2;
127+
ComponentRef cr1, cr2;
128128
algorithm
129129
cr1 := Connector.name(c1);
130130
cr2 := Connector.name(c2);
131131
// print("Check: connect(" + ComponentRef.toString(cr1) + ", " + ComponentRef.toString(cr2) + ")\n");
132132

133133
for c in broken loop
134-
((lhs, rhs, _)) := c;
135-
136-
if ComponentRef.isPrefix(lhs, cr1) and ComponentRef.isPrefix(rhs, cr2) or
137-
ComponentRef.isPrefix(lhs, cr2) and ComponentRef.isPrefix(rhs, cr1)
134+
if ComponentRef.isPrefix(c.lhs, cr1) and ComponentRef.isPrefix(c.rhs, cr2) or
135+
ComponentRef.isPrefix(c.lhs, cr2) and ComponentRef.isPrefix(c.rhs, cr1)
138136
then
139137
// print("Ignore broken: connect(" + Connector.toString(c1) + ", " + Connector.toString(c2) + ")\n");
140138
b := true;

OMCompiler/Compiler/NFFrontEnd/NFConnections.mo

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ protected
4949
import Type = NFType;
5050

5151
public
52-
type BrokenEdge = tuple<ComponentRef, ComponentRef, list<Equation>>;
52+
uniontype BrokenEdge
53+
record BROKEN_EDGE
54+
ComponentRef lhs;
55+
ComponentRef rhs;
56+
DAE.ElementSource source;
57+
list<Equation> brokenEquations;
58+
end BROKEN_EDGE;
59+
end BrokenEdge;
60+
5361
type BrokenEdges = list<BrokenEdge>;
5462

5563
record CONNECTIONS

OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ algorithm
20682068

20692069
// append the equalityConstraint call equations for the broken connects
20702070
if System.getHasOverconstrainedConnectors() then
2071-
ec_eql := List.flatten(list(Util.tuple33(e) for e in broken));
2071+
ec_eql := List.flatten(list(e.brokenEquations for e in broken));
20722072
flatModel.equations := listAppend(ec_eql, flatModel.equations);
20732073
end if;
20742074

0 commit comments

Comments
 (0)