Skip to content

Commit fc795eb

Browse files
author
Jens Frenkel
committed
- fix test
- small improvements to OnRelaxation git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14118 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 93b6717 commit fc795eb

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

Compiler/BackEnd/BackendDump.mo

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,55 +2249,60 @@ public function dumpMarkedEqns
22492249
input BackendDAE.EqSystem syst;
22502250
input list<Integer> inIntegerLst;
22512251
output String outString;
2252+
protected
2253+
BackendDAE.EquationArray eqns;
2254+
list<Integer> sortedeqns;
22522255
algorithm
2253-
outString := match (syst,inIntegerLst)
2254-
local
2255-
String s1,s2,s3,res;
2256-
Integer e_1,e;
2257-
BackendDAE.Equation eqn;
2258-
BackendDAE.EquationArray eqns;
2259-
list<Integer> es;
2260-
case (_,{}) then "";
2261-
case (BackendDAE.EQSYSTEM(orderedEqs = eqns),(e :: es))
2262-
equation
2263-
s1 = dumpMarkedEqns(syst, es);
2264-
e_1 = e - 1;
2265-
eqn = BackendDAEUtil.equationNth(eqns, e_1);
2266-
s2 = equationStr(eqn);
2267-
s3 = intString(e);
2268-
res = stringAppendList({s3,": ",s2,";\n",s1});
2269-
then
2270-
res;
2271-
end match;
2256+
BackendDAE.EQSYSTEM(orderedEqs = eqns) := syst;
2257+
outString := List.fold1(inIntegerLst,dumpMarkedEqns1,eqns,"");
22722258
end dumpMarkedEqns;
22732259

2260+
protected function dumpMarkedEqns1
2261+
input Integer e;
2262+
input BackendDAE.EquationArray eqns;
2263+
input String inS;
2264+
output String outS;
2265+
protected
2266+
String s1,s2,s3;
2267+
Integer e_1;
2268+
BackendDAE.Equation eqn;
2269+
algorithm
2270+
e_1 := e - 1;
2271+
eqn := BackendDAEUtil.equationNth(eqns, e_1);
2272+
s2 := equationStr(eqn);
2273+
s3 := intString(e);
2274+
outS := stringAppendList({inS,s3,": ",s2,";\n"});
2275+
end dumpMarkedEqns1;
2276+
22742277
public function dumpMarkedVars
22752278
"Dumps only the variable names given as list of indexes to a string."
22762279
input BackendDAE.EqSystem syst;
22772280
input list<Integer> inIntegerLst;
22782281
output String outString;
2282+
protected
2283+
BackendDAE.Variables vars;
2284+
list<String> slst;
22792285
algorithm
2280-
outString:=
2281-
match (syst,inIntegerLst)
2282-
local
2283-
String s1,s2,res,s3;
2284-
Integer v;
2285-
DAE.ComponentRef cr;
2286-
BackendDAE.Variables vars;
2287-
list<Integer> vs;
2288-
case (_,{}) then "";
2289-
case (BackendDAE.EQSYSTEM(orderedVars = vars),(v :: vs))
2290-
equation
2291-
s1 = dumpMarkedVars(syst, vs);
2292-
BackendDAE.VAR(varName = cr) = BackendVariable.getVarAt(vars, v);
2293-
s2 = ComponentReference.printComponentRefStr(cr);
2294-
s3 = intString(v);
2295-
res = stringAppendList({s2,"(",s3,"), ",s1});
2296-
then
2297-
res;
2298-
end match;
2286+
BackendDAE.EQSYSTEM(orderedVars = vars) := syst;
2287+
slst := List.map1(inIntegerLst,dumpMarkedVars1,vars);
2288+
outString := stringDelimitList(slst,", ");
22992289
end dumpMarkedVars;
23002290

2291+
protected function dumpMarkedVars1
2292+
"Dumps only the variable names given as list of indexes to a string."
2293+
input Integer v;
2294+
input BackendDAE.Variables vars;
2295+
output String outS;
2296+
protected
2297+
String s1,s2,s3;
2298+
DAE.ComponentRef cr;
2299+
algorithm
2300+
BackendDAE.VAR(varName = cr) := BackendVariable.getVarAt(vars, v);
2301+
s2 := ComponentReference.printComponentRefStr(cr);
2302+
s3 := intString(v);
2303+
outS := stringAppendList({s2,"(",s3,")"});
2304+
end dumpMarkedVars1;
2305+
23012306
public function dumpComponentsGraphStr
23022307
"Dumps the assignment graph used to determine strong
23032308
components to format suitable for Mathematica"

Compiler/BackEnd/OnRelaxation.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ algorithm
241241
// transform to nonscalar
242242
ass1 = BackendDAETransform.varAssignmentNonScalar(1,size,ass1,mapIncRowEqn,{});
243243
ass22 = BackendDAETransform.eqnAssignmentNonScalar(1,arrayLength(mapEqnIncRow),mapEqnIncRow,ass2,{});
244-
eorphans = List.unique(List.map1r(eorphans,arrayGet,mapIncRowEqn));
244+
eorphans = List.uniqueIntN(List.map1r(eorphans,arrayGet,mapIncRowEqn),arrayLength(mapIncRowEqn));
245245
(subsyst,m,mt) = BackendDAEUtil.getIncidenceMatrix(subsyst, BackendDAE.ABSOLUTE());
246246
// BackendDump.dumpIncidenceMatrix(m);
247247
// BackendDump.dumpIncidenceMatrixT(mt);
@@ -585,7 +585,7 @@ algorithm
585585
elst = List.select1(List.flatten(List.map1r(rlst,arrayGet,mt)),intGt,0);
586586
// print("Search for " +& intString(o) +& " Parnters in: " +& stringDelimitList(List.map(elst,intString),", ") +& "\n");
587587
partner = List.select1(elst,isResOrphan,ass2);
588-
partner = List.unique(List.removeOnTrue(o, intEq, partner));
588+
partner = List.uniqueIntN(List.removeOnTrue(o, intEq, partner),arrayLength(colummarks));
589589
List.map2_0(partner,doMark,colummarks,mark);
590590
// print("Found for " +& intString(o) +& " Parnters: " +& stringDelimitList(List.map(partner,intString),", ") +& "\n");
591591
// BackendDump.debuglst((rlst,intString,", ","\n"));

0 commit comments

Comments
 (0)