Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Mar 28, 2017
1 parent d379a34 commit 803f52c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 39 deletions.
52 changes: 23 additions & 29 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,7 @@ algorithm
then varIxs;
else {};
end matchcontinue;

(outIntegerLst,rowSize) := matchcontinue (inEquation)
local
AvlSetInt.Tree lst1,lst2,res;
Expand Down Expand Up @@ -2593,32 +2594,31 @@ public function incidenceRowExp "author: PA
input BackendDAE.IndexType inIndexType;
output AvlSetInt.Tree outIntegerLst;
algorithm
outIntegerLst := match (inExp, inVariables, inIntegerLst, functionTree, inIndexType)
outIntegerLst := match inIndexType
local
AvlSetInt.Tree vallst;

case (_, _, _, _, BackendDAE.SPARSE()) equation
case BackendDAE.SPARSE() equation
(_, (_, vallst)) = Expression.traverseExpTopDown(inExp, traversingincidenceRowExpFinderwithInput, (inVariables, inIntegerLst));
then vallst;

case (_, _, _, _, BackendDAE.SOLVABLE()) equation
case BackendDAE.SOLVABLE() equation
(_, (_, vallst, _)) = Expression.traverseExpTopDown(inExp, traversingincidenceRowExpSolvableFinder, (inVariables, inIntegerLst, functionTree));
then vallst;

case (_, _, _, _, BackendDAE.BASECLOCK_IDX()) equation
case BackendDAE.BASECLOCK_IDX() equation
(_, (_, vallst)) = Expression.traverseExpTopDown(inExp, traversingIncidenceRowExpFinderBaseClock, (inVariables, inIntegerLst));
then vallst;

case (_, _, _, _, BackendDAE.SUBCLOCK_IDX()) equation
case BackendDAE.SUBCLOCK_IDX() equation
(_, (_, vallst)) = Expression.traverseExpTopDown(inExp, traversingIncidenceRowExpFinderSubClock, (inVariables, inIntegerLst));
then vallst;

else
equation
(_, (_, vallst)) = Expression.traverseExpTopDown(inExp, traversingincidenceRowExpFinder, (inVariables, inIntegerLst));
// only absolute indexes?
vallst = applyIndexType(vallst, inIndexType);
then vallst;
else equation
(_, (_, vallst)) = Expression.traverseExpTopDown(inExp, traversingincidenceRowExpFinder, (inVariables, inIntegerLst));
// only absolute indexes?
vallst = applyIndexType(vallst, inIndexType);
then vallst;
end match;
end incidenceRowExp;

Expand Down Expand Up @@ -2816,7 +2816,7 @@ public function traversingincidenceRowExpFinder "
output tuple<BackendDAE.Variables,AvlSetInt.Tree> outTpl;
algorithm
(outExp,cont,outTpl) := matchcontinue(inExp,inTpl)
local
local
list<Integer> p;
AvlSetInt.Tree pa,res;
DAE.ComponentRef cr;
Expand Down Expand Up @@ -6995,10 +6995,13 @@ algorithm
//List.map_0(args,BackendDump.SSSHandlerArgString);

// do state selection
BackendDAE.DAE(systs,shared) := stateDeselectionDAE(causalized,outDAE,args,stateDeselection);
if causalized then
BackendDAE.DAE(systs,shared) := stateDeselectionDAE(outDAE, args, stateDeselection);
end if;

// sort assigned equations to blt form
systs := mapSortEqnsDAE(systs,shared);
outDAE := BackendDAE.DAE(systs,shared);
systs := mapSortEqnsDAE(systs, shared);
outDAE := BackendDAE.DAE(systs, shared);
end causalizeDAE;

protected function mapCausalizeDAE "
Expand Down Expand Up @@ -7098,10 +7101,6 @@ algorithm
end causalizeDAEWork;

protected function stateDeselectionDAE
"Run the matching Algorithm.
In case of an DAE an DAE-Handler is used to reduce
the index of the dae."
input Boolean causalized;
input BackendDAE.BackendDAE inDAE;
input list<Option<BackendDAE.StructurallySingularSystemHandlerArg>> args;
input tuple<BackendDAEFunc.StructurallySingularSystemHandlerFunc,String,BackendDAEFunc.stateDeselectionFunc,String> stateDeselection;
Expand All @@ -7110,14 +7109,10 @@ protected
String methodstr;
BackendDAEFunc.stateDeselectionFunc sDfunc;
algorithm
if causalized then
// do state selection
(_, _, sDfunc, methodstr) := stateDeselection;
outDAE := sDfunc(inDAE, args);
//execStat("transformDAE -> state selection " + methodstr);
else
outDAE := inDAE;
end if;
// do state selection
(_, _, sDfunc, methodstr) := stateDeselection;
outDAE := sDfunc(inDAE, args);
//execStat("transformDAE -> state selection " + methodstr);
end stateDeselectionDAE;

protected function mapSortEqnsDAE "Run Tarjan's Algorithm."
Expand Down Expand Up @@ -7200,8 +7195,7 @@ algorithm
outDAE := causalizeDAE(outDAE, SOME((BackendDAE.NO_INDEX_REDUCTION(), BackendDAE.EXACT())), inMatchingAlgorithm, inDAEHandler, false);
execStat("postOpt " + (if debug then "causalize " else "") + moduleStr);
if Flags.isSet(Flags.OPT_DAE_DUMP) then
print("\npost-optimization module " + moduleStr + ":\n\n");
BackendDump.printBackendDAE(outDAE);
BackendDump.dumpBackendDAE(outDAE, "post-optimization module " + moduleStr);
end if;
else
execStat("<failed> postOpt " + moduleStr);
Expand Down
14 changes: 6 additions & 8 deletions Compiler/BackEnd/Initialization.mo
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ algorithm
execStat("inlineWhenForInitialization (initialization)");

(dae, initVars, outPrimaryParameters, outAllPrimaryParameters, outGlobalKnownVars) := selectInitializationVariablesDAE(dae);
// if Flags.isSet(Flags.DUMP_INITIAL_SYSTEM) then
// BackendDump.dumpVarList(outPrimaryParameters, "selected primary parameters");
// BackendDump.dumpVarList(outAllPrimaryParameters, "selected all primary parameters");
// end if;
//if Flags.isSet(Flags.DUMP_INITIAL_SYSTEM) then
// BackendDump.dumpVarList(outPrimaryParameters, "selected primary parameters");
// BackendDump.dumpVarList(outAllPrimaryParameters, "selected all primary parameters");
//end if;
execStat("selectInitializationVariablesDAE (initialization)");

hs := collectPreVariables(dae);
Expand Down Expand Up @@ -177,8 +177,7 @@ algorithm
// split the initial system into independend subsystems
initdae := BackendDAE.DAE({initsyst}, shared);
if Flags.isSet(Flags.OPT_DAE_DUMP) then
print(stringAppendList({"\ncreated initial system:\n\n"}));
BackendDump.printBackendDAE(initdae);
BackendDump.dumpBackendDAE(initdae, "created initial system");
end if;

if Flags.isSet(Flags.PARTITION_INITIALIZATION) then
Expand All @@ -188,8 +187,7 @@ algorithm
end if;

if Flags.isSet(Flags.OPT_DAE_DUMP) then
print(stringAppendList({"\npartitioned initial system:\n\n"}));
BackendDump.printBackendDAE(initdae);
BackendDump.dumpBackendDAE(initdae, "partitioned initial system");
end if;
// initdae := BackendDAE.DAE({initsyst}, shared);

Expand Down
3 changes: 1 addition & 2 deletions Compiler/SimCode/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6354,8 +6354,7 @@ algorithm
// startValueEquationsTmp2 = listAppend(startValueEquationsTmp2, startValueEquationsTmp);

(simeqns1, uniqueEqIndex) = List.mapFold(startValueEquationsTmp2, dlowEqToSimEqSystem, uniqueEqIndex);
then
((uniqueEqIndex, listAppend(simeqns1, simeqns)));
then ((uniqueEqIndex, listAppend(simeqns1, simeqns)));

else equation
Error.addInternalError("function createStartValueEquations failed", sourceInfo());
Expand Down

0 comments on commit 803f52c

Please sign in to comment.