Skip to content

Commit

Permalink
improved guarding rule in ExpressionSolve agianst sign and IFEXP
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21439 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Vitalij Ruge committed Jul 7, 2014
1 parent 322f92b commit 13fd991
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Compiler/BackEnd/ExpressionSolve.mo
Expand Up @@ -363,8 +363,9 @@ algorithm
// cr = (e1-e2)/(der(e1-e2,cr))
case (_,_,DAE.CREF(componentRef = cr),_)
equation
false = isCrefInIFEXP(inExp1,cr) or isCrefInIFEXP(inExp2,cr);
false = hasOnlyFactors(inExp1,inExp2);
({},_) = List.split1OnTrue(Expression.factors(inExp1),isCrefInIFEXP,cr); // check: differentiateExpSolve is allowed
({},_) = List.split1OnTrue(Expression.factors(inExp2),isCrefInIFEXP,cr); // check: differentiateExpSolve is allowed
e = Expression.makeDiff(inExp1,inExp2);
dere = Differentiate.differentiateExpSolve(e, cr);
(dere,_) = ExpressionSimplify.simplify(dere);
Expand Down Expand Up @@ -756,7 +757,7 @@ algorithm
end matchcontinue;
end hasOnlyFactors;

protected function isCrefInIFEXP " Returns true if expression is DAE.IFEXP(f(cr)) for cr = incr"
protected function isCrefInIFEXP " Returns true if expression is DAE.IFEXP(f(cr)) or sign(f(cr)) for cr = incr"
input DAE.Exp e;
input DAE.ComponentRef incr;
output Boolean res;
Expand All @@ -766,7 +767,11 @@ protected function isCrefInIFEXP " Returns true if expression is DAE.IFEXP(f(cr)

case(DAE.IFEXP(e1,_,_),_)
then Expression.expHasCref(e1, incr);
else
case(DAE.CALL(path = Absyn.IDENT(name = "sign"),expLst = {e1}),_)
then Expression.expHasCref(e1, incr);
case(DAE.CAST(exp =e1),_)
then isCrefInIFEXP(e1,incr);
else
then false;
end match;
end isCrefInIFEXP;
Expand Down

0 comments on commit 13fd991

Please sign in to comment.