@@ -55,6 +55,7 @@ import Expression;
5555import ExpressionDump ;
5656import ExpressionSolve ;
5757import ExpressionSimplify ;
58+ import GC ;
5859import Global ;
5960import HashSet ;
6061import HashTableExpToExp ;
@@ -2038,7 +2039,7 @@ protected
20382039 BackendDAE . EqSystem eqSys;
20392040 BackendDAE . Variables vars, pathVars;
20402041 list< BackendDAE . Var > varLst;
2041- list< BackendDAE . Equation > eqLst;
2042+ list< BackendDAE . Equation > eqLst, eqLst_all ;
20422043 BackendDAE . EquationArray eqs;
20432044 list< tuple< Boolean , String >> varAtts, eqAtts;
20442045 Integer numVars, varIdx;
@@ -2052,15 +2053,15 @@ algorithm
20522053 pathVars := BackendVariable . listVar1(List . map1(pathVarIdcs, BackendVariable . getVarAtIndexFirst, allVars));
20532054 pathVarIdxMap := listArray(List . map1(pathVarIdcs,Array . getIndexFirst,varMap));
20542055 cses := cseIn;
2056+ eqLst_all := BackendEquation . equationList(allEqs);
20552057
20562058 if BackendVariable . varsSize(pathVars) > 0 then
20572059 for partition in allPartitions loop
20582060 // print("partition "+stringDelimitList(List.map(partition, intString), ", ")+"\n");
20592061 // print("pathVarIdxMap "+stringDelimitList(List.map(List.map1(pathVarIdcs,Array.getIndexFirst,varMap), intString), ", ")+"\n");
20602062
20612063 // get only the partition equations
2062- eqLst := BackendEquation . equationList(allEqs);
2063- eqLst := List . map1(partition,List . getIndexFirst,eqLst);
2064+ eqLst := List . map1(partition,List . getIndexFirst,eqLst_all);
20642065 eqs := BackendEquation . listEquation(eqLst);
20652066
20662067 eqSys := BackendDAEUtil . createEqSystem(pathVars, eqs);
@@ -2078,12 +2079,13 @@ algorithm
20782079 if listLength(adjEqs)== 2 then
20792080 // print("varIdx1 "+intString(varIdx)+"\n");
20802081 // print("adjEqs "+stringDelimitList(List.map(adjEqs,intString),",")+"\n");
2081- adjEqs := List . map1(adjEqs,List . getIndexFirst,partition);
2082- adjEqs := List . map1(adjEqs, Array . getIndexFirst, eqMap);
2082+ adjEqs := list(arrayGet(eqMap,listGet(partition,eq)) for eq in adjEqs);
20832083 varIdx := arrayGet(pathVarIdxMap,idx);
20842084 cses := SHORTCUT_CSE (adjEqs,varIdx)::cses;
20852085 end if ;
20862086 end for ; // end the variables
2087+ GC . free(m);
2088+ GC . free(mT);
20872089 end for ; // end all partitions
20882090 // print("the SHORTPATH cses : \n"+stringDelimitList(List.map(cses, printCSE), "\n")+"\n");
20892091 end if ;
0 commit comments