Discussion papers

CPM-16-227 - 21 January 2016

Factbase -- a NetLogo Extension

Ruth Meyer

Factbase is a new extension for NetLogo offered for beta-testing by the CPM. It introduces a new data type: a structured set of data called a “fact base”, that will be particularly useful for those who want to program more cognitive models in their social simulations.

What is it?

Factbase is an extension for NetLogo (version 5.2) that introduces a new data type: a structured set of data called a “fact base”. A fact base can be thought of as a table of named columns (“fields”), where each row comprises an entry (“fact”). Facts can be asserted to this, then extracted in a very flexible manner.

At creation, the user has to define the structure of the fact base, that means define the field names. Note that in keeping with the NetLogo philosophy of a type-free language, data types for fields are not specified. After creating a fact base, facts can be asserted, queried and retracted. Facts are represented as lists of values, with one value for each field and all values in the same order as defined by the list of field names. Duplicate facts are not allowed. Therefore, trying to assert a fact with all values identical to an already existing fact is ignored.

To be able to use indexing (and thus, faster retrieval), each fact is internally assigned an ID, starting with 0. A new fact will be assigned the highest number so far in use + 1. Retracting a fact will result in its ID being unassigned, thus trying to retrieve a retracted fact will generate an error.

How to use it

Download the archive factbase.zip, un-zip it and place the resulting folder factbase inside the extensions directory of the NetLogo directory. The factbase extension comes bundled with example models and a brief documentation.

The source code is provided on github.


Extension developed under the DiDIY Project funded from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 644344. The views expressed in this article do not necessarily reflect the views of the EC.