From Animations to Science

M. Drew LaMar
February 18, 2022

Chapter 5: From Animations to Science - Learning Objectives

  • Learn the importance of version control.
  • Understand the concept that using ABMs for science means:
    1. measuring system response and behavior through producing quantitative output, and
    2. conduct simulation experiments (in silico).
  • Perform your first simulation experiment.
  • Define and initialize a global variable by creating a slider or switch.
  • Develop an understanding of what reporters are and how to write them.

Chapter 5: From Animations to Science - Learning Objectives

  • Start learning how to find and fix mistakes in your code.
  • Learn to create output by:
    1. writing text to an output window,
    2. creating a time-series plot, and
    3. exporting plot results to a file.
  • Create a version of the Butterfly model that uses real topographic data by importing data into NetLogo.

Programming Note: Moving global variables to the Interface

  • GUI (Graphical User Interface) elements on the Interface both define and initialize a global variable. What this means if you move a variable to the Interface:
    • You should comment out the variable in the globals [ ] chunk of code. I would also put an additional comment at the end stating it is on the Interface. For example:

Programming Note: Moving global variables to the Interface

  • GUI (Graphical User Interface) elements on the Interface both define and initialize a global variable. What this means if you move a variable to the Interface:
    • You should remove or comment out the variable initialization in the setup procedure. If you choose to comment and not remove, I would also put the same comment from the globals chunk in here as well. For example:

Programming Note: Initializing variables

  • New variables have a default value of zero until assigned another value.
  • Good practice is to explicitly set it to zero anyways in the code.

Programming Note: Troubleshooting tips

Tips to reduce probability of getting stuck and increase probability of getting unstuck.

  • Proceed slowly! Add small chunks of code at a time, check for syntax (using Check button) and runtime (using Go button) errors, and verify and validate code (i.e. is it doing what it is supposed to do?) For verification and validation:
    1. Create a Step button that steps through the program one tick at a time.
    2. Use show statements throughout your code.
    3. Use Agent Monitors.

Programming Note: Troubleshooting tips

Tips to reduce probability of getting stuck and increase probability of getting unstuck.

  • Think logically!
    1. “It should work this way because…”, i.e. critically assess output and results and see if they make sense
    2. “Let me try this and see what happens…”

Chapter 6: Testing your Program - Learning Objectives

“The productive modeler simply assumes that software mistakes are inevitable and continually searches for them.”
- Railsback & Grimm

  • Understand the difference between validation and verification.
  • Seven common kinds of software errors that will blow your mind!
  • Ten important techniques for finding and fixing software errors everyone should know.
  • Understand why and how to document software tests.