﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4005	EncapsulateWhenConditions scales as O(N^3) in models where a when clause is triggered by a large vector of conditions	Francesco Casella	Martin Sjölund	"Consider the following model from the ScalableTestSuite
{{{
model ManyEventsManyConditions ""Model with many events in when clauses and a when clause with many triggering conditions""
  parameter Integer N;
  Real x[N](each start = 0, each fixed = true);
  Boolean e[N](each start = false, each fixed = true);
  Integer v(start = 0, fixed = true);
equation
  for i in 1:N loop
    der(x[i]) = 1/i;
    when x[i] > 1 then
      e[i] = true;
    end when;
  end for;
  when e then
    v = pre(v) + 1;
  end when;
end ManyEventsManyConditions;
}}}
The last when clause is triggered by a boolean array {{{e}}} with {{{N}}} elements in it.

This is the performance of {{{preOpt encapsulateWhenConditions}}} on my PC
||=N=||=Time [s]=||
||1000|| 0.8||
||2000|| 6.3||
||4000|| 54.8||
which scales neatly as O(N^3^)

Is this really necessary, or is it just the result of a (very) inefficient algorithm?"	defect	closed	high	1.12.0	Backend		fixed		Patrick Täuber
