Skip to content

Commit

Permalink
found a bug in rLineMinUa where if the Newton and the initial Cauchy …
Browse files Browse the repository at this point in the history
…directions both fail, the (u,v,h) update had an incorrect sign. Now corrected
  • Loading branch information
GHilmarG committed Oct 26, 2023
1 parent 6530a60 commit 3ac6650
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rLineminUa.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if contains(CtrlVar.rLineMinUa,"-Auto-") && gammaminNewton < gammaminNewtonAccepted && rminNewtonRatio > rminNewtonRatioAccepted

if CtrlVar.InfoLevelNonLinIt >= 10
fprintf(' rLineminUa: Newton step is %f and smaller that %f \n ',gammaminNewton,gammaminNewtonAccepted) ;
fprintf(' rLineminUa: Newton step is %f and smaller than %f \n ',gammaminNewton,gammaminNewtonAccepted) ;
fprintf(' rLineminUa: Will now try using Cauchy step Steepest Descent were the mass matrix replaces the Hessian \n ') ;
end
CtrlVar.rLineMinUa="-Auto-Cauchy M-step-" ;
Expand Down Expand Up @@ -204,11 +204,13 @@
% Try simply to reverse direction...
CtrlVar.InfoLevelBackTrack=1000; CtrlVar.InfoLevelNonLinIt=10 ; CtrlVar.doplots=1;
if Variables=="-uvl-"
funcCauchyM=@(gamma) func(gamma,-DuM,-DvM,-DlM) ;
sM=-[DuM;DvM;DlM];
DuM=-DuM; DvM=-DvM ; DlM=-DlM ;
funcCauchyM=@(gamma) func(gamma,DuM,DvM,DlM) ;
sM=[DuM;DvM;DlM];
else
funcCauchyM=@(gamma) func(gamma,-DuM,-DvM,-DhM,-DlM) ;
sM=-[DuM;DvM;DhM;DlM];
DuM=-DuM; DvM=-DvM ; DhM=-DhM ; DlM=-DlM ;
funcCauchyM=@(gamma) func(gamma,DuM,DvM,DhM,DlM) ;
sM=[DuM;DvM;DhM;DlM];

end
CauchyMSlope0=(-2*R'*H*sM)/Normalisation;
Expand Down Expand Up @@ -714,14 +716,14 @@

if CtrlVar.InfoLevelNonLinIt >= 10
fprintf(" [---------- rLineminUa: \n")
fprintf("\t r0=%-13.7g \t r1/r0=%-13.7g \t rNewton/r0=%-13.7g \t rminCauchyM/r0=%-13.7g \t rDescent/r0=%-13.7g \t rCN/r0=%-13.7g \n",r0,r1/r0,rminNewton/r0,rminCauchyM/r0,rminCauchyD/r0,rCN/r0)
fprintf("\t r0=%-13.7g \t r1/r0=%-13.7g \t rminNewton/r0=%-13.7g \t rminCauchyM/r0=%-13.7g \t rDescent/r0=%-13.7g \t rCN/r0=%-13.7g \n",r0,r1/r0,rminNewton/r0,rminCauchyM/r0,rminCauchyD/r0,rCN/r0)
fprintf("\t g0=%-13.8g \t g1=%-13.7g \t gNewton=%-13.7g \t gM=%-13.7g \t gDescent=%-13.7g \t gCM=%-13.7g \n",0,1,gammaminNewton,gammaminCauchyM/gammaCauchyM,gammaminCauchyD,gammaminCN)
fprintf("\t \t \t \t \t \t normNewton=%-13.7g \t normCauchyM=%-13.7g \t normCauchyD=%-13.7g \t normCN=%-13.7g \n ",...
normNewton/normNewtonStep,normCauchyM/normNewtonStep,normCauchyD/normNewtonStep,normCN/normNewtonStep)
if BestMethod=="Cauchy2Newton"
fprintf("\t \t \t \t minC2N/rCauchy=%f \t minC2N/minN=%f \n",rCN/rminCauchyM,rCN/rminNewton)
end
fprintf("\t =================> Best method is %s with rmin/r0=%g <=====================\n",BestMethod,rmin/r0)
fprintf("\t =================> Best method is %s with rmin/r0=%g with rmin=%g <=====================\n",BestMethod,rmin/r0,rmin)
fprintf(" -------------------------] \n")
end
%%
Expand Down

0 comments on commit 3ac6650

Please sign in to comment.