Opened 12 years ago
Closed 12 years ago
#1943 closed defect (fixed)
Wrong equation count for enum in when equations
Reported by: | Christian Schubert | Owned by: | Jens Frenkel |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.0 |
Component: | Backend | Version: | trunk |
Keywords: | equation count | Cc: | Adrian Pop, Martin Sjölund |
Description
if an enum is set using an if equation inside a when equation, the OpenModelica Compiler the number of equations is set the possible states the enum can have rather than the dimensionality of the variable itself. Thus such models seem to be unbalanced.
Consider the model
model WhenCount type EnumA = enumeration( Value1, Value2); EnumA a; equation when (time > 0.5) then if (time < 1) then a = EnumA.Value1; else a = EnumA.Value2; end if; end when; end WhenCount;
OMC reports:
Too many equations, overdetermined system. The model has 2 equation(s) and 1 variable(s).
Attachments (2)
Change History (7)
by , 12 years ago
Attachment: | WhenCount.mo added |
---|
by , 12 years ago
Attachment: | WhenCount.mos added |
---|
comment:1 by , 12 years ago
Cc: | added |
---|
comment:2 by , 12 years ago
change
case (DAE.ENUM_LITERAL(name = p)) then DAE.T_ENUMERATION(NONE(), p, {}, {}, {}, DAE.emptyTypeSource);
to
case (DAE.ENUM_LITERAL(name = p, index=i)) then DAE.T_ENUMERATION(SOME(i), p, {}, {}, {}, DAE.emptyTypeSource);
comment:3 by , 12 years ago
I fail to see the problem for the equation counting. Isn't the number of equations/vars always one for enumeration literals?
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The Problem is that in the Backend the type of the ComponentRef is used. But the Type is Enumeration and there is the size the number of Elements in the Enumeration. If we use the right hand side the size would be zero because there the list of Elements is thero. This is maybe a bad implementation.