Class FWSimProject

java.lang.Object
net.simplace.sim.FWSimProject

public final class FWSimProject extends Object
A project is an ensemble of simulation runs that share the solution and its resources (e.g. files, databases) but differ in the values of their FWSimVariables. The simulations are created in chunks by a plug-in FWSimulationGenerator (see updateSimulations(FWSimulationControlCache)) and run in a thread pool (see simulate(List)). A project is defined in a project file (.proj.xml); without project file only the solution is simulated.

The FWSimProject.PROJECT_MODE describes how the simulations are created:

In synchronized mode (defined by the control map) all simulations of a chunk run in parallel and exchange data via the sync manager of the session whenever all of them are waiting.
Author:
Andreas Enders
  • Constructor Details

    • FWSimProject

      public FWSimProject(String aProjectID, FWSimulationGenerator aGenerator, FWSimProject.PROJECT_MODE aProjectMode, FWSimulationControlCache aCache)
      Creates a project and resets the generator to its initial state.
      Parameters:
      aProjectID - id (name) of the project
      aGenerator - generator creating the simulations
      aProjectMode - mode of the project
      aCache - control cache of the project run; its control map defines whether the run is synchronized
  • Method Details

    • initProject

      public static List<FWSimSimulation> initProject(List<FWSimSimulation> aSimulationList) throws Exception
      Initializes a project run with the first chunk of simulations: updates the resources and registers the simulations at the output manager. The run is skipped if the output manager reports that the output already exists (skip-above-size check).
      Parameters:
      aSimulationList - first chunk of simulations; the variable map of the first one is used for the project settings
      Returns:
      the given list, or null if the project run is skipped
      Throws:
      Exception - if the resources cannot be updated or the outputs cannot be registered
    • toXML

      public org.jdom2.Element toXML()
      Creates an XML representation of the project: a project element with one simulation element per simulation, containing its variables of content type var and dyn.

      Note: calls updateSimulations(FWSimulationControlCache) with null, which fails; the method therefore currently ends with a NullPointerException.

      Returns:
      the project element
    • updateSimulations

      public List<FWSimSimulation> updateSimulations(FWSimulationControlCache aControlCache) throws Exception
      Lets the generator create the next chunk of simulations (at most FWSimEngine.MAX_SIMULATION_COUNT per call). The first chunk also initializes the project run (see initProject(List)).
      Parameters:
      aControlCache - control cache of the project run; its update counter is increased
      Returns:
      the next simulations to run, or null if the generator has no more simulations or the project run is skipped
      Throws:
      Exception - if the generator or the project initialization fails
    • setSimulations

      public void setSimulations(List<FWSimSimulation> aSimulations)
      Sets the simulations of the project manually. This list is not filled by updateSimulations(FWSimulationControlCache).
      Parameters:
      aSimulations - the simulations (copied into a new list)
    • getSimulations

      public List<FWSimSimulation> getSimulations()
      Returns:
      the simulations set by setSimulations(List), or null if none were set
    • getID

      public String getID()
      Returns:
      the id of the project
    • getProjectMode

      public final FWSimProject.PROJECT_MODE getProjectMode()
      Returns:
      the project mode
    • setProjectMode

      public final void setProjectMode(FWSimProject.PROJECT_MODE mode)
      Parameters:
      mode - the new project mode
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSimulationCount

      public int getSimulationCount()
      Returns:
      the current simulation count of the control cache
    • canUpdate

      public boolean canUpdate()
      Returns:
      true if the generator can create more simulations for this project
    • getFieldMap

      public HashMap<String, FWSimVariable<?>> getFieldMap()
      Returns:
      the field map of the generator (the project variables)
    • getSyncVarMap

      public FWSimVarMap getSyncVarMap()
      Not implemented.
      Returns:
      always null