genopt
Class GenOpt

java.lang.Object
  extended by java.lang.Thread
      extended by genopt.GenOpt
All Implemented Interfaces:
java.lang.Runnable

public class GenOpt
extends java.lang.Thread

Object for optimizing an objective function computed by a simulation program.

This project was carried out at:

and supported by

The version numbering format is M.m.P.s, where M is the major version number, m is the minor version number, P is the patch level, and s is the snapshot number. Full releases have P set to zero, and it is incremented for each subsequent bug fix release on the post-release stable branch. The snapshot number s is present only for between-release snapshots of the development and stable branches.

Copyright Notice

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.

If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Technology Transfer Department at TTD@lbl.gov.

NOTICE. This software was developed under partial funding from the U.S. Department of Energy. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, prepare derivative works, and perform publicly and display publicly. Beginning five (5) years after the date permission to assert copyright is obtained from the U.S. Department of Energy, and subject to any subsequent five (5) year renewals, the U.S. Government is granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.

License agreement

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.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

(1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

(3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

You are under no obligation whatsoever to provide any bug fixes, patches, or upgrades to the features, functionality or performance of the source code ("Enhancements") to anyone; however, if you choose to make your Enhancements available either publicly, or directly to Lawrence Berkeley National Laboratory, without imposing a separate written license agreement for such Enhancements, then you hereby grant the following license: a non-exclusive, royalty-free perpetual license to install, use, modify, prepare derivative works, incorporate into other computer software, distribute, and sublicense such enhancements or derivative works thereof, in binary and source code form.

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

Author:
Michael Wetter

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String ACKNOWLEDGMENT
          Describe constant ACKNOWLEDGMENT here.
static java.lang.String AUTHOR
          Describe constant AUTHOR here.
 ContinuousParameter[] conPar
          continuous parameters
static java.lang.String COPYRIGHT
          Describe constant COPYRIGHT here.
static boolean DEBUG
          Flag whether we are in debug mode or not.
static java.lang.String DEBUG_WARNING
          String containing the debug warning.
protected  int dimCon
          dimension of the continuous parameters
protected  int dimDis
          dimension of the discrete parameters
protected  int dimInpFun
          dimension of the input functions
 DiscreteParameter[] disPar
          discrete parameters
static java.lang.String DIVIDER
          Divider for output.
 ErrorChecker ErrChe
          error checker
private static int exiFla
          exit flag of the optimization
 InfoManager infMan
          info manager
 InputFunction[] inpFun
          input functions
 IOSettings ioSet
          io settings
private static java.lang.String LS
          Line separator
private  java.lang.String maiAlg
          name of the main algorithm
 OptimizationIni OptIni
          optimization initialization
private  java.lang.String optIniFilNam
          name of optimization ini file
private  java.lang.String optIniPat
          path of optimization ini file
 OptimizationSettings OptSet
          optimization settings
private  Preference pref
          user preference
static java.lang.String PROGRAMINFO
          Program information.
 ResultChecker resChe
          result Checker
 ResultManager ResMan
          result manager
static java.lang.String RUNHEADER
          Describe constant RUNHEADER here.
 SimulationStarter SimSta
          simulation starter
protected  java.util.Date startDate
          date when the optimization started
private static boolean stopGenOpt
          flag to indicate whether GenOpt has to be stopped after the current simulation
private static boolean suspend
          flag to indicate whether GenOpt has to be suspended
static java.lang.String USER_STOP_MESSAGE
          Message that appears if the user stops GenOpt.
 java.lang.String USERDIR
          User directory (working directory).
static java.lang.String VERSION
          Describe constant VERSION here.
static java.lang.String VERSION_ID
          Describe constant VERSION_ID here.
static java.lang.String VERSION_NUMBER
          Describe constant VERSION_NUMBER here.
static java.lang.String VERSIONINFO
          Version string.
 WarningManager warMan
          warning manager
protected  WinGenOpt wgo
          reference to WinGenOpt
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GenOpt()
          allocates a new GenOpt Object containing nothing
GenOpt(java.lang.String optIniFileName, InputFormatException inpForExc, WinGenOpt windowVersion)
          allocates a new GenOpt Object
 
Method Summary
private  void flushLogFile(java.lang.String content)
          writes physically the log file GenOpt.log to the log directory.
 java.io.StreamTokenizer getAlgorithmSection()
          gets a StreamTokenizer whereas its pointer points to the start of the Algorithm section
The pointer in the StreamTokenizer is moved beyond the section start character ('{').
 java.io.StreamTokenizer getAlgorithmSection(InputFormatException e)
          gets a StreamTokenizer whereas its pointer points to the start of the Algorithm section
The pointer in the StreamTokenizer is moved beyond the section start character ('{').
 int getDimensionContinuous()
          gets the number of the continuous parameters
 int getDimensionDiscrete()
          gets the number of discrete parameters
 int getExitFlag()
          gets the exit flag of the optimization run
private  void getFunctionInput(java.io.StreamTokenizer optComStrTok, InputFormatException inpForExc, java.lang.String fn)
          makes an instance of a function input.
protected  java.io.File getIniStartUpFile()
          gets the initialization startup file
static javax.swing.JFileChooser getInitializationFileChooser(java.io.File IniStartUpFile)
          gets an optimization initialization file chooser
 java.lang.String getMainAlgorithm()
          gets the name of the main algorithm
private  java.lang.String[] getMultipleStringPairs(java.lang.String[] keys, boolean[] required, java.io.StreamTokenizer st, InputFormatException ife, java.lang.String fn)
          gets the entries of the keys pair in a string array.
private  OrderedMap getObjectiveFunctionDelimiter(java.io.StreamTokenizer st, InputFormatException ife, java.lang.String fn)
          gets the entries of the objective function delimiter
 java.io.File getOptimizationIniFile()
          gets the optimization ini file
private  Optimizer getOptimizer()
          gets a new instance of the Optimizer object
private  void getParameterInput(java.io.StreamTokenizer optComStrTok, InputFormatException inpForExc, java.lang.String fn)
          makes an instance of a free Parameter.
protected  java.lang.String getRunInfo()
          gets the GenOpt run info for output report
 java.lang.String getRuntime(java.util.Date now)
          gets the current runtime of the optimization in the format xhh:mm:ss
 java.lang.String getSeparator()
          gets the separator, as specified in properties.txt
 java.util.Date getStartDate()
          gets the start date of the optimization
private  void initializeOptimizationIniName(java.lang.String optIniFileName)
          initializes the optimization ini file name and path
private  void instantiateErrChe_SimSta(InputFormatException inpForExc)
          makes an instance of ErrorChecker, SimulationStarter, and sets the data member 'ObjectiveFunctionLocation' in the instance of OptimizationIni
private  void instantiateErrorChecker(java.io.StreamTokenizer optCfgStrTok, InputFormatException inpForExc, java.lang.String fn)
          makes an instance of ErrorChecker
private  void instantiateFreePar_OptSet_ResChe_maiAlg(InputFormatException inpForExc, int maxEqualResults)
          makes an instance of FreePar, OptimizationSettings, and ResultChecker
private  void instantiateFreePar(java.io.StreamTokenizer optComStrTok, InputFormatException inpForExc, java.lang.String fn)
          makes all instances of FreePar and input functions
private  void instantiateIOSettings(java.io.StreamTokenizer optCfgStrTok, InputFormatException inpForExc, java.lang.String fn)
          sets the accuracy of the file writing (number format)
private  OrderedMap instantiateOptimizationIni(InputFormatException inpForExc)
          makes an instance of OptimizationIni, and returns the objective function delimiters
private  void instantiateOptimizationSettings_ResultChecker(java.io.StreamTokenizer optComStrTok, InputFormatException inpForExc, java.lang.String fn, int maxEqualResults)
          makes an instance of OptimizationSettings and ResultChecker
private  void instantiateResultManager(InputFormatException inpForExc)
          makes an instance of ResultManager
(package private)  void instantiateSimulationStarter(java.io.StreamTokenizer optCfgStrTok, InputFormatException inpForExc, java.lang.String fn)
          makes an instance of SimulationStarter
 boolean isDebug()
          checks whether we should run in debug mode
static void main(java.lang.String[] args)
          Main routine
 boolean mustStopOptimization()
          returns a flag whether GenOpt must be stopped after the current simulation
private static boolean parseBoolean(java.io.StreamTokenizer st, java.lang.String keyWord, java.lang.String value, InputFormatException inpForExc, java.lang.String fileName)
          parses a String to a boolean an writes error into the InputFormatException
private static ContinuousParameter parseContinuousPar(java.lang.String[] val, InputFormatException e, int lineNumber, java.lang.String fileName)
          gets a new instance of a ContinuousParameter Object based on the value in 'val'.
private static DiscreteParameter parseDiscretePar(java.io.StreamTokenizer optComStrTok, java.lang.String[] key, java.lang.String[] val, InputFormatException inpForExc, java.lang.String fileName)
          gets a new instance of a DiscreteParameter Object.
private static double parseDouble(java.io.StreamTokenizer st, java.lang.String keyWord, java.lang.String value, double minVal, double maxVal, InputFormatException inpForExc, java.lang.String fileName)
          parses a String to a double and writes error into the InputFormatException
private static double parseDouble(java.io.StreamTokenizer st, java.lang.String variableName, java.lang.String keyWord, java.lang.String value, double minVal, double maxVal, InputFormatException inpForExc, java.lang.String fileName)
          parses a String to a double and writes error into the InputFormatException
private static int parseInteger(java.io.StreamTokenizer st, java.lang.String keyWord, java.lang.String value, int minVal, int maxVal, InputFormatException inpForExc, java.lang.String fileName)
          parses a String to an int and writes error into the InputFormatException
private static int parseInteger(java.io.StreamTokenizer st, java.lang.String variableName, java.lang.String keyWord, java.lang.String value, int minVal, int maxVal, InputFormatException inpForExc, java.lang.String fileName)
          parses a String to an int and writes error into the InputFormatException
 void print(java.lang.String text)
          prints a message to the output device without finishing the line
 void printError(java.lang.String text)
          prints an error to the output device
 void println(java.lang.String text)
          prints a message to the output device, and then finishs the line
static void printStackTrace(java.lang.Throwable t)
          prints a stackTrace to the output and error stream
 void run()
          runs the optimization method
 void setNewTrial()
          reports a new optimization trial to the GUI
private  void setupProperties()
          sets up the properties
private static void setWrongClassTypeInputFormatException(java.io.StreamTokenizer st, java.lang.String keyWord, java.lang.String value, InputFormatException inpForExc, java.lang.Object wrapperClass, java.lang.String fileName)
          sets an error message in the InputFormatException instance indicating that a wrong data type has been received
 void sleepGenOpt(boolean susp)
          suspends GenOpt if susp is true, otherwise resume GenOpt
 void stopOptimization()
          forces GenOpt to stop the optimization after the current simulation
 void writeLogFile()
          writes the log file GenOpt.log to the log directory.
 void writeLogFile(java.lang.String errorMessage)
          writes the log file GenOpt.log to the log directory.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LS

private static final java.lang.String LS
Line separator


VERSION_NUMBER

public static final java.lang.String VERSION_NUMBER
Describe constant VERSION_NUMBER here.

See Also:
Constant Field Values

VERSION_ID

public static final java.lang.String VERSION_ID
Describe constant VERSION_ID here.

See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
Describe constant VERSION here.

See Also:
Constant Field Values

COPYRIGHT

public static final java.lang.String COPYRIGHT
Describe constant COPYRIGHT here.


AUTHOR

public static final java.lang.String AUTHOR
Describe constant AUTHOR here.


ACKNOWLEDGMENT

public static final java.lang.String ACKNOWLEDGMENT
Describe constant ACKNOWLEDGMENT here.


VERSIONINFO

public static final java.lang.String VERSIONINFO
Version string.

See Also:
Constant Field Values

PROGRAMINFO

public static final java.lang.String PROGRAMINFO
Program information.


DIVIDER

public static final java.lang.String DIVIDER
Divider for output.

See Also:
Constant Field Values

RUNHEADER

public static final java.lang.String RUNHEADER
Describe constant RUNHEADER here.


USER_STOP_MESSAGE

public static final java.lang.String USER_STOP_MESSAGE
Message that appears if the user stops GenOpt.

See Also:
Constant Field Values

DEBUG

public static boolean DEBUG
Flag whether we are in debug mode or not.


DEBUG_WARNING

public static final java.lang.String DEBUG_WARNING
String containing the debug warning.


USERDIR

public java.lang.String USERDIR
User directory (working directory).


wgo

protected WinGenOpt wgo
reference to WinGenOpt


dimCon

protected int dimCon
dimension of the continuous parameters


dimDis

protected int dimDis
dimension of the discrete parameters


dimInpFun

protected int dimInpFun
dimension of the input functions


warMan

public WarningManager warMan
warning manager


infMan

public InfoManager infMan
info manager


conPar

public ContinuousParameter[] conPar
continuous parameters


disPar

public DiscreteParameter[] disPar
discrete parameters


inpFun

public InputFunction[] inpFun
input functions


OptIni

public OptimizationIni OptIni
optimization initialization


OptSet

public OptimizationSettings OptSet
optimization settings


ioSet

public IOSettings ioSet
io settings


SimSta

public SimulationStarter SimSta
simulation starter


ErrChe

public ErrorChecker ErrChe
error checker


ResMan

public ResultManager ResMan
result manager


resChe

public ResultChecker resChe
result Checker


maiAlg

private java.lang.String maiAlg
name of the main algorithm


startDate

protected java.util.Date startDate
date when the optimization started


optIniPat

private java.lang.String optIniPat
path of optimization ini file


optIniFilNam

private java.lang.String optIniFilNam
name of optimization ini file


exiFla

private static int exiFla
exit flag of the optimization


stopGenOpt

private static boolean stopGenOpt
flag to indicate whether GenOpt has to be stopped after the current simulation


suspend

private static volatile boolean suspend
flag to indicate whether GenOpt has to be suspended


pref

private Preference pref
user preference

Constructor Detail

GenOpt

public GenOpt()
allocates a new GenOpt Object containing nothing


GenOpt

public GenOpt(java.lang.String optIniFileName,
              InputFormatException inpForExc,
              WinGenOpt windowVersion)
       throws java.io.FileNotFoundException,
              java.io.IOException
allocates a new GenOpt Object

Parameters:
optIniFileName - a String value
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
windowVersion - reference to WinGenOpt Object or null pointer
Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

getInitializationFileChooser

public static javax.swing.JFileChooser getInitializationFileChooser(java.io.File IniStartUpFile)
gets an optimization initialization file chooser

Parameters:
IniStartUpFile - a File value
Returns:
a JFileChooser value

getIniStartUpFile

protected java.io.File getIniStartUpFile()
gets the initialization startup file

Returns:
the initialization file startup file

initializeOptimizationIniName

private void initializeOptimizationIniName(java.lang.String optIniFileName)
                                    throws java.io.IOException
initializes the optimization ini file name and path

Parameters:
optIniFileName - name of optimization ini file or null pointer
Throws:
java.io.IOException - If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries

instantiateOptimizationIni

private OrderedMap instantiateOptimizationIni(InputFormatException inpForExc)
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException
makes an instance of OptimizationIni, and returns the objective function delimiters

Parameters:
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
Returns:
a OrderedMap of the form [[Name1, Delimiter1] , ... , [NameN, DelimiterN]] if present or a null pointer otherwise
Throws:
java.io.FileNotFoundException
java.io.IOException - If the canonical path of the user directory cannot be obtained

getObjectiveFunctionDelimiter

private OrderedMap getObjectiveFunctionDelimiter(java.io.StreamTokenizer st,
                                                 InputFormatException ife,
                                                 java.lang.String fn)
                                          throws java.io.IOException
gets the entries of the objective function delimiter

Parameters:
st - StreamTokenizer where pointer is set before the section start
ife - refernce to InputFormatException. InputFormatException will be written in this Object
fn - associated file name. Used for error report only
Throws:
java.io.IOException

instantiateErrChe_SimSta

private void instantiateErrChe_SimSta(InputFormatException inpForExc)
                               throws java.io.FileNotFoundException
makes an instance of ErrorChecker, SimulationStarter, and sets the data member 'ObjectiveFunctionLocation' in the instance of OptimizationIni

Parameters:
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
Throws:
java.io.FileNotFoundException

getMultipleStringPairs

private java.lang.String[] getMultipleStringPairs(java.lang.String[] keys,
                                                  boolean[] required,
                                                  java.io.StreamTokenizer st,
                                                  InputFormatException ife,
                                                  java.lang.String fn)
gets the entries of the keys pair in a string array. The order of the keys in the file is arbitrary.

Parameters:
keys - a pair of Strings where each String is a keyword for the entry to be read
required - true if key must be specified, false if key is optional
st - StreamTokenizer from which will be read
ife - reference to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of file that is being read
Returns:
a String array with all the entries that have been found in the order [val1(key[1]), val1(key[2]), val2(key[1]), ....]. If a key is not required and was not specified, then the current element is set to null

instantiateErrorChecker

private void instantiateErrorChecker(java.io.StreamTokenizer optCfgStrTok,
                                     InputFormatException inpForExc,
                                     java.lang.String fn)
makes an instance of ErrorChecker

Parameters:
optCfgStrTok - StreamTokenizer of the optimization configuration file
inpForExc - reference to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization configuration file

instantiateIOSettings

private void instantiateIOSettings(java.io.StreamTokenizer optCfgStrTok,
                                   InputFormatException inpForExc,
                                   java.lang.String fn)
sets the accuracy of the file writing (number format)

Parameters:
optCfgStrTok - StreamTokenizer of the optimization configuration file
inpForExc - reference to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization configuration file

instantiateSimulationStarter

void instantiateSimulationStarter(java.io.StreamTokenizer optCfgStrTok,
                                  InputFormatException inpForExc,
                                  java.lang.String fn)
makes an instance of SimulationStarter

Parameters:
optCfgStrTok - StreamTokenizer of the optimization configuration file
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization configuration file

instantiateFreePar_OptSet_ResChe_maiAlg

private void instantiateFreePar_OptSet_ResChe_maiAlg(InputFormatException inpForExc,
                                                     int maxEqualResults)
                                              throws java.io.FileNotFoundException,
                                                     java.io.IOException
makes an instance of FreePar, OptimizationSettings, and ResultChecker

Parameters:
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
maxEqualResults - default value for maximum number of equal result before GenOpt terminates with an error
Throws:
java.io.FileNotFoundException
java.io.IOException

instantiateFreePar

private void instantiateFreePar(java.io.StreamTokenizer optComStrTok,
                                InputFormatException inpForExc,
                                java.lang.String fn)
makes all instances of FreePar and input functions

Parameters:
optComStrTok - StreamTokenizer of the optimization command file
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization command file

getFunctionInput

private void getFunctionInput(java.io.StreamTokenizer optComStrTok,
                              InputFormatException inpForExc,
                              java.lang.String fn)
makes an instance of a function input. This function must be called when the keyword "Function" is found in the input file.

Parameters:
optComStrTok - StreamTokenizer of the optimization command file
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization command file

getParameterInput

private void getParameterInput(java.io.StreamTokenizer optComStrTok,
                               InputFormatException inpForExc,
                               java.lang.String fn)
makes an instance of a free Parameter. This function must be called when the keyword "Parameter" is found in the input file.

Parameters:
optComStrTok - StreamTokenizer of the optimization command file
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization command file

instantiateOptimizationSettings_ResultChecker

private void instantiateOptimizationSettings_ResultChecker(java.io.StreamTokenizer optComStrTok,
                                                           InputFormatException inpForExc,
                                                           java.lang.String fn,
                                                           int maxEqualResults)
makes an instance of OptimizationSettings and ResultChecker

Parameters:
optComStrTok - StreamTokenizer of the optimization command file
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fn - file name (including path) of optimization command file
maxEqualResults - default value for maximum number of equal result before GenOpt terminates with an error

parseBoolean

private static boolean parseBoolean(java.io.StreamTokenizer st,
                                    java.lang.String keyWord,
                                    java.lang.String value,
                                    InputFormatException inpForExc,
                                    java.lang.String fileName)
parses a String to a boolean an writes error into the InputFormatException

Parameters:
st - the StreamTokenizer
keyWord - the keyWord associated with the value val
value - the value received for keyWord
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fileName - name of the file where input comes from

parseInteger

private static int parseInteger(java.io.StreamTokenizer st,
                                java.lang.String keyWord,
                                java.lang.String value,
                                int minVal,
                                int maxVal,
                                InputFormatException inpForExc,
                                java.lang.String fileName)
parses a String to an int and writes error into the InputFormatException

Parameters:
st - the StreamTokenizer
keyWord - the keyWord associated with the value val
value - the value received for keyWord
minVal - minimal allowed value
maxVal - maximal allowed value
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fileName - name of the file where input comes from
Returns:
the int value of val

parseInteger

private static int parseInteger(java.io.StreamTokenizer st,
                                java.lang.String variableName,
                                java.lang.String keyWord,
                                java.lang.String value,
                                int minVal,
                                int maxVal,
                                InputFormatException inpForExc,
                                java.lang.String fileName)
parses a String to an int and writes error into the InputFormatException

Parameters:
st - the StreamTokenizer
variableName - the variable name associated with the value val
keyWord - the keyWord associated with the value val
value - the value received for keyWord
minVal - minimal allowed value
maxVal - maximal allowed value
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fileName - name of the file where input comes from
Returns:
the int value of val

parseDouble

private static double parseDouble(java.io.StreamTokenizer st,
                                  java.lang.String variableName,
                                  java.lang.String keyWord,
                                  java.lang.String value,
                                  double minVal,
                                  double maxVal,
                                  InputFormatException inpForExc,
                                  java.lang.String fileName)
parses a String to a double and writes error into the InputFormatException

Parameters:
st - the StreamTokenizer
variableName - the variable name associated with the value val
keyWord - the keyWord associated with the value val
value - the value received for keyWord
minVal - minimal allowed value
maxVal - maximal allowed value
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fileName - name of the file where input comes from
Returns:
the double value of val

parseDouble

private static double parseDouble(java.io.StreamTokenizer st,
                                  java.lang.String keyWord,
                                  java.lang.String value,
                                  double minVal,
                                  double maxVal,
                                  InputFormatException inpForExc,
                                  java.lang.String fileName)
parses a String to a double and writes error into the InputFormatException

Parameters:
st - the StreamTokenizer
keyWord - the keyWord associated with the value val
value - the value received for keyWord
minVal - minimal allowed value
maxVal - maximal allowed value
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
fileName - name of the file where input comes from

setWrongClassTypeInputFormatException

private static void setWrongClassTypeInputFormatException(java.io.StreamTokenizer st,
                                                          java.lang.String keyWord,
                                                          java.lang.String value,
                                                          InputFormatException inpForExc,
                                                          java.lang.Object wrapperClass,
                                                          java.lang.String fileName)
sets an error message in the InputFormatException instance indicating that a wrong data type has been received

Parameters:
st - the StreamTokenizer
keyWord - the keyWord associated with the value val
value - the value received for keyWord
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object
wrapperClass - any of the wrapper class of the primitive Java type
fileName - name of the file where input comes from

instantiateResultManager

private void instantiateResultManager(InputFormatException inpForExc)
makes an instance of ResultManager

Parameters:
inpForExc - refernce to InputFormatException. InputFormatException will be written in this Object

parseContinuousPar

private static ContinuousParameter parseContinuousPar(java.lang.String[] val,
                                                      InputFormatException e,
                                                      int lineNumber,
                                                      java.lang.String fileName)
gets a new instance of a ContinuousParameter Object based on the value in 'val'.

Parameters:
val - String array with following elements: val[0] = Name; val[1] = Min ; val[2] = Ini; val[3] = Max ; val[4] = Step;
e - reference to InputFormatException. Error messages are written into this Object
lineNumber - line number to which the error report will be referred to
fileName - name of file (for error report only) or null pointer
Returns:
the ContinuousParameter Object

parseDiscretePar

private static DiscreteParameter parseDiscretePar(java.io.StreamTokenizer optComStrTok,
                                                  java.lang.String[] key,
                                                  java.lang.String[] val,
                                                  InputFormatException inpForExc,
                                                  java.lang.String fileName)
gets a new instance of a DiscreteParameter Object.

Parameters:
optComStrTok - StreamTokenizer of the optimization command file
key - String array with the keywords: key[0] = Name; key[1] = Min ; key[2] = Ini; key[3] = Max ; key[4] = Step; key[5] = Type; key[6] = Values;
val - String array the values for key
inpForExc - reference to InputFormatException. Error messages are written into this Object
fileName - name of file (for error report only)
Returns:
the ContinuousParameter Object

getMainAlgorithm

public java.lang.String getMainAlgorithm()
gets the name of the main algorithm

Returns:
a String value

getAlgorithmSection

public java.io.StreamTokenizer getAlgorithmSection()
                                            throws InputFormatException,
                                                   java.io.IOException
gets a StreamTokenizer whereas its pointer points to the start of the Algorithm section
The pointer in the StreamTokenizer is moved beyond the section start character ('{'). Text that occurs before the keyWord 'Algorithm' is skipped without an error message

Returns:
a StreamTokenizer value
Throws:
InputFormatException
java.io.IOException

getAlgorithmSection

public java.io.StreamTokenizer getAlgorithmSection(InputFormatException e)
                                            throws java.io.IOException
gets a StreamTokenizer whereas its pointer points to the start of the Algorithm section
The pointer in the StreamTokenizer is moved beyond the section start character ('{'). Text that occurs before the keyWord 'Algorithm' is skipped without an error message

Parameters:
e - reference to InputFormatException. Error messages are written into this Object
Returns:
a StreamTokenizer value
Throws:
java.io.IOException

writeLogFile

public void writeLogFile(java.lang.String errorMessage)
writes the log file GenOpt.log to the log directory.
Note: Use this method only if an error occured

Parameters:
errorMessage - the error message

writeLogFile

public void writeLogFile()
writes the log file GenOpt.log to the log directory.
Note: Use this method only if no error occured


flushLogFile

private void flushLogFile(java.lang.String content)
writes physically the log file GenOpt.log to the log directory.
Note: Use this method only if no error occured

Parameters:
content - the content of the file

getOptimizationIniFile

public java.io.File getOptimizationIniFile()
gets the optimization ini file

Returns:
the optimization ini file

getRunInfo

protected java.lang.String getRunInfo()
gets the GenOpt run info for output report

Returns:
the GenOpt run info

getRuntime

public java.lang.String getRuntime(java.util.Date now)
gets the current runtime of the optimization in the format xhh:mm:ss

Parameters:
now - a Date value
Returns:
the current runtime

getStartDate

public java.util.Date getStartDate()
gets the start date of the optimization

Returns:
the date when the optimization started

setNewTrial

public void setNewTrial()
reports a new optimization trial to the GUI


print

public void print(java.lang.String text)
prints a message to the output device without finishing the line

Parameters:
text - the text to be printed

println

public void println(java.lang.String text)
prints a message to the output device, and then finishs the line

Parameters:
text - the text to be printed

printError

public void printError(java.lang.String text)
prints an error to the output device

Parameters:
text - the text to be printed

run

public void run()
runs the optimization method

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

stopOptimization

public void stopOptimization()
forces GenOpt to stop the optimization after the current simulation


sleepGenOpt

public void sleepGenOpt(boolean susp)
suspends GenOpt if susp is true, otherwise resume GenOpt

Parameters:
susp - a boolean value

mustStopOptimization

public boolean mustStopOptimization()
returns a flag whether GenOpt must be stopped after the current simulation

Returns:
true if GenOpt has to be stopped, false otherwise

getDimensionContinuous

public int getDimensionContinuous()
gets the number of the continuous parameters

Returns:
the number of continuous parameters

getDimensionDiscrete

public int getDimensionDiscrete()
gets the number of discrete parameters

Returns:
the number of discrete parameters

getOptimizer

private Optimizer getOptimizer()
                        throws java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               InputFormatException,
                               java.io.IOException
gets a new instance of the Optimizer object

Throws:
java.lang.InstantiationException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
InputFormatException
java.io.IOException

getExitFlag

public int getExitFlag()
gets the exit flag of the optimization run

Returns:
the exit flag of the optimization run

printStackTrace

public static void printStackTrace(java.lang.Throwable t)
prints a stackTrace to the output and error stream

Parameters:
t - Throwable

setupProperties

private void setupProperties()
sets up the properties


getSeparator

public java.lang.String getSeparator()
gets the separator, as specified in properties.txt

Returns:
the separator

isDebug

public boolean isDebug()
checks whether we should run in debug mode

Returns:
true if we run in debug mode, false otherwise

main

public static void main(java.lang.String[] args)
Main routine

Parameters:
args - optional parameter for optimization initialization file