BDI4MABS: A C++-based BDI  framework for agent-based simulations

Agent-based simulation has shown great success for the study of complex adaptive systems which are hard or even impossible to analyse using conventional analytical techniques. At present, agent-based models are typically implemented in conventional, general purpose programming languages such as Java or C++ which severely limits the level of behavioural sophistication that a non-technical modeller is able to achieve. In the more general field of multiagent systems, agent-oriented programming (AOP) has emerged as a powerful paradigm for the implementation of intelligent, practically reasoning agents. However, current AOP languages tend to prioritise expressivity over performance which critically limits their application in a time-critical simulation context.

One of my goals was to address this problem and develop an AOP approach for the purpose of agent-based simulation in C++. This involved the development of an efficient and customisable BDI framework together with an AOP interface that allows for the implementation of BDI-based simulation models on a high level of abstraction. The balance between efficiency and convenience of development is to be achieved by utilising advanced C++ template metaprogramming techniques.

1. Core framework

BDI4MABS is a header-only library that consists of just a single header file (bdi4mabs.h). Once included, all definitions can be used straight away. The file can be downloaded here.

1.1. Customisation points

As described in the original thesis [2], BDI4MABS provides several points for customisation by the user. Each customisation point is represented as a type that needs to be passed to the AgentState template as a parameter (as described below).

At present, the following applicability checking mechanisms are supported.

  • CTAllApplicable: all plans are applicable by default (checked at compile time).
  • RTAllApplicable: all plans are applicable by default (checked at runtime).
  • RTApplicability: applicability checking mechanism can be provided by the user (checked at runtime)

Furthermore, BDI4MABS currently supports the following plan selection mechanisms.

  • CTHeadSelector: the first plan in the list of intentions is selected by default (performed at compile time).
  • RandomSelector: a plan is selected randomly (performed at runtime).
  • Utility selectors:
    • MaxUtilitySelector: the plan with the highest utility is selected (performed at runtime). The utility functions must be provided by the user.
    • UtilityEvalSelector: a plan is selected randomly based on the distribution yielded by the utility values for all plans (performed at compile time).
2. Example model: party scenario

The files for the party scenario introduced in the paper (adapted from Padgham et al. [1]) can be downloaded here. The archive contains three files:

  1. partyScenario.h: header file that contains class and function definitions, and data structures for the party scenario.
  2. partyScenario.cpp: source file that contains a simple main function.
  3. CMakeLists.txt: A CMake configuration file. It checks for necessary dependencies and generates the final Makefile.
2.1. Customisation

In order to activate the appropriate applicability checking and plan selection mechanism, the respective types need to be passed as a parameter to the AgentState template. For example, in order to activate compile time applicability checking (i.e. to declare all plans applicable by default) and runtime plan selection using a utility evaluation, the AgentState template needs to be declared as follows (relevant parameters in bold).

typedef AgentState<
> AS;
AS state;

For further information about the customisation points, please refer to the original thesis [2].

2.2. Compilation and execution

In order to ensure all necessary dependencies (Boost 1.57 or above) are present and the final Makefile is generated correctly, CMake is best used. To that end, a build directory needs to be created first; the compilation can then be invoked as follows (note that, due to extensive use of template metaprogramming in BDI4MABS, a recent version of g++ (4.9 or above) should be used).

cd <path to build directory>
cmake -i -G “Unix Makefiles” <path to CMakeLists.txt>

The compiled scenario can then be simply invoked as follows.


2.3. Additional files
  • The Jason version of the party scenario can be downloaded here.

[1] L. Padgham, D. Scerri, G. Jayatilleke, and S. Hickmott. Integrating BDI reasoning into agent based modeling and simulation. In Proceedings of the Winter Simulation Conference, pages 345-356, 2011.
[2] B. Herd. BDI4MABS: A BDI-based programming approach for high-performance multiagent-based simulation. Master’s thesis, University of Oxford, 2015.