Scheduling Model Behavior

EES 4760/5760

Agent-Based & Individual-Based Computational Modeling

Jonathan Gilligan

Class #17: Tuesday Mar. 20 2018

Models to Download

Models to Download

Modeling for Actionable Research

Modeling for Actionable Research

  • Using agent-based models of socio-environmental systems to inform planners, public, government decision-makers
    • Disaster planning
    • Conservation and sustainability
  • Grand challenges:
    • Data: Combining different kinds of data, new sources of data, managing big data, …
    • Challenges of research disciplines: Using models to integrate different kinds of knowledge. Challenge of aligning different ways of thinking.
    • Predictions and Uncertainty: Can models built on today’s conditions anticipate very different future conditions? How to plan for uncertain future? How to communicate with public about models?
    • Making models useful: What do non-experts want to know? Results of models, or modeling process? Participatory and interactive models. Tools to let non-programmers develop models.
    • Challenges of future technology: Modeling tens or hundreds of millions of people. Integrating people into big models of climate, rivers, cities, etc.

Scheduling Actions:

Scheduling Actions:

  • Representing time:
    • Discrete (tick)
    • Continuous (tick-advance)
  • Execution order
    • Synchronous
    • Asynchronous
      • Random order
      • Determined order

Repeating actions

  • repeat repeats a certain number of times

    repeat 5 [ wander ]


    repeat random count turtles [ wander ]
  • while repeats as long as a condition is true

    while not any? turtles-here [ wander ]
  • loop repeats forever (until stop or report)

    loop [
      if any? turtles-here [ stop ]

Discrete vs. continuous time

  • Almost all models use discrete time:
    • tick advances tick counter by 1.
    • ticks is always an integer.
  • Continuous time
    • tick-advance 2.3
    • ticks can have fractional values.
  • Things to think about:
    • When to tick?
to go
  ask patches [ do-patch-stuff ]
  ask turtles [ do-turtle-stuff ]

  if ticks > run-duration [stop]
to go
  if ticks > run-duration [stop]

  ask patches [ do-patch-stuff ]
  ask turtles [ do-turtle-stuff ]

Order of execution

  • ask: Asks turtles in a random order.

    ask turtles [do-sales]
  • Suppose we wanted bigger turtles to act before the smaller ones?

    foreach sort-on [(- size)] turtles 
      next-turtle -> ask next-turtle [do-sales] 

Concurrent execution

  • ask-concurrent (not recommended)

This is a relic from older versions and can create problems if you use it.

Synchronous vs. asynchronous updating

  • What is the difference?
  • When would you want to use one or the other?
    • Business investor model?
    • Telemarketer model?
  • How would you do asynchronous updating?
  • How would you do synchronous updating?
    • Hidden state-variables (turtle can’t see other turtle’s hidden variables)
    • Two ways:
      1. Break submodel into two parts:
        1. Turtles have sense and update hidden state-variables that others can’t sense
        2. Update environment (including state-variables that others can sense)
      2. Make shadow copy of all state variables:
        1. Sensing sees originals, updates change shadow-copies
        2. Update the original (set original shadow-copy)
  • What advantages or disadvantages does synchronous updating have versys asynchronous?

Mousetrap model

Mousetrap model

Breeding Synchrony Model

Breeding Synchrony Model

  • Colonies of sea birds (up to several thousand) often exhibit synchronized breeding:
    • Birds with very different characteristics & histories lay eggs at the same time
      • Different stored energy, different arrival times, …
  • Different colonies in nearby areas lay eggs at different times
    • So environemntal factors (e.g., phase of moon) aren’t explanation
  • Why?

Breeding Synchrony Model

  • Is stress the answer?
    • “Stressful neighborhoods”:
      • If other birds are still competing for mates, nesting material, it’s dangerous to lay eggs.
      • Hypothesis: Birds wait until neighborhood is fairly calm to lay eggs.

Breeding Synchrony Model

  • Model:
    • Birds’ activities cause stress in neighbors
    • Key variables:
      • OSL: a bird’s own stress level,
      • mean NSL: average of neighbors’ stress levels,
      • NR (0–1): neighborhood relevance: how much a bird’s stress is influenced by its neighbors,
      • SD = 10: stress decay rate: How quickly a bird loses stress without external stimulus. \[ \text{OSL}_t = (1 - \text{NR}) \text{OSL}_{t-1} + (\text{NR} \times \text{mean NSL}_{t - 1}) - \text{SD} \]
  • Birds start out with random \(\text{OSL}\) between 100 and 300.
  • Birds lay eggs when \(\text{OSL} \le 10\).
  • Synchronous updating:
    • All birds compute \(\text{OSL}_t\) using stress levels at \(t-1\), then they all update together
  • How does breeding synchrony depend on \(\text{NR}\)?