class documentation

class Observer(_Observer):

Constructor: Observer(name, options)

View In Hierarchy

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 signal_restart Undocumented
Property name name of the observer as used with Observer(name, ...) to instantiate self before
Property options Undocumented
Property result_folder name of the output folder.
Property state Undocumented
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).

def signal_restart(self, problem):

Undocumented

@property
name =

name of the observer as used with Observer(name, ...) to instantiate self before

@property
options =

Undocumented

@property
result_folder =

name of the output folder.

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

@property
state =

Undocumented