samer@0: /* samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.maths.opt; samer@0: import samer.maths.*; samer@0: import samer.core.*; samer@0: import samer.core.types.*; samer@0: samer@0: /** samer@0: Cubic line search with positivity constraints samer@0: dimensions become inactive when they go to samer@0: zero and the gradient > GEPS samer@0: */ samer@0: samer@0: public class Positivity extends Constraints samer@0: { samer@0: double XEPS=1e-6; samer@0: double GEPS=1e-4; samer@0: int [] zerod; samer@0: int released; samer@0: samer@0: public Positivity(MinimiserBase minimiser) samer@0: { samer@0: super(minimiser); samer@0: zerod=new int[n]; samer@0: samer@0: minimiser.add(new VParameter("XEPS", new DoubleModel() { samer@0: public void set(double t) { XEPS=t; } samer@0: public double get() { return XEPS; } samer@0: } ) samer@0: ); samer@0: samer@0: minimiser.add(new VParameter("GEPS", new DoubleModel() { samer@0: public void set(double t) { GEPS=t; } samer@0: public double get() { return GEPS; } samer@0: } ) samer@0: ); samer@0: } samer@0: samer@0: /** constrain all dimensions which are currently set samer@0: to zero. samer@0: */ samer@0: samer@0: public void initialise() samer@0: { samer@0: int p=0, q=0; samer@0: samer@0: for (int i=0; i=-GEPS) { samer@0: inactivate(j); samer@0: flag=true; samer@0: } samer@0: } samer@0: samer@0: return flag; samer@0: } samer@0: samer@0: samer@0: public void lineSearch(Condition convergence, CubicLineSearch ls, double beta0) samer@0: { samer@0: if (clipStep(beta0)) return; samer@0: samer@0: while (!convergence.test()) { samer@0: // formulate any other direction change conditions samer@0: samer@0: if (S.P2.f