Exit if initial guess is a solution...
Without entering in the nonlinear solvers.fix-nonlinear-solvers
parent
b236027365
commit
56863d6e2f
|
@ -92,13 +92,13 @@ end
|
||||||
if jacobian_flag
|
if jacobian_flag
|
||||||
[fvec, fjac] = feval(f, x, arguments{:});
|
[fvec, fjac] = feval(f, x, arguments{:});
|
||||||
wrong_initial_guess_flag = false;
|
wrong_initial_guess_flag = false;
|
||||||
if ~all(isfinite(fvec)) || any(isinf(fjac(:))) || any(isnan((fjac(:)))) ...
|
if ~all(isfinite(fvec)) || any(isinf(fjac(:))) || any(isnan((fjac(:)))) || any(~isreal(fvec)) || any(~isreal(fjac(:)))
|
||||||
|| any(~isreal(fvec)) || any(~isreal(fjac(:)))
|
if max(abs(fvec)) < tolf
|
||||||
if max(abs(fvec)) < tolf %return if initial value solves problem
|
% return if initial value solves problem
|
||||||
exitflag = -1;
|
exitflag = -1;
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
disp_verbose('Randomize initial guess...',options.verbosity)
|
disp_verbose('Randomize initial guess...', options.verbosity)
|
||||||
% Let's try random numbers for the variables initialized with the default value.
|
% Let's try random numbers for the variables initialized with the default value.
|
||||||
wrong_initial_guess_flag = true;
|
wrong_initial_guess_flag = true;
|
||||||
% First try with positive numbers.
|
% First try with positive numbers.
|
||||||
|
@ -129,6 +129,11 @@ if jacobian_flag
|
||||||
else
|
else
|
||||||
fvec = feval(f, x, arguments{:});
|
fvec = feval(f, x, arguments{:});
|
||||||
fjac = zeros(nn, nn);
|
fjac = zeros(nn, nn);
|
||||||
|
if max(abs(fvec)) < tolf
|
||||||
|
% return if initial value solves problem
|
||||||
|
exitflag = -1;
|
||||||
|
return;
|
||||||
|
end
|
||||||
wrong_initial_guess_flag = false;
|
wrong_initial_guess_flag = false;
|
||||||
if ~all(isfinite(fvec))
|
if ~all(isfinite(fvec))
|
||||||
% Let's try random numbers for the variables initialized with the default value.
|
% Let's try random numbers for the variables initialized with the default value.
|
||||||
|
|
Loading…
Reference in New Issue