Skip to content

Commit bbce7fe

Browse files
committed
Adapted optimization modules for Jacobians
1 parent e7e6f99 commit bbce7fe

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

Compiler/BackEnd/BackendDAEUtil.mo

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6978,42 +6978,39 @@ end postOptimizeDAE;
69786978
// end match;
69796979
// end countComponents;
69806980

6981-
public function getSolvedSystemforJacobians
6982-
" Run the equation system pipeline."
6981+
public function getSolvedSystemforJacobians "Run the equation system pipeline."
69836982
input BackendDAE.BackendDAE inDAE;
69846983
input Option<list<String>> strPreOptModules;
6985-
input Option<String> strmatchingAlgorithm;
6986-
input Option<String> strdaeHandler;
6987-
input Option<list<String>> strpostOptModules;
6988-
output BackendDAE.BackendDAE outSODE;
6984+
input Option<String> strMatchingAlgorithm;
6985+
input Option<String> strDAEHandler;
6986+
input Option<list<String>> strPostOptModules;
6987+
output BackendDAE.BackendDAE outDAE;
69896988
protected
6990-
BackendDAE.BackendDAE dae,optdae,sode;
6989+
BackendDAE.BackendDAE dae;
69916990
list<tuple<BackendDAEFunc.preOptimizationDAEModule,String,Boolean>> preOptModules;
69926991
list<tuple<BackendDAEFunc.postOptimizationDAEModule,String,Boolean>> postOptModules;
69936992
tuple<BackendDAEFunc.StructurallySingularSystemHandlerFunc,String,BackendDAEFunc.stateDeselectionFunc,String> daeHandler;
69946993
tuple<BackendDAEFunc.matchingAlgorithmFunc,String> matchingAlgorithm;
69956994
algorithm
69966995
preOptModules := getPreOptModules(strPreOptModules);
6997-
postOptModules := getPostOptModules(strpostOptModules);
6998-
matchingAlgorithm := getMatchingAlgorithm(strmatchingAlgorithm);
6999-
daeHandler := getIndexReductionMethod(strdaeHandler);
6996+
postOptModules := getPostOptModules(strPostOptModules);
6997+
matchingAlgorithm := getMatchingAlgorithm(strMatchingAlgorithm);
6998+
daeHandler := getIndexReductionMethod(strDAEHandler);
70006999

70017000
//fcall2(Flags.DUMP_DAE_LOW, BackendDump.dumpBackendDAE, inDAE, "dumpdaelow");
70027001
// pre optimisation phase
7003-
_ := traverseBackendDAEExps(inDAE,ExpressionSimplify.simplifyTraverseHelper,0) "simplify all expressions";
7004-
optdae := preOptimizeDAE(inDAE,preOptModules);
7002+
dae := preOptimizeDAE(inDAE, preOptModules);
70057003

70067004
// transformation phase (matching and sorting using a index reduction method
7007-
sode := causalizeDAE(optdae,NONE(),matchingAlgorithm,daeHandler,true);
7008-
//fcall(Flags.DUMP_DAE_LOW, BackendDump.bltdump, ("bltdump",sode));
7005+
dae := causalizeDAE(dae, NONE(), matchingAlgorithm, daeHandler, true);
7006+
//fcall(Flags.DUMP_DAE_LOW, BackendDump.bltdump, ("bltdump", dae));
70097007

70107008
// post-optimization phase
7011-
outSODE := postOptimizeDAE(sode,postOptModules,matchingAlgorithm,daeHandler);
7012-
_ := traverseBackendDAEExps(outSODE,ExpressionSimplify.simplifyTraverseHelper,0) "simplify all expressions";
7009+
outDAE := postOptimizeDAE(dae, postOptModules, matchingAlgorithm, daeHandler);
70137010

7014-
//fcall2(Flags.DUMP_INDX_DAE, BackendDump.dumpBackendDAE, outSODE, "dumpindxdae");
7015-
//bcall(Flags.isSet(Flags.DUMP_BACKENDDAE_INFO) or Flags.isSet(Flags.DUMP_STATESELECTION_INFO) or Flags.isSet(Flags.DUMP_DISCRETEVARS_INFO), BackendDump.dumpCompShort, outSODE);
7016-
//fcall2(Flags.DUMP_EQNINORDER, BackendDump.dumpEqnsSolved, outSODE, "system for jacobians");
7011+
//fcall2(Flags.DUMP_INDX_DAE, BackendDump.dumpBackendDAE, outDAE, "dumpindxdae");
7012+
//bcall(Flags.isSet(Flags.DUMP_BACKENDDAE_INFO) or Flags.isSet(Flags.DUMP_STATESELECTION_INFO) or Flags.isSet(Flags.DUMP_DISCRETEVARS_INFO), BackendDump.dumpCompShort, outDAE);
7013+
//fcall2(Flags.DUMP_EQNINORDER, BackendDump.dumpEqnsSolved, outDAE, "system for jacobians");
70177014
end getSolvedSystemforJacobians;
70187015

70197016
/*************************************************
@@ -7178,6 +7175,7 @@ algorithm
71787175
(BackendDAEOptimize.removeUnusedVariables, "removeUnusedVariables", false),
71797176
(BackendDAEOptimize.replaceEdgeChange, "replaceEdgeChange", false),
71807177
(BackendDAEOptimize.residualForm, "residualForm", false),
7178+
(BackendDAEOptimize.simplifyAllExpressions, "simplifyAllExpressions", false),
71817179
(BackendDAEOptimize.simplifyIfEquations, "simplifyIfEquations", false),
71827180
(BackendDAEOptimize.sortEqnsVars, "sortEqnsVars", false),
71837181
(BackendDump.dumpDAE, "dumpDAE", false),

Compiler/BackEnd/SymbolicJacobian.mo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,10 @@ algorithm
18231823
end if;
18241824

18251825
backendDAE2 = BackendDAEUtil.getSolvedSystemforJacobians(backendDAE,
1826-
SOME({"evalFunc","removeEqualFunctionCalls","removeSimpleEquations"}),
1826+
SOME({"simplifyAllExpressions",
1827+
"evalFunc",
1828+
"removeEqualFunctionCalls",
1829+
"removeSimpleEquations"}),
18271830
NONE(),
18281831
NONE(),
18291832
SOME({"inlineArrayEqn",
@@ -1833,7 +1836,8 @@ algorithm
18331836
"tearingSystem",
18341837
"solveSimpleEquations",
18351838
"simplifyTimeIndepFuncCalls",
1836-
"calculateStrongComponentJacobians"}));
1839+
"calculateStrongComponentJacobians",
1840+
"simplifyAllExpressions"}));
18371841
_ = Flags.set(Flags.EXEC_STAT, b);
18381842
if Flags.isSet(Flags.JAC_DUMP) then
18391843
BackendDump.bltdump("Symbolic Jacobian",backendDAE2);

Compiler/Util/Flags.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ constant ConfigFlag PRE_OPT_MODULES = CONFIG_FLAG(12, "preOptModules",
716716
("replaceEdgeChange", Util.gettext("Replace edge(b) = b and not pre(b) and change(b) = v <> pre(v).")),
717717
("residualForm", Util.gettext("Transforms simple equations x=y to zero-sum equations 0=y-x.")),
718718
("resolveLoops", Util.gettext("resolves linear equations in loops")),
719+
("simplifyAllExpressions", Util.notrans("Does simplifications on all expressions.")),
719720
("simplifyIfEquations", Util.gettext("Tries to simplify if equations by use of information from evaluated parameters.")),
720721
("sortEqnsVars", Util.notrans("Heuristic sorting for equations and variables. This module requires +d=sortEqnsAndVars.")),
721722
("stateMachineElab", Util.gettext("Does the elaboration of state machines.")),

0 commit comments

Comments
 (0)