Package net.simplace.sim.wrapper
Class SimplaceWrapper
java.lang.Object
net.simplace.sim.wrapper.SimplaceWrapper
- Direct Known Subclasses:
JavaSimplaceWrapper
This class serves as wrapper to access the SIMPLACE Model Engine (net.simplace.sim) from other applications.
It can further be wrapped by system or language specific wrappers like the
- Author:
- Andreas Enders net.simplace.core.r.WrapperTest to get an idea how to use this class. There the process is fully compiled through.
- See Also:
-
JavaSimplaceWrapper
SimplaceWrapper.R
PythonSimplaceWrapper.py
MatlabSimplaceWrapper.mat
-
Field Summary
Modifier and TypeFieldDescriptionprotected FWSimSession
Holds the currently (last) initialized session The method should only be used for single session approachprotected int
Holds the number of all created simulations.protected List<FWSimSimulation>
Holds the list of active simulationsprotected boolean
When simulation is initialized it can directly be run this method can only be used for single session approach -
Constructor Summary
ConstructorDescriptiononly used by test classes - proper use: give workdir and outputdir .SimplaceWrapper
(String aWorkDir, String aOutputDir) Creates the wrapper class and sets the work directory and output directorySimplaceWrapper
(String aWorkDir, String aOutputDir, String aProjectsDir, String aDataDir) Creates the wrapper class and sets the directories -
Method Summary
Modifier and TypeMethodDescriptioncreateSimulation
(Object[][] aParameterMap) Pass a parameter map with key (name of variable) and value (value of variable) to the systemString[]
Sets directories used by solutionUsed for getting results of the performed simulations.String[]
void
initializeSpecificSimulation
(int aSimulationQueueIndex) Initializes an specific simulation before the parameters are set or the simulation is run stepwise.void
prepareSession
(String aProject, String aSolution) prepares the project or solution to use it with next methods.prepareSession
(String aProject, String aSolution, Object[][] aParameterMap) /** prepares the project or solution to use it with next methods.void
registerModelListener
(FWSimulationListener aModelListener) Model listener gets Model Event with the current Modelvoid
registerOutputListener
(FWSimOutputListener aOutputListener) Output listener gets Output Event with the current VarMapvoid
removeModelListener
(FWSimulationListener aModelListener) Model listener gets Model Event with the current Modelvoid
removeOutputListener
(FWSimOutputListener aOutputListener) Output listener gets Output Event with the current VarMapvoid
resets the queue of active simulationsvoid
run()
runs the prepared project or solution - not to be used without calling prepare Project beforevoid
runs the prepared project or solution - not to be used without calling prepare Project beforevoid
runSimulations
(boolean doSelectSolution) Calculates the last prepared simulation (only one!)void
runSimulations
(boolean doSelectSolution, boolean doUpdateResources) Calculates the last prepared simulation (only one!)void
setAllSimulationValues
(Object[][][] aParameterMap) Sets the parameters of all simulations varmapvoid
setCheckLevel
(String aCheckLevel) void
setDirectories
(String aWorkDir, String aOutputDir, String aProjectsDir, String aDataDir) Sets directories used by solutionvoid
setProjectLines
(Integer[] aProjectLines) void
setProjectLines
(String aProjectLines) void
setSimulationValues
(int aSimulationQueueIndex, Object[][] aParameterMap) Sets the parameters of the first simulations varmapvoid
setSimulationValues
(Object[][] aParameterMap) Sets the parameters of the first simulations varmapvoid
setSpecificSimulationValues
(int aSimulationQueueIndex, Object[][][] aParameterMap) Sets the parameters of all simulations varmapvoid
shutDown()
Has to be called at the end.step()
Used running the simulation stepwise.step
(int aStepCount) Used running the simulation stepwise.Used running the simulation stepwise.Used running the simulation stepwise.Used running the simulation stepwise.Used running the simulation stepwise.Used running the simulation stepwise.Used running the simulation stepwise.stepAll()
stepAll
(int aStepCount) Used running the simulation stepwise.Used running the simulation stepwise.Used running the simulation stepwise.stepAll
(Object[][][] aParameterMap, String[] aOutputFilterArray, int aStepCount, boolean aParallelized) Used running the simulation stepwise.Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex) Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex, int aStepCount) Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex, Object[][] aParameterMap) Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex, Object[][] aParameterMap, int aStepCount) Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex, Object[][] aParameterMap, String[] aOutputFilterArray) Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex, Object[][] aParameterMap, String[] aOutputFilterArray, int aStepCount) Used running the i-th simulation in queue stepwise.stepSpecific
(int aSimulationQueueIndex, String[] aOutputFilterArray) Used running the simulation stepwise.stepSpecific
(int aSimulationQueueIndex, String[] aOutputFilterArray, int aStepCount) Used running the simulation stepwise.
-
Field Details
-
isSimulationInitialized
protected boolean isSimulationInitializedWhen simulation is initialized it can directly be run this method can only be used for single session approach -
iCurrentSession
Holds the currently (last) initialized session The method should only be used for single session approach -
iSimulationsQueue
Holds the list of active simulations -
iSimulationsCount
protected int iSimulationsCountHolds the number of all created simulations. -
iInitializedSimulations
-
-
Constructor Details
-
SimplaceWrapper
Creates the wrapper class and sets the directories- Parameters:
aWorkDir
-aOutputDir
-aProjectsDir
-aDataDir
-
-
SimplaceWrapper
Creates the wrapper class and sets the work directory and output directory- Parameters:
aWorkDir
-aOutputDir
-
-
SimplaceWrapper
public SimplaceWrapper()only used by test classes - proper use: give workdir and outputdir .
-
-
Method Details
-
setDirectories
public void setDirectories(String aWorkDir, String aOutputDir, String aProjectsDir, String aDataDir) Sets directories used by solution- Parameters:
aWorkDir
-aOutputDir
-aProjectsDir
-aDataDir
-
-
getDirectories
Sets directories used by solution- Returns:
-
prepareSession
prepares the project or solution to use it with next methods. CurrentSession instance variable is set and used. Just callrun()
to start the simulation. You can also use "step" to start the first step of the first simulation.- Parameters:
aProject
- - optional if project should be usedaSolution
- - required- Returns:
- the newly created session.
-
prepareSession
/** prepares the project or solution to use it with next methods. CurrentSession instance variable is set and used. Just callrun()
to start the simulation. You can also use "step" to start the first step of the first simulation.- Parameters:
aProject
- - optional if project should be usedaSolution
- - required- Returns:
- the newly created session.
-
run
runs the prepared project or solution - not to be used without calling prepare Project before- Throws:
Exception
-
run
runs the prepared project or solution - not to be used without calling prepare Project before- Parameters:
aProjectlines
- option to set project lines as a string ("1,2,5,9-100,111") the according lines in the project data file are evaluated - others are ignored.- Throws:
Exception
-
createSimulation
Pass a parameter map with key (name of variable) and value (value of variable) to the system. - not to be used without calling prepare Project before simulation is put into the prepared project to make possible to run them in parallel Note: only solution defined constants (v...) should be passed to the system- Parameters:
aParameterMap
- giving the parameterizations for this simulation- Returns:
- the simulation created from parameters passed to the method
- Throws:
Exception
-
runSimulations
Calculates the last prepared simulation (only one!) or, depending on your way to create the solutions, the whole queue of solutions. For the ladder you can choose, if a selection should be done. Therefore it is necessary to specify the selection variant in the project file. - not to be used without calling prepare Project before- Parameters:
doUpdateResources
- if resources should be reinitialized before calculating a new simulationdoSelectSolution
- if resources should be reinitialized before calculating a new simulation- Throws:
Exception
-
runSimulations
Calculates the last prepared simulation (only one!) or, depending on your way to create the solutions, the whole queue of solutions. For the ladder you can choose, if a selection should be done. Therefore it is necessary to specify the selection variant in the project file. - not to be used without calling prepare Project before- Parameters:
doUpdateResources
- if resources should be reinitialized before calculating a new simulationdoSelectSolution
- if resources should be reinitialized before calculating a new simulation- Throws:
Exception
-
initializeSpecificSimulation
public void initializeSpecificSimulation(int aSimulationQueueIndex) Initializes an specific simulation before the parameters are set or the simulation is run stepwise.- Parameters:
aSimulationQueueIndex
-
-
resetSimulationQueue
public void resetSimulationQueue()resets the queue of active simulations -
getSimulationIDs
- Returns:
- List of all IDs of all simulations in the queue.
-
getResult
Used for getting results of the performed simulations. You have to use asimulationID or null - prepareProject and optional - createSimulation AND necessarily - runSimulations or run before!- Parameters:
aName
- of the MEMORY type outputaSimulationID
- of the simulation- Returns:
- an object array containing the cached data
-
setSimulationValues
Sets the parameters of the first simulations varmap- Parameters:
aSimulationQueueIndex
-aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)
-
setSimulationValues
Sets the parameters of the first simulations varmap- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)
-
setSpecificSimulationValues
Sets the parameters of all simulations varmap- Parameters:
aSimulationQueueIndex
-aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)
-
setAllSimulationValues
Sets the parameters of all simulations varmap- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)
-
stepSpecific
public DataContainer stepSpecific(int aSimulationQueueIndex, Object[][] aParameterMap, String[] aOutputFilterArray, int aStepCount) throws Exception Used running the i-th simulation in queue stepwise. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aOutputFilterArray
- only these Keys will be included in the output arrayaStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aStepCount
- number of steps calculated- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
public DataContainer stepSpecific(int aSimulationQueueIndex, String[] aOutputFilterArray) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aOutputFilterArray
- only these Keys will be included in the output array- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
public DataContainer stepSpecific(int aSimulationQueueIndex, String[] aOutputFilterArray, int aStepCount) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aOutputFilterArray
- only these Keys will be included in the output arrayaStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
public DataContainer stepSpecific(int aSimulationQueueIndex, Object[][] aParameterMap) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
public DataContainer stepSpecific(int aSimulationQueueIndex, Object[][] aParameterMap, int aStepCount) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepSpecific
public DataContainer stepSpecific(int aSimulationQueueIndex, Object[][] aParameterMap, String[] aOutputFilterArray) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aSimulationQueueIndex
-aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aOutputFilterArray
- only these Keys will be included in the output array- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
public DataContainer step(Object[][] aParameterMap, String[] aOutputFilterArray, int aStepCount) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is usable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aOutputFilterArray
- only these Keys will be included in the output arrayaStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aStepCount
- number of steps calculated- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aOutputFilterArray
- only these Keys will be included in the output array- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aOutputFilterArray
- only these Keys will be included in the output arrayaStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
step
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aOutputFilterArray
- only these Keys will be included in the output array- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
initSimulations
- Throws:
Exception
MissingSimResourceException
-
stepAll
public DataContainer[] stepAll(Object[][][] aParameterMap, String[] aOutputFilterArray, int aStepCount, boolean aParallelized) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is usable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aOutputFilterArray
- only these Keys will be included in the output arrayaStepCount
- count of steps to be calculated before returning the resultaParallelized
- if true, then the simulations are stepped in parallel (caution: may cause problems if solution has outputs)- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepAll
public DataContainer[] stepAll(Object[][][] aParameterMap, String[] aOutputFilterArray, int aStepCount) throws Exception - Throws:
Exception
-
stepAll
- Throws:
Exception
-
stepAll
- Throws:
Exception
-
stepAll
- Throws:
Exception
-
stepAll
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aOutputFilterArray
- only these Keys will be included in the output arrayaStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepAll
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepAll
Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aStepCount
- count of steps to be calculated before returning the result- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
stepAll
public DataContainer[] stepAll(Object[][][] aParameterMap, String[] aOutputFilterArray) throws Exception Used running the simulation stepwise. Only the last created or the first simulation in the first project is useable. You have to run - prepareProject and optional - createSimulation before!- Parameters:
aParameterMap
- Map (String,Object) of key value pairs to be used in the VarMap for this simulation day(s)aOutputFilterArray
- only these Keys will be included in the output array- Returns:
- an object array containing the var map data of this step
- Throws:
Exception
-
registerOutputListener
Output listener gets Output Event with the current VarMap- Parameters:
aOutputListener
-
-
removeOutputListener
Output listener gets Output Event with the current VarMap- Parameters:
aOutputListener
-
-
registerModelListener
Model listener gets Model Event with the current Model- Parameters:
aModelListener
-
-
removeModelListener
Model listener gets Model Event with the current Model- Parameters:
aModelListener
-
-
shutDown
public void shutDown()Has to be called at the end. -
setCheckLevel
- Parameters:
aCheckLevel
- the checkLevel to set, To be called before generating a session/solution can be OFF, LAZY, INTENSE, CUSTOM or ONLY
-
setProjectLines
- Parameters:
aProjectLines
- the projectLines to read while reading project data file.
-
setProjectLines
- Parameters:
aProjectLines
- the projectLines to read while reading project data file.
-