Opened 10 years ago

Last modified 10 years ago

#3165 new defect

Cyclically dependent parameters due to min/max attribute

Reported by: Lennart Ochel Owned by: somebody
Priority: high Milestone: Future
Component: Frontend Version: trunk
Keywords: Cc: Adrian Pop

Description

model test
  parameter Real a(min=0, max=b) = 2;
  parameter Real b(min=a) = 3;
end test;

OpenModelica throws following error message for this model:

Translation Error
Cyclically dependent constants or parameters found in scope test: {b,a}.

Is that intended? Dymola does not complain about cyclically dependent parameters in this case.

Change History (3)

comment:1 by Rüdiger Franke, 10 years ago

Modelica.Fluid goes one step further. In order to solve a long standing ticket (https://trac.modelica.org/Modelica/ticket/736), we introduced things like:

model CyclicParameterBinding
  parameter Boolean use_newFeature = false annotation(Evaluate = true);
  parameter Real a = if use_newFeature then b else 1;
  parameter Real b = if use_newFeature then 2 else a;
end CyclicParameterBinding;

Then Modelica tools became more pedantic. At the 81st Modelica Design Meeting a poll concluded with a majority of 90% (10% abstaining):

Cycles are allowed if the cycles disappear when evaluating parameters having annotation Evaluate=true that are not part of the cycle.

Doesn't this mean that the above min/max cycle should be accepted as well?

comment:2 by Martin Sjölund, 10 years ago

  1. Results of polls are not part of the specification :)
  2. The min/max cycle above does not use Evaluate=true

However, the constraint is only for the binding equation. I don't think the min/max should be checked there. However, min and max are defined by structural parameters, so if we fail to evaluate them that should be a warning (or an error). Thus, a and b should be evaluated and replaced anyway.

comment:3 by Lennart Ochel, 10 years ago

Component: UnknownFrontend

This is caught in the front end.

Version 0, edited 10 years ago by Lennart Ochel (next)
Note: See TracTickets for help on using tickets.