Class MultiRun

  • All Implemented Interfaces:
    java.lang.Runnable, EngineListener, ExperimentBuilder

    public abstract class MultiRun
    extends java.lang.Thread
    implements EngineListener, ExperimentBuilder
    MultiRun is a template abstract class useful to guide the modeller to build an automatic simulation launcher, able to change interactively parameters on the basis of the last run.
    The best way to understand hot it works is to see the MultiRun example in the JAS/examples directory.

    The key methods of multi run are startModel() and nextModel(). The first one must create the simulation model(s), set its(their) parameters a vector containing them.
    The jas engine will attach the returning list of model and execute the simulation. When the SIMULATION_END signal is sent to Sim.engine the multi run will execute the nextModel() method. Here user can observe the result of the last run and decide which parameters to use at next run. If method returns true another simulation run will be executed and the startModel() method will be called again, otherwise the progam will exit.

    Title: JAS

    Description: Java Agent-based Simulation library

    Copyright: Copyright (C) 2002 Michele Sonnessa

    Company:

    Author:
    Michele Sonnessa
    • Constructor Detail

      • MultiRun

        public MultiRun()
        Create a new multi run session.
        Parameters:
        title - is the title of the multi run control panel (see MultiRunFrame API).
        maxRuns - is the length of the progress bar. It is not so important. It has only a simbolic meaning.
    • Method Detail

      • nextModel

        public abstract boolean nextModel()
        When a SIMULATION_END signal is sent to JAS by one of the running models, simulation is stopped and this method is called. If it returns true the multi run will continue with the next run, otherwise the program will exit.
        Returns:
        a value deciding if simulation is to be continued.
      • setupRunLabel

        public abstract java.lang.String setupRunLabel()
      • run

        public void run()
        MultiRun is an independent thread. The run method controls the sequence of simulations.
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • go

        public void go()
        The go method starts the multi-run simulation.
      • onEngineEvent

        public void onEngineEvent​(SystemEventType event)
        Implementing the ISimEngineListener. This method monitors the Sim.EVENT_SIMULATION_END signal. When it is raised the MultiRun class shutdowns current run and invokes the nextModel() method.
        Specified by:
        onEngineEvent in interface EngineListener
        Parameters:
        actionType - a valid system eventID.
      • getCounter

        public int getCounter()
      • setExperimentBuilder

        public void setExperimentBuilder​(ExperimentBuilder experimentBuilder)
      • getMultiRunListeners

        public java.util.List<MultiRunListener> getMultiRunListeners()
      • setMultiRunListeners

        public void setMultiRunListeners​(java.util.List<MultiRunListener> multiRunListeners)
      • getMultiRunId

        public java.lang.String getMultiRunId()
      • setMultiRunId

        public void setMultiRunId​(java.lang.String multiRunId)
      • getEngineListeners

        public java.util.List<EngineListener> getEngineListeners()
      • setEngineListeners

        public void setEngineListeners​(java.util.List<EngineListener> engineListeners)
      • getParameterDomains

        public java.util.List<ParameterDomain> getParameterDomains()
      • setParameterDomains

        public void setParameterDomains​(java.util.List<ParameterDomain> parameterDomains)
      • getMaxConfigurations

        public int getMaxConfigurations()
      • getConfiguration

        public java.util.Map<java.lang.String,​java.lang.Object> getConfiguration​(int counter)
      • setCopyInputFolderStructure

        public static void setCopyInputFolderStructure​(boolean copyInputFolderStructure_)
        Sets whether to copy the input files into a new input folder within a new output folder for each simulation run
        Parameters:
        copyInputFolderStructure - - set to true if wanting a copy of the input files to be stored in the output folder for each simulation run, otherwise set to false