Opened 9 years ago
Closed 4 years ago
#3557 closed defect (fixed)
PreOptModules messes up model
Reported by: | Martin Sjölund | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | high | Milestone: | 1.16.0 |
Component: | Backend | Version: | |
Keywords: | Cc: | Lennart Ochel, Willi Braun |
Description
The following model passes the frontend, but some preOptModule messes up the structure very badly:
model M record R String name "Unique name used as identifier"; Real c "Coefficient"; end R; function name input R r; output String n=r.name; end name; R[3] dictionary = {R(name="A", c=1), R(name="B", c=2), R(name="C", c=3)} "Data dictionary"; Boolean[:] b = {name(r) == "B" for r in dictionary}; Integer i = Modelica.Math.BooleanVectors.firstTrueIndex(b); Real c = dictionary[i].c "Coefficient"; annotation(uses(Modelica(version="3.2.1"))); end M;
Error: Model is structurally singular, error found sorting equations 3: 3.0 = 3.0; 4: "A" = false; 5: "B" = false; 6: "C" = false; for variables dictionary[1].c(8), b[3](3), b[2](4), b[1](5), dictionary[3].c(6)
Change History (3)
comment:1 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:2 by , 9 years ago
It seems that this model covers also another issue. instantiateModel
generates following output:
class M String dictionary[1].name = \"A\" \"Unique name used as identifier\"; Real dictionary[1].c = 1.0 \"Coefficient\"; String dictionary[2].name = \"B\" \"Unique name used as identifier\"; Real dictionary[2].c = 2.0 \"Coefficient\"; String dictionary[3].name = \"C\" \"Unique name used as identifier\"; Real dictionary[3].c = 3.0 \"Coefficient\"; Boolean b[1]; Boolean b[2]; Boolean b[3]; Integer i = Modelica.Math.BooleanVectors.firstTrueIndex({b[1], b[2], b[3]}); Real c = dictionary[i].c \"Coefficient\"; equation b = {false, false, false}; end M;
However, b
should be {false, true, false}
.
comment:3 by , 4 years ago
Milestone: | Future → 1.16.0 |
---|---|
Resolution: | → fixed |
Status: | accepted → closed |
Using the old frontend the model now passes the backend, so I assume that issue was fixed. It still evaluate b incorrectly, but that's fixed in the new frontend.
Note:
See TracTickets
for help on using tickets.
This is an issue of the module
removeSimpleEquations
. I will have a look.