genopt.algorithm.util.gps
Class ModelGPS

java.lang.Object
  extended by genopt.algorithm.Optimizer
      extended by genopt.algorithm.util.gps.ModelGPS
Direct Known Subclasses:
GPSCoordinateSearch

public abstract class ModelGPS
extends Optimizer

Abstract class with model Generalized Pattern Search algorithm.

This project was carried out at:

and supported by

GenOpt Copyright (c) 1998-2011, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

Version:
GenOpt(R) 3.1.0 (December 8, 2011)

Author:
Michael Wetter

Field Summary
private  double Alpha
          Exponent used for the control of the mesh size if adaptive precision function evaluations are used
 double[][] basDirMat
          The base direction matrix.
private  Point[] BesPoi
          Points for the multi-start algorithms.
protected  boolean checkObjFun
          A flag whether the cost function value has to be checked for previous matching results.
private  double Delta
          The mesh size factor
private  int dimF
          The number of function values
private  int dimX
          The number of independent variables
static Point[] EMPTY_SEARCH_SET
          Array of points with zero elements.
protected static java.lang.String FAIMOV
           
private  double fNor
          The cost function value that will be used in the normalization of the sufficient decrease condition
private  int iniMesSizExp
          The initial mesh size exponent 's_k'
private  int k
          The iteration number (counting only the main loop)
private  int mesSizDiv
          The mesh size divider 'r'
private  int mesSizExpInc
          The increment of the mesh size exponent 't_k' (fixed for all k)
protected static java.lang.String NEGDIR
           
protected  int nMaxSteRed
          The maximal number of step reduction before the algorithm terminates
private  int nSteRed
          The number of step reduction done up to now
private  int NumIniPoi
          Number of intial point of the multi-start algorithm
private  FunctionEvaluator PhiFun
          Function evaluator for the sufficient decrease condition and the mesh size control, i.e., the function phi
protected static java.lang.String POSDIR
           
private  java.util.Random RanGen
          Random number generator (used for multistart algorithm)
private  boolean RepMin
          Flag that determines whether the minimum will be reported or not
protected static java.lang.String SUCMOV
           
private  Point[] x
          The sequence of iterates
private  double Zeta
          Factor that will be multiplied with the function PhiFun for sufficient decrease in cost
 
Fields inherited from class genopt.algorithm.Optimizer
done, EXCLUDING, FS, INCLUDING, LS, MAINITERATION, ORIGINAL, SUBITERATION, TRANSFORMED
 
Constructor Summary
ModelGPS(GenOpt genOptData)
          Constructor used to run it as a single algorithm.
ModelGPS(int meshSizeDivider, int initialMeshSizeExponent)
          Constructor used to run the algorithm in a hybrid algorithm for the last iterations.
 
Method Summary
private  double _getFunctionValue(FunctionEvaluator f, Point x)
           
private  FunctionEvaluator _getPrecisionControlFunction(java.lang.String funNam, int include)
          Makes an instance of the function that is used for a sufficient decrease condition.
private  int _run(Point xIni)
          Runs the optimization process until a termination criteria is satisfied
protected  Point[] add(Point[] x0, Point[] x1)
          Adds two vectors of points
 void checkObjectiveFunctionValue(Point x)
          Checks whether the cost function value has already been obtained previously.
static double[] getClosestEuclideanMeshPoint(double[] x, double[] xMes, double[] delta)
          Gets the mesh point, on a rectangular mesh, that is closest to the argument.
protected  double getDelta()
          Gets the current mesh size factor
 Point getF(Point x)
          Gets the cost function value and registers it into the data base
protected static int getIndexLowestFunctionValue(Point[] x)
           
protected  double getInitialDelta()
          Gets the initial mesh size divider
protected  int getIterationNumber()
          Gets the iteration number
protected  int getMaximumNumberOfStepReduction()
          Gets the maximum number of step reductions.
 Point getMinimumPoint()
          Gets the minimum point.
protected  int getNumberOfStepReduction()
          Gets the number of step reductions done up to now.
private  Point[] getRandomPoints(int numPoi)
          Initializes the iterates for the multi-start algorithm.
protected abstract  Point[] globalSearch(Point[] x, double delta)
          Abstract method for the global search.
protected  boolean haveSufficientDecrease(Point xNew, Point xBestOld)
           
private static Point[] increaseSize(Point[] x)
           
protected abstract  double[][] initializeBaseDirectionMatrix()
          Method that initializes the base direction matrix.
protected abstract  Point[] localSearch(Point[] x, double delta)
          Abstract method for the local search.
private  void parseCommandFile(int meshSizeDivider, int initialMeshSizeExponent)
          Parses the command file.
 void report(Point x, boolean MainIteration)
          Reports the new trial
protected  void reportMinimum()
          Reports the minimum point depending on the flag set by protected void reportMinimum(boolean).
protected  void reportMinimum(boolean doReport)
          Sets a flag that determines whether the minimum will be reported or not.
 int run(Point x0)
          Runs the optimization process until a termination criteria is satisfied
protected  void setMaximumNumberOfStepReduction(int maxNumberOfStepReductions)
          Sets the maximum number of step reductions.
 
Methods inherited from class genopt.algorithm.Optimizer
algorithmRequiresUsageOfStepNumber, appendToOutputListing, checkMaxIteration, ensureOnlyContinuousParameters, ensureOnlyDiscreteParameters, getAbsAccuracyFunction, getDimensionContinuous, getDimensionDiscrete, getDimensionF, getDimensionX, getDiscreteValueDouble0, getDx, getDx0, getF, getIndex0, getIndex0, getInputValueBoolean, getInputValueDouble, getInputValueDouble, getInputValueInteger, getInputValueInteger, getInputValueString, getInputValueString, getKindOfConstraint, getL, getLengthDiscrete, getMainIterationNumber, getMaximumThreadPoolSize, getMaxIterationNumber, getMode, getObjectiveFunctionName, getOutputPath, getPointerToEqualPoints, getRelAccuracyFunction, getSimulationNumber, getStepNumber, getU, getVariableNameContinuous, getVariableNameDiscrete, getX0, getX0, goToEndOfCommandFile, increaseStepNumber, increaseStepNumber, isFeasible, isNextToken, maxIterationReached, mustStopOptimization, print, println, replace, reportCurrentLowestPoint, resetStepNumber, roundCoordinates, run, setInfo, setMode, setNumberOfMatchingResults, setToFeasibleCoordinate, setToFeasibleCoordinate, setWarning, simulate, throwInputError, useStepNumber, writeStepNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_SEARCH_SET

public static final Point[] EMPTY_SEARCH_SET
Array of points with zero elements.


dimX

private int dimX
The number of independent variables


dimF

private int dimF
The number of function values


Zeta

private double Zeta
Factor that will be multiplied with the function PhiFun for sufficient decrease in cost


PhiFun

private FunctionEvaluator PhiFun
Function evaluator for the sufficient decrease condition and the mesh size control, i.e., the function phi


Alpha

private double Alpha
Exponent used for the control of the mesh size if adaptive precision function evaluations are used


basDirMat

public double[][] basDirMat
The base direction matrix.
Each column vector is a direction.


mesSizDiv

private int mesSizDiv
The mesh size divider 'r'


iniMesSizExp

private int iniMesSizExp
The initial mesh size exponent 's_k'


mesSizExpInc

private int mesSizExpInc
The increment of the mesh size exponent 't_k' (fixed for all k)


nMaxSteRed

protected int nMaxSteRed
The maximal number of step reduction before the algorithm terminates


nSteRed

private int nSteRed
The number of step reduction done up to now


x

private Point[] x
The sequence of iterates


fNor

private double fNor
The cost function value that will be used in the normalization of the sufficient decrease condition


k

private int k
The iteration number (counting only the main loop)


Delta

private double Delta
The mesh size factor


checkObjFun

protected boolean checkObjFun
A flag whether the cost function value has to be checked for previous matching results.


NumIniPoi

private int NumIniPoi
Number of intial point of the multi-start algorithm


BesPoi

private Point[] BesPoi
Points for the multi-start algorithms. This array holds the best iterate obtained from each starting point.


RepMin

private boolean RepMin
Flag that determines whether the minimum will be reported or not


RanGen

private java.util.Random RanGen
Random number generator (used for multistart algorithm)


SUCMOV

protected static java.lang.String SUCMOV

FAIMOV

protected static java.lang.String FAIMOV

POSDIR

protected static final java.lang.String POSDIR
See Also:
Constant Field Values

NEGDIR

protected static final java.lang.String NEGDIR
See Also:
Constant Field Values
Constructor Detail

ModelGPS

public ModelGPS(GenOpt genOptData)
         throws OptimizerException,
                java.io.IOException,
                java.lang.Exception,
                InputFormatException
Constructor used to run it as a single algorithm.

Parameters:
genOptData - a reference to the GenOpt object.
Note: The object is used as a reference. Hence, its data are modified by this Class.
Throws:
OptimizerException
java.lang.Exception
java.io.IOException - if an I/O exception occurs
InputFormatException

ModelGPS

public ModelGPS(int meshSizeDivider,
                int initialMeshSizeExponent)
         throws OptimizerException,
                java.io.IOException,
                java.lang.Exception,
                InputFormatException
Constructor used to run the algorithm in a hybrid algorithm for the last iterations.

Parameters:
meshSizeDivider - the mesh size divider. If set to Integer.MAX_VALUE, then the value will be read from the command file
initialMeshSizeExponent - the initial mesh size exponent. If set to Integer.MAX_VALUE, then the value will be read from the command file
Throws:
OptimizerException
java.lang.Exception
java.io.IOException - if an I/O exception occurs
InputFormatException
Method Detail

parseCommandFile

private void parseCommandFile(int meshSizeDivider,
                              int initialMeshSizeExponent)
                       throws OptimizerException,
                              java.io.IOException,
                              java.lang.Exception,
                              InputFormatException
Parses the command file.

Parameters:
meshSizeDivider - the mesh size divider. If set to Integer.MAX_VALUE, then the value will be read from the command file
initialMeshSizeExponent - the initial mesh size exponent. If set to Integer.MAX_VALUE, then the value will be read from the command file
Throws:
OptimizerException
java.lang.Exception
java.io.IOException - if an I/O exception occurs
InputFormatException

_getPrecisionControlFunction

private final FunctionEvaluator _getPrecisionControlFunction(java.lang.String funNam,
                                                             int include)
                                                      throws OptimizerException,
                                                             java.io.IOException,
                                                             java.lang.Exception,
                                                             InputFormatException
Makes an instance of the function that is used for a sufficient decrease condition.

Parameters:
funNam - the keyword of the function
include - flag that specifies if zero is includes as a function value or not
Returns:
the function that is used for a sufficient decrease condition
Throws:
OptimizerException
java.lang.Exception
java.io.IOException
InputFormatException

initializeBaseDirectionMatrix

protected abstract double[][] initializeBaseDirectionMatrix()
Method that initializes the base direction matrix.

Each column vector is a direction, and the set of column vectors must be a positive span for the domain of independent parameters.

Returns:
baseDireMat the base direction matrix

getRandomPoints

private Point[] getRandomPoints(int numPoi)
Initializes the iterates for the multi-start algorithm.

Parameters:
numPoi - number of initial points
Returns:
the initial iterates

run

public int run(Point x0)
        throws SimulationInputException,
               OptimizerException,
               java.lang.NoSuchMethodException,
               java.lang.IllegalAccessException,
               java.lang.Exception
Runs the optimization process until a termination criteria is satisfied

Specified by:
run in class Optimizer
Parameters:
x0 - Initial iterate
Returns:
-1 if the maximum number of iteration is exceeded
+1 if the required accuracy is reached
Throws:
OptimizerException - if an OptimizerException occurs or if the user required to stop GenOpt
SimulationInputException - if an error in writing the simulation input file occurs
java.lang.NoSuchMethodException - if a method that should be invoked could not be found
java.lang.IllegalAccessException - if an invoked method enforces Java language access control and the underlying method is inaccessible
java.lang.reflect.InvocationTargetException - if an invoked method throws an exception
java.lang.Exception - if an I/O error in the simulation input file occurs

_run

private int _run(Point xIni)
          throws SimulationInputException,
                 OptimizerException,
                 java.lang.NoSuchMethodException,
                 java.lang.IllegalAccessException,
                 java.lang.Exception
Runs the optimization process until a termination criteria is satisfied

Returns:
-1 if the maximum number of iteration is exceeded
+1 if the required accuracy is reached
Throws:
OptimizerException - if an OptimizerException occurs or if the user required to stop GenOpt
SimulationInputException - if an error in writing the simulation input file occurs
java.lang.NoSuchMethodException - if a method that should be invoked could not be found
java.lang.IllegalAccessException - if an invoked method enforces Java language access control and the underlying method is inaccessible
java.lang.reflect.InvocationTargetException - if an invoked method throws an exception
java.lang.Exception - if an I/O error in the simulation input file occurs

_getFunctionValue

private final double _getFunctionValue(FunctionEvaluator f,
                                       Point x)
                                throws OptimizerException,
                                       java.lang.NoSuchMethodException,
                                       java.lang.IllegalAccessException,
                                       java.lang.reflect.InvocationTargetException
Throws:
OptimizerException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

haveSufficientDecrease

protected final boolean haveSufficientDecrease(Point xNew,
                                               Point xBestOld)
                                        throws OptimizerException,
                                               java.lang.NoSuchMethodException,
                                               java.lang.IllegalAccessException,
                                               java.lang.reflect.InvocationTargetException
Throws:
OptimizerException
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

add

protected final Point[] add(Point[] x0,
                            Point[] x1)
Adds two vectors of points

Parameters:
x0 - first vector of points
x1 - second vector of points
Returns:
the new vector of points

getInitialDelta

protected final double getInitialDelta()
Gets the initial mesh size divider

Returns:
the initial mesh size divider

getDelta

protected final double getDelta()
Gets the current mesh size factor

Returns:
the current mesh size factor

getIterationNumber

protected final int getIterationNumber()
Gets the iteration number

Returns:
the iteration number

increaseSize

private static final Point[] increaseSize(Point[] x)

getIndexLowestFunctionValue

protected static int getIndexLowestFunctionValue(Point[] x)

reportMinimum

protected void reportMinimum(boolean doReport)
Sets a flag that determines whether the minimum will be reported or not. This is used by algorithms that run ModelGPS multiple times, such as multi-start methods, and need to prevent it from reporting the minimum.

Parameters:
doReport -

reportMinimum

protected void reportMinimum()
                      throws java.io.IOException
Reports the minimum point depending on the flag set by protected void reportMinimum(boolean).
This method gets the minimum point from the data base, calls the function report with an corresponding comment and reports the minimum point to the output device.

Overrides:
reportMinimum in class Optimizer
Throws:
java.io.IOException - if an I/O error in the optimization output files occurs

getMinimumPoint

public Point getMinimumPoint()
Gets the minimum point.

Overrides:
getMinimumPoint in class Optimizer
Returns:
the point with the lowest function value

globalSearch

protected abstract Point[] globalSearch(Point[] x,
                                        double delta)
                                 throws SimulationInputException,
                                        OptimizerException,
                                        java.lang.NoSuchMethodException,
                                        java.lang.IllegalAccessException,
                                        java.lang.Exception
Abstract method for the global search.

Parameters:
x - Sequence of previous iterates
delta - current mesh size
Returns:
the sequence of points that have been evaluated in the global search. Each point must be a mesh point. If no point has been evaluated, then this method must return EMPTY_SEARCH_SET.
Throws:
OptimizerException - if an OptimizerException occurs or if the user required to stop GenOpt
SimulationInputException - if an error in writing the simulation input file occurs
java.lang.NoSuchMethodException - if a method that should be invoked could not be found
java.lang.IllegalAccessException - if an invoked method enforces Java language access control and the underlying method is inaccessible
java.lang.reflect.InvocationTargetException - if an invoked method throws an exception
java.lang.Exception - if an I/O error in the simulation input file occurs

localSearch

protected abstract Point[] localSearch(Point[] x,
                                       double delta)
                                throws SimulationInputException,
                                       OptimizerException,
                                       java.lang.NoSuchMethodException,
                                       java.lang.IllegalAccessException,
                                       java.lang.Exception
Abstract method for the local search.

Parameters:
x - Sequence of previous iterates
delta - current mesh size
Returns:
the sequence of points that have been evaluated in the local search, regardless whether they reduced the cost function value or not.
Throws:
OptimizerException - if an OptimizerException occurs or if the user required to stop GenOpt
SimulationInputException - if an error in writing the simulation input file occurs
java.lang.NoSuchMethodException - if a method that should be invoked could not be found
java.lang.IllegalAccessException - if an invoked method enforces Java language access control and the underlying method is inaccessible
java.lang.reflect.InvocationTargetException - if an invoked method throws an exception
java.lang.Exception - if an I/O error in the simulation input file occurs

checkObjectiveFunctionValue

public void checkObjectiveFunctionValue(Point x)
                                 throws OptimizerException
Checks whether the cost function value has already been obtained previously.
If it has been obtained previously, an information message is reported. If the maximum number of matching function value is obtained, an exception is thrown.

Overrides:
checkObjectiveFunctionValue in class Optimizer
Parameters:
x - the point to be checked
Throws:
OptimizerException - thrown if the maximum number of matching function value is obtained

report

public void report(Point x,
                   boolean MainIteration)
            throws java.io.IOException
Reports the new trial

Overrides:
report in class Optimizer
Parameters:
x - the point to be reported
MainIteration - true if step was a main iteration or false if it was a sub iteration
Throws:
java.io.IOException - if an I/O error in the optimization output files occurs

getF

public Point getF(Point x)
           throws SimulationInputException,
                  OptimizerException,
                  java.lang.NoSuchMethodException,
                  java.lang.IllegalAccessException,
                  java.lang.Exception
Gets the cost function value and registers it into the data base

Overrides:
getF in class Optimizer
Parameters:
x - the point being evaluated
Returns:
a clone of the point with the new function values stored
Throws:
OptimizerException - if an OptimizerException occurs or if the user required to stop GenOpt
SimulationInputException - if an error in writing the simulation input file occurs
java.lang.NoSuchMethodException - if a method that should be invoked could not be found
java.lang.IllegalAccessException - if an invoked method enforces Java language access control and the underlying method is inaccessible
java.lang.reflect.InvocationTargetException - if an invoked method throws an exception
java.lang.Exception - if an I/O error in the simulation input file occurs

getNumberOfStepReduction

protected int getNumberOfStepReduction()
Gets the number of step reductions done up to now. The return value is a zero-based counter.

Returns:
the number of step reductions done up to now

getMaximumNumberOfStepReduction

protected int getMaximumNumberOfStepReduction()
Gets the maximum number of step reductions.

Returns:
the maximum number of step reductions

setMaximumNumberOfStepReduction

protected void setMaximumNumberOfStepReduction(int maxNumberOfStepReductions)
Sets the maximum number of step reductions.

Parameters:
maxNumberOfStepReductions - the maximum number of step reductions

getClosestEuclideanMeshPoint

public static double[] getClosestEuclideanMeshPoint(double[] x,
                                                    double[] xMes,
                                                    double[] delta)
Gets the mesh point, on a rectangular mesh, that is closest to the argument.

Parameters:
x - independent parameter
xMes - any point on the mesh
delta - mesh size factor times the step size of the variable
Returns:
the mesh point that is closest to x in the Euclidean norm.