﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5139	Initialization failures due to min/max and assert() violations do not trigger the homotopy-based initialization	Francesco Casella	Andreas Heuermann	"Please run this model
{{{
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;
  annotation(__OpenModelica_commandLineOptions = ""-d=nowarnMinMax"");
end Test;
}}}
The simulation fails with
{{{
assert | warning | The following assertion has been violated at time 0.000000 x > = 0.0
assert | error | Variable violating min constraint: 0.0 <= x, has value: -0.5
assert | info | simulation terminated by an assertion at initialization
stdout | error | Simulation process failed. Exited with code -1.
}}}
The User's Guide says about [https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/simulationflags.html#simflag-homotopyonfirsttry -homotopyOnFirstTry]:
  
  If the model contains the homotopy operator, directly use the homotopy method to solve the initialization problem. Without this flag, the solver first tries to solve the initialization problem without homotopy and only uses homotopy as fallback option. 

If this was actually done, homotopy would ensure the convergence of the nonlinear solver to the positive solution, which would then be accepted by the min/max checks.

A similar issue takes place with [https://libraries.openmodelica.org/branches/newInst/ModelicaTest_3.2.3/files/ModelicaTest_3.2.3_ModelicaTest.Blocks.LimitersHomotopy.sim ModelicaTest.Blocks.LimitersHomotopy], which currently fails with the message:
{{{
Regular simulation: ./ModelicaTest_3.2.3_ModelicaTest.Blocks.LimitersHomotopy -abortSlowSimulation -alarm=480   
assert            | warning | The following assertion has been violated during initialization at time 0.000000
|                 | |       | abs(mustUseHomotopy.x - 100.0) < 1e-06
assert            | error   | Wrong solution selected
assert            | info    | simulation terminated by an assertion at initialization
}}}
In both cases I would suggest to print out the following notification message:
  Invalid initial solution obtained without homotopy. Trying with homotopy-based initialization. You can skip the attempt without homotopy with the -homotopyOnFirstTry simulation flag.

then restart the solution process with the homotopy-based solver.
"	defect	assigned	high	1.14.0	Run-time				Lennart Ochel Andreas Heuermann
