Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#3910 closed defect (fixed)

Very strange behaviour of CSE

Reported by: Francesco Casella Owned by: Patrick Täuber
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 Francesco Casella 9 years ago.
.mos file to reproduce the problem

Download all attachments as: .zip

Change History (5)

by Francesco Casella, 9 years ago

Attachment: testStrangeCSE.mos added

.mos file to reproduce the problem

comment:1 by anonymous, 9 years ago

possible it is

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

comment:2 by jhagemann, 9 years ago

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 by jhagemann, 9 years ago

Resolution: fixed
Status: newclosed

This is fixed in a1f6080.

comment:4 by Martin Sjölund, 7 years ago

Milestone: 1.10.0

Milestone deleted

Note: See TracTickets for help on using tickets.