Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 52cd129

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Additional debug messages for overdetermined systems
Belonging to [master]: - #2843
1 parent 2b1c2bf commit 52cd129

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9304,6 +9304,7 @@ protected
93049304
constant Boolean debug=false;
93059305
constant Boolean alwaysCheck=false;
93069306
SourceInfo info;
9307+
String str;
93079308
algorithm
93089309
varsArray := syst.orderedVars;
93099310
eqsArray := syst.orderedEqs;
@@ -9322,6 +9323,18 @@ algorithm
93229323
solvedVars := arrayCreate(arrayLength(mT), 0);
93239324
solvedEqs := arrayCreate(arrayLength(m), {});
93249325

9326+
for i in 1:arrayLength(m) /* Not eqnSize; that is the size including arrays */ loop
9327+
_equation := BackendEquation.get(eqsArray, i);
9328+
info := BackendEquation.equationInfo(_equation);
9329+
eqSize := BackendEquation.equationSize(_equation);
9330+
count := listLength(arrayGet(m, i));
9331+
if eqSize > count then
9332+
str := stringDelimitList(list(ComponentReference.printComponentRefStr(BackendVariable.varCref(BackendVariable.getVarAt(varsArray, j))) for j in arrayGet(m, i)), ", ");
9333+
Error.addInternalError(BackendDump.equationString(_equation) + " has size size " + String(eqSize) + " but " + String(count) + " variables ("+ str +")", info);
9334+
return;
9335+
end if;
9336+
end for;
9337+
93259338
if debug then
93269339
print("Got adjacency matrix "+String(varSize)+" "+String(arrayLength(m))+" "+String(eqnSize)+" "+String(arrayLength(mT))+"...\n");
93279340
end if;
@@ -9415,6 +9428,29 @@ algorithm
94159428
if alwaysCheck and varSize == eqnSize then
94169429
return;
94179430
end if;
9431+
if debug then
9432+
for i in 1:arrayLength(mT) /* = varSize */ loop
9433+
var := BackendVariable.getVarAt(varsArray, i);
9434+
if 0 == arrayGet(solvedVars, i) then
9435+
print("Remaining unsolved variable:" + ComponentReference.printComponentRefStr(var.varName) + "\n");
9436+
end if;
9437+
end for;
9438+
for i in 1:arrayLength(m) /* = varSize */ loop
9439+
_equation := BackendEquation.get(eqsArray, i);
9440+
eqnSize := BackendEquation.equationSize(_equation);
9441+
count := listLength(arrayGet(solvedEqs, i));
9442+
if eqnSize <> count then
9443+
vars := arrayGet(m, i);
9444+
print("Remaining vars: " + stringDelimitList(list(String(j) for j in vars), ", ") + "\n");
9445+
if count > 0 then
9446+
str := stringDelimitList(list(ComponentReference.printComponentRefStr(Util.tuple21(e)) for e in arrayGet(solvedEqs, i)), ", ");
9447+
print("Remaining equation (already solved "+str+"): " + BackendDump.equationString(_equation) + "\n");
9448+
else
9449+
print("Remaining equation: " + BackendDump.equationString(_equation) + "\n");
9450+
end if;
9451+
end if;
9452+
end for;
9453+
end if;
94189454
fail();
94199455
end checkIncidenceMatrixSolvability;
94209456

0 commit comments

Comments
 (0)