﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5659	Wrong behaviour of backend in algorithm section	Francesco Casella	Karim Adbdelhak	"Please consider the following model

{{{
model foo
   discrete Real data[2];
algorithm
   when sample(0,0.1) then
     data[1] := time;
   end when;
end foo;
}}}
The backend issues the following error:
{{{
[1] 23:59:23 Translation Error
Internal error IndexReduction.pantelidesIndexReduction failed!
Found empty set of continues equations. 
Use -d=bltdump to get more information.
}}}
The fact that the model doesn't contain continuous equations (wrong spelling, BTW) doesn't mean that the model is invalid, it just only contains discrete variables. I'm not aware of any restrictions prohibiting this particular case.

If I add one dummy continuous equation
{{{
model bar
   discrete Real data[2];
   Real x = time;
algorithm

   when sample(0,0.1) then
     data[1] := time;
   end when;
end bar;
}}}
I get
{{{
[1] 00:02:03 Symbolic Error
An independent subset of the model has imbalanced number of equations (2) and variables (1).
variables:
data[1]
equations:
1 : algorithm
  when sample(1, 0.0, 0.1) then
    data[1] := time;
  end when;
}}}

As I understand, this is also wrong. [https://specification.modelica.org/v3.4/Ch11.html#algorithm-sections Section 11.1.2] of the Modelica Specification states:

  Whenever an algorithm section is invoked, all variables appearing on the left hand side of the assignment operator ”:=” are initialized (at least conceptually)
  - A discrete variable v is initialized with pre(v).
  - If at least one element of an array appears on the left hand side of the assignment operator, then the complete array is initialized in this algorithm section.

Hence, the entire {{{data}}} array should be initialized to {{{pre(v)}}}. Then, the fact that there is no explicit assignment to {{{data[2]}}} means that this variable will remain constant, but the model is otherwise balanced and well-posed."	defect	closed	critical	1.14.0	Backend		fixed		alberto.leva@… Per Östlund
