Opened 13 years ago
Last modified 13 years ago
#1665 closed defect (fixed)
parameter equations not part of generated code
Reported by: | Martin Sjölund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | trunk | |
Keywords: | Cc: | Martin Sjölund, Frenkel TUD, Willi Braun |
Description
{{{type CondEnum = enumeration(a, b);
model Test
final parameter CondEnum cond = CondEnum.b;
parameter Real val = 1.0;
final parameter Real final_value = 1.0;
parameter Real value1 = if cond == CondEnum.a then val else -val;
final parameter Real value2 = if cond == CondEnum.a then val else -val;
parameter Real value3 = if cond == CondEnum.a then final_value else -final_value;
Real result1;
Real result2;
Real result3;
equation
result1 = value1; ok (==-val)
result2 = value2; error (==0)
result3 = value3; error (==0)
end Test; }}}
Post on the forums when completed: http://www.openmodelica.org/index.php/forum/topic?id=459#p1749
Recarding to the specifiation chapter 7.2.6 final parameters are not changeable turing simulation. Subseqentliy the compilers calculated the value and replace all final parameters with its calculated value for optimisation reasons. The resulting model should be
model Test
equation
end Test;</pre>
The strange thinks are that if you use +d=optdaedump the optimisation module removeFinalParameters
Why is CondEnum.b == CondEnum.a not simplify to false?
Why is value3 replaced?
value3 has a final bind expression. Hence parameters with bind expression cannot changed directly. Subsequently the optimisation module also replace this parameters with constant bind expression resulting from final parameters for optimisation reasons.