class documentation

class Problem(_Problem):

View In Hierarchy

Problem instances are usually generated using class Suite.

The main feature of a problem instance is that it is callable, returning the objective function value when called with a candidate solution as input.

It provides other useful properties and methods like dimension, number_of_constraints, observe_with, initial_solution_proposal...

Method __init__ Undocumented
Method add_observer add_observer(self, observer: Observer), see observe_with.
Method constraint return constraint values for x.
Method free Free the given test problem.
Method initial_solution_proposal return feasible initial solution proposals.
Method logger_biobj_feed_solution Feed the given solution to logger_biobj in order to reconstruct its output.
Method observe_with observe_with(self, observer: Observer) attaches an Observer instance to this problem.
Property best_observed_fvalue1 Undocumented
Property dimension alias for number_of_variables of the input space
Property evaluations number of times this Problem instance was evaluated
Property final_target_fvalue1 Undocumented
Property final_target_hit return 1 if the final target is known and has been hit, 0 otherwise
Property id ID as string without spaces or weird characters
Property id_function function number inferred from id
Property id_instance instance number inferred from id
Property id_triple unique problem id triplet (function, dimension, instance)
Property index problem index in the benchmark Suite of origin
Property info human readible info, alias for str(self).
Property initial_solution return feasible initial solution
Property is_observed problem p is observed p.is_observed times.
Property lower_bounds depending on the test bed, these are not necessarily strict bounds
Property name human readible short description with spaces
Property number_of_constraints number of constraints
Property number_of_objectives number of objectives, if equal to 1, call returns a scalar
Property number_of_variables Number of variables this problem instance expects as input.
Property observers list of observers wrapped around this problem
Property suite benchmark suite this problem is from
Property upper_bounds depending on the test bed, these are not necessarily strict bounds
Method _f0 "inofficial" interface to self with target f-value of zero.
def __init__(self):

Undocumented

def add_observer(self, observer):

add_observer(self, observer: Observer), see observe_with.

def constraint(self, x):

return constraint values for x.

By convention, constraints with values <= 0 are satisfied.

def free(self, force=False):

Free the given test problem.

Not strictly necessary (unless, possibly, for the observer). free ensures that all files associated with the problem are closed as soon as possible and any memory is freed. After free()ing the problem, all other operations are invalid and will raise an exception.

def initial_solution_proposal(self, restart_number=None):

return feasible initial solution proposals.

For unconstrained problems, the proposal is different for each consecutive call without argument and for each restart_number and may be different under repeated calls with the same restart_number. self.initial_solution_proposal(0) is the same as self.initial_solution.

Conceptual example:

# given: a suite instance, a budget, and fmin
for problem in suite:
    # restart until budget is (over-)exhausted
    while problem.evaluations < budget and not problem.final_target_hit:
        fmin(problem, problem.initial_solution_proposal())

Details: by default, the first proposal is the domain middle or the (only) known feasible solution. Subsequent proposals are coordinate-wise sampled as the sum of two iid random variates uniformly distributed within the domain boundaries. On the 'bbob' suite their density is 0.2 * (x / 5 + 1) for x in [-5, 0] and 0.2 * (1 - x / 5) for x in [0, 5] and zero otherwise.

def logger_biobj_feed_solution(self, evaluation, y):

Feed the given solution to logger_biobj in order to reconstruct its output.

Return 1 if the given solution updated the archive and 0 otherwise.

Used by preprocessing when updating the .info, .dat and .tdat files with new indicator reference values.

def observe_with(self, observer):

observe_with(self, observer: Observer) attaches an Observer instance to this problem.

Attaching an observer can be considered as wrapping the observer around the problem. For the observer to be finalized, the problem must be free'd (implictly or explicitly).

Return the observed problem self.

Details: observer can be None, in which case nothing is done.

See also: class Observer

@property
best_observed_fvalue1 =

Undocumented

@property
dimension =

alias for number_of_variables of the input space

@property
evaluations =

number of times this Problem instance was evaluated

@property
final_target_fvalue1 =

Undocumented

@property
final_target_hit =

return 1 if the final target is known and has been hit, 0 otherwise

@property
id =

ID as string without spaces or weird characters

@property
id_function =

function number inferred from id

@property
id_instance =

instance number inferred from id

@property
id_triple =

unique problem id triplet (function, dimension, instance)

@property
index =

problem index in the benchmark Suite of origin

@property
info =

human readible info, alias for str(self).

The format of this info string is not guarantied and may change in future.

See also: repr(self)

@property
initial_solution =

return feasible initial solution

@property
is_observed =

problem p is observed p.is_observed times.

See also: the list of observers in property observers.

@property
lower_bounds =

depending on the test bed, these are not necessarily strict bounds

@property
name =

human readible short description with spaces

@property
number_of_constraints =

number of constraints

@property
number_of_objectives =

number of objectives, if equal to 1, call returns a scalar

@property
number_of_variables =

Number of variables this problem instance expects as input.

@property
observers =

list of observers wrapped around this problem

@property
suite =

benchmark suite this problem is from

@property
upper_bounds =

depending on the test bed, these are not necessarily strict bounds

def _f0(self, x):

"inofficial" interface to self with target f-value of zero.