Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#3910 closed defect (fixed)

Very strange behaviour of CSE

Reported by: casella Owned by: ptaeuber
Priority: critical Milestone:
Component: Backend Version:
Keywords: Cc: jan.hagemann@…

Description

Consider the following package:

  model Test1
    Real x;
    Real y;
    Real z;
    Real w(fixed = true);
  equation
    der(w) = 1 - w;
    x = 3*sin(w);
    y = 3*sin(w);
    z = 6*sin(w)-1;
   end Test1;

  model Test2
     Real x(fixed = true);
     Real y;
     Real z;
   equation
     der(x) =  1 - x;
     y = sin(x);
     z = 2*sin(x);
   end Test2;
end CSE;

and execute the following script:

setDebugFlags("dumpCSE"); getErrorString();
setCommandLineOptions("--postOptModules+=wrapFunctionCalls"); getErrorString();
simulate(CSE.Test1); getErrorString();
simulate(CSE.Test2); getErrorString();

In the first test case, the CSE is performed correctly and the term sin(w) is only computed once. In the second one, instead, no CSE is performed at all.

I am unable to understand what is the structural difference between the two test cases.

Attachments (1)

testStrangeCSE.mos (589 bytes) - added by casella 8 years ago.
.mos file to reproduce the problem

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by casella

.mos file to reproduce the problem

comment:1 Changed 8 years ago by anonymous

possible it is

CommonSubExpression.wrapFunctionCalls_advanced
...
case (DAE.CALL(), DAE.CREF()) // sin(x) = y;

comment:2 Changed 8 years ago by jhagemann

yes, that is right. y is also a cse variable, but nevertheless there is a bug. the boolean to restart the matching has to be true. i will fix it tomorrow. this is also the reasons for the problems in ticket 3102 (testIF97CSE.mos).

comment:3 Changed 8 years ago by jhagemann

  • Resolution set to fixed
  • Status changed from new to closed

This is fixed in a1f6080.

comment:4 Changed 7 years ago by sjoelund.se

  • Milestone 1.10.0 deleted

Milestone deleted

Note: See TracTickets for help on using tickets.