Observer which can be "attached to" one or several problems, however not necessarily at the same time.

The typical observer records data to be used in the COCO post-processing module cocopp afterwards.

>>> import cocoex as ex
>>> suite = ex.Suite("bbob", "", "")
>>> assert len(suite) == 2160
>>> f = suite.get_problem(33)
>>> assert f.id.endswith('f003_i04_d02')
>>> observer = ex.Observer("bbob",
...                        "result_folder: doctest")
>>> f.observe_with(observer)  # the same as observer.observe(f)  # doctest: +ELLIPSIS
<cocoex...
>>> # work work work with observed f
>>> f.free()

Details

  • f.free() in the above example must be called before to observe another problem with the "bbob" observer. Otherwise the Python interpreter will crash due to an error raised from the C code.
  • Due to technical sublties between Python/Cython/C, the pointer to the underlying C observer is passed by global assignment with _update_current_observer_global()
Method __init__ options can be a string or a dict
Method observe observe(problem) let self observe the problem: Problem by calling problem.observe_with(self).
Method name name of the observer as used with Observer(name, ...) to instantiate self before
Method options Undocumented
Method state Undocumented
Method result_folder name of the output folder.
def __init__(self, name, options):
options can be a string or a dict
def observe(self, problem):
observe(problem) let self observe the problem: Problem by calling problem.observe_with(self).
@property
def name(self):
name of the observer as used with Observer(name, ...) to instantiate self before
@property
def options(self):
Undocumented
@property
def state(self):
Undocumented
@property
def result_folder(self):

name of the output folder.

This name may not be the same as input option result_folder.

API Documentation for cocoex, generated by pydoctor at 2020-01-21 17:05:05.