Definitions of functions regarding COCO observers. More...
#include "coco.h"
#include "coco_internal.h"
#include <limits.h>
#include <float.h>
#include <math.h>
#include "logger_bbob.c"
#include "logger_biobj.c"
#include "logger_toy.c"
#include "logger_rw.c"
Data Structures | |
struct | coco_observer_targets_t |
The type for triggers based on target values. More... | |
struct | coco_observer_evaluations_t |
The type for triggers based on numbers of evaluations. More... | |
Macros | |
#define | COCO_MAX_EVALS_TO_LOG 1000 |
The maximum number of evaluations to trigger logging. More... | |
Functions | |
static coco_observer_t * | coco_observer_allocate (const char *result_folder, const char *observer_name, const char *algorithm_name, const char *algorithm_info, const size_t number_target_triggers, const double target_precision, const size_t number_evaluation_triggers, const char *base_evaluation_triggers, const int precision_x, const int precision_f, const int precision_g, const int log_discrete_as_int) |
Allocates memory for a coco_observer_t instance. More... | |
void | coco_observer_free (coco_observer_t *observer) |
Frees the given observer. More... | |
coco_observer_t * | coco_observer (const char *observer_name, const char *observer_options) |
Constructs a COCO observer. More... | |
coco_problem_t * | coco_problem_add_observer (coco_problem_t *problem, coco_observer_t *observer) |
Adds an observer to the given problem. More... | |
coco_problem_t * | coco_problem_remove_observer (coco_problem_t *problem, coco_observer_t *observer) |
Removes an observer from the given problem. More... | |
const char * | coco_observer_get_result_folder (const coco_observer_t *observer) |
Returns result folder name, where logger output is written. More... | |
Methods regarding triggers based on target values | |
static coco_observer_targets_t * | coco_observer_targets (const size_t number_of_targets, const double precision) |
Creates and returns a structure containing information on targets. More... | |
static int | coco_observer_targets_trigger (coco_observer_targets_t *targets, const double given_value) |
Computes and returns whether the given value should trigger logging. More... | |
Methods regarding triggers based on numbers of evaluations. | |
static coco_observer_evaluations_t * | coco_observer_evaluations (const char *base_evaluations, const size_t dimension) |
Creates and returns a structure containing information on triggers based on evaluation numbers. More... | |
static int | coco_observer_evaluations_trigger_first (coco_observer_evaluations_t *evaluations, const size_t evaluation_number) |
Computes and returns whether the given evaluation number triggers the first condition of the logging based on the number of evaluations. More... | |
static int | coco_observer_evaluations_trigger_second (coco_observer_evaluations_t *evaluations, const size_t evaluation_number) |
Computes and returns whether the given evaluation number triggers the second condition of the logging based on the number of evaluations. More... | |
static int | coco_observer_evaluations_trigger (coco_observer_evaluations_t *evaluations, const size_t evaluation_number) |
Returns 1 if any of the two triggers based on the number of evaluations equal 1 and 0 otherwise. More... | |
static void | coco_observer_evaluations_free (coco_observer_evaluations_t *evaluations) |
Frees the given evaluations object. More... | |
Detailed Description
Definitions of functions regarding COCO observers.
Macro Definition Documentation
#define COCO_MAX_EVALS_TO_LOG 1000 |
The maximum number of evaluations to trigger logging.
- Note
- This is not the maximal evaluation number to be logged, but the maximal number of times logging is triggered by the number of evaluations.
Function Documentation
coco_observer_t* coco_observer | ( | const char * | observer_name, |
const char * | observer_options | ||
) |
Constructs a COCO observer.
Currently, three observers are supported:
- "bbob" is the observer for single-objective (both noisy and noiseless) problems with known optima, which creates *.info, *.dat, *.tdat and *.rdat files and logs the distance to the optimum.
- "bbob-biobj" is the observer for bi-objective problems, which creates *.info, *.dat and *.tdat files for the given indicators, as well as an archive folder with *.adat files containing nondominated solutions.
- "toy" is a simple observer that logs when a target has been hit.
- Parameters
-
observer_name A string containing the name of the observer. Currently supported observer names are "bbob", "bbob-biobj", "toy". Strings "no_observer", "" or NULL return NULL. observer_options A string of pairs "key: value" used to pass the options to the observer. Some observer options are general, while others are specific to some observers. Here we list only the general options, see observer_bbob, observer_biobj and observer_toy for options of the specific observers. - "result_folder: NAME" determines the folder within the "exdata" folder into which the results will be output. If the folder with the given name already exists, first NAME_001 will be tried, then NAME_002 and so on. The default value is "default".
- "algorithm_name: NAME", where NAME is a short name of the algorithm that will be used in plots (no spaces are allowed). The default value is "ALG".
- "algorithm_info: STRING" stores the description of the algorithm. If it contains spaces, it must be surrounded by double quotes. The default value is "" (no description).
- "number_target_triggers: VALUE" defines the number of targets between each 10**i and 10**(i+1) (equally spaced in the logarithmic scale) that trigger logging. The default value is 100.
- "target_precision: VALUE" defines the precision used for targets (there are no targets for abs(values) < target_precision). The default value is 1e-8.
- "number_evaluation_triggers: VALUE" defines the number of evaluations to be logged between each 10**i and 10**(i+1). The default value is 20.
- "base_evaluation_triggers: VALUES" defines the base evaluations used to produce an additional evaluation-based logging. The numbers of evaluations that trigger logging are every base_evaluation * dimension * (10**i). For example, if base_evaluation_triggers = "1,2,5", the logger will be triggered by evaluations dim*1, dim*2, dim*5, 10*dim*1, 10*dim*2, 10*dim*5, 100*dim*1, 100*dim*2, 100*dim*5, ... The default value is "1,2,5".
- "precision_x: VALUE" defines the precision used when outputting variables and corresponds to the number of digits to be printed after the decimal point. The default value is 8.
- "precision_f: VALUE" defines the precision used when outputting f values and corresponds to the number of digits to be printed after the decimal point. The default value is 15.
- "precision_g: VALUE" defines the precision used when outputting constraints and corresponds to the number of digits to be printed after the decimal point. The default value is 3.
- "log_discrete_as_int: VALUE" determines whether the values of integer variables (in mixed-integer problems) are logged as integers (1) or not (0 - in this case they are logged as doubles). The default value is 0.
- Returns
- The constructed observer object or NULL if observer_name equals NULL, "" or "no_observer".
|
static |
Allocates memory for a coco_observer_t instance.
|
static |
Creates and returns a structure containing information on triggers based on evaluation numbers.
The numbers of evaluations that trigger logging are any of the two:
- every 10**(exponent1/number_of_triggers) for exponent1 >= 0
- every base_evaluation * dimension * (10**exponent2) for exponent2 >= 0
- Note
- The coco_observer_evaluations_t object instances need to be freed using the coco_observer_evaluations_free function!
- Parameters
-
base_evaluations Evaluation numbers formatted as a string, which are used as the base to compute the second trigger. For example, if base_evaluations = "1,2,5", the logger will be triggered by evaluations dim*1, dim*2, dim*5, 10*dim*1, 10*dim*2, 10*dim*5, 100*dim*1, 100*dim*2, 100*dim*5, ...
|
static |
Frees the given evaluations object.
|
static |
Returns 1 if any of the two triggers based on the number of evaluations equal 1 and 0 otherwise.
The numbers of evaluations that trigger logging are any of the two:
- every 10**(exponent1/number_of_triggers) for exponent1 >= 0
- every base_evaluation * dimension * (10**exponent2) for exponent2 >= 0
|
static |
Computes and returns whether the given evaluation number triggers the first condition of the logging based on the number of evaluations.
The second condition is: evaluation_number == 10**(exponent1/number_of_triggers)
|
static |
Computes and returns whether the given evaluation number triggers the second condition of the logging based on the number of evaluations.
The second condition is: evaluation_number == base_evaluation[base_index] * dimension * (10**exponent2)
void coco_observer_free | ( | coco_observer_t * | observer | ) |
Frees the given observer.
const char* coco_observer_get_result_folder | ( | const coco_observer_t * | observer | ) |
Returns result folder name, where logger output is written.
Get the result folder name, which is a unique folder name constructed from the result_folder option.
- Parameters
-
observer The COCO observer, whose logger may be wrapping a problem.
- Returns
- The result folder name, where the logger writes its output.
|
static |
Creates and returns a structure containing information on targets.
- Parameters
-
number_of_targets The number of targets between 10**(i/n) and 10**((i+1)/n) for each i. precision Minimal precision of interest.
|
static |
Computes and returns whether the given value should trigger logging.
coco_problem_t* coco_problem_add_observer | ( | coco_problem_t * | problem, |
coco_observer_t * | observer | ||
) |
Adds an observer to the given problem.
Wraps the observer's logger around the problem if the observer is not NULL and invokes the initialization of this logger.
- Parameters
-
problem The given COCO problem. observer The COCO observer, whose logger will wrap the problem.
- Returns
- The observed problem in the form of a new COCO problem instance or the same problem if the observer is NULL.
coco_problem_t* coco_problem_remove_observer | ( | coco_problem_t * | problem, |
coco_observer_t * | observer | ||
) |
Removes an observer from the given problem.
Frees the observer's logger and returns the inner problem.
- Parameters
-
problem The observed COCO problem. observer The COCO observer, whose logger was wrapping the problem.
- Returns
- The unobserved problem as a pointer to the inner problem or the same problem if the problem was not observed.