OpenModelica icon indicating copy to clipboard operation
OpenModelica copied to clipboard

Start value lost for parameter alias

Open phannebohm opened this issue 1 year ago • 2 comments

Description

Somehow the start value of y in the following MWE is lost and both y and p become zero.

model M
  Real y(start = 1, fixed = true);
  parameter Real p(fixed = false);
equation
  y = p;
end M;

Note that this does not happen if we instead have the equation y = 2*p, then everything is fine. So I suspect it's the alias elimination.

Expected Behavior

Both p and y should be equal to 1, not 0.

phannebohm avatar Apr 18 '24 20:04 phannebohm

@phannebohm the output of the debugger seems fine to me

immagine

It seems more like a problem with the generate code, which is probably running y := $START.y before assigning the start value to 1. Besides, there can't be alias elimination between variables and parameters (I guess).

Do I miss something?

casella avatar Apr 21 '24 18:04 casella

On the other hand, the following warning is issued:

[1] 21:05:55 Translation Warning
Assuming fixed start value for the following 1 variables:
         y:VARIABLE(start = 1.0 fixed = true )  = p M type: Real

which is kind of weird: why should the fixed attribute of variable y be "assumed" to be fixed, when it is explicitly declared to be so?

casella avatar Apr 21 '24 19:04 casella