Skip to content

Commit

Permalink
- Fixed sorting of boolean parameters
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25674 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Apr 22, 2015
1 parent 2729e7d commit 4d1f61e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDump.mo
Expand Up @@ -2679,7 +2679,7 @@ public function dumpIncidenceMatrixT "Prints the transposed incidence matrix on
protected
Integer rowIndex=0;
algorithm
print("\nTransposed Incidence Matrix (row: equation)\n" + UNDERLINE + "\n");
print("\nTransposed Incidence Matrix (row: variable)\n" + UNDERLINE + "\n");
print("number of rows: " + intString(arrayLength(mT)));

for row in mT loop
Expand Down
28 changes: 14 additions & 14 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -794,33 +794,33 @@ algorithm
nParam := BackendVariable.varsSize(allParameters);

if nParam > 0 then
// BackendDump.dumpVariables(allParameters, "all parameters");
// BackendDump.dumpEquationArray(allParameterEqns, "all parameter equations");
//BackendDump.dumpVariables(allParameters, "all parameters");
//BackendDump.dumpEquationArray(allParameterEqns, "all parameter equations");

paramSystem := BackendDAE.EQSYSTEM(allParameters, allParameterEqns, NONE(), NONE(), BackendDAE.NO_MATCHING(), {}, BackendDAE.UNKNOWN_PARTITION());
(_, m, mT, _, _) := BackendDAEUtil.getIncidenceMatrixScalar(paramSystem, BackendDAE.SOLVABLE(), NONE());
// BackendDump.dumpIncidenceMatrix(m);
// BackendDump.dumpIncidenceMatrix(mT);
(_, m, mT, _, _) := BackendDAEUtil.getIncidenceMatrixScalar(paramSystem, BackendDAE.NORMAL(), NONE());
//BackendDump.dumpIncidenceMatrix(m);
//BackendDump.dumpIncidenceMatrixT(mT);

// match the system
// ass1 and ass2 should be {1, 2, ..., nParam}
(ass1, ass2) := Matching.PerfectMatching(m);
// BackendDump.dumpMatchingVars(ass1);
// BackendDump.dumpMatchingEqns(ass2);
//BackendDump.dumpMatchingVars(ass1);
//BackendDump.dumpMatchingEqns(ass2);

comps := Sorting.Tarjan(m, ass1);
// BackendDump.dumpComponentsOLD(comps);
comps := mapListIndices(comps, ass2) "map to var indices" ;
// BackendDump.dumpComponentsOLD(comps);
//BackendDump.dumpComponentsOLD(comps);
comps := mapListIndices(comps, ass2) "map to var indices (not really needed, since ass2 should be {1, 2, ..., nParam})" ;
//BackendDump.dumpComponentsOLD(comps);

// flattern list and look for cyclic dependencies
flatComps := list(flattenParamComp(comp, allParameters) for comp in comps);
// BackendDump.dumpIncidenceRow(flatComps);
//BackendDump.dumpIncidenceRow(flatComps);

// select secondary parameters
secondary := arrayCreate(nParam, 0);
secondary := selectSecondaryParameters(flatComps, allParameters, mT, secondary);
// BackendDump.dumpMatchingVars(secondary);
//BackendDump.dumpMatchingVars(secondary);

// get primary and secondary parameters
for i in 1:nParam loop // for i in flatComps loop
Expand Down Expand Up @@ -1352,8 +1352,8 @@ algorithm
BackendDAEEXT.getAssignment(vec2, vec1);
perfectMatching := 0 == listLength(Matching.getUnassigned(nVars+nAddVars, vec1, {}));
// (vec1, vec2, perfectMatching) := Matching.RegularMatching(m, nVars+nAddVars, nEqns+nAddEqs);
// BackendDump.dumpMatchingVars(vec1);
// BackendDump.dumpMatchingEqns(vec2);
//BackendDump.dumpMatchingVars(vec1);
//BackendDump.dumpMatchingEqns(vec2);

// check whether or not a complete matching was found
if not perfectMatching then
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/Sorting.mo
Expand Up @@ -107,7 +107,7 @@ algorithm
(outStack, outIndex, outComponents) := StrongConnect(m, ass1, eqn2, outStack, outIndex, number, lowlink, onStack, outComponents);
arrayUpdate(lowlink, eqn, intMin(lowlink[eqn], arrayGet(lowlink, eqn2)));
elseif arrayGet(onStack, eqn2) then
// Successor eqn2 is in stack stack and hence in the current SCC
// Successor eqn2 is in the stack and hence in the current SCC
arrayUpdate(lowlink, eqn, intMin(lowlink[eqn], arrayGet(number, eqn2)));
end if;
end for;
Expand Down Expand Up @@ -184,7 +184,7 @@ algorithm
(outStack, outIndex, outComponents) := StrongConnectTransposed(mT, ass2, eqn2, outStack, outIndex, number, lowlink, onStack, outComponents);
arrayUpdate(lowlink, eqn, intMin(lowlink[eqn], arrayGet(lowlink, eqn2)));
elseif arrayGet(onStack, eqn2) then
// Successor eqn2 is in stack stack and hence in the current SCC
// Successor eqn2 is in the stack and hence in the current SCC
arrayUpdate(lowlink, eqn, intMin(lowlink[eqn], arrayGet(number, eqn2)));
end if;
end for;
Expand Down

0 comments on commit 4d1f61e

Please sign in to comment.