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

Change History (1)

comment:1 by Jens Frenkel, 13 years ago

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

<pre>type CondEnum = enumeration(a, b);

model Test

parameter Real val = 1.0;

parameter Real value1 = -val;

parameter Real value3 = -1.0;

                                 

Real result1; 

Real result2;

Real result3;

equation

result1 = value1;

result2 = -1.0;

result3 = value3;

end Test;</pre>

The strange thinks are that if you use +d=optdaedump the optimisation module removeFinalParameters

ends with

result1 = value1
 result2 = if CondEnum.b == CondEnum.a then 1.0 else -1.0
 result3 = if CondEnum.b == CondEnum.a then 1.0 else -1.0

Why is  CondEnum.b == CondEnum.a not simplify to false?

  • Fixed by Expression.getRealConst add case for enumerations "case DAE.ENUM_LITERAL(index = i) then intReal(i);"

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.

Note: See TracTickets for help on using tickets.