Mercurial > hg > jslab
view src/samer/maths/opt/UnconstrainedMinimiser.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.util.heavy.*; /** unconstrained minimiser for smooth functions: - ConjugateGradient - OR Quasi-newton (using GillMurray uydates) - Safeguarded cubic interpolation line search using gradients */ public class UnconstrainedMinimiser extends MinimiserBase { GillMurray dir; double guess; /** expects to find Vec at top of stack, Functionx just below. */ public UnconstrainedMinimiser(Vec v, Functionx f) { // can we rely on evaluation order here? super(v,f); dir = new GillMurray(this); add( dir.hessin.viewable()); } public void run() { double beta; int i, maxiter=getMaxiter(); // boolean triedSteepest=false; // dir.resetHessian(1); evaluate(); dir.init(); setSlope(); // beta = beta.value; beta = initialStep(); sig1.off(); for (i=1; i<=maxiter; i++) { lstest.init(); step(beta); 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.steepest(); dir.update(); dir.init(); setSlope(); // triedSteepest=true; continue; } if (xfconv.isSatisfied(this)) { break; } // beta = beta.value; beta = nextStep(); dir.update(); move(); perIteration(); } perOptimisation(i); dir.hessin.changed(); } }