private boolean processStepResults ( double fx_candidate , double actualReduction , double predictedReduction ) { double ratio = actualReduction / predictedReduction ; boolean accepted ; // Accept the new state if the score improved if ( fx_candidate < fx ) { // reduce the amount of dampening. Magic equation from [1]. My attempts to improve // upon it have failed. It is truly magical. lambda = lambda * max ( 1.0 / 3.0 , 1.0 - Math . pow ( 2.0 * ratio - 1.0 , 3.0 ) ) ; nu = NU_INITIAL ; accepted = true ; } else { lambda *= nu ; nu *= 2 ; accepted = false ; } if ( UtilEjml . isUncountable ( lambda ) || UtilEjml . isUncountable ( nu ) ) throw new OptimizationException ( "BUG! lambda=" + lambda + " nu=" + nu ) ; if ( accepted ) { boolean converged = checkConvergenceFTest ( fx_candidate , fx ) ; if ( verbose != null ) { double length_p = NormOps_DDRM . normF ( p ) ; // TODO compute elsewhere ? verbose . printf ( "%-4d %9.3E %10.3E %9.3E %9.3E %9.3E %6.3f %6.2E\n" , totalSelectSteps , fx_candidate , fx_candidate - fx , length_p , ftest_val , gtest_val , ratio , lambda ) ; if ( converged ) { verbose . println ( "Converged f-test" ) ; } } acceptNewState ( fx_candidate ) ; return maximumLambdaNu ( ) || converged ; } else return false ; }
Sees if this is an improvement worth accepting . Adjust dampening parameter and change the state if accepted .