pub struct Suite { /* private fields */ }
Expand description
A COCO suite
Implementations§
source§impl Suite
impl Suite
sourcepub fn new(name: SuiteName, instance: &str, options: &str) -> Option<Suite>
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?
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);
}
}
}
sourcepub fn next_problem<'s>(
&'s mut self,
observer: Option<&mut Observer>
) -> Option<Problem<'s>>
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?
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);
}
}
}
sourcepub fn problem_by_function_dimension_instance(
&mut self,
function: usize,
dimension: usize,
instance: usize
) -> Option<Problem<'_>>
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
.
sourcepub fn problem_by_function_dimension_instance_index(
&mut self,
function_idx: usize,
dimension_idx: usize,
instance_idx: usize
) -> Option<Problem<'_>>
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.
sourcepub fn number_of_problems(&self) -> usize
pub fn number_of_problems(&self) -> usize
Returns the total number of problems in the suite.