Skip to content

Commit

Permalink
- replace evalAllParams-implementation
Browse files Browse the repository at this point in the history
- dump bipartite graphs for sccs after backend
  • Loading branch information
vwaurich authored and unknown committed Nov 19, 2015
1 parent 4b930ae commit c7b7e74
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
14 changes: 8 additions & 6 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -3695,6 +3695,7 @@ public function dumpBipartiteGraphStrongComponent"dumps a bipartite graph of an
waurich: TUD 2014-09"
input BackendDAE.StrongComponent inComp;
input BackendDAE.EqSystem eqSys;
input Option<DAE.FunctionTree> funcs;
input String name;
protected
BackendDAE.EquationArray eqs;
Expand All @@ -3705,16 +3706,17 @@ algorithm
BackendDAE.EQSYSTEM(orderedVars=vars, orderedEqs=eqs) := eqSys;
varLst := BackendVariable.varList(vars);
eqLst := BackendEquation.equationList(eqs);
dumpBipartiteGraphStrongComponent1(inComp,eqLst,varLst,name);
dumpBipartiteGraphStrongComponent1(inComp,eqLst,varLst,funcs,name);
end dumpBipartiteGraphStrongComponent;

public function dumpBipartiteGraphStrongComponent1"helper function for dumpBipartiteGraphStrongComponent which handles either an equationsystem or a torn system"
input BackendDAE.StrongComponent inComp;
input list<BackendDAE.Equation> eqsIn;
input list<BackendDAE.Var> varsIn;
input Option<DAE.FunctionTree> funcs;
input String graphName;
algorithm
() := matchcontinue(inComp,eqsIn,varsIn,graphName)
() := matchcontinue(inComp,eqsIn,varsIn,funcs,graphName)
local
Integer numEqs, numVars, compIdx;
list<Boolean> tornInfo;
Expand All @@ -3728,7 +3730,7 @@ algorithm
BackendDAE.IncidenceMatrix m,mT;
list<BackendDAE.Equation> compEqLst;
list<BackendDAE.Var> compVarLst;
case((BackendDAE.EQUATIONSYSTEM(eqns=eqIdcs,vars=varIdcs)),_,_,_)
case((BackendDAE.EQUATIONSYSTEM(eqns=eqIdcs,vars=varIdcs)),_,_,_,_)
equation
compEqLst = List.map1(eqIdcs,List.getIndexFirst,eqsIn);
compVarLst = List.map1(varIdcs,List.getIndexFirst,varsIn);
Expand All @@ -3737,13 +3739,13 @@ algorithm

numEqs = listLength(compEqLst);
numVars = listLength(compVarLst);
(m,_) = BackendDAEUtil.incidenceMatrixDispatch(compVars,compEqs, BackendDAE.NORMAL());
(_,m,_,_,_) = BackendDAEUtil.getIncidenceMatrixScalar(BackendDAE.EQSYSTEM(compVars,compEqs,NONE(),NONE(),BackendDAE.NO_MATCHING(),{},BackendDAE.UNKNOWN_PARTITION(),BackendEquation.emptyEqns()), BackendDAE.SOLVABLE(), funcs);

varAtts = List.threadMap(List.fill(false,numVars),List.fill("",numVars),Util.makeTuple);
eqAtts = List.threadMap(List.fill(false,numEqs),List.fill("",numEqs),Util.makeTuple);
dumpBipartiteGraphStrongComponent2(compVars,compEqs,m,varAtts,eqAtts,"rL_eqSys_"+graphName);
then ();
case((BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(residualequations=rEqIdcs,tearingvars=tVarIdcs,otherEqnVarTpl=otherEqnVarTplIdcs))),_,_,_)
case((BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(residualequations=rEqIdcs,tearingvars=tVarIdcs,otherEqnVarTpl=otherEqnVarTplIdcs))),_,_,_,_)
equation
//gather equations ans variables
eqIdcs = List.map(otherEqnVarTplIdcs,Util.tuple21);
Expand All @@ -3758,7 +3760,7 @@ algorithm
// get incidence matrix
numEqs = listLength(compEqLst);
numVars = listLength(compVarLst);
m = BackendDAEUtil.incidenceMatrixDispatch(compVars,compEqs, BackendDAE.NORMAL());
(_,m,_,_,_) = BackendDAEUtil.getIncidenceMatrixScalar(BackendDAE.EQSYSTEM(compVars,compEqs,NONE(),NONE(),BackendDAE.NO_MATCHING(),{},BackendDAE.UNKNOWN_PARTITION(),BackendEquation.emptyEqns()), BackendDAE.SOLVABLE(), funcs);

// add tearing info to graph object and dump graph
addInfo = List.map(varIdcs,intString);// the DAE idcs for the vars
Expand Down
28 changes: 26 additions & 2 deletions Compiler/BackEnd/EvaluateParameter.mo
Expand Up @@ -190,6 +190,26 @@ algorithm
end if;
end evaluateReplaceProtectedFinalEvaluateParameters;

public function evaluateAllParameters "author: waurich
Evaluates all parameters and replaces them with their value, if possible."
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE;
protected
BackendVarTransform.VariableReplacements repl;
algorithm
if Flags.isSet(Flags.EVAL_ALL_PARAMS) then
BackendDump.dumpBackendDAE(inDAE,"INDAE");
(outDAE,repl) := evaluateParameters(inDAE,BackendVariable.isParam);
if not BackendVarTransform.isReplacementEmpty(repl) then
BackendVarTransform.dumpReplacements(repl);
outDAE := replaceEvaluatedParametersEqns(outDAE, repl);
end if;
BackendDump.dumpBackendDAE(outDAE,"OUTDAE");
else
outDAE := inDAE;
end if;
end evaluateAllParameters;

/*
* protected section
*
Expand Down Expand Up @@ -1122,11 +1142,13 @@ algorithm
end replaceEvaluatedParametersSystemEqns;



/*
//------------------------------------------
// evaluate all parameters
//------------------------------------------
public function evaluateAllParameters
public function evaluateAllParameters_obsolete
"author Waurich TUD
evaluates and replaces all parameters"
input BackendDAE.BackendDAE inDAE;
Expand All @@ -1151,6 +1173,7 @@ protected
list<list<Integer>> comps;
algorithm
if Flags.isSet(Flags.EVAL_ALL_PARAMS) then
print("the old evalAllParams\n");
BackendDAE.DAE (systs, shared as BackendDAE.SHARED(knownVars=knvars, initialEqs=initEqs, functionTree=functionTree)) := inDAE;
knVarsLst := BackendVariable.varList(knvars);
//BackendDump.dumpVarList(knVarsLst,"knVarsLst");
Expand Down Expand Up @@ -1215,7 +1238,7 @@ algorithm
else
outDAE := inDAE;
end if;
end evaluateAllParameters;
end evaluateAllParameters_obsolete;
protected function getParameterBindingReplacements "gathers replacements for the vars with binding"
Expand Down Expand Up @@ -1289,6 +1312,7 @@ algorithm
crefs := BackendEquation.equationCrefs(eq);
b := List.fold(List.map2(crefs,BackendVariable.existsVar,knownVars,false),boolAnd,true);
end isParameterEquation;
*/

annotation(__OpenModelica_Interface="backend");
end EvaluateParameter;
2 changes: 1 addition & 1 deletion Compiler/BackEnd/HpcOmEqSystems.mo
Expand Up @@ -2323,7 +2323,7 @@ algorithm
//print("otherSimEqSysIdcs "+stringDelimitList(List.map(otherSimEqSysIdcs,intString),",")+"\n");

// dump graphs
BackendDump.dumpBipartiteGraphStrongComponent1(comp,eqsIn,varsIn,"tornSys_bipartite_"+intString(compIdxIn));
BackendDump.dumpBipartiteGraphStrongComponent1(comp,eqsIn,varsIn,NONE(),"tornSys_bipartite_"+intString(compIdxIn));
BackendDump.dumpDAGStrongComponent(graph,meta,"tornSys_matched_"+intString(compIdxIn));

//GRS
Expand Down
10 changes: 9 additions & 1 deletion Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -2707,6 +2707,10 @@ algorithm
if Flags.isSet(Flags.FAILTRACE) then
Debug.trace("function createOdeSystem create continuous system.\n");
end if;
if Flags.isSet(Flags.GRAPHML) then
BackendDump.dumpBipartiteGraphStrongComponent1(inComp,BackendEquation.equationList(eqns),BackendVariable.varList(vars), SOME(BackendDAEUtil.getFunctions(ishared)),"BIPARITEGRPAH_LS_"+intString(iuniqueEqIndex));
end if;

// print("\ncreateOdeSystem -> Cont sys: ...\n");
// extract the variables and equations of the block.
(eqn_lst, var_lst,_) = BackendDAETransform.getEquationAndSolvedVar(comp, eqns, vars);
Expand All @@ -2726,8 +2730,12 @@ algorithm

// TORNSYSTEM

case (_, _, BackendDAE.TORNSYSTEM(strictTearingSet, casualTearingSet, linear=b, mixedSystem=mixedSystem))
case (BackendDAE.EQSYSTEM(orderedVars=vars, orderedEqs=eqns), _, BackendDAE.TORNSYSTEM(strictTearingSet, casualTearingSet, linear=b, mixedSystem=mixedSystem))
equation
if Flags.isSet(Flags.GRAPHML) then
BackendDump.dumpBipartiteGraphStrongComponent1(inComp,BackendEquation.equationList(eqns),BackendVariable.varList(vars), SOME(BackendDAEUtil.getFunctions(ishared)),"BIPARITEGRPAH_LS_"+intString(iuniqueEqIndex));
end if;

(equations_, uniqueEqIndex, tempvars) = createTornSystem(b, skipDiscInAlgorithm, strictTearingSet, casualTearingSet, isyst, ishared, iuniqueEqIndex, mixedSystem, itempvars);
tmpEqSccMapping = appendSccIdx(uniqueEqIndex-1, isccIndex, ieqSccMapping);
tmpBackendMapping = iBackendMapping;
Expand Down

0 comments on commit c7b7e74

Please sign in to comment.