﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4360	Is static tearing of parameter-dependent linear systems a good idea?	Francesco Casella	Patrick Täuber	"Maybe not. Consider this test case
{{{
loadString(""
model M
  parameter Real a = 1;
  parameter Real b = 0.5;
  parameter Real c = 0.5;
  parameter Real d = 1;
  Real x,y;
equation
  a*x + b*y = 1;
  c*x + d*y = -1;
end M;
""); getErrorString();

setCommandLineOptions(""-d=dumpSimCode"");getErrorString();
simulate(M, simflags=""-lv=LOG_STATS"");getErrorString();
simulate(M, simflags=""-lv=LOG_STATS -override=b=0"");getErrorString();
simulate(M, simflags=""-lv=LOG_STATS -override=b=1e-9"");getErrorString();
}}}

The back-end solves the linear system by tearing like this:
{{{
6: y=DIVISION(1.0 - a * x, b) [Real ]
7: 1.0 + d * y + c * x (RESIDUAL)
}}}
which is fine when b=0.5, but is definitely not a good idea when b=0, and also not very numerically sound when b=1e-9.

My conclusion would be that we should by default avoid solving for variables that are multiplied by a parameter in the torn variable section.

If one wants the efficiency of full tearing, then he or she should turn on {{{-d=evaluateAllParameters}}}, which would at least avoid problem when b = 0 because that dependency will be totally eliminated. 

Unfortuntely, that won't help much when b = 1e-9, unless the tearing heuristics somehow tries to avoid solving w.r.t. variables which are multiplied by a small coefficient.

Comments?"	discussion	closed	normal	2.0.0	Backend		fixed		
