Run EMOD
Objective
The goal of this tutorial is for you to learn how to run a single simulation of EMOD-HIV using emodpy-workflow. There are many ways to run EMOD:
- From the command line
- Using emodpy-hiv
- Using emodpy-workflow
- On an HPC
- On your laptop
- As part of a parameter calibration
- As a parameter sweep
However, you will frequently want to run a single simulation when you creating different behaviors in your simulation or while debugging.
Prerequisites
To run EMOD per the instructions of this tutorial, you need to have done the followinng:
Control how and where EMOD runs
Before we can start using the "run" command, we first need to know where we can control the what and where EMOD runs. The manifest.py file is used by emopdy-workflow to know what EMOD executable binary to use, to specify a container for the executable binary to run in, to specify any simulation post processing scripts, etc. The idmtools.ini file is used to specify how EMOD is run on different platforms, where a "platform" is a computing device like an HPC or laptop.
View manifest.py
- In the root of your project directory, open the
manifest.pyfile. - On about line 39, you should see a variable called
executable_path. This tells emodpy-workflow where to get the EMOD executable binary. - Just below that you should also see a variable called
asset_collection_of_container. This is variable is used by emodpy-workflow to know what container to run EMOD in. (Containers reduce your need to install everything needed to run EMOD.) - For more information see manifest.py.
View idmtools.ini
- In the root of your project directory, open the
idmtools.inifile. -
Towards the top of the file, you should see something similar to the following:
-
This tells emodpy-workflow that there is a platform called
ContainerPlatformthat is of typeContainerand that simulation jobs should go in to theemodpy-jobsdirectory. - For more information see idmtools.ini.
Create a results directory
Since we will be running EMOD multiple times, it is handy to put the results into their own directory.
-
Execute the following command in the root of your project (the directory that contains the
manifest.pyfile):This should create a directory called
resultsin your project directory.
Using the run command
To run EMOD, we will use the emodpy-workflow run command.
-
Execute the following command in the root of your project:
This should produce output similar to the following:
-
For our purposes, we are going to focus on the following arguments:
- suite name - This is the name you give to a collection of experiments, 'my_first_suite'.
- frame - This is the name of the frame who's configuration is what you want to use. In our case, it will be 'baseline'
- output directory - The path of the directory to put the data for your run, say 'results/my_first_run'.
- platform - This is the name of a platform defined in your 'idmtools.ini' file. We will be using 'ContainerPlatform'.
-
Execute the following command:
You should see output similar to the following:
Note
This means that the simulations have been submitted to start running. It does not mean they are done.
Get status on your experiment
Notice how in the last four lines of the output that there is information about finding the status of your output. In this case, the following line
says get status on experiment with the given ID.
If you execute that line, you should see something similar to:
Note
This only works when using the Container Platform. To see status when using other platforms, please see the Command Line Interface documentation for your platform.
View the files produced when running an experiment
When using the Container and SLURM platforms, you can access the directories where the experiments and simulations are running. In our case, we are using the Container Platform and our idmtools.ini file told emodpy-workflow to put the files into a local folder called "emodpy-jobs". If we navigate into this folder, we can see all of the files associated with running the experiment and simulations. Let's go investigate.
-
From the main project directory execute the following commands:
You should see something similar to:
Notice the directory
my_first_suite_2f7f3943-0814-418a-9792-604fc7db2a31starts with the name we gave the suite. -
Look in the the suite directory by executing commands similar to the following (your directory name is likely different):
You should see something similar to the following:
Yes, it looks very similar, but this is the experiment directory.
-
Look in the experiment directory by executing commands similar to the following (your directory name is likely different): === "Windows"
=== "Linux"You should see something similar to the following:
The experiment directory will have one folder for each simulation of the experiment. In this case, there is only one simulation with ID:
84efd93c-b13a-4bd4-ae54-f4ac5ab7aa9d45eefc10-bf1d-48bf-a7f0-d90d1c94bd8fFor the most part, you do not need to know about the other files in the directory. However, the
metadata.jsonfile does contain some details about the experiment and its simulations. -
Look in the simulation directory
84efd93c-b13a-4bd4-ae54-f4ac5ab7aa9dYou should see something similar to the following:
The simulation directory is the directory where a single realization/simulation of EMOD is being run. If you have simulations that are failing or not running to completion, you should look at the
stderr.txtfile and thestdout.txtfile. These files can contain error messages directly from the EMOD executable. Finally, theoutputdirectory contains the report data that was generated for this realization/simulation. (We will be using thedownloadcommand to organize our report files, but if that becomes limiting, you can access them directly.)Note
If something is failing or not working like you expect, an EMOD developer will need the contents of this directory in order to duplicate and debug the issue.
-
View the end of the
stdout.txtfile.Use a text editor to view
stdout.txtfile and scroll to the bottom. You should see something similar to the following:The
stdout.txtfile contains information that EMOD can log to standard out. For example, the line that has[Simulation] Update(): Time:in it is printed each time step of the simulation. Seeing these being written out can be helpful to know that the simulation is still running. The line that containsController executed successfullylets us know that the simulation has finished. This file can contain warnings or error messages. This can be a great place to look when starting to debug why your simulations are not running. -
Go back to the project directory -
my_projectYou should see something similar to:
You should be back to your project directory.
View the results/my_first_run folder and the "receipt file"
In our run command, you specified the output as -o results/my_first_run.
-
Look at the contents of the
results/my_first_runfolderYou should see something similar to the following:
-
Look at the contents of the
results/my_first_run/experiment_index.csvYou should see something similar to the following:
This file can provide you information about the experiment and where the files are located. We will use it in our next step to download the report data.
Download the results/output/reports
Now that we have seen all of the files created when running an experiment, let's get back to our project directory and get our report data.
-
Execute the
downloadcommand to see what the options areYou should see something similar to the following:
-
Execute the
downloadcommand to download the InsetChart.json filesIn this command, we specified the following:
-d "output/InsetChart.json- EMOD puts the report files into a subfolder called "outputs". In this case, we want the InsetChart.json report since it contains a lot of high level statistics.-r results/my_first_run/experiment_index.csv- Since we have a "receipt" file, we use it here to tell thedownloadcommand where the data is.-p ContainerPlatform- This tells thedownloadcommand to use the Container protocol when getting data.
You should see something similar to the following:
As you can tell, there are many ways to specify the download of the data. The how-tos can show you different ways to do it.
-
See that a new folder was added to the `results/my_first_run:
Now when we look in this folder we should see something similar to the following:
The
my_first_suite--0directory was created. -
See that a folder was created with the name of the report:
You should see something similar to the following:
Notice that
InsetChartis the base name of the report file we requested to download. -
See where the data has been put by executing the following command:
You should see something similar to the following:
The directory should contain one file for each simulation of the experiment. In this case, there is only one.
Plot the results
Now that we have our data downloaded, let's plot the data to see what happened in the simulation.
-
Execute the following command to see what options are available when plotting InsetChart.
You should see something similar to the following:
Note
If you are executing these commands via SSH or on Codespaces, you will need to use the
-oor--outputoption to create an image file that you can view. -
Execute the following command to plot the data in InsetChart.json:
This should produce an image or window that looks like the following:

If we look at the plot in column three, row three, you see something like the following:

where prevalence goes up to about 1.5% in the middle of the simulation and then declines to about 0.5%.
Next up: Modifying the simulation
Now that you have run EMOD once, investigate the other tutorials where you can modify the simulation and run the model.