Demo models‎ > ‎MacroABM‎ > ‎

Running the model

The start class ( and multi-run class (

The MacroStart class initializes the JAS-mine simulation engine and defines the list of models to be used. In general, the Start class is designed to handle two 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; 

Another mode of operation can be:
  • 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.
In this latter case, the MacroMultiRun class should be run instead of the MacroStart class.  The MacroMultiRun class uses the JAS-mine engine to perform multiple sequential simulation runs, and is the place to specify how the parameters should be varied between runs, if indeed this is the purpose of the multi-run session.


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 MacroABM, a typical user may start exploring the model by running a simulation in interactive mode (Box 1).

public class MacroStart implements ExperimentBuilder {

public static void main(String[] args) {

boolean showGui = true;

SimulationEngine engine = SimulationEngine.getInstance();

MicrosimShell gui = null;

if (showGui) {

gui = new MicrosimShell(engine);



MacroStart experimentBuilder = new MacroStart();




public void buildExperiment(SimulationEngine engine) {

MacroModel model = new MacroModel();

MacroCollector collector = new MacroCollector(model);


MacroObserver observer = new MacroObserver(model, collector);






Box 1. The MacroStart class.

The MacroStart 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 MacroStart” 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 'GUI parameters' of the Model (labelled as 'MacroModel's parameters'), another mask for defining the specific Collector parameters (labelled as 'MacroCollector's parameters'), and finally a mask of Observer parameters (labelled as 'MacroObserver's parameters').  

After the user adjusts the  GUI parameters to the desired values, the user should click on the 'Build simulation model' button (labelled 'Build' in Figure 1, second from the left in the top panel).  This will build the model and bring up the (empty) charts.  The user then starts the simulation run by clicking on the 'Start simulation' button (labelled 'Run' in Figure 1, third from the left, next to the 'Build simulation model' button).  The dynamic graphs defined in the Observer class will begin to populate with data from the simulation run.  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, though in order to create an output database, the 'Export To Database' GUI parameter should be enabled (check its tick-box) in the list of 'MacroCollector's parameters' .  By selecting a specific database (either the 'INPUT' database or the output databases labelled by the timestamp of when the simulation was executed) 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: 


The following Figure 2 displays the typical output from such a command.  If you find that there is no such information, ensure that you have enabled the 'Export To Database' boolean parameter in the 'MacroCollector's parameters' mask in the GUI (or in the class itself, by setting the exportToDatabase = true), and ensure that you have selected the correct output database time-stamp (in case there are other simulation executions where exportToDatabase was set to false or not enabled in the GUI).

Figure 2. Exploring the bank data stored in the output database, using the command 'SELECT * FROM BANK;'

Previous: Charts