Opened 11 years ago
Closed 10 years ago
#2452 closed defect (fixed)
wrong calculation of the number of variables and equations
Reported by: | Lennart Ochel | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9.1 |
Component: | Backend | Version: | trunk |
Keywords: | Cc: | Adrian Pop |
Description
OpenModelica counts only 8 equations and 10 variables for the following model:
model test record R Integer d; Integer dummy; end R; parameter Integer N = 3; Boolean b[N] = {true,false,true}; R d[N]; Integer n; algorithm n := 0; for i in 1:N loop if b[i] then n := 1 + n; d[n].d := i; d[n].dummy := 0; else end if; end for; end test;
It should count 10 equations and 10 variables.
Change History (21)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
The five counted outputs of the algorithm are
1. n 2. d[n].d.d 3. d[n].dummy.d 4. d[n].d.dummy 5. d[n].dummy.dummy
However, I would expect something like
1. n 2. d[1].d 3. d[1].dummy 4. d[2].d 5. d[2].dummy 6. d[3].d 7. d[3].dummy
comment:3 by , 10 years ago
In the meantime the equations get count in a different way, but still wrong:
Check of test completed successfully. Class test has 6 equation(s) and 10 variable(s). 3 of these are trivial equation(s).
comment:4 by , 10 years ago
Cc: | added |
---|
This is a blocker and should get fixed soon. There is still no response after almost one year. Adrian, can you push this a bit. Maybe you know better who need to be included.
comment:5 by , 10 years ago
Check model does wrong counting as far as i know.
The back-end does its own counting which is correct, maybe we should use that.
As far as I know the check model counting part was implemented by Jens.
comment:6 by , 10 years ago
The back end counts the algorithm as three outputs. That is the same as for the front end.
comment:7 by , 10 years ago
I don't get it. Is it a specification question? We don't know how to count it?
Or somebody needs to implement it correctly?
comment:9 by , 10 years ago
Ok. We'll take it up in the next OSMC dev meeting on Monday and see who can do it.
comment:10 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:11 by , 10 years ago
Status: | assigned → accepted |
---|
comment:12 by , 10 years ago
I think this is now fixed in r22581.
Just to be sure though:
Lennart how many equations do you expect from the algorithm section for this model (/simulation/modelica/arrays/BooleanArray2.mos)
model Bug2112 Boolean b[3]; equation for i in 2:3 loop b[i] = time>0.1+i/10; end for; algorithm b[1] := false; for i in 2:3 loop b[1] := b[1] or change(b[i]); end for; end Bug2112;
It was counted 5 equations (3 from algorithm section) and was accepted as correct. Dymola also counts 5 equations.
The way I interpreted the spec it should be only 1 equation/output from the algorithm section (only b[1] is output) and two from equation section. So the model is balanced with 3 equations and vars.
What do you think?
comment:13 by , 10 years ago
Great. The counting for algorithms seem to be correct. Now this model stuck in the code generation. Who can take care of that issue?
Regarding Bug2112: I think 5 equations is the correct counting. Adrian, what do you think?
follow-up: 15 comment:14 by , 10 years ago
5 equations is correct. The specification says this:
model Test // wrong Modelica model (has 4 equations for 2 unknowns) Real x[2](start={-11, -22}); algorithm // conceptually: x = {1,-22} x[1] := 1; algorithm // conceptually: x = {-11,2} x[2] := 2; end Test;
follow-ups: 16 17 comment:15 by , 10 years ago
Replying to sjoelund.se:
5 equations is correct. The specification says this: ...
Okay found this example now. It is on 3.2 rev 2 only :). Missing from spec 3.3.
Anyway treating a whole array as a "variable" will simplify things for us. The way it is now we consider the whole array only if we can not tell which specific members are used.
I will update the fix to not check if the subs are known and all that stuff and just take the whole array.
follow-up: 18 comment:16 by , 10 years ago
Replying to mahge930:
I will update the fix to not check if the subs are known and all that stuff and just take the whole array.
Just for algorithms, right?
comment:17 by , 10 years ago
Replying to mahge930:
Okay found this example now. It is on 3.2 rev 2 only :). Missing from spec 3.3.
Use spec 3.3 rev 1. Spec 3.3 is ancient :)
comment:18 by , 10 years ago
comment:19 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:20 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Upps. This is still not working properly (e.g., simulation/modelica/arrays/BooleanArray2.mos
).
comment:21 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed in r22689.
We needed to differentiate between
model test record R Integer d; end R; R r[2]; algorithm r[1].d := 0; algorithm r[2].d := 0; end test;
which is unbalanced according to the spec and
model test model R Integer d; algorithm d := 0; end R; R r[2]; end test;
which is balanced.
because as far as the back-end was concerned the second model looked like
algorithm r[1].d := 0; algorithm r[2].d := 0;
However in this case the outputs should not be considered as the whole array in each section.
The algorithm get counted as 5 equations. That is wrong.