Pakman
Implementing a Controller subclass

In order to implement an ABC algorithm in Pakman, you need to formulate the algorithm in an iterative manner in a Controller class. This means that the same iterate() function is called over and over, and at every iteration you have a set of actions that you can take. You can push new tasks to the Master, receive finished tasks, flush the Master's tasks queues, or terminate the Master, as well as any combination of these actions (although you can only terminate the Master once, as the program will then terminate).

The Master can be accessed by the inherited member variable AbstractController::m_p_master. For example, terminating the Master is done by calling m_p_master->terminate(). See the documentation of AbstractMaster for a full list of public member functions that you can use in a Controller class.

The classes ABCRejectionController, ABCSMCController, and SweepController provide examples of how to implement the ABC rejection, the ABC SMC, and the parameter sweep algorithms iteratively.

In order to integrate a new Controller class called ExampleController into Pakman, you need to follow these steps:

  1. Add the example Controller type to the controller_t enum type, defined in common.h.
  2. Add an else if statement to AbstractController::getController() in AbstractControllerStatic.cc to translate the appropriate command-line argument into the right controller_t value.
  3. Write a new Controller class in src/controller/ExampleController.h that inherits from AbstractController.
  4. Override the pure virtual functions AbstractController::iterate() and AbstractController::getSimulator() in src/controller/ExampleController.cc.
  5. Implement the static functions help(), addLongOptions(), and makeController() in src/controller/ExampleControllerStatic.cc.
  6. Add corresponding entries to the switch statements in AbstractController::help(), AbstractController::addLongOptions(), and AbstractController::makeController() in AbstractControllerStatic.cc.
  7. Add a line to the Pakman overview message generated by overview() in help.cc.
  8. Add source files ExampleController.cc and ExampleControllerStatic.cc to src/controller/CMakeLists.txt.