Struct coco_rs::Observer

source ·
pub struct Observer { /* private fields */ }
Expand description

An observer to log results in COCO’s data format.

Can be provided to Suite::next_problem and it will automatically be attached to the returned problem.

Implementations§

source§

impl Observer

source

pub fn new(name: ObserverName, options: &str) -> Option<Observer>

Creates a new observer.

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 dim1, dim2, dim5, 10dim1, 10dim2, 10dim5, 100dim1, 100dim2, 100dim*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.
Examples found in repository?
examples/example-experiment.rs (line 32)
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
fn example_experiment(
    suite_name: SuiteName,
    suite_options: &str,
    observer_name: ObserverName,
    observer_options: &str,
    random_generator: &mut RandomState,
) {
    let suite = &mut Suite::new(suite_name, "", suite_options).unwrap();
    let observer = &mut Observer::new(observer_name, observer_options).unwrap();

    while let Some(problem) = &mut suite.next_problem(Some(observer)) {
        let dimension = problem.dimension();

        for _ in 1..=INDEPENDENT_RESTARTS {
            let evaluations_done = problem.evaluations() + problem.evaluations_constraints();
            let evaluations_remaining =
                (dimension * BUDGET_MULTIPLIER).saturating_sub(evaluations_done as usize);

            if problem.final_target_hit() || evaluations_remaining == 0 {
                break;
            }

            my_random_search(problem, evaluations_remaining, random_generator);
        }
    }
}
source

pub fn result_folder(&self) -> &str

Prints where the result is written to.

Trait Implementations§

source§

impl Drop for Observer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.