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

[BE] Fix handling of mixed determined systems #3085

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Compiler/BackEnd/Initialization.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ algorithm
// modify incidence matrix for under-determined systems
nAddEqs := intMax(nVars-nEqns + index, index);
if debug then print("nAddEqs: " + intString(nAddEqs) + "\n"); end if;
m := fixUnderDeterminedSystem(m_, stateIndices, nEqns, nAddEqs);
m := fixUnderDeterminedSystem(m_, nEqns, nAddEqs);

// modify incidence matrix for over-determined systems
nAddVars := intMax(nEqns-nVars + index, index);
Expand Down Expand Up @@ -1410,12 +1410,11 @@ end fixInitialSystem;

protected function fixUnderDeterminedSystem "author: lochel"
input BackendDAE.IncidenceMatrix inM;
input list<Integer> inInitVarIndices;
input Integer inNEqns;
input Integer inNAddEqns;
output BackendDAE.IncidenceMatrix outM;
protected
list<Integer> newEqIndices;
list<Integer> newEqIndices,allVarIndices;
algorithm
if inNAddEqns < 0 then
Error.addInternalError("function fixUnderDeterminedSystem failed due to invalid input", sourceInfo());
Expand All @@ -1426,7 +1425,8 @@ algorithm
outM := arrayCreate(inNEqns+inNAddEqns, {});
outM := Array.copy(inM, outM);
newEqIndices := List.intRange2(inNEqns+1, inNEqns+inNAddEqns);
outM := List.fold1(newEqIndices, squareIncidenceMatrix1, inInitVarIndices, outM);
allVarIndices := List.intRange2(1,inNEqns+inNAddEqns);
outM := List.fold1(newEqIndices, squareIncidenceMatrix1, allVarIndices, outM);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me. The introduced artificial equations should only be connected to inInitVarIndices (states, discrete states, and parameters having fixed=false).

else
outM := arrayCopy(inM) "deep copy";
end if;
Expand Down