Opened 12 years ago
Closed 6 years ago
#1991 closed defect (fixed)
StateSelect Attribute with unfixed parameters wrong evaluated without warning
Reported by: | Jens Frenkel | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | trunk |
Keywords: | Cc: | Martin Sjölund, Willi Braun, Lennart Ochel |
Description (last modified by )
Consider the following model. The state select attribute is set via unfixed parameters. The FrontEnd evaluates the unfixed parameters but report no warning about that. The result is totaly different to the exprected from the modelers view for y and z.
model StateSelectCheck parameter Boolean preferredStates=true; parameter Boolean preferredStatesUnfixed(fixed=false); parameter Boolean preferredStatesUnfixedStart(fixed=false,start=true); Real x(stateSelect = if preferredStates then StateSelect.prefer else StateSelect.avoid); Real y(stateSelect = if preferredStatesUnfixed then StateSelect.prefer else StateSelect.avoid); Real z(stateSelect = if preferredStatesUnfixedStart then StateSelect.prefer else StateSelect.avoid); initial equation preferredStatesUnfixed = true; preferredStatesUnfixedStart = false; equation der(z) = time; 0 = x^2 + y^2 + z^2; y = x + z; end StateSelectCheck;
Result after the FrontEnd:
class StateSelectCheck parameter Boolean preferredStates = true; parameter Boolean preferredStatesUnfixed(fixed = false); parameter Boolean preferredStatesUnfixedStart(start = true, fixed = false); Real x(StateSelect = StateSelect.prefer); Real y; Real z(StateSelect = StateSelect.prefer); initial equation preferredStatesUnfixed = true; preferredStatesUnfixedStart = false; equation der(z) = time; 0.0 = x ^ 2.0 + y ^ 2.0 + z ^ 2.0; y = x + z; end StateSelectCheck;
Attachments (1)
Change History (17)
by , 12 years ago
Attachment: | StateSelectCheck.mo added |
---|
comment:1 by , 12 years ago
Description: | modified (diff) |
---|
comment:2 by , 12 years ago
comment:4 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:5 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:10 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:11 by , 7 years ago
Yes, that model should be rejected. But in fact, the state select attribute of y
and z
is ignored, i.e. removed, without any feedback.
comment:12 by , 7 years ago
Component: | Frontend → New Instantiation |
---|---|
Milestone: | 1.12.0 → 2.0.0 |
Owner: | changed from | to
Status: | new → assigned |
As of v1.13.0-dev-155-g68350e9, using the new front end, the translation fails with
[1] 01:35:33 Translation Error Internal error Instantiation of M failed with no error message. [2] 01:35:34 Scripting Error [C:/dev/OpenModelica64bit/OMCompiler/Compiler/NFFrontEnd/NFFlatten.mo:1314:9-1314:72:writable]Modelica Assert: NFFlatten.makeStateSelectAttribute got non StateSelect value!
I guess this is the expected behaviour, even though the error message is not that clear. @perost can you please check?
comment:13 by , 7 years ago
The error message is now
[1] 19:11:38 Translation Error [C:/dev/OpenModelica64bit/OMCompiler/Compiler/NFFrontEnd/NFCeval.mo: 1096:9-1097:96]: Internal error NFCeval.evalIfExp: unimplemented case for if preferredStatesUnfixed then StateSelect.prefer else StateSelect.avoid
I guess a clearer error message is still needed.
comment:15 by , 6 years ago
Replying to casella:
Still valid as of v1.13.0-dev-798-g1c8bb86de
The NF actually detected the error, but the logic for when to print an error message was wrong. With the fix in cc477d0 the model now fails with:
[test.mo:3:3-3:56:writable] Notification: From here: [test.mo:6:10-6:96:writable] Error: Constant preferredStatesUnfixed is used without having been given a value.
Good enough?
Note that it is valid for a tool to reject non-fixed structural parameters. That is, if the parameter cannot be evaluated like a constant, we could reject the model.