Commit ca092283 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'mr_hessian' into 'master'

mr_hessian.m: prevent infinite loop

Closes #1636

See merge request !1645
parents 69065667 d5e25c8f
Pipeline #747 passed with stages
in 101 minutes and 36 seconds
...@@ -125,17 +125,20 @@ while i<n ...@@ -125,17 +125,20 @@ while i<n
end end
if abs(dx(it))>(3*hess_info.htol) if abs(dx(it))>(3*hess_info.htol)
hess_info.h1(i)= hess_info.htol/abs(dx(it))*hess_info.h1(i); hess_info.h1(i)= hess_info.htol/abs(dx(it))*hess_info.h1(i);
hess_info.h1(i) = max(hess_info.h1(i),1e-10);
xh1(i)=x(i)+hess_info.h1(i); xh1(i)=x(i)+hess_info.h1(i);
try try
[fx,exit_flag,ffx]=penalty_objective_function(xh1,func,penalty,varargin{:}); [fx,exit_flag,ffx]=penalty_objective_function(xh1,func,penalty,varargin{:});
catch catch
fx=1.e8; fx=1.e8;
end end
while (fx-f0)==0 iter=0;
while (fx-f0)==0 && iter<50
hess_info.h1(i)= hess_info.h1(i)*2; hess_info.h1(i)= hess_info.h1(i)*2;
xh1(i)=x(i)+hess_info.h1(i); xh1(i)=x(i)+hess_info.h1(i);
[fx,exit_flag,ffx]=penalty_objective_function(xh1,func,penalty,varargin{:}); [fx,exit_flag,ffx]=penalty_objective_function(xh1,func,penalty,varargin{:});
ic=1; ic=1;
iter=iter+1;
end end
end end
it=it+1; it=it+1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment