Skip to content

Commit

Permalink
- remove transformDAE,mapTransformDAE,transformDAEWork,restartMatchin…
Browse files Browse the repository at this point in the history
…g from BackendDAEUtil.mo

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12371 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jul 30, 2012
1 parent 97174c4 commit 7c852ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 147 deletions.
131 changes: 0 additions & 131 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -8260,7 +8260,6 @@ algorithm
(optdae,Util.SUCCESS()) := preoptimiseDAE(inDAE,preOptModules);

// transformation phase (matching and sorting using a index reduction method
//sode := transformDAE(optdae,NONE(),matchingAlgorithm,daeHandler);
sode := reduceIndexDAE(optdae,NONE(),matchingAlgorithm,daeHandler);
Debug.fcall(Flags.BLT_DUMP, BackendDump.bltdump, ("bltdump",sode));

Expand Down Expand Up @@ -8346,138 +8345,9 @@ protected
algorithm
matchingAlgorithm := getMatchingAlgorithm(strmatchingAlgorithm);
indexReductionMethod := getIndexReductionMethod(strindexReductionMethod);
//outDAE := transformDAE(inDAE,inMatchingOptions,matchingAlgorithm,indexReductionMethod);
outDAE := reduceIndexDAE(inDAE,inMatchingOptions,matchingAlgorithm,indexReductionMethod);
end transformBackendDAE;

public function transformDAE
"function transformDAE
Run the matching Algorithm and the sorting algorithm.
In case of an DAE an DAE-Handler is used to reduce
the index of the dae."
input BackendDAE.BackendDAE inDAE;
input Option<MatchingOptions> inMatchingOptions;
input tuple<matchingAlgorithmFunc,String> matchingAlgorithm;
input tuple<StructurallySingularSystemHandlerFunc,String,stateDeselectionFunc,String> daeHandler;
output BackendDAE.BackendDAE outDAE;
protected
list<BackendDAE.EqSystem> systs;
BackendDAE.Shared shared;
algorithm
BackendDAE.DAE(systs,shared) := inDAE;
(systs,shared) := mapTransformDAE(systs,shared,inMatchingOptions,matchingAlgorithm,daeHandler,{});
outDAE := BackendDAE.DAE(systs,shared);
end transformDAE;

protected function mapTransformDAE
"function transformDAE
Run the matching Algorithm and the sorting algorithm.
In case of an DAE an DAE-Handler is used to reduce
the index of the dae."
input list<BackendDAE.EqSystem> isysts;
input BackendDAE.Shared ishared;
input Option<MatchingOptions> inMatchingOptions;
input tuple<matchingAlgorithmFunc,String> matchingAlgorithm;
input tuple<StructurallySingularSystemHandlerFunc,String,stateDeselectionFunc,String> daeHandler;
input list<BackendDAE.EqSystem> acc;
output list<BackendDAE.EqSystem> osysts;
output BackendDAE.Shared oshared;
algorithm
(osysts,oshared) := matchcontinue (isysts,ishared,inMatchingOptions,matchingAlgorithm,daeHandler,acc)
local
BackendDAE.EqSystem syst;
list<BackendDAE.EqSystem> systs;
BackendDAE.Shared shared;
case ({},_,_,_,_,_) then (listReverse(acc),ishared);
case (syst::systs,_,_,_,_,_)
equation
(syst,shared) = transformDAEWork(syst,ishared,inMatchingOptions,matchingAlgorithm,daeHandler);
(systs,shared) = mapTransformDAE(systs,shared,inMatchingOptions,matchingAlgorithm,daeHandler,syst::acc);
then (systs,shared);
end matchcontinue;
end mapTransformDAE;

protected function transformDAEWork
"function transformDAE
Run the matching Algorithm and the sorting algorithm.
In case of an DAE an DAE-Handler is used to reduce
the index of the dae."
input BackendDAE.EqSystem isyst;
input BackendDAE.Shared ishared;
input Option<MatchingOptions> inMatchingOptions;
input tuple<matchingAlgorithmFunc,String> matchingAlgorithm;
input tuple<StructurallySingularSystemHandlerFunc,String,stateDeselectionFunc,String> daeHandler;
output BackendDAE.EqSystem osyst;
output BackendDAE.Shared oshared;
algorithm
(osyst,oshared) := matchcontinue (isyst,ishared,inMatchingOptions,matchingAlgorithm,daeHandler)
local
String str,methodstr,mAmethodstr;
array<Integer> v1;
BackendDAE.StrongComponents comps;
MatchingOptions match_opts;
StructurallySingularSystemHandlerFunc daeHandlerfunc;
matchingAlgorithmFunc matchingAlgorithmfunc;
BackendDAE.EqSystem syst;
BackendDAE.Shared shared;
list<list<BackendDAE.Value>> icomps;
array<list<Integer>> mapEqnIncRow;
array<Integer> mapIncRowEqn;
BackendDAE.StructurallySingularSystemHandlerArg arg;

case (_,_,_,(matchingAlgorithmfunc,mAmethodstr),(daeHandlerfunc,methodstr,_,_))
equation
(syst,_,_,mapEqnIncRow,mapIncRowEqn) = getIncidenceMatrixScalar(isyst,ishared,BackendDAE.SOLVABLE());
match_opts = Util.getOptionOrDefault(inMatchingOptions,(BackendDAE.INDEX_REDUCTION(), BackendDAE.EXACT()));
// matching algorithm
arg = IndexReduction.getStructurallySingularSystemHandlerArg(syst,ishared,mapEqnIncRow,mapIncRowEqn);
(syst,shared,arg) = matchingAlgorithmfunc(syst,ishared, match_opts, daeHandlerfunc,arg);
Debug.execStat("transformDAE -> matchingAlgorithm " +& mAmethodstr +& " index Reduction Method " +& methodstr,BackendDAE.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
// sorting algorithm
(syst,_,_,mapEqnIncRow,mapIncRowEqn) = getIncidenceMatrixScalar(syst,shared,BackendDAE.NORMAL());
(syst as BackendDAE.EQSYSTEM(matching=BackendDAE.MATCHING(ass1=v1)),comps) = BackendDAETransform.strongComponentsScalar(syst, shared,mapEqnIncRow,mapIncRowEqn);
// if comps vector does not match to matching size
// restart the matching
(syst,shared) = restartMatching(not checkCompsMatching(comps,systemSize(syst)),syst, shared, match_opts, matchingAlgorithmfunc, daeHandlerfunc,arg);
Debug.execStat("transformDAE -> sort components",BackendDAE.RT_CLOCK_EXECSTAT_BACKEND_MODULES);
then (syst,shared);
else
equation
str = "Transformation Module failed!";
Error.addMessage(Error.INTERNAL_ERROR, {str});
then fail();
end matchcontinue;
end transformDAEWork;

protected function restartMatching
"Restarts matching if cond is true."
input Boolean cond;
input BackendDAE.EqSystem isyst;
input BackendDAE.Shared ishared;
input MatchingOptions opts;
input matchingAlgorithmFunc matchingAlgorithm;
input StructurallySingularSystemHandlerFunc daeHandler;
input BackendDAE.StructurallySingularSystemHandlerArg arg;
output BackendDAE.EqSystem osyst;
output BackendDAE.Shared oshared;
algorithm
(osyst,oshared) := match (cond,isyst,ishared,opts,matchingAlgorithm,daeHandler,arg)
local
BackendDAE.EqSystem syst;
BackendDAE.Shared shared;
array<list<Integer>> mapEqnIncRow;
array<Integer> mapIncRowEqn;
case (false,_,_,_,_,_,_) then (isyst,ishared);
case (true,_,_,_,_,_,_)
equation
(syst,_,_,mapEqnIncRow,mapIncRowEqn) = getIncidenceMatrixScalar(isyst,ishared,BackendDAE.SOLVABLE());
(syst,shared,_) = BackendDAETransform.matchingAlgorithm(syst, ishared, opts, daeHandler,arg);
(syst,_,_,mapEqnIncRow,mapIncRowEqn) = getIncidenceMatrixScalar(syst,shared,BackendDAE.NORMAL());
(syst,_) = BackendDAETransform.strongComponentsScalar(syst,shared,mapEqnIncRow,mapIncRowEqn);
then (syst,shared);
end match;
end restartMatching;

protected function reduceIndexDAE
"function reduceIndexDAE
Run the matching Algorithm.
Expand Down Expand Up @@ -8799,7 +8669,6 @@ algorithm
(optdae,Util.SUCCESS()) := preoptimiseDAE(inDAE,preOptModules);

// transformation phase (matching and sorting using a index reduction method
//sode := transformDAE(optdae,NONE(),matchingAlgorithm,daeHandler);
sode := reduceIndexDAE(optdae,NONE(),matchingAlgorithm,daeHandler);
Debug.fcall(Flags.DUMP_DAE_LOW, BackendDump.bltdump, ("bltdump",sode));

Expand Down
24 changes: 8 additions & 16 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -1423,10 +1423,10 @@ algorithm
print(str);
print(":");
dumpKind(kind);
print(" ");
print("(");
dumpFlow(flowPrefix);
print(" ");
dumpAttributes(dae_var_attr);
print(") ");
paths = DAEUtil.getElementSourceTypes(source);
paths_lst = List.map(paths, Absyn.pathString);
path_str = stringDelimitList(paths_lst, ", ");
Expand All @@ -1439,7 +1439,9 @@ algorithm
indx_str = intString(indx) "print \" \" & print comment_str & print \" former: \" & print old_name &" ;
str = dumpTypeStr(var_type);print( " type: "); print(str);
print(ComponentReference.printComponentRef2Str("", arrayDim));
print("(");
dumpAttributes(dae_var_attr);
print(") ");
print(" indx = ");
print(indx_str);
print("\n");
Expand Down Expand Up @@ -1475,10 +1477,10 @@ algorithm
print(str);
print(":");
dumpKind(kind);
print(" ");
print("(");
dumpFlow(flowPrefix);
print(" ");
dumpAttributes(dae_var_attr);
print(") ");
print(path_str);
indx_str = intString(indx) "print \" former: \" & print old_name &" ;
str = dumpTypeStr(var_type);print( " type: "); print(str);
Expand Down Expand Up @@ -1532,8 +1534,8 @@ public function dumpFlow
algorithm
_:=
match(flowPrefix)
case DAE.FLOW() equation print("flow=true"); then ();
case DAE.NON_FLOW() equation print("flow=false"); then ();
case DAE.FLOW() equation print("flow=true "); then ();
case DAE.NON_FLOW() equation print("flow=false "); then ();
case DAE.NON_CONNECTOR() equation print(""); then ();
end match;
end dumpFlow;
Expand All @@ -1555,7 +1557,6 @@ algorithm
then ();
case SOME(DAE.VAR_ATTR_REAL(min=(min,max),initial_=start,fixed=fixed,nominal=nominal,isProtected=isProtected,finalPrefix=finalPrefix,distributionOption=dist))
equation
print("(");
dumpOptExpression(min,"min");
dumpOptExpression(max,"max");
dumpOptExpression(start,"start");
Expand All @@ -1564,55 +1565,46 @@ algorithm
dumpOptBoolean(isProtected,"protected");
dumpOptBoolean(finalPrefix,"final");
dumpOptDistribution(dist);
print(") ");
then ();
case SOME(DAE.VAR_ATTR_INT(min=(NONE(),NONE()),initial_=NONE(),fixed=NONE(),isProtected=NONE(),finalPrefix=NONE(),distributionOption=NONE()))
then ();
case SOME(DAE.VAR_ATTR_INT(min=(min,max),initial_=start,fixed=fixed,isProtected=isProtected,finalPrefix=finalPrefix,distributionOption=dist))
equation
print("(");
dumpOptExpression(min,"min");
dumpOptExpression(max,"max");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptBoolean(isProtected,"protected");
dumpOptBoolean(finalPrefix,"final");
dumpOptDistribution(dist);
print(") ");
then ();
case SOME(DAE.VAR_ATTR_BOOL(initial_=NONE(),fixed=NONE(),isProtected=NONE(),finalPrefix=NONE()))
then ();
case SOME(DAE.VAR_ATTR_BOOL(initial_=start,fixed=fixed,isProtected=isProtected,finalPrefix=finalPrefix))
equation
print("(");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptBoolean(isProtected,"protected");
dumpOptBoolean(finalPrefix,"final");
print(") ");
then ();
case SOME(DAE.VAR_ATTR_STRING(initial_=NONE(),isProtected=NONE(),finalPrefix=NONE()))
then ();
case SOME(DAE.VAR_ATTR_STRING(initial_=start,isProtected=isProtected,finalPrefix=finalPrefix))
equation
print("(");
dumpOptExpression(start,"start");
dumpOptBoolean(isProtected,"protected");
dumpOptBoolean(finalPrefix,"final");
print(") ");
then ();
case SOME(DAE.VAR_ATTR_ENUMERATION(min=(NONE(),NONE()),start=NONE(),fixed=NONE(),isProtected=NONE(),finalPrefix=NONE()))
then ();
case SOME(DAE.VAR_ATTR_ENUMERATION(min=(min,max),start=start,fixed=fixed,isProtected=isProtected,finalPrefix=finalPrefix))
equation
print("(");
dumpOptExpression(min,"min");
dumpOptExpression(max,"max");
dumpOptExpression(start,"start");
dumpOptExpression(fixed,"fixed");
dumpOptBoolean(isProtected,"protected");
dumpOptBoolean(finalPrefix,"final");
print(") ");
then ();
else ();
end match;
Expand Down

0 comments on commit 7c852ac

Please sign in to comment.