|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgenopt.algorithm.Optimizer
public abstract class Optimizer
Abstract Class that represents the structure of an optimization
algorithm class and offers generic methods to run the optimization.
All optimization algorithms must extend this class.
Note that many data fields are static. This is needed for the
hybrid algorithms.
This project was carried out at:
and supported byGenOpt 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.
| Field Summary | |
|---|---|
private static java.io.StreamTokenizer |
algorithm
The section Algorithm of the command file |
private int |
conMode
flag for indicating how constraints are treated |
private static GenOpt |
data
The reference to the GenOpt kernel |
private static int |
dimCon
The number of independent, continuous variables |
private static int |
dimDis
The number of independent, discrete variables |
private static int |
dimF
The number of cost function values |
private static int |
dimInpFun
The number of input functions |
private static int |
dimX
The number of independent variables (sum of continuous and discrete) |
static java.util.concurrent.CountDownLatch |
done
Count down latch for parallel function evaluations |
private static java.util.Map<Point,java.lang.Double[]> |
evaPoi
The list with evaluated points and its function values. |
static int |
EXCLUDING
constant to indicate strict inequality |
private boolean |
firstSimulations
Flag that indicates whether the set of points that are currently evaluated are the first simulations. |
protected static java.lang.String |
FS
System dependent file separator |
private static java.util.concurrent.atomic.AtomicBoolean |
functionValuesParsed
Flag that indicates whether function values have been parsed at least once |
private java.util.concurrent.CountDownLatch |
funValParLat
Count down latch, if 0, the function value pointer funValPoi has been set |
private static int[] |
funValPoi
pointer that assign to each objective function value the number of the output file in which it is stored |
static int |
INCLUDING
constant to indicate weak inequality |
protected static java.lang.String |
LS
System dependent line separator |
static boolean |
MAINITERATION
constant to indicate that it is a main iteration |
private static int |
maxThrPoo
The maximum number of threads in the pool |
private static java.lang.String[] |
nameF
The name of the function values |
private static int |
nSimInpFil
The number of the simulation input files |
private static int |
nSimLogFil
The number of the simulation log files |
private static int |
nSimOutFil
The number of the simulation output files |
private static ObjectiveFunctionLocation[] |
objFunObj
The objective function objects |
private static java.lang.String |
optComFilNam
The name of the optimization command file |
static int |
ORIGINAL
constant for indicating that the optimization is in the original space |
private static java.lang.String |
separator
Separator that separate the objective function value from the values behind it. |
private static FileHandler[] |
simInpTemFilHan
The simulation input template file handler |
private static int |
stepNumber
The step number (for implementing variation of the weighting factors for penalty function and barrier function |
static boolean |
SUBITERATION
constant to indicate that it is a sub iteration |
static int |
TRANSFORMED
constant for indicating that the optimization is in the transformed space |
private static boolean |
useSteNum
A flag to indicate whether the step number is used by the optimization algorithm. |
private static boolean |
wriSteNum
A flag to indicate whether the step number has to be written in the simulation input file (and hence a simulation done) |
| Constructor Summary | |
|---|---|
|
Optimizer()
Constructor |
protected |
Optimizer(GenOpt genOptData,
int constraintMode)
Constructor |
| Method Summary | |
|---|---|
private void |
_copyRunFiles(java.lang.String[] savePath,
java.lang.String[] path,
java.lang.String[] name,
int simNum)
Copies the files from path to savePath and
adds the run number in front of the file name. |
private void |
_deleteRunFiles(java.lang.String[] path,
java.lang.String[] name)
Deletes the run files specified by path and name. |
private Point |
_evaluateSimulation(Point x)
Evaluates the simulation writes a new input file launches the simulation checks for simulation errors returns an array with the values of the objective function |
private static double[] |
_processResultFunction(java.lang.String[] formula,
double[] objFunVal)
Process the function objects for post processing of the objective function. |
private static boolean |
_replaceInInputFile(java.lang.String text,
java.lang.String value,
FileHandler[] simulationInput)
Replaces text with value in simulationInput. |
private Point |
_retryEvaluateSimulation(Point x,
java.lang.Throwable t)
Tries to evaluate the simulation a second time if an exception has been thrown |
private static double |
_setToFeasibleCoordinate(double x,
double l,
double u)
Computes x := 2 * l - x if x < l,
or x := 2 * u - x if x < u. |
private static int |
_setToFeasibleCoordinate(int x,
int l,
int u)
Computes x := 2 * l - x if x < l,
or x := 2 * u - x if x < u. |
private static void |
_variableNotFound(java.lang.String variableName)
Throws a SimulationInputException that says that the variable
could not be found. |
protected void |
algorithmRequiresUsageOfStepNumber()
A call to this method sets useSteNum = true. |
void |
appendToOutputListing(java.lang.String s)
appends a String to the output listing files |
protected boolean |
checkMaxIteration()
Checks if the maximum number of iteration is exceeded |
void |
checkObjectiveFunctionValue(Point x)
Checks whether the last objective function value has already been obtained previously. |
protected void |
ensureOnlyContinuousParameters()
Checks whether all independent parameters are continuous. |
protected void |
ensureOnlyDiscreteParameters()
Checks whether all independent parameters are discrete. |
protected double |
getAbsAccuracyFunction()
Gets the absolute accuracy of the last two main iterations |
int |
getDimensionContinuous()
Gets the number of independent, continuous variables |
int |
getDimensionDiscrete()
Gets the number of independent, continuous variables |
int |
getDimensionF()
Gets the number of function values |
int |
getDimensionX()
Gets the number of independent variables (sum of continuous and discrete) |
double |
getDiscreteValueDouble0(int variableNumber)
Gets the double representation of the variableNumber-th
discrete parameter as specified in the command fileIf the variable represents discrete numerical values, then the double value of the currently selected value is returned. |
double |
getDx(int i,
double x)
Gets the step size dx[i] of the i-th continuous variableNote: dx[i] might be in the transformed space
depending on the value of conMode. |
double |
getDx0(int i)
Gets the step size dx[i] of the i-th continuous variable as specified
in the command file. |
Point |
getF(Point x)
Evaluates the simulation for the point x The value conMode determines in which mode the constraints
are treated. |
Point[] |
getF(Point[] x,
boolean stopAtError)
Evaluates the simulation for the point x The value conMode determines in which mode the constraints
are treated. |
int[] |
getIndex0()
Gets the indices of the discrete variable x |
int |
getIndex0(int i)
Gets the value (i.e., the index) of x[i] |
protected boolean |
getInputValueBoolean(java.lang.String keyWord)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
protected double |
getInputValueDouble(java.lang.String keyWord)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
protected double |
getInputValueDouble(java.lang.String keyWord,
double min,
double minEqu,
double max,
double maxEqu)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
protected int |
getInputValueInteger(java.lang.String keyWord)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
protected int |
getInputValueInteger(java.lang.String keyWord,
int min,
int minEqu,
int max,
int maxEqu)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
protected java.lang.String |
getInputValueString(java.lang.String keyWord)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
protected java.lang.String |
getInputValueString(java.lang.String keyWord,
java.lang.String[] admVal)
Gets the value of keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown |
int |
getKindOfConstraint(int i)
Gets the kind of constraint that is imposed on the i-th continuous variable |
double |
getL(int i)
Gets the lower bound l[i] of the continuous
variable x[i] |
int |
getLengthDiscrete(int i)
Gets the number of elements of the i-th discrete variable |
protected int |
getMainIterationNumber()
Gets the main iteration number |
static int |
getMaximumThreadPoolSize()
Returns the maximum size of the thread pool |
protected int |
getMaxIterationNumber()
Gets the maximum number of allowed main iterations |
Point |
getMinimumPoint()
Gets the minimum point. |
int |
getMode()
Gets the mode of the optimization |
java.lang.String |
getObjectiveFunctionName(int i)
Gets the name of the i-th objective function value. |
protected java.lang.String |
getOutputPath()
Gets the output path. |
static int[] |
getPointerToEqualPoints(Point[] x)
Gets an integer array that shows what points are equals. |
protected double |
getRelAccuracyFunction()
Gets the relative accuracy of the last two main iterations |
protected static int |
getSimulationNumber()
Gets the number of simulation. |
protected int |
getStepNumber()
Gets the current step number |
double |
getU(int i)
Gets the upper bound u[i] of the continuous
variable x[i] |
java.lang.String |
getVariableNameContinuous(int i)
Gets the name of the continuous variable x[i] |
java.lang.String |
getVariableNameDiscrete(int i)
Gets the name of the discrete variable x[i] |
double[] |
getX0()
Gets the values of the continuous variable xNote: x might be in the transformed space
depending on the value of conMode |
double |
getX0(int i)
Gets the value of x[i]Note: x[i] might be in the transformed space
depending on the value of conMode |
void |
goToEndOfCommandFile()
Checks whether the current section is closed and then moves to the end of the file. |
protected void |
increaseStepNumber()
Increases the step number without a function evaluation. |
protected Point |
increaseStepNumber(Point x)
Increases the step number. |
protected boolean |
isFeasible(Point x)
Checks whether a point is feasible. |
boolean |
isNextToken(java.lang.String keyWord)
Checks whether the next Token is equal to the passed String. |
protected boolean |
maxIterationReached()
Checks if the maximum number of iteration is reached. |
boolean |
mustStopOptimization()
Returns a flag that indicates whether GenOpt must be stopped after the current simulation (due to a user request). |
void |
print(java.lang.String text)
Prints a message to the output device without finishing the line Note: Use this method instead of System.out.printl(String),
otherwise it won't be reported in the GUI |
void |
println(java.lang.String text)
Prints a message to the output device, and then finishs the line Note: Use this method instead of System.out.println(String),
otherwise it won't be reported in the GUI |
protected static boolean |
replace(java.lang.String[] strArr,
java.lang.String text,
java.lang.String value)
Replaces text with value in input functions. |
void |
report(Point x,
boolean MainIteration)
Reports an iterate to the output files and to the internal data structure reports the new trial reports the objective function value increases the number of the iteration Note: If a sub iteration is also a main iteration, then you have to call this function twice, first with MainIteration = false and then with
MainIteration = true |
protected void |
reportCurrentLowestPoint()
Reports the current lowest point for the case that GenOpt has to terminate. |
protected void |
reportMinimum()
Reports the minimum point. |
protected static void |
resetStepNumber(int sN)
Sets the step number. |
protected static Point |
roundCoordinates(Point x)
Rounds the coordinates of the continuous parameters to float format. |
int |
run()
Method for running the optimization algorithm until a termination criteria is satisfied. |
abstract int |
run(Point x0)
Abstract method for running the optimization algorithm until a termination criteria is satisfied |
protected void |
setInfo(java.lang.String s,
int simNum)
Sets a message in the InformationManager The message will be displayed in the output stream (GUI in WinGenOpt, command shell otherwise) and in the log file |
private boolean[] |
setKnownFunctionValues(Point[] x)
Sets the function values in these points that are already known. |
void |
setMode(int constraintMode)
Sets the mode of the optimization |
protected void |
setNumberOfMatchingResults(int maxNumberOfMatchingResults)
Sets the maximal allowed number of matching results |
static double |
setToFeasibleCoordinate(double x,
double l,
double u)
Restricts the value of x such that l <= x <= u. |
static int |
setToFeasibleCoordinate(int x,
int l,
int u)
Restricts the value of x such that l <= x <= u. |
protected void |
setWarning(java.lang.String s,
int simNum)
Sets a message in the WarningManager. |
void |
simulate(Point x)
Evaluates the simulation based on the parameter set x |
protected void |
throwInputError(java.lang.String expectedValue)
Throws an input error. |
boolean |
useStepNumber()
Returns the flag that indicates whether the step number is used by the optimization algorithm. |
boolean |
writeStepNumber()
Returns the flag that indicates whether the step number has to written to the simulation input file or not. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String LS
protected static final java.lang.String FS
public static final boolean MAINITERATION
public static final boolean SUBITERATION
public static final int ORIGINAL
public static final int TRANSFORMED
public static final int EXCLUDING
public static final int INCLUDING
private int conMode
private static int dimCon
private static int dimDis
private static int dimX
private static int dimInpFun
private static int dimF
private static java.lang.String[] nameF
public static java.util.concurrent.CountDownLatch done
private static GenOpt data
private static java.io.StreamTokenizer algorithm
Algorithm of the command file
private static java.lang.String optComFilNam
private static java.lang.String separator
private static int stepNumber
private static boolean wriSteNum
private static boolean useSteNum
wriSteNum = true or
if the algorithm requires explicitly the step number to be used.
This is typically the case for algorithm that construct at some point a
surrogate function and then only seek to optimize the surrogate.
private static FileHandler[] simInpTemFilHan
private static ObjectiveFunctionLocation[] objFunObj
private static int nSimInpFil
private static int nSimLogFil
private static int nSimOutFil
private static int[] funValPoi
private static java.util.Map<Point,java.lang.Double[]> evaPoi
genopt.algorithm.util.math.Point.compareTo(java.lang.Object o)
private static int maxThrPoo
private static java.util.concurrent.atomic.AtomicBoolean functionValuesParsed
private java.util.concurrent.CountDownLatch funValParLat
private boolean firstSimulations
true, then no second simulation is done in case of an error.
| Constructor Detail |
|---|
protected Optimizer(GenOpt genOptData,
int constraintMode)
throws InputFormatException,
OptimizerException,
java.io.IOException,
java.lang.Exception
genOptData - a reference to the GenOpt object.constraintMode - a flag indicating how constraints are treated0: optimization is in original space (constraints are not taken into account) 1: optimization is in transformed space
InputFormatException - if an error occurs while searching for Main
in the Algorithm section
java.io.IOException - if an I/O exception occurs
java.lang.Exception - in an exception occurs
OptimizerExceptionpublic Optimizer()
| Method Detail |
|---|
protected static void resetStepNumber(int sN)
sN - protected java.lang.String getOutputPath()
Algorithms that write their own output files should write them
to the directory returned by this function.
protected void ensureOnlyContinuousParameters()
throws OptimizerException
OptimizerException is thrown (with an
descriptive information)
OptimizerException - if some independent parameters are not continuous
protected void ensureOnlyDiscreteParameters()
throws OptimizerException
OptimizerException is thrown (with an
descriptive information)
OptimizerException - if some independent parameters are not discrete
private void _deleteRunFiles(java.lang.String[] path,
java.lang.String[] name)
throws java.lang.Exception
path - path of the filesname - name of the files
java.lang.Exception - if a SecurityException occured
private void _copyRunFiles(java.lang.String[] savePath,
java.lang.String[] path,
java.lang.String[] name,
int simNum)
throws java.lang.SecurityException,
java.lang.Exception
path to savePath and
adds the run number in front of the file name.
savePath - path where the files have to be copied to.
If it does not exist, it will be created.path - source path of the filesname - name of the filessimNum - The number of the simulation
java.lang.SecurityException - if a SecurityException occured
java.lang.Exception - if the directory could not be madeprotected final void algorithmRequiresUsageOfStepNumber()
useSteNum = true.
This method is typically called by multiple layer algorithm that
optimize different functions during the whole optimization.
An example for such an algorithm is one that -- after some iterations --
constructs a surrogate function and then only attempts to optimize the
surrogate, neglecting all previous results.
protected final void increaseStepNumber()
WriteStepNumber is set to false, then the step number
is not increased
increaseStepNumber(Point)
protected final Point increaseStepNumber(Point x)
throws SimulationInputException,
OptimizerException,
java.lang.Exception
WriteStepNumber in the optimization
command file is set to true, the function
getF(Point x) is called and the new point is returned.WriteStepNumber is set to false,
then the step number is not increased, and no simulation is done.
The passed argument x is returned.
x - the new point for the simulation
OptimizerException - if an OptimizerException occurs
SimulationInputException - if an error in writing the
simulation input file occurs
java.lang.Exception - if an Exception occursgetF(Point)public final boolean writeStepNumber()
true, then
after each iteration step, the method
increaseStepNumber(...) has to be called
in order to allow the implementation of penalty function,
barrier function and slackness variables.
true if the step number has to written,
false otherwisepublic final boolean useStepNumber()
wriSteNum = true or
if the algorithm requires explicitly the step number to be used.
Note that useStepNumber() always returns true
if writeStepNumber() returns true, but
writeStepNumber() may return false if
useStepNumber() returns true.
protected int getStepNumber()
public void goToEndOfCommandFile()
throws InputFormatException,
java.io.IOException
InputFormatException - if either of the checks fails
java.io.IOException - if the optimization command file cannot be accessed
public final boolean isNextToken(java.lang.String keyWord)
throws java.io.IOException
keyWord - the keyword that has to be searched for
true if the next Token equals the value of keyWord,
false otherwise
java.io.IOException - if the optimization command file cannot be accessed
protected final java.lang.String getInputValueString(java.lang.String keyWord)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWord
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessed
protected final java.lang.String getInputValueString(java.lang.String keyWord,
java.lang.String[] admVal)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWordadmVal - the admissible values
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessed
protected final boolean getInputValueBoolean(java.lang.String keyWord)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWord
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessed
protected final int getInputValueInteger(java.lang.String keyWord)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWord
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessed
protected final int getInputValueInteger(java.lang.String keyWord,
int min,
int minEqu,
int max,
int maxEqu)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWordmin - the minimum allowed valueminEqu - flag whether the minimum equality is strict or weak,
as defined by Optimizer.EXCLUDING and
Optimizer.INCLUDINGmax - the maximum allowed valuemaxEqu - flag whether the maximum equality is strict or weak,
as defined by Optimizer.EXCLUDING and
Optimizer.INCLUDING
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessed
protected final double getInputValueDouble(java.lang.String keyWord)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWord
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessed
protected final double getInputValueDouble(java.lang.String keyWord,
double min,
double minEqu,
double max,
double maxEqu)
throws InputFormatException,
java.io.IOException
keyWord from the algorithmEntry
If another String than keyWord is at the current position
of the algorithmEntry, an InputFormatException is thrown
keyWord - the expected keyWordmin - the minimum allowed valueminEqu - flag whether the minimum equality is strict or weak,
as defined by Optimizer.EXCLUDING and
Optimizer.INCLUDINGmax - the maximum allowed valuemaxEqu - flag whether the maximum equality is strict or weak,
as defined by Optimizer.EXCLUDING and
Optimizer.INCLUDING
keyWord
InputFormatException - if another String than keyWord
is read or if it is a invalid type
java.io.IOException - if the optimization command file cannot be accessedpublic static int getMaximumThreadPoolSize()
protected final void throwInputError(java.lang.String expectedValue)
throws InputFormatException
getInputValue... method is not valid.
expectedValue - a String that specifies the value you expected
InputFormatException - the thrown exception with the error messagepublic final int getDimensionX()
public final int getDimensionContinuous()
public final int getDimensionDiscrete()
public final int getDimensionF()
public final void setMode(int constraintMode)
constraintMode - a flag indicating how constraints are treated0: optimization is in original space (constraints are not taken into account) 1: optimization is in transformed space
public final int getMode()
0: optimization is in original space (constraints are not taken into account) 1: optimization is in transformed space
public abstract int run(Point x0)
throws OptimizerException,
SimulationInputException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.Exception
x0 - Initial iterate
-1 if the maximum number of iteration
is exceeded
+1 if any required accuracy is reached
+2 if the absolute accuracy is reached
+3 if the relative accuracy is reached
+4 if run is finished without checking
a convergence criteria
(e.g., parametric runs)
OptimizerException - if an OptimizerException occurs
InputFormatException - if an InputFormatException 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 Exception occurs
SimulationInputException
public final int run()
throws OptimizerException,
SimulationInputException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.Exception
-1 if the maximum number of iteration
is exceeded
+1 if any required accuracy is reached
+2 if the absolute accuracy is reached
+3 if the relative accuracy is reached
+4 if run is finished without checking
a convergence criteria
(e.g., parametric runs)
OptimizerException - if an OptimizerException occurs
InputFormatException - if an InputFormatException 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 Exception occurs
SimulationInputException
public Point[] getF(Point[] x,
boolean stopAtError)
throws SimulationInputException,
OptimizerException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.Exception
conMode determines in which mode the constraints
are treated. The return value contains the same point but with its function value
as determined by the simulation.
x - the points to be evaluatedstopAtError - set to false to continue with function evaluations even if there was an error
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
public Point getF(Point x)
throws SimulationInputException,
OptimizerException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.Exception
conMode determines in which mode the constraints
are treated. The return value contains the same point but with its function value
as determined by the simulation.
x - the point being evaluated
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
private boolean[] setKnownFunctionValues(Point[] x)
throws OptimizerException
x - the points for which the function values are needed
true if a simulation is needed
for a particular point
OptimizerException - if an OptimizerException occurs or
if the user required to stop GenOptpublic static int[] getPointerToEqualPoints(Point[] x)
x - the points for which the function values are needed
true if a simulation is needed
for a particular point
OptimizerException - if an OptimizerException occurs or
if the user required to stop GenOpt
public void simulate(Point x)
throws SimulationInputException,
OptimizerException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.Exception
x - the point being evaluated
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
private Point _retryEvaluateSimulation(Point x,
java.lang.Throwable t)
throws SimulationInputException,
OptimizerException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.Exception
x - the point being evaluatedt - the caught Throwable
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 exception occurs
public final void appendToOutputListing(java.lang.String s)
throws java.io.IOException
s - String to be appended to output listing files
java.io.IOException
protected void reportCurrentLowestPoint()
throws java.io.IOException
java.io.IOException - if an I/O error in the optimization output files
occurs
private Point _evaluateSimulation(Point x)
throws OptimizerException,
SimulationInputException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.Exception
x - the point being evaluated
OptimizerException - if an OptimizerException occurs
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 exception occurs
private static boolean _replaceInInputFile(java.lang.String text,
java.lang.String value,
FileHandler[] simulationInput)
text with value in simulationInput.
text - text to be searched forvalue - value that will replace textsimulationInput - file handler in which search will take place
true if text was found, false otherwise
protected static boolean replace(java.lang.String[] strArr,
java.lang.String text,
java.lang.String value)
text with value in input functions.
strArr - array of strings that will be searchedtext - text to be searched forvalue - value that will replace text
true if text was found, false otherwise
private static void _variableNotFound(java.lang.String variableName)
throws SimulationInputException
SimulationInputException that says that the variable
could not be found.
variableName - name of the variable that was not found.
SimulationInputException
private static double[] _processResultFunction(java.lang.String[] formula,
double[] objFunVal)
throws OptimizerException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.io.IOException
formula - all formulas or null, if no function object has been specified
for an objective functionobjFunVal - the objective function values for which no
function object has been specified
OptimizerException - if not all arguments in a function could be replaced
java.lang.NoSuchMethodException - if the 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.io.IOException - if an error occurs
public void checkObjectiveFunctionValue(Point x)
throws OptimizerException
x - the point to be checked
OptimizerException - thrown if the maximum number of matching
function value is obtained
protected void setInfo(java.lang.String s,
int simNum)
s - the messagesimNum - The number of the simulationsetWarning(java.lang.String, int)
protected void setWarning(java.lang.String s,
int simNum)
s - the messagesimNum - The number of the simulationsetInfo(java.lang.String, int)protected void setNumberOfMatchingResults(int maxNumberOfMatchingResults)
maxNumberOfMatchingResults - the number how many results can be
equal before an OptimizerException is thrownpublic double getX0(int i)
x[i]x[i] might be in the transformed space
depending on the value of conMode
i - the number of the variable (zero-based counter)
public int getIndex0(int i)
x[i]
i - the number of the variable (zero-based counter)
public double getDiscreteValueDouble0(int variableNumber)
variableNumber-th
discrete parameter as specified in the command file
variableNumber - the number of the variable (zero-based counter)
public double[] getX0()
xx might be in the transformed space
depending on the value of conMode
public int[] getIndex0()
x
public final int getLengthDiscrete(int i)
i - the number of the variable (zero-based counter)
public final java.lang.String getVariableNameContinuous(int i)
x[i]
i - number of the variable (zero-based counter)
x[i]public final java.lang.String getVariableNameDiscrete(int i)
x[i]
i - number of the variable (zero-based counter)
x[i]public final java.lang.String getObjectiveFunctionName(int i)
i-th objective function value.
The name of the objective function value is specified by the key word
Namei (i = 1, 2, ... getDimensionF())
in the section ObjectiveFunctionLocation.i is zero-based in the Java code, but one-based
in the input file. Thus, to get the name of the first objective
function value, you need to call this function with argument
0.
i - number of the objective function value (zero-based counter)
[i]-th objective function valuepublic double getL(int i)
l[i] of the continuous
variable x[i]
i - the number of the variable (zero-based counter)
public double getU(int i)
u[i] of the continuous
variable x[i]
i - the number of the variable (zero-based counter)
public int getKindOfConstraint(int i)
i - the number of the variable (zero-based counter)
1: no under boundary, no upper boundary 2: under boundary, no upper boundary 3: under boundary, upper boundary 4: no under boundary, upper boundary
public double getDx(int i,
double x)
dx[i] of the i-th continuous variabledx[i] might be in the transformed space
depending on the value of conMode.
i - the number of the variable (zero-based counter)x - the current value of the variable. If the optimization algorithm works in the transformed
space, then x need to be in the transformed space as well.
public double getDx0(int i)
dx[i] of the i-th continuous variable as specified
in the command file.
i - the index of the variable (zero-based counter)
public void print(java.lang.String text)
System.out.printl(String),
otherwise it won't be reported in the GUI
text - the text to be printedpublic void println(java.lang.String text)
System.out.println(String),
otherwise it won't be reported in the GUI
text - the text to be printed
protected void reportMinimum()
throws java.io.IOException
java.io.IOException - if an I/O error in the optimization output files
occurspublic Point getMinimumPoint()
java.io.IOException - if an I/O error in the optimization output files
occurs
public void report(Point x,
boolean MainIteration)
throws java.io.IOException
MainIteration = false and then with
MainIteration = true
x - the point to be reportedMainIteration - true if step was a main iteration or
false if it was a sub iteration
java.io.IOException - if an I/O error in the optimization output files
occursprotected final boolean maxIterationReached()
true if the number of simulation is
equal or bigger than the maximum number of iteration,
false otherwiseprotected final double getAbsAccuracyFunction()
protected final double getRelAccuracyFunction()
protected final int getMainIterationNumber()
protected static final int getSimulationNumber()
protected final int getMaxIterationNumber()
protected boolean checkMaxIteration()
true if the main iteration number is
equal or bigger than the maximum number of iteration,
false otherwisepublic final boolean mustStopOptimization()
true if GenOpt has to be stopped, false
otherwiseprotected static Point roundCoordinates(Point x)
x - the point to be rounded.
protected boolean isFeasible(Point x)
x - the point to be checked
true if point is feasible,
false otherwise
public static double setToFeasibleCoordinate(double x,
double l,
double u)
x such that l <= x <= u.
This method recursively reassigning
x := 2 * l - x if x < l,
or x := 2 * u - x if x < u.
If x is feasible, then it returns x unmodified.
x - the independent paramterl - the lower boundu - the upper bound
x, such that l <= x <= u
private static double _setToFeasibleCoordinate(double x,
double l,
double u)
x := 2 * l - x if x < l,
or x := 2 * u - x if x < u.
If x is feasible, then it returns x unmodified.
x - the independent paramterl - the lower boundu - the upper bound
x, such that l <= x <= u
public static int setToFeasibleCoordinate(int x,
int l,
int u)
x such that l <= x <= u.
This method recursively reassigning
x := 2 * l - x if x < l,
or x := 2 * u - x if x < u.
If x is feasible, then it returns x unmodified.
x - the independent paramterl - the lower boundu - the upper bound
x, such that l <= x <= u
private static int _setToFeasibleCoordinate(int x,
int l,
int u)
x := 2 * l - x if x < l,
or x := 2 * u - x if x < u.
If x is feasible, then it returns x unmodified.
x - the independent paramterl - the lower boundu - the upper bound
x, such that l <= x <= u
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||