|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgenopt.simulation.SimulationStarter
public class SimulationStarter
Object for calling a simulation program.
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 | |
|---|---|
protected java.lang.String |
CommandLine
|
protected java.util.concurrent.locks.ReentrantLock |
lock
|
private static java.lang.String |
LS
System dependent line separator |
protected int |
maxThrPoo
The maximum number of threads in the pool |
protected OptimizationIni |
OptIni
|
protected java.lang.Process[] |
pro
|
protected java.util.concurrent.atomic.AtomicBoolean[] |
proFre
Array with boolean flag, flag is true if this process number can be used |
protected boolean |
PrombtFileExtension
|
protected java.lang.String |
worDir
|
| Constructor Summary | |
|---|---|
SimulationStarter(java.lang.String command,
boolean promptInputFileExtension,
java.lang.String workingDirectory,
OptimizationIni optIni)
constructor |
|
| Method Summary | |
|---|---|
private int |
_getThreadNumber()
Returns the thread number to be used by this process |
(package private) void |
_processProcessOutput(int iPro,
ThreadedInputStream errorStream,
java.io.File proWorDir,
java.lang.String comLin)
Processes the output of the simulation |
private java.lang.String |
_updateAndGetCommandLine(java.lang.String worDirPre)
Updates the command line by replacing the output paths with the output path of the working directory, which can change from one simulation to another. |
private void |
_updateCommandLine()
Updates the command line. |
void |
destroyProcess()
Destroys all processes that exists |
void |
destroyProcess(int iPro)
destroys the process if it exists |
java.lang.String |
getCommandDiagnostics(java.lang.String worDirPre)
Gets a string representation of the command line and the working directory. |
static java.lang.String |
replaceString(java.lang.String Original,
java.lang.String Find,
java.lang.String Set)
Replace all occurences of the String 'Find' with the String 'Set' in the String 'Original' even if 'Find' appears several times. |
void |
run(java.lang.String worDirPre)
Runs the simulation program |
void |
setMaximumNumberOfThreads(int maximumThreads)
Sets the maximum number of threads in the pool. |
void |
setWorkingDirectory(java.lang.String workingDirectory)
Sets the working directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String LS
protected java.lang.String CommandLine
protected boolean PrombtFileExtension
protected java.lang.String worDir
protected OptimizationIni OptIni
protected java.lang.Process[] pro
protected java.util.concurrent.atomic.AtomicBoolean[] proFre
protected int maxThrPoo
protected java.util.concurrent.locks.ReentrantLock lock
| Constructor Detail |
|---|
public SimulationStarter(java.lang.String command,
boolean promptInputFileExtension,
java.lang.String workingDirectory,
OptimizationIni optIni)
throws java.io.IOException
command - the command line (with placeholder for the variables)promptInputFileExtension - flag for specifying whether the extension
of the inputfile must be written in the command or not.true if the extension has to be written,
false otherwise.)workingDirectory - the working directory for the process.optIni - Instance of the OptimizationIni class
java.io.IOException - If an I/O error occurs, which is possible because the construction of the
canonical pathname may require filesystem queries| Method Detail |
|---|
public void setMaximumNumberOfThreads(int maximumThreads)
throws OptimizerException
maximumThreads - The maximum number of threads in the pool
OptimizerException - If the maximum number of processes has already been allocatedprivate void _updateCommandLine()
private java.lang.String _updateAndGetCommandLine(java.lang.String worDirPre)
throws java.io.IOException
worDirPre - Prefix for working directory. This will be added to all output and log paths.
java.io.IOException - If an I/O error occurs, which is possible because the construction of the
canonical pathname may require filesystem queries
public static java.lang.String replaceString(java.lang.String Original,
java.lang.String Find,
java.lang.String Set)
Original - String that has be scanned for 'Find'Find - String that has to be found and replacedSet - String that has to be set at the position of 'Find'
private int _getThreadNumber()
throws OptimizerException
OptimizerException - If no thread is available. This condition should never occur.
public java.lang.String getCommandDiagnostics(java.lang.String worDirPre)
throws java.io.IOException
worDirPre - working directory prefix, to be added to current working directory to enable
parallel simulations
java.io.IOException
public void run(java.lang.String worDirPre)
throws java.io.IOException,
OptimizerException,
java.lang.Exception
worDirPre - working directory prefix, to be added to current working directory to enable
parallel simulations
java.io.IOException
OptimizerException
java.lang.Exception
void _processProcessOutput(int iPro,
ThreadedInputStream errorStream,
java.io.File proWorDir,
java.lang.String comLin)
throws java.lang.NullPointerException,
OptimizerException,
java.io.IOException
iPro - the process numberproWorDir - the process working directory (used for error reporting)comLin - the command line (used for error reporting)
java.lang.NullPointerException - If the user requested GenOpt to stop
OptimizerException
java.io.IOException - if the output or error stream cannot be readpublic void destroyProcess()
public void destroyProcess(int iPro)
iPro - number of the processpublic void setWorkingDirectory(java.lang.String workingDirectory)
workingDirectory - the working directory.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||