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

Commit db18f0d

Browse files
kabdelhakOpenModelica-Hudson
authored andcommitted
[BE]apply simplifyIfEquations on initial equations
Belonging to [master]: - #2889 - OpenModelica/OpenModelica-testsuite#1112
1 parent eb421e8 commit db18f0d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Compiler/BackEnd/BackendDAEOptimize.mo

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,19 +2226,27 @@ algorithm
22262226
(osyst,oshared) := matchcontinue (isyst, ishared)
22272227
local
22282228
BackendDAE.Variables vars, globalKnownVars;
2229-
BackendDAE.EquationArray eqns;
2229+
BackendDAE.EquationArray eqns, initialEqs;
22302230
list<BackendDAE.Equation> eqnslst, asserts;
22312231
BackendDAE.EqSystem syst;
22322232
BackendDAE.Shared shared;
2233+
Boolean systChanged;
22332234

22342235
case ( syst as BackendDAE.EQSYSTEM(orderedEqs=eqns),
2235-
shared as BackendDAE.SHARED(globalKnownVars=globalKnownVars) )
2236+
shared as BackendDAE.SHARED(globalKnownVars=globalKnownVars, initialEqs=initialEqs) )
22362237
algorithm
22372238
// traverse the equations
22382239
eqnslst := BackendEquation.equationList(eqns);
22392240
// traverse equations in reverse order, than branch equations of if equaitions need no reverse
2240-
((eqnslst,asserts,true)) := List.fold31(listReverse(eqnslst), simplifyIfEquationsFinder, globalKnownVars, {},{},false);
2241+
((eqnslst,asserts,systChanged)) := List.fold31(listReverse(eqnslst), simplifyIfEquationsFinder, globalKnownVars, {},{},false);
22412242
syst.orderedEqs := BackendEquation.listEquation(eqnslst);
2243+
2244+
// traverse the initial equations
2245+
eqnslst := BackendEquation.equationList(initialEqs);
2246+
// traverse equations in reverse order, than branch equations of if equaitions need no reverse
2247+
((eqnslst,asserts,true)) := List.fold31(listReverse(eqnslst), simplifyIfEquationsFinder, globalKnownVars, {},{},systChanged);
2248+
shared.initialEqs := BackendEquation.listEquation(eqnslst);
2249+
22422250
syst := BackendDAEUtil.clearEqSyst(syst);
22432251
syst := BackendEquation.requationsAddDAE(asserts, syst);
22442252
then (syst, shared);

0 commit comments

Comments
 (0)