Opened 4 years ago

Last modified 4 years ago

#4858 new defect

Discrete fixed=true with event generating binding expression causes problems

Reported by: jsten Owned by: Jesper Mattsson
Priority: major Milestone: 2.0.x
Component: Modelica/MiddleEnd Version: trunk
Keywords: Cc:


The following model:

model A
    Integer i(start=2,fixed=true) = integer(time);
end A;

Fails with the following error:

Error in flattened model:
  The initialization system is structurally singular. The following equation(s) could not be matched to any variable:
    pre(i) = 2

The problem is that we will extract the binding expression, integer(time), to a temporary variable and insert the initial equation pre(temp_1) = 0;
temp_1 is then alias eliminated with i and the initial equation is rewritten to pre(i) = 0.
However since the variable is discrete, has a start value and declared as fixed=true, then we introduce the initial equation pre(i) = 2 which causes the system to be unbalanced.
The problem here is that the expression is extracted and causes an alias equation. A possible solution is to not insert the pre(temp) initial equation and instead relying on the matchings and BLT of the initial system to insert the correct initial equation as needed?

Change History (1)

comment:1 Changed 4 years ago by Jesper Mattsson

Another possibility is to remove the initial equation during alias elimination.

This should be equivalent to:

model B
    Integer i(start=2, fixed=true);
    Integer i2;
    i = i2;
    i2 = integer(time);
end B;

It is also unclear what the meaning of the model (i.e. A) is - isn't the equation for i valid in the initialization system? Then it is inconsistently overdetermined (both i=0 & i=2).

Last edited 4 years ago by Jesper Mattsson (previous) (diff)
Note: See TracTickets for help on using tickets.