Class SimplaceWrapper

java.lang.Object
net.simplace.sim.wrapper.SimplaceWrapper
Direct Known Subclasses:
JavaSimplaceWrapper

public class SimplaceWrapper extends Object
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:
  • Field Details

    • isSimulationInitialized

      protected boolean isSimulationInitialized
      When simulation is initialized it can directly be run this method can only be used for single session approach
    • iCurrentSession

      protected FWSimSession iCurrentSession
      Holds the currently (last) initialized session The method should only be used for single session approach
    • iSimulationsQueue

      protected List<FWSimSimulation> iSimulationsQueue
      Holds the list of active simulations
    • iSimulationsCount

      protected int iSimulationsCount
      Holds the number of all created simulations.
    • iInitializedSimulations

      protected List<Boolean> iInitializedSimulations
  • Constructor Details

    • SimplaceWrapper

      public SimplaceWrapper(String aWorkDir, String aOutputDir, String aProjectsDir, String aDataDir)
      Creates the wrapper class and sets the directories
      Parameters:
      aWorkDir -
      aOutputDir -
      aProjectsDir -
      aDataDir -
    • SimplaceWrapper

      public SimplaceWrapper(String aWorkDir, String aOutputDir)
      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

      public String[] getDirectories()
      Sets directories used by solution
      Returns:
    • prepareSession

      public FWSimSession prepareSession(String aProject, String aSolution)
      prepares the project or solution to use it with next methods. CurrentSession instance variable is set and used. Just call run() 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 used
      aSolution - - required
      Returns:
      the newly created session.
    • prepareSession

      public FWSimSession prepareSession(String aProject, String aSolution, Object[][] aParameterMap)
      /** prepares the project or solution to use it with next methods. CurrentSession instance variable is set and used. Just call run() 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 used
      aSolution - - required
      Returns:
      the newly created session.
    • run

      public void run() throws Exception
      runs the prepared project or solution - not to be used without calling prepare Project before
      Throws:
      Exception
    • run

      public void run(String aProjectlines) throws Exception
      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

      public FWSimSimulation createSimulation(Object[][] aParameterMap) throws Exception
      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

      public void runSimulations(boolean doSelectSolution, boolean doUpdateResources) throws Exception
      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 simulation
      doSelectSolution - if resources should be reinitialized before calculating a new simulation
      Throws:
      Exception
    • runSimulations

      public void runSimulations(boolean doSelectSolution) throws Exception
      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 simulation
      doSelectSolution - 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

      public String[] getSimulationIDs()
      Returns:
      List of all IDs of all simulations in the queue.
    • getResult

      public DataContainer getResult(String aName, String aSimulationID)
      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 output
      aSimulationID - of the simulation
      Returns:
      an object array containing the cached data
    • setSimulationValues

      public void setSimulationValues(int aSimulationQueueIndex, Object[][] aParameterMap)
      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

      public void setSimulationValues(Object[][] aParameterMap)
      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

      public void setSpecificSimulationValues(int aSimulationQueueIndex, Object[][][] aParameterMap)
      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

      public void setAllSimulationValues(Object[][][] aParameterMap)
      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 array
      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) 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 -
      Returns:
      an object array containing the var map data of this step
      Throws:
      Exception
    • stepSpecific

      public DataContainer stepSpecific(int aSimulationQueueIndex, 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 -
      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 array
      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) 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 array
      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

      public DataContainer step() 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!
      Returns:
      an object array containing the var map data of this step
      Throws:
      Exception
    • step

      public DataContainer step(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:
      aStepCount - number of steps calculated
      Returns:
      an object array containing the var map data of this step
      Throws:
      Exception
    • step

      public DataContainer step(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:
      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(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:
      aOutputFilterArray - only these Keys will be included in the output array
      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

      public DataContainer step(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:
      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

      public DataContainer step(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:
      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

      public DataContainer step(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
    • initSimulations

      public void initSimulations() throws Exception, MissingSimResourceException
      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 array
      aStepCount - count of steps to be calculated before returning the result
      aParallelized - 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

      public DataContainer[] stepAll() throws Exception
      Throws:
      Exception
    • stepAll

      public DataContainer[] stepAll(int aStepCount) throws Exception
      Throws:
      Exception
    • stepAll

      public DataContainer[] stepAll(String[] aOutputFilterArray) throws Exception
      Throws:
      Exception
    • stepAll

      public DataContainer[] stepAll(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:
      aOutputFilterArray - only these Keys will be included in the output array
      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) 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)
      Returns:
      an object array containing the var map data of this step
      Throws:
      Exception
    • stepAll

      public DataContainer[] stepAll(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:
      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

      public void registerOutputListener(FWSimOutputListener aOutputListener)
      Output listener gets Output Event with the current VarMap
      Parameters:
      aOutputListener -
    • removeOutputListener

      public void removeOutputListener(FWSimOutputListener aOutputListener)
      Output listener gets Output Event with the current VarMap
      Parameters:
      aOutputListener -
    • registerModelListener

      public void registerModelListener(FWSimulationListener aModelListener)
      Model listener gets Model Event with the current Model
      Parameters:
      aModelListener -
    • removeModelListener

      public void removeModelListener(FWSimulationListener aModelListener)
      Model listener gets Model Event with the current Model
      Parameters:
      aModelListener -
    • shutDown

      public void shutDown()
      Has to be called at the end.
    • setCheckLevel

      public void setCheckLevel(String aCheckLevel)
      Parameters:
      aCheckLevel - the checkLevel to set, To be called before generating a session/solution can be OFF, LAZY, INTENSE, CUSTOM or ONLY
    • setProjectLines

      public void setProjectLines(String aProjectLines)
      Parameters:
      aProjectLines - the projectLines to read while reading project data file.
    • setProjectLines

      public void setProjectLines(Integer[] aProjectLines)
      Parameters:
      aProjectLines - the projectLines to read while reading project data file.