Dark theme

Data variables


Not all ABM have all the ABM elements, so, for example, you may have an ABM where the agents only interact with the environment and not each other. However, here we're going to build a relatively generic model which will contain all the core elements.

Because of this, and because we want to concentrate on the programming rather than the application of programming, the agents will have relatively simple behaviours and the model will be relatively abstract. Hopefully, however, it will be clear how the code could act as the framework for more problem-centred models or analysis toolkits.

If you want to imagine the model as something real, you can imagine it as modelling herbivores like sheep in an environment. The model is going to involve agents wandering around and eating material (data) from the underlying landscape. However, the model can act as the foundation for a very wide range of models, not limited to ecological scenarios – as we'll discuss towards the end of our coding.


Essentially, over these practicals we're going to build up a model that:

 

  • builds a series of agents in space;
  • each agent will have a list of the other agents so they can communicate;
  • each agent will know about the environment it is in and be able to query/change the environment;
  • agents will move around the environment eating it, but checking first that other agents aren't already in the neighbourhood;
  • the environment will contain data from a file;
  • we'll display the environment and other data after the model has run;
  • we'll be able to save the environment as results of the model.

As you can see, although the behaviour is simple (eating the environment data) it involves checking the environment to see what's in a location and changing it, along with interacting with other agents on a neighbourhood basis (asking them if they are in a neighbourhood around a position). As such, the code gives the foundations for a wide range of models.

In addition, in giving you code that reads, displays, and writes data files, it gives you the core elements of any data analysis tool, should you wish to chuck out the agent-based modelling elements.

We'll also have a separate practical on documenting code which will help us comment and document the framework.

The application will ultimately look a map, however, for the first few sessions it'll just print stuff to the command line &ndash we *will* get to display, but we need some basics under our belts first.

So, let's get coding!


  1. Agent-based models
  2. This page
  3. Capturing a position in space <-- next
  4. Moving y and x
  5. Distance between two points
  6. Final ideas