org.omegahat.Numerics.Optimizers
Class LineStepBasic

java.lang.Object
  |
  +--org.omegahat.Numerics.Optimizers.LineStepBasic
All Implemented Interfaces:
LineStep

public class LineStepBasic
extends java.lang.Object
implements LineStep

the basic representation of a step in a line search.

Included is a field for the step size.

Also included are some methods to deal with gradients, but gradient-free search algorithms can just ignore these.


Field Summary
protected  NumericArray direction
           
protected  NumericArray origin
           
protected  ModelPointNumericInt point
           
protected  double slope
          the slope (component of the gradient along this direction).
protected  double step
          the step along the search direction.
 
Constructor Summary
LineStepBasic(ModelPointNumericInt point)
           
 
Method Summary
 void copyData(LineStep source)
          Copy data from an arbitrary line step object.
 void copyData(LineStepBasic source)
          Copy in the information from another LineStepBasic object.
 void evaluate()
           
 NumericArray getDirection()
          Accessor for direction field
 NumericArray getOrigin()
          Accessor for origin field
 ModelPointNumericInt getPoint()
          Accessor for point field
 double getSlope()
          Accessor for slope field
 double getStep()
          Accessor for step field
 double getValue()
          Get the value of the underlying model at this step point.
 void getValues(boolean doValue, boolean doGradient)
          Compute the value and/or the gradient of the underlying model.
 NumericArray setDirection(NumericArray value)
          Accessor for setting direction field.
 NumericArray setOrigin(NumericArray value)
          Accessor for setting origin field
 ModelPointNumericInt setPoint(ModelPointNumericInt value)
          Accessor for setting point field
 double setSlope()
          compute the slope field from the gradient at the point.
 double setSlope(double value)
          Accessor for setting slope field
 double setStep(double value)
          Accessor for setting step field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

point

protected ModelPointNumericInt point

step

protected double step
the step along the search direction.

It may or may not be normalized, depending on the algorithm.


slope

protected double slope
the slope (component of the gradient along this direction).

direction

protected NumericArray direction

origin

protected NumericArray origin
Constructor Detail

LineStepBasic

public LineStepBasic(ModelPointNumericInt point)
Method Detail

getPoint

public ModelPointNumericInt getPoint()
Accessor for point field
Specified by:
getPoint in interface LineStep

setPoint

public ModelPointNumericInt setPoint(ModelPointNumericInt value)
Accessor for setting point field
Specified by:
setPoint in interface LineStep

getStep

public double getStep()
Accessor for step field
Specified by:
getStep in interface LineStep

setStep

public double setStep(double value)
Accessor for setting step field.

The parameters property is set correspondingly, using the origin and direction properties and the given step.

Specified by:
setStep in interface LineStep

getSlope

public double getSlope()
Accessor for slope field
Specified by:
getSlope in interface LineStep

setSlope

public double setSlope(double value)
Accessor for setting slope field
Specified by:
setSlope in interface LineStep

getDirection

public NumericArray getDirection()
Accessor for direction field
Specified by:
getDirection in interface LineStep

setDirection

public NumericArray setDirection(NumericArray value)
Accessor for setting direction field.

Also computes and sets the slope property, if the gradient has been evaluated at the point. To start a line search computation, you should arrange for the model point to be evaluated, or else make sure that the slope is set explicitly. Also, if the slope is to be set to something other than the inner product of the gradient and the direction (a slightly perverse idea), you will need to set the slope explicitly after setting the direction.

Specified by:
setDirection in interface LineStep

getOrigin

public NumericArray getOrigin()
Accessor for origin field
Specified by:
getOrigin in interface LineStep

setOrigin

public NumericArray setOrigin(NumericArray value)
Accessor for setting origin field
Specified by:
setOrigin in interface LineStep

setSlope

public double setSlope()
compute the slope field from the gradient at the point.

If the gradient is null, the slope is NaN.

Specified by:
setSlope in interface LineStep

getValue

public double getValue()
Get the value of the underlying model at this step point.

If necessary, evaluate the model.

Specified by:
getValue in interface LineStep

getValues

public void getValues(boolean doValue,
                      boolean doGradient)
Compute the value and/or the gradient of the underlying model.

copyData

public void copyData(LineStepBasic source)
Copy in the information from another LineStepBasic object.

If suitable fields (parameters, gradient, hessian) exist in the current object, they are overwritten from the source; if they do not exist or are the wrong size, new fields are allocated.


copyData

public void copyData(LineStep source)
Copy data from an arbitrary line step object. However, only works if the object can be cast to LineStepBasic.
Specified by:
copyData in interface LineStep

evaluate

public void evaluate()
              throws ModelEvaluationException