Model initialisation

MtM ABM description

Author

David O’Sullivan

Published

February 19, 2025

Modified

August 5, 2025

The steps in model initialisation are shown in the flow chart below. Although almost all code between these two initialisation pathways is shared, they are executed in separate sequences to ensure that random seed initialisation works correctly in the random geography case.

An important detail is that initialisation completes with a run of a single cycle of the model. This means in the GIS initialisation case that the starting state of the model will not necessarily match exactly the data contained in the initialisation files, but will reflect one tick of model evolution. Using a random seed, this step is guaranteed to be the same every time so that repeatability is not affected. A single ‘burn-in’ step is needed to generate plausible prior year income and costs which the model requires to run.

flowchart TB
  A((START))
  B[Read land uses and<br>interventions from files]
  C{Geography<br>from GIS<br>files?}
  D[Read LUC<br>from <span style='font-family:monospace;'>luc.asc</span>]
  E[Read farms<br>from <span style='font-family:monospace;'>parcels.shp</span>]
  F[Initialise farmers<br>one per farm]
  G[Read land use from <span style='font-family:monospace;'>landuse.asc</span> and assign to farms]
  H[Setup farmer networks]
  I[Partition farms by LUC into holdings]
  J[Setup LUC<br>on land]
  K[Partition land<br>into farms]
  L[Initialise farmers<br>one per farm]
  M[Partition farms by LUC<br>into holdings]
  N[Setup farmer networks]
  O[Partition farms by LUC into holdings]
  P[Initialise market<br>settings from files]
  Q[Run one cycle]
  R[Store settings<br>for rapid reset]
  S((END))
  A --> B
  B --> C
  C -->|Y| D
  D --> E
  E --> F
  F --> G
  G --> H
  H --> I
  I --> P
  C -->|N| J
  J --> K
  K --> L
  L --> M
  M --> N
  N --> O
  O --> P
  P --> Q
  Q --> R
  R --> S
  classDef pink fill:#fcc
  classDef blue fill:#cdf
  class D,E,G pink
  class J,K,M blue

It is worth noting that there are some tricky sequencing issues in the setup which make the associated code a little ‘fragile’ with some obvious-seeming changes for ‘efficiency’ likely to break the model! (These are noted in code comments.) The steps colour pink and blue below run differently depending on whether initialisation is random or from GIS files.

Date Changes
2025-02-19 Initial post.
2025-08-05 Made differences between random and GIS initialisation clearer.