pub struct Problem<'suite> { /* private fields */ }
Expand description
A specific problem instance.
Instances can be optained using Suite::next_problem and Suite::problem_by_function_dimension_instance.
Implementations§
Source§impl Problem<'_>
impl Problem<'_>
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
Returns the ID of the problem.
For the toy
suite this is
{function-name}_d{dimension}
For bbob
it is
- bbob_f{function-index}_i{instance}_d{dimension}
Sourcepub fn add_observer(&mut self, observer: &Observer)
pub fn add_observer(&mut self, observer: &Observer)
Adds an observer to the given problem.
Sourcepub fn remove_observer(&mut self, observer: &Observer)
pub fn remove_observer(&mut self, observer: &Observer)
Removes an observer to the given problem.
Sourcepub fn suite_index(&self) -> ProblemIdx
pub fn suite_index(&self) -> ProblemIdx
Returns the problem index of the problem in its current suite.
Sourcepub fn evaluate_function(&mut self, x: &[f64], y: &mut [f64])
pub fn evaluate_function(&mut self, x: &[f64], y: &mut [f64])
Evaluates the problem at x
and returns the result in y
.
The length of x
must match Problem::dimension and the
length of y
must match Problem::number_of_objectives.
Sourcepub fn evaluate_constraint(&mut self, x: &[f64], y: &mut [f64])
pub fn evaluate_constraint(&mut self, x: &[f64], y: &mut [f64])
Evaluates the problem constraints in point x and save the result in y.
The length of x
must match Problem::dimension and the
length of y
must match Problem::number_of_constraints.
Sourcepub fn final_target_hit(&self) -> bool
pub fn final_target_hit(&self) -> bool
Returns true if a previous evaluation hit the target value.
Sourcepub fn final_target_value(&self) -> f64
pub fn final_target_value(&self) -> f64
Returns the optimal function value + delta of the problem
Sourcepub fn best_value(&self) -> f64
pub fn best_value(&self) -> f64
Returns the optimal function value of the problem
To check whether the target has been reached use [Problem::final_target_value] or [Problem::final_target_hit] instead.
Sourcepub fn best_observed_value(&self) -> f64
pub fn best_observed_value(&self) -> f64
Returns the best observed value for the first objective.
Sourcepub fn number_of_objectives(&self) -> usize
pub fn number_of_objectives(&self) -> usize
Returns the number of objectives of the problem.
Sourcepub fn number_of_constraints(&self) -> usize
pub fn number_of_constraints(&self) -> usize
Returns the number of constraints of the problem.
Sourcepub fn number_of_integer_variables(&self) -> usize
pub fn number_of_integer_variables(&self) -> usize
Returns the numver of integer variables of the problem.
The first n
variables will be integers then.
Returns 0
if all variables are continuous.
Sourcepub fn ranges_of_interest(&self) -> Vec<RangeInclusive<f64>>
pub fn ranges_of_interest(&self) -> Vec<RangeInclusive<f64>>
Returns the upper and lover bounds of the problem.
Sourcepub fn evaluations(&self) -> u64
pub fn evaluations(&self) -> u64
Returns how often this instance has been evaluated.
Sourcepub fn evaluations_constraints(&self) -> u64
pub fn evaluations_constraints(&self) -> u64
Returns how often this instances constrants have been evaluated.
Sourcepub fn initial_solution(&self, x: &mut [f64])
pub fn initial_solution(&self, x: &mut [f64])
Writes a feasible initial solution into x
.
If the problem does not provide a specific solution, it will be the center of the problem’s region of interest.