Return the initial guess if nonlinear system is ill-behaved...

At the initial guess, and we were not able to find another guess (randomizing).
fix-nonlinear-solvers
Stéphane Adjemian (Ryûk) 2022-04-04 15:51:53 +02:00
parent 56863d6e2f
commit 48c41e6b0d
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
1 changed files with 4 additions and 1 deletions

View File

@ -66,6 +66,9 @@ end
errorflag = false;
nn = size(x,1);
% Keep a copy of the initial guess.
x0 = x;
% Get status of the initial guess (default values?)
if any(x)
% The current initial guess is not the default for all the variables.
@ -168,7 +171,7 @@ end
% Exit with error if no initial guess has been found.
if wrong_initial_guess_flag
errorflag = true;
x = NaN(size(fvec));
x = x0;
return
end