Chapter 2: Using FRED Local

Once you have FRED Local installed and have verified the installation as described in Chapter 1, you are ready to use FRED to build and run your own simulations.

This chapter presents some suggestions for using FRED Local and provides some suggestions for updating the simpleflu model to become more familiar with the FRED Modeling Language™.

Direct Shell Access

Running a model as shown in Chapter 1 works well, and you can certainly use this approach to run your own models. Another approach is to run a shell directly in the container and use FRED commands more directly. This section walks through how to run the sample model using this other approach.

You should have a FRED Local container already running called fred as described in Chapter 1. Run a shell script with the following commands:

$ docker exec -it fred /bin/bash
root@a48b40b88a53:/fred/models# pwd

After this command, you are running directly in the Docker container, so the instructions are identical regardless of the underlying platform. Your actual shell prompt will vary since it includes a portion of the container identifier (the a48b40b88a53 portion of the prompt in our example).

You can now run FRED Simulation Information Management System (SIMS) commands directly, as described in the FRED SIMS documentation. For example, you can verify the container configuration as follows:

root@a48b40b88a53:/fred/models# fred_verify_container_configuration
Verifying FRED container configuration..
No issues found! Container configuration verified!


As another example, you could invoke the METHODS script in the simpleflu model, or execute the commands from this script directly as shown here.

root@a48b40b88a53:/fred/models# cd FRED-tutorials/simpleflu/

root@a48b40b88a53:/fred/models/FRED-tutorials/simpleflu# fred_delete -f -k simpleflu
fred_delete: KEY = simpleflu  JOB = 129
fred_delete: /fred/results/JOB/129 deleted

root@a48b40b88a53:/fred/models/FRED-tutorials/simpleflu# fred_job -k simpleflu \
-p main.fred -n 4 -m 2

fred_job: starting job simpleflu at Mon May  3 14:33:06 GMT 2021

fred_compile -p main.fred
No errors found.
No warnings.

fred_job: running job simpleflu id 130 run 1 ...
fred_job: running job simpleflu id 130 run 2 ...
run_set 0 completed at Mon May  3 14:33:09 GMT 2021

fred_job: running job simpleflu id 130 run 3 ...
fred_job: running job simpleflu id 130 run 4 ...
run_set 1 completed at Mon May  3 14:33:12 GMT 2021

fred_job: finished job simpleflu 130 at Mon May  3 14:33:13 GMT 2021

root@a48b40b88a53:/fred/models/FRED-tutorials/simpleflu# fred_plot -o weekly \
-k simpleflu -v INFLUENZA.newExposed -b -t "Simple Flu Model" -l "Weekly Incidence" \
-d 0 -w --clean
fred_plot: image_file = weekly.pdf


Using the shell directly in this manner may be easier than invoking commands externally. For more information on the FRED command-line tools, see the document FRED Simulation Information Management Guide available on the Epistemix Documentation site.

Epistemix Tutorial Models

The other tutorial models downloaded in Chapter 1 as part of the FRED-tutorials repository provide a good overview of some key features of FRED. We recommend reading through the Tutorials documentation found at the FRED Language Tutorials link and running one or more simulations for each of the models.

Each model has a METHODS script, just list simpleflu, so you can run this script directly. A more instructive approach might be to execute the FRED SIMS commands directly as we show in the prior example. The FRED SIMS documentation includes reference pages for each command, if you wish to explore these commands further.

Learning FRED programming

It is beneficial to modify the simpleflu and other tutorial programs as a way to experience the keywords and syntax of FRED programs. In the simpleflu model directory, for example, here are some changes you could make after reading through the other tutorials. Copy the code to a new directory and run your model after each suggestion to see the impact on the results.

Suggested simpleflu Changes for Practice

  1. Modify the locations setting in the main.fred file to use your local county. Note that if your county population is more than a few hundred thousand, you may need to increase the memory for your docker container. You can do this in the Preferences settings in Docker Desktop, under the Resources options. For the simpleflu model, we would recommend 8 GB of memory per 1 million residents of an area. FRED does use a lot of memory, and if the memory available is exceeded, then the program will be killed by the operating system.

  2. Add a variables.fred file to define a symptomatic_transmissibility variable set to 1.0, and replace the INFLUENZA.trans assignments to use this variable in both the InfectiousSymptomatic and InfectiousAsymptomatic states. Don’t forget to include the new variables.fred file in your main.fred file.

  3. Add a parameters.fred file to the program that overrides the value of symptomatic_transmissibility to be 0.75. Generate the weekly.pdf plots for both transmissibility values to compare when the peak number of exposures occurs within the population.

  4. Modify the INFLUENZA state so that an agent has a 5% chance of dying when they are symptomatic and a 1% chance of dying when they are asymptomatic. You will need to use the die() function for this scenario, which causes the agent to die.

Create a New Model

At some point you will want to create your own models with FRED. We recommend reading through the available documentation before attempting this, of course. You should also consider creating a state diagram of your conditions as a way to think through the behavior and transitions for the agents in your model. FRED’s declarative programming style lends itself to such diagrams, and the modelers at Epistemix often use them.

As an example, here is a state transition diagram of the INFLUENZA condition in the simple flu model, in a form you might create before writing the condition.

simpleflu state transition diagram

A state transition diagram for the simple flu INFLUENZA condition.

As an alternative, here is a diagram generated from the simpleflu code directly. This has the advantage of showing the states and FRED code used in the program.

simpleflu state transition diagram with embedded code

A generated state transition diagram for the INFLUENZA condition. This shows the actual state names used in the FRED program, and the code for each state. Note that the implicit transition from Susceptible to Exposed is not reflected here.

Getting Help

If you need assistance or have questions using FRED Local or the FRED Modeling Language, contact our Customer Service team at