Tutorials

The following tutorials provide step-by-step instructions on how to build a variety of models within Insight Maker. Tutorials marked with "SD" are primarily System Dynamics focused while tutorials marked ABM are primarily focused on Agent-Based Modeling.

Before starting on the tutorials, it may be useful to familiarize yourself with basic Insight Maker model-building practices. Specifically, you should familiarize yourself with how to create primitives and run models.

Disease Dynamics (SD)

    This tutorial describes how to construct a model of an infectious disease. Before starting the tutorial, make sure you have familiarized yourself with how to create primitives and run models.
  1. Create a new Stock named Healthy.
  2. Create a new Stock named Infected.
  3. The model diagram should now look something like this:
  4. Create a new Flow going from the primitive Healthy to the primitive Infected. Name that flow Infection.
  5. The model diagram should now look something like this:
    The basic model structure has been laid-out, we can start to define parameter values and equations. We'll start with a very simple model containing a population of 100 people and where 2 people becoming sick each year.
  6. Change the Initial Value of the primitive Healthy to 100.
  7. Change the Flow Rate of the primitive Infection to 2.
  8. Run the model. Here are sample results:
    The results are as we would expect. However this is not a model of an infectious disease as the infection rate does not depend on the presence of infected individuals. Let's change the infection rate so it depends on the contact rates between sick and healthy people.
  9. Change the Flow Rate of the primitive Infection to 0.006*[Healthy]*[Infected].
  10. Run the model. Here are sample results:
    That's strange. No one ever gets sick. Why is that? It turns out it is because we start the simulation with no infected people in the model. Since we're modeling an infectious disease, this means there is no one to start the epidemic! Let's change that we'll add a single infected person to get the epidemic started.
  11. Change the Initial Value of the primitive Infected to 1.
  12. Run the model. Here are sample results:
    That looks about right. Before moving on, let's spend a moment to improve our model structure. Right now if we wanted to edit the infection rate, we would have to dig down in the equations to find the right number. Let's make our model more modular, without changing any results, by separating the infection rate into its own variable.
  13. Create a new Variable named Infection Rate.
  14. Create a new Link going from the primitive Infection Rate to the primitive Infection.
  15. The model diagram should now look something like this:
  16. Change the Equation of the primitive Infection Rate to 0.006.
  17. Change the Flow Rate of the primitive Infection to [Infection Rate]*[Healthy]*[Infected].
  18. Run the model. Here are sample results:
    We can hide the display of the infection rate primitive by configuring the display.
  19. Run the model. Here are sample results:
    Now that we have our basic model working, let's extend it by adding the phenomena of people recovering from the disease. We'll model something like the Chicken Pox where people become immune to the disease after they recover.
  20. Create a new Stock named Immune.
  21. Create a new Flow going from the primitive Infected to the primitive Immune. Name that flow Recovery.
  22. Create a new Variable named Recovery Rate.
  23. Create a new Link going from the primitive Recovery Rate to the primitive Recovery.
  24. The model diagram should now look something like this:
  25. Change the Equation of the primitive Recovery Rate to 0.1.
  26. Change the Flow Rate of the primitive Recovery to [Recovery Rate]*[Infected].
  27. Change the Equation of the primitive Infection Rate to 0.008.
  28. Run the model. Here are sample results:
    Fantastic! Now we have a working disease simulation. You can experiment with different population sizes, infection rates and recovery rates to see how the results change.

Disease Dynamics (ABM)

    This tutorial describes how to construct a model of an infectious disease using Insight Maker. Agent-Based Modeling techniques are used in the construction of this model. Before starting the tutorial, make sure you have familiarized yourself with how to create primitives and run models.
  1. Create a new State named Healthy.
  2. Create a new State named Infected.
  3. Create a new State named Recovered.
  4. The model diagram should now look something like this:
    States represent the condition someone is in. So in our model a person can either be healthy, infected, or recovered from the infection. Now, lets add transitions that move a person from state to state.
  5. Create a new Transition going from the primitive Healthy to the primitive Infected. Name that transition Infection.
  6. Create a new Transition going from the primitive Infected to the primitive Recovered. Name that transition Recovery.
  7. The model diagram should now look something like this:
    Please note that in this model someone who is recovered cannot become sick again. They have gained immunity to the disease.

    Now that the model structure has been designed, let's add equations and configure the primitives.
  8. Change the Initial Active property of the primitive Healthy to true.
    When a state is active, it means a person is in that state. By setting Healthy to start true, we have the person start in the healthy state.
  9. Change the Trigger Type property of the primitive Infection to Probability.
  10. Change the Value/Equation property of the primitive Infection to 0.3.
  11. Change the Trigger Type property of the primitive Recovery to Probability.
  12. Change the Value/Equation property of the primitive Recovery to 0.2.
    Using the Probability type for the transition trigger means that the person has a fixed probability of transitioning from one state to the next each year.
  13. Run the model. Here are sample results:
    Don't worry if your results do not look exactly like this. This is a stochastic model so each time we run it, we will get different results. Let's give it a try.
  14. Run the model. Here are sample results:
  15. Run the model. Here are sample results:
    When a state takes on the value 1 it means the person is in the state. We can see how the person moves from healthy, to infected, to recovered in these three different simulation runs. Right now we are only simulating a single person. Let's extend our model to simulate a population of people.
  16. Create a new Folder named Person. The folder should surround the primitives Healthy, Infected, Recovered, Infection and Recovery.
  17. The model diagram should now look something like this:
  18. Change the Behavior property of the primitive Person to Agent.
  19. Create a new Agent Population named Population.
  20. Change the Agent Base property of the primitive Population to Person.
  21. The model diagram should now look something like this:
  22. Run the model. Here are sample results:
    That looks pretty good! We can see the disease gradually spread through our population of 100 people.

    However, right now the probability of a person getting sick is independent of the other people in the model. Let's change the model so the more sick people there are, the higher the likelihood that a healthy person will become sick.
  23. Create a new Variable named Percent Infected.
  24. Create a new Link going from the primitive Population to the primitive Percent Infected.
  25. Create a new Link going from the primitive Percent Infected to the primitive Infection.
  26. The model diagram should now look something like this:
    Now let's configure the value of Percent Infected and change the Infection transition to use it.
  27. Change the Equation property of the primitive Percent Infected to Count(FindState([Population], [Infected]))/PopulationSize([Population]).
    This equation uses the FindState function to select all the people in the Population primitive who are in the Infected state. It then divides the count of those people by the total size of the population.
  28. Change the Value/Equation property of the primitive Infection to [Percent Infected], and the Recalculate property of the primitive Infection to Yes.
    The Recalculate property causes the infection rate to be recalculated and updated at every time step of the simulation.
  29. Run the model. Here are sample results:
    Nothing happened because we don't have anyone to start the infection. Let's seed the model with a single initial infected person.
  30. Change the Initial Active property of the primitive Infected to Index(Self) == 1.
  31. Change the Initial Active property of the primitive Healthy to Index(Self) <> 1.
    Each of the people in the population is given an unique Index. The first agent will have an index of 1, the second an index of 2, and so on. Self always refers to the current agent. These equations will set the first agent created to start in the Infected state while all the other agents will start in the Healthy state.
  32. Run the model. Here are sample results:
    Since this is a stochastic model, each time you run it, you will get slightly different results. Let's give it a try.
  33. Run the model. Here are sample results:
  34. Run the model. Here are sample results:
    That works great! We now have a full Agent-Based Model of disease.

    We can also configure the display type to be a map of the people in the model in a two-dimensional geography. Right now, people are placed randomly, but we could configure their locations or make them move around in response to different factors. We could also change the infection rate so the infection spread geographically.
  35. Run the model. Here are sample results:

Predator-Prey Interactions (SD)

    This tutorial describes how to construct a model of the interactions between a predator species (wolves) and a prey species (moose). Before starting the tutorial, make sure you have familiarized yourself with how to create primitives and run models.
    First, let's create the structure to model a small population of moose.
  1. Create a new Stock named Moose.
  2. Create a new Flow going from empty space to the primitive Moose. Name that flow Moose Births.
  3. Create a new Flow going from the primitive Moose to empty space. Name that flow Moose Deaths.
  4. The model diagram should now look something like this:
    Now that the structure has been defined, let's enter the equations to define how our moose population behaves. We'll assume 150 moose to start and constant birth- and death-rates.
  5. Change the Initial Value property of the primitive Moose to 150.
  6. Change the Flow Rate property of the primitive Moose Births to 0.16*[Moose].
  7. Change the Flow Rate property of the primitive Moose Deaths to 0.10*[Moose].
  8. Run the model. Here are sample results:
    We see an exponential growth pattern to this model. That because the birth-rate is higher than the death-rate. If the reverse had been true, we would have seen a population decline over time.

    Now let's create a population of wolves.
  9. Create a new Stock named Wolves.
  10. Create a new Flow going from empty space to the primitive Wolves. Name that flow Wolf Births.
  11. Create a new Flow going from the primitive Wolves to empty space. Name that flow Wolf Deaths.
  12. The model diagram should now look something like this:
    Now we can enter equations to define the behavior of the wolf population.
  13. Change the Initial Value property of the primitive Wolves to 100.
  14. Change the Flow Rate property of the primitive Wolf Births to 0.2*[Wolves].
  15. Change the Flow Rate property of the primitive Wolf Deaths to 0.12*[Wolves].
  16. Run the model. Here are sample results:
    So far, so good.

    Before we have the two populations interact, let's make our model more modular by putting all the rate constants into separate variable primitives. This will make the model easier to mantain.
  17. Create a new Variable named Moose Birth Rate.
  18. Create a new Variable named Wolf Birth Rate.
  19. Create a new Variable named Moose Death Rate.
  20. Create a new Variable named Wolf Death Rate.
  21. The model diagram should now look something like this:
  22. Create a new Link going from the primitive Moose Birth Rate to the primitive Moose Births.
  23. Create a new Link going from the primitive Wolf Birth Rate to the primitive Wolf Births.
  24. Create a new Link going from the primitive Moose Death Rate to the primitive Moose Deaths.
  25. Create a new Link going from the primitive Wolf Death Rate to the primitive Wolf Deaths.
  26. The model diagram should now look something like this:
    Let's add the equations for the new cariables to complete this modularization.
  27. Change the Flow Rate property of the primitive Moose Births to [Moose Birth Rate]*[Moose].
  28. Change the Equation property of the primitive Moose Birth Rate to 0.16.
  29. Change the Flow Rate property of the primitive Moose Deaths to [Moose Death Rate]*[Moose].
  30. Change the Equation property of the primitive Moose Death Rate to 0.10.
  31. Change the Flow Rate property of the primitive Wolf Births to [Wolf Birth Rate]*[Wolves].
  32. Change the Equation property of the primitive Wolf Birth Rate to 0.2.
  33. Change the Flow Rate property of the primitive Wolf Deaths to [Wolf Death Rate]*[Wolves].
  34. Change the Equation property of the primitive Wolf Death Rate to 0.12.
    That's it! Let's check to make sure we get the same results as before.
  35. Run the model. Here are sample results:
    Now it's time to make the wolf and moose populations interact. In this model extension, wolves will chase and consume the moose. The more moose they catch, the faster the wolves reproduce, and the faster the moose population declines. We'll make the moose death-rate dependent on the number of wolves, and the wolf birth-rate dependent on the number of moose.
  36. Create a new Link going from the primitive Moose to the primitive Wolf Birth Rate.
  37. Create a new Link going from the primitive Wolves to the primitive Moose Death Rate.
  38. The model diagram should now look something like this:
  39. Change the Equation property of the primitive Wolf Birth Rate to 0.001*[Moose].
  40. Change the Equation property of the primitive Moose Death Rate to 0.0008*[Wolves].
  41. Run the model. Here are sample results:
    That's getting interesting! Let's increase the length and accuracy of our simulation.
  42. Change the Analysis Algorithm property of the Time Settings to RK4.
  43. Change the Simulation Time Step property of the Time Settings to 0.5.
  44. Change the Simulation Length property of the Time Settings to 100.
  45. Run the model. Here are sample results:
    Great! The oscillatory behavior we see is typical of some predator-prey systems. The wolves kill many of the moose, but then the wolves have nothing to eat. This leads the wolf population to drop, allowing the moose population to recovery. This repeats in an ongoing cycle.

    We can also configure the display to use a scatter-plot instead of a time-series to show the phase-plane oscillatory behavior clearly.
  46. Run the model. Here are sample results:
    There are many parameters in this model you can experiment with. This form of model what is known as the Lotka-Volterra Model in the modeling community.