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

Commit

Permalink
update module sortEqnsandVars
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Mar 6, 2017
1 parent 4f66de9 commit 8f1fd56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4129,8 +4129,11 @@ algorithm
algorithm
(_, m, mT) := BackendDAEUtil.getIncidenceMatrix(syst, BackendDAE.ABSOLUTE(), SOME(functionTree));
//debug
//BackendDump.dumpIncidenceMatrix(m);
//BackendDump.dumpIncidenceMatrixT(mT);
if Flags.isSet(Flags.SORT_EQNS_AND_VARS) then
BackendDump.dumpIncidenceMatrix(m);
BackendDump.dumpIncidenceMatrixT(mT);
end if;

BackendDAE.VARIABLES(varArr = BackendDAE.VARIABLE_ARRAY(varOptArr = varOptArr, numberOfElements = nv)) := vars;
BackendDAE.EQUATION_ARRAY(equOptArr = equOptArr, numberOfElement = ne) := eqns;
//init weights
Expand All @@ -4152,18 +4155,22 @@ algorithm
//sort eqns
tplIndexWeight := list((i, w_eqns[i]) for i in 1:ne);
//sorted eqns
tplIndexWeight := List.sort(tplIndexWeight, Util.compareTuple2IntLt);
tplIndexWeight := List.sort(tplIndexWeight, Util.compareTuple2IntGt);
//new order eqns indexs
indexs := sortEqnsVarsWorkTpl(tplIndexWeight);
eqn_lst := list(BackendEquation.equationNth1(eqns, i) for i in indexs);
//new eqns
eqns := BackendEquation.listEquation(eqn_lst);
syst1.orderedEqs := eqns;
syst1.orderedVars := vars;

//debug
//(_, m, mT) := BackendDAEUtil.getIncidenceMatrix(syst1, BackendDAE.ABSOLUTE(), SOME(functionTree));
//BackendDump.dumpIncidenceMatrix(m);
//BackendDump.dumpIncidenceMatrixT(mT);
if Flags.isSet(Flags.SORT_EQNS_AND_VARS) then
(_, m, mT) := BackendDAEUtil.getIncidenceMatrix(syst1, BackendDAE.ABSOLUTE(), SOME(functionTree));
BackendDump.dumpIncidenceMatrix(m);
BackendDump.dumpIncidenceMatrixT(mT);
end if;

GC.free(w_vars);
GC.free(w_eqns);
then BackendDAEUtil.clearEqSyst(syst1);
Expand Down
6 changes: 3 additions & 3 deletions Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ constant DebugFlag CHECK_EXT_LIBS = DEBUG_FLAG(136, "buildExternalLibs", true,
Util.gettext("Use the autotools project in the Resources folder of the library to build missing external libraries."));
constant DebugFlag RUNTIME_STATIC_LINKING = DEBUG_FLAG(137, "runtimeStaticLinking", false,
Util.gettext("Use the static simulation runtime libraries (C++ simulation runtime)."));
constant DebugFlag SORT_EQNS_AND_VARS = DEBUG_FLAG(138, "sortEqnsAndVars", false,
Util.gettext("Heuristic sorting for equations and variables. Influenced: removeSimpleEquations and tearing.\nDeprecated flag: Use --preOptModules+=sortEqnsVars instead."));
constant DebugFlag SORT_EQNS_AND_VARS = DEBUG_FLAG(138, "dumpSortEqnsAndVars", false,
Util.gettext("Dumps debug output for the modules sortEqnsVars."));
constant DebugFlag DUMP_SIMPLIFY_LOOPS = DEBUG_FLAG(139, "dumpSimplifyLoops", false,
Util.gettext("Dump between steps of simplifyLoops"));
constant DebugFlag DUMP_RTEARING = DEBUG_FLAG(140, "dumpRecursiveTearing", false,
Expand Down Expand Up @@ -786,7 +786,7 @@ constant ConfigFlag PRE_OPT_MODULES = CONFIG_FLAG(12, "preOptModules",
("resolveLoops", Util.gettext("resolves linear equations in loops")),
("simplifyAllExpressions", Util.notrans("Does simplifications on all expressions.")),
("simplifyIfEquations", Util.gettext("Tries to simplify if equations by use of information from evaluated parameters.")),
("sortEqnsVars", Util.notrans("Heuristic sorting for equations and variables. This module requires +d=sortEqnsAndVars.")),
("sortEqnsVars", Util.notrans("Heuristic sorting for equations and variables.")),
("stateMachineElab", Util.gettext("Does the elaboration of state machines.")),
("unitChecking", Util.gettext("Does advanced unit checking which consists of two parts: 1. calculation of unspecified unit information for variables; 2. consistency check for all equations based on unit information. Please note: This module is still experimental.")),
("wrapFunctionCalls", Util.gettext("This module introduces variables for each function call and substitutes all these calls with the newly introduced variables."))
Expand Down

0 comments on commit 8f1fd56

Please sign in to comment.