(final int dim, final VEval lastEval)
| 66 | } |
| 67 | |
| 68 | @SuppressWarnings("unused") |
| 69 | private NewtonReturn newtonStep(final int dim, final VEval lastEval) { |
| 70 | final double normsq = LinUtil.dot(lastEval.gx,lastEval.gx); |
| 71 | if(normsq<=minGNormSQ) { |
| 72 | return new NewtonReturn(StepStatus.smallGNorm,null); |
| 73 | } |
| 74 | double[][] hx = lastEval.hx; |
| 75 | if(ridgeTerm>0.0) { // Tikhonov regularization on the linear algebra (indep of any regularization on the overall fn). |
| 76 | hx = LinUtil.copy(hx); |
| 77 | for(int i=0;i<dim;++i) { |
| 78 | hx[i][i] += ridgeTerm; |
| 79 | } |
| 80 | } |
| 81 | try { // try a Newton step |
| 82 | final double[] delta = lSolver.solve(hx,lastEval.gx); |
| 83 | final double[] newX = newX(lastEval.x,delta,-1); |
| 84 | return new NewtonReturn(StepStatus.goodNewtonStep,newX); |
| 85 | } catch (Exception ex) { |
| 86 | log.info("solve caught: " + ex); |
| 87 | } |
| 88 | // sub in gradient as a usable direction |
| 89 | final double[] newX = newX(lastEval.x,lastEval.gx,-1); |
| 90 | return new NewtonReturn(StepStatus.linFailure,newX); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | public VEval maximizeStep(final VectorFn f, final double[] x0, |
no test coverage detected