﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4985	OMC accepts invalid nonlinear system solutions	Francesco Casella	Willi Braun	"Please run the following simple test
{{{
model Test
  Real x(min = 0);
  Real y(start = 0, fixed = true);
equation
  0 = 1e-6*x + sin(x+0.5);
  der(y) = x;
end Test;
}}}
This equation has (among others) two solutions: x = -0.5 and x = pi-0.5. The first is found easily by Newton's algorithm, give the initial guess of zero, but it is invalid because it violates the min constraint.

OMC responds with:
{{{
LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
}}}
which is wrong, because the initialization violates the constraint. Then, it reports
{{{
assert | warning | The following assertion has been violated at time -4.995000
x >= 0.0
assert | warning | Variable violating min constraint: 0.0 <= x, has value: -0.5
}}}
Then the simulation starts anyway and eventually OMC reports
{{{
LOG_SUCCESS | info | The simulation finished successfully.
}}}

IMHO the violation of a min/max attribute should generate an error, not a warning, e.g.
{{{
Error: Variable violating min constraint: 0.0 <= x, has value: -0.5
To disable this check, set the simulation flag -ignoreMinMax
}}}
One could then set a flage to make this a warning, if some old code has wrong min/max attributes, *as an interim solution before the min/max attribute in the model is fixed*

I would also use this assertions as a guide to the solver. For example, consider this revised test case
{{{
model Test
  Real x(min = 0);
  Real y(start = 0, fixed = true);
equation
  0 = homotopy(1e-6*x + sin(x+0.5),
               x-2.65);
  der(y) = x;
end Test;
}}}
in this case, the Newton solver would find the solution x = -0.5, but as it is invalid, the solver should fail. Then, the homotopy-based solver would be invoked, and the right solution would be found. Currently, the wrong one is produced with the default settings."	defect	closed	blocker	1.13.0	Run-time		fixed		
