﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5099	Merging min/max attributes for alias elimination	Francesco Casella	Karim Adbdelhak	"Min/max attributes can have an important influence on the correctness and performance of Modelica models. In particular, this is critical for the optimization of the {{{inStream()}}} operator, see Section 9.2 of the Modelica Specification. 

The current implementation of {{{inStream()}}} (see #3885) opimizes away terms with {{{min >= 0}}} and {{{max <= 0}}} after alias elimination. It is thus essential that min/max information is not lost in the process: when many variables in an alias set are represented by one variable in the problem that will be solved numerically, the min/max attributes of this variable should span the intersection of the min/max intervals of each variable in the set.

In particular, it is important to merge the min/max attributes of variables showing up in alias equations that can stem from connect statements and from typical modelling equations involving flow variables, that is:

  x = y
  x + y = 0
  (-x) + y = 0
  x + (-y) = 0
  x = -y
  -x = y

This functionality is partially implemented as of 29/08/2018 (see e.g. [https://github.com/OpenModelica/OMCompiler/blob/master/Compiler/BackEnd/RemoveSimpleEquations.mo#L1372 here] and [https://github.com/OpenModelica/OMCompiler/blob/master/Compiler/BackEnd/RemoveSimpleEquations.mo#L944 here]), but there are still problems. On the one hand, I'm not sure that all cases listed above are covered. On the other hand, when running the following simple test case with {{{-d=optdaedump}}}
{{{
model TestMinMax
  Real x(min = 0);
  Real y;
  Real z;
equation
  x+y=0;
  z = x;
  y = time;
end TestMinMax;
}}}
the following output is obtained
{{{
1: z:VARIABLE() .TestMinMax type: Real
2: y:VARIABLE() .TestMinMax type: Real
3: x:VARIABLE(min = 0.0 ) .TestMinMax type: Real
}}}
while one would expect to see min = 0 on z and max = 0 on y.

This issue should preferably be solved in 1.13.0, because it has an impact on the optimization of stream connectors, that are widely used in a number of Modelica libraries.

It should also be addressed in the {{{removeSimpleEquations=new}}} module which is currently under development."	enhancement	new	critical	1.13.0	Backend				Willi Braun Vitalij Ruge Bernhard Bachmann Andrea Bartolini
