Skip to content

Commit

Permalink
- speed up Indexreduktion: use List.uniqueIntN instead of List.unique…
Browse files Browse the repository at this point in the history
… for Integer Lists

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15049 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Feb 3, 2013
1 parent 5623c28 commit 7023944
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
26 changes: 13 additions & 13 deletions Compiler/BackEnd/BackendDAETransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2422,30 +2422,30 @@ public function collectVarEqns
input list<Integer> inIntegerLst2;
input BackendDAE.IncidenceMatrixT inMT;
input Integer inArrayLength;
input Integer inNEquations "size of equations array, maximal entry in inMT";
output list<Integer> outIntegerLst;
algorithm
outIntegerLst := matchcontinue (inIntegerLst1,inIntegerLst2,inMT,inArrayLength)
outIntegerLst := matchcontinue (inIntegerLst1,inIntegerLst2,inMT,inArrayLength,inNEquations)
local
BackendDAE.IncidenceMatrixT mt;
Integer i,l;
Integer i;
list<Integer> rest,eqns,ilst,ilst1;
case ({},_,_,_)
case ({},_,_,_,_)
then
inIntegerLst2;
case (i::rest,_,mt,l)
List.uniqueIntN(inIntegerLst2,inNEquations);
case (i::rest,_,_,_,_)
equation
true = intLt(i,l);
eqns = List.map(mt[i],intAbs);
ilst = List.union(eqns,inIntegerLst2);
ilst1 = collectVarEqns(rest,ilst,mt,l);
true = intLt(i,inArrayLength);
eqns = List.map(inMT[i],intAbs);
ilst = listAppend(eqns,inIntegerLst2);
ilst1 = collectVarEqns(rest,ilst,inMT,inArrayLength,inNEquations);
then
ilst1;
case (i::rest,_,mt,l)
case (i::rest,_,_,_,_)
equation
ilst1 = collectVarEqns(rest,inIntegerLst2,mt,l);
ilst1 = collectVarEqns(rest,inIntegerLst2,inMT,inArrayLength,inNEquations);
then
ilst1;
case (i::rest,_,mt,l)
case (i::rest,_,_,_,_)
equation
print("collectVarEqns failed for eqn " +& intString(i) +& "\n");
then fail();
Expand Down
1 change: 1 addition & 0 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8128,6 +8128,7 @@ algorithm
nvars = BackendVariable.daenumVariables(syst);
neqns = systemSize(syst);
syst = Causalize.singularSystemCheck(nvars,neqns,syst,match_opts,matchingAlgorithm,arg,ishared);
Debug.execStat("transformDAE -> singularSystemCheck " +& mAmethodstr,CevalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
// match the system and reduce index if neccessary
(syst,shared,arg) = matchingAlgorithmfunc(syst, ishared, false, match_opts, sssHandler, arg);
Debug.execStat("transformDAE -> matchingAlgorithm " +& mAmethodstr +& " index Reduction Method " +& str1,CevalScript.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/IndexReduction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ algorithm
ass2 = List.fold1r(ilst1,arrayUpdate,-1,inAss2);
// set changed variables assignments to zero
ass1 = List.fold1r(ilst,arrayUpdate,-1,inAss1);
eqnslst1 = BackendDAETransform.collectVarEqns(ilst,{},mt,arrayLength(mt));
eqnslst1 = BackendDAETransform.collectVarEqns(ilst,{},mt,arrayLength(mt),arrayLength(m));
syst = BackendDAE.EQSYSTEM(v1,eqns_1,SOME(m),SOME(mt),matching,stateSets);
eqnslst1 = List.map1r(eqnslst1,arrayGet,imapIncRowEqn);
eqnslst1 = List.uniqueIntN(listAppend(inEqns,eqnslst1),eqnss1);
Expand Down Expand Up @@ -1219,7 +1219,7 @@ algorithm
varlst = BackendVariable.setVarsKind(varlst,BackendDAE.VARIABLE());
v1 = BackendVariable.addVars(varlst,v);
// update IncidenceMatrix
eqnslst1 = BackendDAETransform.collectVarEqns(statesWithUnusedDer,{},mt,arrayLength(mt));
eqnslst1 = BackendDAETransform.collectVarEqns(statesWithUnusedDer,{},mt,arrayLength(mt),arrayLength(m));
eqnslst1 = List.map1r(eqnslst1,arrayGet,imapIncRowEqn);
syst = BackendDAE.EQSYSTEM(v1,eqns,SOME(m),SOME(mt),matching,stateSets);
Debug.fcall(Flags.BLT_DUMP, print, "Update Incidence Matrix: ");
Expand Down Expand Up @@ -1258,7 +1258,7 @@ algorithm
Debug.fcall(Flags.BLT_DUMP, print, "Other Candidates are\n");
Debug.fcall(Flags.BLT_DUMP, BackendDump.printVarList, varlst);
// update IncidenceMatrix
eqnslst1 = BackendDAETransform.collectVarEqns({i},{},mt,arrayLength(mt));
eqnslst1 = BackendDAETransform.collectVarEqns({i},{},mt,arrayLength(mt),arrayLength(m));
eqnslst1 = List.map1r(eqnslst1,arrayGet,imapIncRowEqn);
syst = BackendDAE.EQSYSTEM(v1,eqns,SOME(m),SOME(mt),matching,stateSets);
Debug.fcall(Flags.BLT_DUMP, print, "Update Incidence Matrix: ");
Expand Down

0 comments on commit 7023944

Please sign in to comment.