Mercurial > hg > jslab
view src/samer/maths/opt/UnconstrainedConjGrad.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
/* * Copyright (c) 2000, Samer Abdallah, King's College London. * All rights reserved. * * This software is provided AS iS and WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ package samer.maths.opt; import samer.maths.*; import samer.core.*; import samer.core.types.*; import samer.core.util.heavy.*; /** unconstrained minimiser for smooth functions: - ConjugateGradient - OR Quasi-newton (using GillMurray updates) - Safeguarded cubic interpolation line search using gradients */ public class UnconstrainedConjGrad extends MinimiserBase { ConjGrad dir; double guess; public UnconstrainedConjGrad(Vec v, Functionx f) { super(v,f); dir = new ConjGrad(this); add(new VParameter( "hessian", new DoubleModel() { public void set(double h) { dir.invhess=1/h; } public double get() { return 1/dir.invhess; } } )); } public void stopping() {} public void run() { double beta; int i, maxiter=getMaxiter(); boolean triedSteepest=false; // dir.resetHessian(1); evaluate(); dir.init(); setSlope(); // beta = vs.beta.value; beta = initialStep(); sig1.off(); for (i=0; i<maxiter; i++) { step(beta); lstest.init(); ls.run(lstest); // line search lsiters.next(lstest.count); steplength.next(alpha); if (lstest.tiny && (P2.f>=P1.f)) { // tiny step was no good sig1.on(); sig2.off(); if (gconv.isSatisfied(P1.g,this)) break; if (triedSteepest=true) break; sig2.on(); beta = this.beta.value; dir.init(); // reset to steepest descent setSlope(); triedSteepest=true; continue; } if (xfconv.isSatisfied(this)) { break; } beta = nextStep(); // beta = vs.beta.value; dir.update(); move(); perIteration(); } perOptimisation(i); // finishing off stuff } }