Skip to content

Commit

Permalink
- improve tearing var selection
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12543 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Aug 16, 2012
1 parent f81bd5a commit 25ab8c1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -9748,7 +9748,7 @@ algorithm
Debug.fcall(Flags.TEARING_DUMP, BackendDump.debuglst,(tvars,intString,", ","\nResidualEquations:\n"));
Debug.fcall(Flags.TEARING_DUMP, BackendDump.debuglst,(residual,intString,", ","\n"));
// subsyst := BackendDAEUtil.setEqSystemMatching(subsyst,BackendDAE.MATCHING(ass1,ass2,{}));
// IndexReduction.dumpSystemGraphML(subsyst,shared,NONE(),"TornSystem" +& intString(size) +& ".graphml");
// IndexReduction.dumpSystemGraphML(subsyst,ishared,NONE(),"TornSystem" +& intString(size) +& ".graphml");
// check if tearing make sense
tornsize := listLength(tvars);
true := intLt(tornsize,size-1);
Expand Down Expand Up @@ -10206,6 +10206,7 @@ algorithm
points = List.fold2(states, calcVarWights,mt,ass2,points);
eqns = Matching.getUnassigned(arrayLength(m),ass2,{});
points = List.fold2(eqns,addEqnWights,m,ass1,points);
points = List.fold1(states,discriminateDiscrete,vars,points);
//points = List.fold2(states,addOneEdgeEqnWights,(m,mt),ass1,points);
Debug.fcall(Flags.TEARING_DUMP, BackendDump.dumpMatching,points);
tvar = selectVarWithMostPoints(states,points,-1,-1);
Expand All @@ -10224,6 +10225,23 @@ algorithm
end matchcontinue;
end selectTearingVar;

protected function discriminateDiscrete
input Integer v;
input BackendDAE.Variables vars;
input array<Integer> iPoints;
output array<Integer> oPoints;
protected
Integer p;
Boolean b;
BackendDAE.Var var;
algorithm
var := BackendVariable.getVarAt(vars, v);
b := BackendVariable.isVarDiscrete(var);
p := iPoints[v];
p := Util.if_(b,intDiv(p,10),p);
oPoints := arrayUpdate(iPoints,v,p);
end discriminateDiscrete;

protected function selectVarWithMostEqnsOneEdge
input list<Integer> vars;
input array<Integer> ass1;
Expand Down

0 comments on commit 25ab8c1

Please sign in to comment.