callbacks

This module provides an abstract base class for a callback and a default implementation.

If you want to store the data in a way that is different from the functionality provided by the default callback, you can write your own extension of callback. For example, you can easily implement a callback that stores the data in e.g. a NoSQL file.

The only method to implement is the __call__ magic method. To use logging of progress, always call super.

class ema_workbench.em_framework.callbacks.AbstractCallback(uncertainties, outcomes, levers, nr_experiments, reporting_interval=None, reporting_frequency=10, log_progress=False)

Abstract base class from which different call back classes can be derived. Callback is responsible for storing the results of the runs.

Parameters
  • uncs (list) – a list of the parameters over which the experiments are being run.

  • outcomes (list) – a list of outcomes

  • nr_experiments (int) – the total number of experiments to be executed

  • reporting_interval (int, optional) – the interval at which to provide progress information via logging.

  • reporting_frequency (int, optional) – the total number of progress logs

i

a counter that keeps track of how many experiments have been saved

Type

int

reporting_interval

the interval between progress logs

Type

int,

abstract get_results()

method for retrieving the results. Called after all experiments have been completed. Any extension of AbstractCallback needs to implement this method.

class ema_workbench.em_framework.callbacks.DefaultCallback(uncs, levers, outcomes, nr_experiments, reporting_interval=100, reporting_frequency=10, log_progress=False)

default callback system callback can be used in perform_experiments as a means for specifying the way in which the results should be handled. If no callback is specified, this default implementation is used. This one can be overwritten or replaced with a callback of your own design. For example if you prefer to store the result in a database or write them to a text file

get_results()

method for retrieving the results. Called after all experiments have been completed. Any extension of AbstractCallback needs to implement this method.

class ema_workbench.em_framework.callbacks.FileBasedCallback(uncs, levers, outcomes, nr_experiments, reporting_interval=100, reporting_frequency=10)

Callback that stores data in csv files while running

Parameters
  • uncs (collection of Parameter instances) –

  • levers (collection of Parameter instances) –

  • outcomes (collection of Outcome instances) –

  • nr_experiments (int) –

  • reporting_interval (int, optional) –

  • reporting_frequency (int, optional) –

  • ./temp (the data is stored in) –

  • current (relative to the) –

  • exists (working directory. If this directory already) –

  • be (it will) –

  • overwritten.

Warning

This class is still in beta. API is expected to change over the coming months.

get_results()

method for retrieving the results. Called after all experiments have been completed. Any extension of AbstractCallback needs to implement this method.