public class SimOutputFileHandler
extends java.lang.Object
This project was carried out at:
and supported byGenOpt Copyright (c) 1998-2021, 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.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
delimiter
objective function delimiter
|
protected int |
delLen
length of function delimiter
|
(package private) java.lang.String |
filNam
The file name
|
(package private) int |
firstCharAt
One-based index for the position where the first character of the delimiter starts,
or 0 if unspecified
|
private static java.lang.String |
LS
System dependent line separator
|
private static java.lang.String |
separator
separator after the objective function value (will be initialized below)
|
Constructor and Description |
---|
SimOutputFileHandler(java.lang.String fileName,
java.lang.String Separator)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
cutBeginSpaceAndTab(java.lang.String s)
cuts all space and tab characters at the beginning of the String
|
protected static java.lang.String |
cutEndSpaceAndTab(java.lang.String s)
cuts all space and tab characters at the end of the String
|
private double |
getDoubleAfterLastSpace(java.lang.String s)
gets the double that occurs after the last blank character
|
private double |
getFirstDouble(java.lang.String s)
gets the first double that occurs in the String (which is
separated from the next entries by either a space character,
a tab, a comma, or a semicolon, or a double dot)
|
protected static int |
getIndexOfSeparator(java.lang.String s)
gets the first index of the space character, tab character,
semi-colon, colon, or comma
|
double |
getObjectiveFunctionValue(java.lang.String ObjectiveFunctiondelimiter,
int firstCharacterAt)
gets the last number of the file content
|
private double |
getObjectiveFunctionValueEmpty()
gets the last number of the file content.
|
private double |
getObjectiveFunctionValueNonEmpty()
gets the last number of the file content.
|
static void |
main(java.lang.String[] args)
The main method.
|
private double |
parseToDouble(java.lang.String s)
parses a String to a double value
|
protected void |
throwObjectiveFunctionValueNotFound()
Throws an
OptimizerException with the error message
that the objective function value could not be found. |
private static final java.lang.String LS
private static java.lang.String separator
protected java.lang.String delimiter
protected int delLen
java.lang.String filNam
int firstCharAt
public SimOutputFileHandler(java.lang.String fileName, java.lang.String Separator) throws java.io.IOException, java.io.FileNotFoundException, java.lang.SecurityException
fileName
- the file nameSeparator
- separator after the objective function valuejava.io.IOException
java.io.FileNotFoundException
java.lang.SecurityException
public double getObjectiveFunctionValue(java.lang.String ObjectiveFunctiondelimiter, int firstCharacterAt) throws OptimizerException
ObjectiveFunctiondelimiter
- String that indicates delimiter
(additional to the blank space) of the objective function valuefirstCharacterAt
- one-based index for the position
where the first character of the delimiter starts,
or 0 if unspecifiedOptimizerException
- if objective function value has not been foundjava.io.IOException
- if an IOException occurred while reading the fileprotected static final java.lang.String cutBeginSpaceAndTab(java.lang.String s)
s
- the String to be cuttedprotected static final java.lang.String cutEndSpaceAndTab(java.lang.String s)
s
- the String to be cuttedprotected static int getIndexOfSeparator(java.lang.String s)
s
- the String to be tested-1
if non of them is foundprivate double getDoubleAfterLastSpace(java.lang.String s) throws OptimizerException
s
- the String containing the doubleOptimizerException
private double getFirstDouble(java.lang.String s) throws OptimizerException
s
- the String containing the doubleOptimizerException
private double getObjectiveFunctionValueEmpty() throws OptimizerException, java.io.IOException
OptimizerException
java.io.IOException
private double getObjectiveFunctionValueNonEmpty() throws OptimizerException, java.io.IOException
OptimizerException
java.io.IOException
protected void throwObjectiveFunctionValueNotFound() throws OptimizerException
OptimizerException
with the error message
that the objective function value could not be found.OptimizerException
private double parseToDouble(java.lang.String s) throws OptimizerException
s
- the String to be parsedOptimizerException
- if the String is not a number or
if it is infinitepublic static void main(java.lang.String[] args) throws java.io.IOException, OptimizerException
java.io.IOException
OptimizerException