Demo models‎ > ‎Demo07‎ > ‎

8. The StartPersons class

The StartPersons class initialises the JAS-mine simulation engine and defines the list of models to be used. In general, the Start class is designed to handle three types of experiments:
  • performing a single run of the simulation in interactive mode, through the creation of a Model and related Collectors and Observers, with their GUIs;
  • performing a single run of the simulation in batch mode, through the creation of the Model and possibly the Collectors; this involves managing parameter setup, model creation and execution directly, and is aimed at capturing only the simulation’s numerical output;
  • performing a multi-run session (whose structure is defined in a class extending the MultiRun interface) where the simulation is run repeatedly using different parameter values, so as to explore the space of solutions and produce sensitivity analyses on the specified parameters.
 
The Start class implements the ExperimentBuilder interface, which defines the buildExperiment() method. This method creates managers and adds them to the JAS-mine engine. In demo07, the simulation is run in interactive mode (Box 18).


public class StartPersons implements ExperimentBuilder {

 

        public static void main(String[] args) {

               boolean showGui = true;

              

               StartPersons experimentBuilder = new StartPersons();

               final SimulationEngine engine = SimulationEngine.getInstance();

               MicrosimShell gui = null;

               if (showGui) {

                       gui = new MicrosimShell(engine);            

                       gui.setVisible(true);

               }

              

               engine.setExperimentBuilder(experimentBuilder);

              

               engine.setup();                             

              

        }

 

        @Override

        public void buildExperiment(SimulationEngine engine) {

 

               PersonsModel model = new PersonsModel();

               PersonsCollector collector = new PersonsCollector(model);

               PersonsObserver observer = new PersonsObserver(model, collector);

                             

               engine.addSimulationManager(model);

               engine.addSimulationManager(collector);

               engine.addSimulationManager(observer);

       

        }

 

}

Box 18. The StartPerson class.

The StartPerson class contains the standard main() method which allows a Java application to run. By selecting the 'Run As Java Application' option from the Eclipse menu, or by typing “java StartPersons” from the Command Prompt, this procedure launches the JAS-mine GUI, creates a model instance and gives it to the simulation engine. It then creates a Collector and an Observer and calls the setup() method of the simulation engine, which has the task of loading the experiment into memory. 

The JAS-mine GUI contains a mask for setting the specific Model parameters, another mask for defining the specific Observer parameters and the three dynamic graphs defined in the Observer class. Figure 1 depicts the graphical output of one simulation run.

Figure 1. The graphical output of one simulation run.

The Tools > ‘Database explorer’ tab in the JAS-mine GUI allows to browse the input and output databases. By selecting a specific database and pressing the ‘Show database’ button, the data can be explored in the default web browser using SQL commands. As an example, the output tables can be exported in .csv format for subsequent analysis using specific statistical tools by typing: 

CALL CSVWRITE('person.csv', 'SELECT * FROM PERSON ');



Previous: 7. The PersonsObserver class