Skip to content

Commit

Permalink
- bugfix tests
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12286 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jul 5, 2012
1 parent f316bf6 commit e5b37d5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -1050,7 +1050,7 @@ protected function lowerIfEquation
input list<BackendDAE.Equation> inEqns;
output list<BackendDAE.Equation> outEqns;
algorithm
outEqn := matchcontinue(conditions,theneqns,elseenqs,conditions1,theneqns1,source,functionTree,inEqns)
outEqns := matchcontinue(conditions,theneqns,elseenqs,conditions1,theneqns1,source,functionTree,inEqns)
local
DAE.Exp e;
list<DAE.Exp> explst;
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -3310,7 +3310,6 @@ algorithm
remeqns = BackendDAEUtil.listEquation(eqnslst);
// do replacements in systems
systs = List.map1(systs,removeProtectedParameterswork,repl);
BackendDump.dump(BackendDAE.DAE(systs,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,cache,env,funcs,einfo,eoc,btp,symjacs)));
then
BackendDAE.DAE(systs,BackendDAE.SHARED(knvars,exobj,av,inieqns,remeqns,constrs,cache,env,funcs,einfo,eoc,btp,symjacs));
end match;
Expand Down
46 changes: 45 additions & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -1154,8 +1154,9 @@ algorithm
source = DAEUtil.addSymbolicTransformationSimplifyLst(blst,source,expl1,expl2);
eqnslst = List.map2(eqnslst,replaceEquations2,repl,{});
eqns = replaceEquations2(eqns,repl,{});
eqns = optimizeIfEquation(expl2,eqnslst,eqns,{},{},source,inAcc);
then
replaceEquations2(es,repl,BackendDAE.IF_EQUATION(expl2,eqnslst,eqns,source)::inAcc);
replaceEquations2(es,repl,eqns);

case ((a :: es),repl,_)
equation
Expand All @@ -1165,6 +1166,49 @@ algorithm
end matchcontinue;
end replaceEquations2;

protected function optimizeIfEquation
input list<DAE.Exp> conditions;
input list<list<BackendDAE.Equation>> theneqns;
input list<BackendDAE.Equation> elseenqs;
input list<DAE.Exp> conditions1;
input list<list<BackendDAE.Equation>> theneqns1;
input DAE.ElementSource source;
input list<BackendDAE.Equation> inEqns;
output list<BackendDAE.Equation> outEqns;
algorithm
outEqn := matchcontinue(conditions,theneqns,elseenqs,conditions1,theneqns1,source,inEqns)
local
DAE.Exp e;
list<DAE.Exp> explst;
list<list<BackendDAE.Equation>> eqnslst;
list<BackendDAE.Equation> eqns;

// no true case left with condition<>false
case ({},{},_,{},{},_,_)
then
listAppend(elseenqs,inEqns);
// true case left with condition<>false
case ({},{},_,_,_,_,_)
equation
explst = listReverse(conditions1);
eqnslst = listReverse(theneqns1);
then
BackendDAE.IF_EQUATION(explst,eqnslst,elseenqs,source)::inEqns;
// if true use it
case(DAE.BCONST(true)::_,eqns::_,_,_,_,_,_)
then
eqns;
// if false skip it
case(DAE.BCONST(false)::explst,_::eqnslst,_,_,_,_,_)
then
optimizeIfEquation(explst,eqnslst,elseenqs,conditions1,theneqns1,source,inEqns);
// all other cases
case(e::explst,eqns::eqnslst,_,_,_,_,_)
then
optimizeIfEquation(explst,eqnslst,elseenqs,e::conditions1,eqns::theneqns1,source,inEqns);
end matchcontinue;
end optimizeIfEquation;

protected function replaceWhenEquation "Replaces variables in a when equation"
input BackendDAE.WhenEquation whenEqn;
input VariableReplacements repl;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Util/Flags.mo
Expand Up @@ -499,7 +499,7 @@ constant ConfigFlag NO_SIMPLIFY = CONFIG_FLAG(11, "noSimplify",
protected constant String removeSimpleEquationDesc = "Performs alias elimination and removes constant variables from the DAE, replacing all occurrences of the old variable reference with the new value (constants) or variable reference (alias elimination).";
public constant ConfigFlag PRE_OPT_MODULES = CONFIG_FLAG(12, "preOptModules",
NONE(), EXTERNAL(), STRING_LIST_FLAG({
"evaluateParameters",
// "evaluateParameters",
"removeFinalParameters",
"removeEqualFunctionCalls",
"partitionIndependentBlocks",
Expand Down

0 comments on commit e5b37d5

Please sign in to comment.