Struct coco_rs::Suite

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

A COCO suite

Implementations§

source§

impl Suite

source

pub fn new(name: SuiteName, instance: &str, options: &str) -> Option<Suite>

Instantiates the specified COCO suite.

suite_instance

A string used for defining the suite instances. Two ways are supported:

  • “year: YEAR”, where YEAR is the year of the BBOB workshop, includes the instances (to be) used in that year’s workshop;
  • “instances: VALUES”, where VALUES are instance numbers from 1 on written as a comma-separated list or a range m-n.
suite_options

A string of pairs “key: value” used to filter the suite (especially useful for parallelizing the experiments). Supported options:

  • “dimensions: LIST”, where LIST is the list of dimensions to keep in the suite (range-style syntax is not allowed here),
  • “dimension_indices: VALUES”, where VALUES is a list or a range of dimension indices (starting from 1) to keep in the suite, and
  • “function_indices: VALUES”, where VALUES is a list or a range of function indices (starting from 1) to keep in the suite, and
  • “instance_indices: VALUES”, where VALUES is a list or a range of instance indices (starting from 1) to keep in the suite.
Examples found in repository?
examples/example-experiment.rs (line 31)
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 next_problem<'s>( &'s mut self, observer: Option<&mut Observer> ) -> Option<Problem<'s>>

Returns the next problem or None when the suite completed.

Examples found in repository?
examples/example-experiment.rs (line 34)
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 problem_by_function_dimension_instance( &mut self, function: usize, dimension: usize, instance: usize ) -> Option<Problem<'_>>

Returns the problem for the given function, dimension and instance.

Important: This is different from [Suite::problem_by_function_dimension_instance_index].

While a suite can contain multiple problems with equal function, dimension and instance, this function always returns the first problem in the suite with the given function, dimension and instance values. If the given values don’t correspond to a problem, the function returns None.

source

pub fn problem_by_function_dimension_instance_index( &mut self, function_idx: usize, dimension_idx: usize, instance_idx: usize ) -> Option<Problem<'_>>

Returns the problem for the given function, dimension and instance index.

source

pub fn number_of_problems(&self) -> usize

Returns the total number of problems in the suite.

Trait Implementations§

source§

impl Clone for Suite

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Drop for Suite

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Suite

Auto Trait Implementations§

§

impl RefUnwindSafe for Suite

§

impl !Sync for Suite

§

impl Unpin for Suite

§

impl UnwindSafe for Suite

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.