#3530 closed defect (fixed)
"comSubExp" introduces bad alias variables in certain cases
Reported by: | Lennart Ochel | Owned by: | Volker Waurich |
---|---|---|---|
Priority: | high | Milestone: | 1.9.4 |
Component: | Backend | Version: | |
Keywords: | Cc: | Volker Waurich |
Description
The following model can be used to illustrate the issue:
model test Real x[2]; Real a[2]; Real z; parameter Real t0 = 0.5; Boolean b[2]; Integer j; Real t[2]; equation x[1] = t[2]; x[2] = t[1]; a[1] = if time<t0 then 1.0 else sin(time); a[2] = if time<t0 then 1.0 else time^2; x[1] = a[1]+a[2]; x[2]-a[2] = a[1]; der(z) = x[1]/x[2]; j = 1+integer(time); algorithm if t[j] < time then b[j] := true; end if; end test;
The module "comSubExp" introduces t[1]
as alias variable, which makes the generated c code invalid, since it occurs in an if condition where it cannot be substituted.
Change History (8)
comment:1 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 9 years ago
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Thanks, this is now working.
follow-up: 5 comment:4 by , 9 years ago
Should this get integrated into the removeSimpleEquation module? This could reduce the back end time slightly.
comment:5 by , 9 years ago
Replying to lochel:
Should this get integrated into the removeSimpleEquation module? This could reduce the back end time slightly.
It should be since the purpose is similar. I will think about this, but the algorithm is different to removeSimpleEquations.
Maybe we could just do the substitution to benefit from the symbolic optimization but keep the variables and alias equations in the equation system. That shouldn't affect the performance much.