# problem#

## Types#

### AutomaticProblemRegistration#

template<class Derived, class Parent>
using ioh::problem::AutomaticProblemRegistration = common::AutomaticTypeRegistration<Derived, ProblemRegistryType<Parent>>#

Automatic Factory registration type def.

Template Parameters:
• Derived – type of the problem

• Parent – type of the problem

### Bounds#

template<typename T>
using ioh::problem::Bounds = BoxConstraint<T>#

BoxConstraint object alias.

### CalculateObjectiveFunction#

template<typename T, typename R>
using ioh::problem::CalculateObjectiveFunction = std::function<Solution<T, R>(const int, const int)>#

typedef for functions which compute a value for an optimum based on a given instance, dimension combination Used in wrap_problem

Template Parameters:
• T – type of the problem

• R – the returntype of the problem

### ConstraintFunction#

template<typename T>
using ioh::problem::ConstraintFunction = std::function<double(const std::vector<T>&)>#

function that computes a constraint violation, recieves both the x and y values

### ConstraintPtr#

template<typename T>
using ioh::problem::ConstraintPtr = std::shared_ptr<Constraint<T>>#

Convienence typedef: shared_ptr of a Contraint.

Template Parameters:

T – numeric type for the contraint

### Constraints#

template<typename T>
using ioh::problem::Constraints = std::vector<ConstraintPtr<T>>#

Convienence typedef: vector of ContraintPtr.

Template Parameters:

T – numeric type for the contraint

### IntegerSingleObjective#

using ioh::problem::IntegerSingleObjective = SingleObjectiveProblem<int>#

Type def for Integer problems.

### MultiObjective#

using ioh::problem::MultiObjective = std::vector<double>#

Typedef for mutliobjective problems.

### ObjectiveFunction#

template<typename T, typename R>
using ioh::problem::ObjectiveFunction = std::function<R(const std::vector<T>&)>#

typedef for functions which can be wrapped in SingleObjectiveWrappedProblem

Template Parameters:
• T – type of the problem

• R – the returntype of the problem

### ObjectiveTransformationFunction#

template<typename R>
using ioh::problem::ObjectiveTransformationFunction = std::function<R(const double, const int)>#

typedef for functions which take a value and return a transformed version of that value.

Used in WrappedProblem

Template Parameters:

R – the returntype of the problem

### ProblemFactoryType#

template<typename ProblemType>
using ioh::problem::ProblemFactoryType = common::Factory<ProblemType, int, int>#

Factory type def.

Template Parameters:

ProblemType – type of the problem

### ProblemRegistry#

template<class Parent>
using ioh::problem::ProblemRegistry = ProblemRegistryType<Parent>#

Registry type def.

Template Parameters:

Parent – type of the problem

### ProblemRegistryType#

template<typename ProblemType>
using ioh::problem::ProblemRegistryType = common::RegisterWithFactory<ProblemType, int, int>#

Registry type def.

Template Parameters:

ProblemType – type of the problem

### RealFunction#

using ioh::problem::RealFunction = std::function<double(std::vector<double>)>#

### RealSingleObjective#

using ioh::problem::RealSingleObjective = SingleObjectiveProblem<double>#

Type def for Real problems.

### SingleObjective#

using ioh::problem::SingleObjective = double#

Typedef for single objective problems

### VariablesTransformationFunction#

template<typename T>
using ioh::problem::VariablesTransformationFunction = std::function<std::vector<T>(std::vector<T>, const int)>#

typedef for functions which take a vector and return a transformed version of that vector.

Used in WrappedProblem

Template Parameters:

T – type of the problem

## Classes#

### BBOB#

class BBOB : public ioh::problem::SingleObjectiveProblem<double>#

BBOB base class.

Public Functions

inline BBOB(const int problem_id, const int instance, const int n_variables, const std::string &name, const double condition = sqrt(10.0))#

Construct a new BBOB object.

Parameters:
• problem_id – The id of the problem

• instance – The instance of the problem

• n_variables – the dimension of the problem

• name – the name of the problem

• condition – the conditioning of the problem

inline Solution<double, double> calculate_optimum(const int box_size = 4) const#

Calculate the optimum to the problem.

Parameters:

box_size – the size of the inner box, defined as [-box_size, box_size] that contains the location of the optimum. Standard BBOB defines this optimum to always be in the location [-4, -4], the sbox-cost suite defines this to be the full domain of the problem [-5, -5]

Returns:

the location of the optimum

Protected Functions

inline virtual double transform_objectives(const double y) override#

Default objective transform for BBOB.

Protected Attributes

struct ioh::problem::BBOB::TransformationState transformation_state_#

The current transformation state.

double box_size_#
struct TransformationState#

Container for BBOB transformation data.

Public Functions

inline TransformationState(const long problem_id, const int instance, const int n_variables, const double condition = sqrt(10.0))#

Construct a new Transformation State object.

Parameters:
• problem_id – the id of the problem

• instance – the instance of the problem

• n_variables – the dimension of the problem

• condition – the conditioning of the problem

Public Members

long seed#

The seed.

std::vector<double> exponents = {}#

A vector with exponents.

std::vector<double> conditions = {}#

A vector with conditions.

std::vector<std::vector<double>> transformation_matrix = {}#

Main transformation matrix.

std::vector<double> transformation_base = {}#

Main transformation vector.

std::vector<std::vector<double>> second_transformation_matrix = {}#

Second transformation matrix.

std::vector<std::vector<double>> first_rotation = {}#

First rotation matrix.

std::vector<std::vector<double>> second_rotation = {}#

Second rotation matrix.

Public Static Functions

static inline std::vector<std::vector<double>> compute_rotation(const long rotation_seed, const int n_variables)#

Compute a rotation for a problem.

Parameters:
• rotation_seed – the seed of the rotation

• n_variables – the dimension of the problem

Returns:

std::vector<std::vector<double>> the rotation

### CEC2013#

class CEC2013 : public ioh::problem::SingleObjectiveProblem<double>#

Public Functions

inline CEC2013(const int problem_id, const int instance, const int n_variables, const std::string &name, const double lb, const double ub, const size_t n_optima)#

Constructs a new CEC problem instance.

Parameters:
• problem_id – Unique identifier for the problem.

• instance – The instance number of the problem (currently ignored for CEC problems).

• n_variables – The number of variables in the problem, representing the dimensionality of the search

• lb – The lower bound of the problem

• ub – The lower bound of the problem

• n_optima – The number of global optima space.

• name – A unique name for the problem.

Public Members

size_t n_optima#

Number of global optima.

Protected Functions

inline virtual double transform_objectives(const double y) override#

Transforms the objective function value using the current objective shift value.

Parameters:

y – The original objective function value.

Returns:

The transformed objective function value.

inline std::vector<double> transform_variables(std::vector<double> x) override#

Transforms the input variables based on the current transformation data.

Parameters:

x – The original input variables.

Returns:

The transformed input variables.

### CEC2022#

class CEC2022 : public ioh::problem::SingleObjectiveProblem<double>#

The CEC2022 class represents a problem in the CEC2022 benchmark suite.

It inherits from the RealSingleObjective class and contains methods to load transformation data from static files and apply transformations to problem variables and objectives.

Public Functions

inline CEC2022(const int problem_id, const int instance, const int n_variables, const std::string &name)#

Constructs a new CEC problem instance.

Parameters:
• problem_id – Unique identifier for the problem.

• instance – The instance number of the problem (currently ignored for CEC problems).

• n_variables – The number of variables in the problem, representing the dimensionality of the search space.

• name – A unique name for the problem.

inline virtual double transform_objectives(const double y) override#

Transforms the objective function value using the current objective shift value.

Parameters:

y – The original objective function value.

Returns:

The transformed objective function value.

inline std::vector<double> transform_variables(std::vector<double> x) override#

Transforms the input variables based on the current transformation data.

Parameters:

x – The original input variables.

Returns:

The transformed input variables.

Protected Attributes

std::vector<std::vector<double>> variables_shifts_#

A collection of shift values applied to the problem variables during transformation.

std::vector<std::vector<std::vector<double>>> linear_transformations_#

A collection of matrices representing linear transformations applied to the problem variables.

std::vector<int> input_permutation_#

A permutation vector applied to the input variables during transformation.

Private Functions

Loads the transformation data from static files based on the problem ID and the number of variables.

Loads the objective shift data from a file and stores it in the objective_shift_ member variable.

Loads the linear transformation data from a file and stores it in the linear_transformations_ member variable.

Loads the variables shift data from a file and stores it in the variables_shifts_ member variable.

Loads the shuffle data from a file and stores it in the input_permutation_ member variable.

### Constraint#

template<typename T>
class Constraint : public ioh::common::HasRepr#

Abstract type for constraints.

Template Parameters:

T – the data type, matches problem data type

Public Functions

inline Constraint(const constraint::Enforced enforced = constraint::Enforced::NOT, const double weight = 1.0, const double exponent = 1.0)#

Construct a new contraint object.

Parameters:
• enforced – policy for enforcing the penalty on the constraint see constraint::Enforced

• weight – the penalty weight

• exponent – the penalty exponent

inline double operator()(const std::vector<T> &x, const double y)#

apply the constraint, and return a (potentially) penalized value for y

Parameters:
• x – the search space value

• y – the objective space value

Returns:

penalized value for y

inline bool is_feasible(const std::vector<T> &x)#

Checks whether the x and y values are in the feasible domain.

Parameters:

x – the search space value

Returns:

true if both x and y are feasible, false otherwise

inline bool cached_is_feasible() const#

The value for is_feasibile_ is cached, in order not to call compute_violation again.

This value corresponse to the last call of is_feasible

Returns:

is_feasible_

virtual bool compute_violation(const std::vector<T> &x) = 0#

Compute if x or y has any violations of the constraint.

This should set violation_.

Parameters:

x – the search space value

Returns:

true when there is violation and false otherwise.

inline virtual double penalize(const double y) const#

Penalize the y value.

This method is only called when there is a violation, and is_feasible returns a false value, see operator().

Parameters:

y – the objective space value

Returns:

the penalized value for y.

inline virtual double violation() const#

Accessor for violation_.

inline virtual double penalty() const#

Accessor for penalty.

Public Members

constraint::Enforced enforced#

Enforcement strategy.

double weight#

Weight put on violation in penalty computation (penalty = weight * violation ^ exponent)

double exponent#

Exponent put on violation in penalty computation (penalty = weight * violation ^ exponent)

Protected Attributes

double violation_#

The amount of violation of the last evaluated point.

bool is_feasible_#

Wheter the last evaluated point is feasible.

### FunctionalConstraint#

template<typename T>
class FunctionalConstraint : public ioh::problem::Constraint<T>#

Wrapper for functions, that compute a constraint violation.

Template Parameters:

T – the numeric type for the search space values

Public Functions

inline FunctionalConstraint(ConstraintFunction<T> fn, const double weight = 1.0, const double exponent = 1.0, const constraint::Enforced enforced = constraint::Enforced::SOFT, const std::string &name = "")#

Construct a new functional constraint.

Parameters:
• fn – the function that computes the violation

• weight – the constraint penalty weight, used to penalize the y value as weight * violation ^ exponent

• exponent – the constraint penalty exponent, used to penalize the y value as weight * violation ^ exponent

• enforced – enforcement policy, see constraint::Enforced

• name – a name for this constraint, only used for the string representation.

inline virtual bool compute_violation(const std::vector<T> &x) override#

Override for Constraint::compute_violation, calls fn_ to compute violation_ value.

Parameters:

x – the search space value

Returns:

true when the absolute value for violation_ > 0 false otherwise

inline virtual std::string repr() const override#

Override string representation.

Private Members

ConstraintFunction<T> fn_#
std::string name_#

### PBO#

class PBO : public ioh::problem::SingleObjectiveProblem<int>#

PBO base class.

Public Functions

inline PBO(const int problem_id, const int instance, const int n_variables, const std::string &name)#

Construct a new PBO object.

Parameters:
• problem_id – The id of the problem

• instance – The instance of the problem

• n_variables – the dimension of the problem

• name – the name of the problem

Protected Functions

inline std::vector<int> transform_variables(std::vector<int> x) override#

Variables transformation method.

inline virtual double transform_objectives(const double y) override#

Objectives transformation method.

inline std::vector<int> reset_transform_variables(std::vector<int> x)#

Optimum before transformation.

### PBOProblem#

template<typename ProblemType>
class PBOProblem : public ioh::problem::PBO, private ioh::common::AutomaticTypeRegistration<ProblemType, PBO>, private ioh::common::AutomaticTypeRegistration<ProblemType, IntegerSingleObjective>#

CRTP class for PBO problems.

Inherit from this class when defining new PBO problems

Template Parameters:

ProblemType – The New PBO problem class

Public Functions

inline PBO(const int problem_id, const int instance, const int n_variables, const std::string &name)#

Construct a new PBO object.

Parameters:
• problem_id – The id of the problem

• instance – The instance of the problem

• n_variables – the dimension of the problem

• name – the name of the problem

### Problem#

template<typename T, typename R>
class Problem#

Problem Base class.

Template Parameters:
• T – type of the problem

• R – the returntype of the problem (evaluate)

Public Types

using Type = T#

The current type held within the instance.

using ReturnType = R#

The current ReturnType.

Public Functions

inline Problem(MetaData meta_data, Bounds<T> bounds, ConstraintSet<T> constraintset, State<T, R> state, Solution<T, R> optimum)#

Default constructor.

virtual R operator()(const std::vector<T> &x) = 0#

Public call interface.

virtual std::vector<R> operator()(const std::vector<std::vector<T>> &X) = 0#
virtual ~Problem() = default#

destructor

inline virtual void reset()#

Reset method, resets problem state and logger if attached.

inline const logger::Info &log_info() const#

inline void set_log_info(const logger::Info &info)#

inline void attach_logger(Logger &logger)#

Attach a logger.

inline void detach_logger()#

Dettach a logger.

inline void enforce_bounds(const double weight = 1.0, const constraint::Enforced enforced = constraint::Enforced::SOFT, const double exponent = 1.0)#

Enforced the bounds(box-constraints) as constraint.

Parameters:
• weight – The weight for computing the penalty

• how – The constraint::Enforced strategy

• exponent – the exponent for scaling the contraint

Accessor for `meta_data_`

inline Solution<T, R> optimum() const#

Accessor for `optimum_`

inline State<T, R> state() const#

Accessor for `state_`

inline Bounds<T> &bounds()#

Accessor for `bounds_`

inline ConstraintSet<T> &constraints()#

Accessor for `constraintset_`

inline void remove_constraint(const ConstraintPtr<T> &c)#

Alias for constraints().remove.

Call this method after updating any fields on meta_data_.

inline void set_id(const int new_id)#

Accessor for problem id.

inline void set_instance(const int new_instance)#

Accessor for problem instance.

inline void set_name(const std::string &new_name)#

Accessor for problem name.

Protected Functions

inline bool check_input_dimensions(const std::vector<T> &x)#

Method for checking the input given to the problem has the correct dimension.

Parameters:

x – the input vector

Returns:

true input is correct

Returns:

false input is incorrect

template<typename Integer = T>
inline std::enable_if<std::is_integral<Integer>::value, bool>::type check_input(const std::vector<T> &x)#

Check input given to problem for Integer types.

Template Parameters:

Integer – integer type

Parameters:

x – the input

Returns:

true if correct

template<typename Floating = T>
inline std::enable_if<std::is_floating_point<Floating>::value, bool>::type check_input(const std::vector<T> &x)#

Check input given to problem for Floating point types.

Template Parameters:

Floating – floating type

Parameters:

x – the input

Returns:

true if correct

virtual R evaluate(const std::vector<T> &x) = 0#

Evaluation function.

inline virtual std::vector<T> transform_variables(std::vector<T> x)#

Variables transformation function.

inline virtual R transform_objectives(const R y)#

Objectives transformation function.

Protected Attributes

Problem meta data.

Bounds<T> bounds_#

The problem bounds.

ConstraintSet<T> constraintset_#

The associated constraints constriants.

State<T, R> state_#

The Problem state.

Solution<T, R> optimum_#

The solution to the problem.

Logger *logger_ = {}#

A pointer to the attached logger.

logger::Info log_info_#

Friends

inline friend std::ostream &operator<<(std::ostream &os, const Problem &obj)#

Stream operator.

### SingleObjectiveProblem#

template<typename T>
class SingleObjectiveProblem : public ioh::problem::Problem<T, SingleObjective>#

CRTP class for Single objective problems.

Template Parameters:

T – the type of the problem

Public Functions

inline explicit SingleObjectiveProblem(MetaData meta_data, Bounds<T> bounds, ConstraintSet<T> constraints, Solution<T, SingleObjective> optimum)#

Construct a new Problem object.

Parameters:
• meta_data – meta data for the problem

• bounds – the bounds to the problem

• constraints – a set of constraints for the problem

• optimum – the solution to the problem

inline explicit SingleObjectiveProblem(MetaData meta_data, Bounds<T> bounds = Bounds<T>(), ConstraintSet<T> constraints = {})#

Construct a new Problem object with an unkown solution.

Parameters:
• meta_data – meta data for the problem

• bounds – the bounds to the problem

• constraints – a set of constraint for the problem

inline void evaluate_for_state(const std::vector<T> &x, State<T, SingleObjective> &state)#
inline void update_state_and_log()#
inline virtual double operator()(const std::vector<T> &x) override#

Main call interface.

inline virtual std::vector<double> operator()(const std::vector<std::vector<T>> &X) override#

### SingleObjectiveWrappedProblem#

template<typename T>
class SingleObjectiveWrappedProblem : public ioh::problem::SingleObjectiveProblem<T>#

Wrapper class for new single objective problems.

Template Parameters:

T

Public Functions

inline SingleObjectiveWrappedProblem(ObjectiveFunction<T, SingleObjective> f, const std::string &name, const int n_variables, const int problem_id = 0, const int instance_id = 0, const common::OptimizationType optimization_type = common::OptimizationType::MIN, Bounds<T> bounds = {}, VariablesTransformationFunction<T> transform_variables_function = utils::identity<std::vector<T>, int>, ObjectiveTransformationFunction<SingleObjective> transform_objectives_function = utils::identity<double, int>, std::optional<Solution<T, double>> objective = std::nullopt, ConstraintSet<T> constraints = {})#

Construct a new Wrapped Problem object.

Parameters:
• f – a function to be wrapped

• name – the name for the new function in the registry

• n_variables – the dimension of the problem

• problem_id – the problem id

• instance_id – the problem instance

• optimization_type – the type of optimization

• bounds – the box-constraints for the problem

• transform_variables_function – function which transforms the variables of the search problem prior to calling f.

• transform_objectives_function – a function which transforms the objective value of the search problem after calling f.

• objective – the value for the objective

• constraints – the constraints applied to the problem

Protected Functions

inline virtual double evaluate(const std::vector<T> &x) override#

Pass call to wrapped function.

inline virtual std::vector<T> transform_variables(std::vector<T> x) override#

Variables transformation function.

inline virtual double transform_objectives(const double y) override#

Objectives transformation function.

Protected Attributes

ObjectiveFunction<T, SingleObjective> function_#

Wrapped objective function.

VariablesTransformationFunction<T> transform_variables_function_#

Wrapped variables transformation function.

ObjectiveTransformationFunction<SingleObjective> transform_objectives_function_#

Wrapped objective transformation function.

### WModel#

class WModel : public ioh::problem::SingleObjectiveProblem<int>#

Base class for WModel problems.

Public Functions

inline WModel(const int problem_id, const int instance, const int n_variables, const std::string &name, const double dummy_select_rate, const int epistasis_block_size, const int neutrality_mu, const int ruggedness_gamma)#

Construct a new WModel object.

Parameters:
• problem_id – the problem id

• name – the name of the problem

• instance – instance id

• n_variables – the dimension of the problem

• dummy_select_rate – select rate

• epistasis_block_size – block size

• neutrality_mu – neutrality parameter

• ruggedness_gamma – ruggedness parameter

Protected Functions

inline virtual std::vector<int> transform_variables(std::vector<int> x) override#

Apply a random transformation to the solution itself.

Transformations are seeded on the instance ID (passed to the constructor). If the `instance` is in ]1, 50], it’s random flips. If the `instance` is in ]50,100], it’s random reorder. If `instance` is anything else, no transformation is applied.

You may disable this transformation by subclassing and returning `x` instead of calling this function.

inline virtual double transform_objectives(const double y) override#

Apply a random shift and a scaling to the objective function’s value.

The transformation is seeded on the instance ID (passed to the constructor). The shift adds a random number in [-0.2, 4.8] and the scale multiplies by a random number in [1e3, 2e3].]

You may disable this transformation by subclassing and returning `y` instead of calling this function.

inline double evaluate(const std::vector<int> &x) override#

Evaluation method.

virtual int wmodel_evaluate(const std::vector<int> &x) = 0#

Evaluation method for WModel functions.

Protected Attributes

std::vector<int> dummy_info_#

Dummy variables.

double dummy_select_rate_ = 0#

select rate

int epistasis_block_size_ = 0#

block size

int neutrality_mu_ = 0#

Neutrality parameter.

int ruggedness_gamma_ = 0#

Ruggedness parameter.

std::vector<int> ruggedness_info_#

Ruggedness dummy parameter.

## Structs#

### InstanceBasedProblem#

struct InstanceBasedProblem#

Definition interface of problems that are defined in static files.

Public Types

template<typename T, typename ...Args>
using Constructor = std::function<T(Args&&...)>#

A problem class with multiple instances defined, where each instance is a single unique problem, with its own dimension etc.

Every fid has only 1 instance, and only one dimension. A constructor function

template<typename T, typename ...Args>
using ConstructorTuple = std::tuple<Constructor<T, Args...>, int, std::optional<std::string>>#

Shorthand for tuple used in constructor list.

template<typename T, typename ...Args>
using Constructors = std::vector<ConstructorTuple<T, Args...>>#

A vector of constructors-id pairs.

Public Static Functions

template<typename T, typename ...Args>
static inline Constructors<T, Args...> load_instances(const std::optional<fs::path> &definitions = std::nullopt)#

Template Parameters:
• T – The type of the problem

• Args – the arguments of the constructor

Parameters:

definitions – the file with instance defintions

Returns:

Constructors<T, Args…> a vector of constrcutor functions

### SBOX#

struct SBOX : public ioh::problem::BBOB#

Public Functions

template<typename ...Args>
inline SBOX(Args&&... args)#

### BBOProblem#

template<template<typename> class ProblemType>
struct BBOProblem : public ioh::common::AutomaticTypeRegistration<ProblemType<SBOX>, SBOX>, public ioh::common::AutomaticTypeRegistration<ProblemType<BBOB>, BBOB>, public ioh::common::AutomaticTypeRegistration<ProblemType<BBOB>, RealSingleObjective>#

CRTP class for BBOB problems.

Inherit from this class when defining new BBOB problems

Template Parameters:

ProblemType – The New BBOB problem class

### CEC2013Problem#

template<typename ProblemType>
struct CEC2013Problem : public ioh::problem::CEC2013, public ioh::problem::InstanceBasedProblem, public ioh::common::AutomaticTypeRegistration<ProblemType, CEC2013>, public ioh::common::AutomaticTypeRegistration<ProblemType, RealSingleObjective>#

A template class for creating new CEC problems.

Inherit from this class when defining new CEC problems to enable automatic registration in hash maps.

Template Parameters:

ProblemType – The class representing the new CEC problem.

Public Functions

inline CEC2013(const int problem_id, const int instance, const int n_variables, const std::string &name, const double lb, const double ub, const size_t n_optima)#

Constructs a new CEC problem instance.

Parameters:
• problem_id – Unique identifier for the problem.

• instance – The instance number of the problem (currently ignored for CEC problems).

• n_variables – The number of variables in the problem, representing the dimensionality of the search

• lb – The lower bound of the problem

• ub – The lower bound of the problem

• n_optima – The number of global optima space.

• name – A unique name for the problem.

### CEC2022Problem#

template<typename ProblemType>
struct CEC2022Problem : public ioh::problem::CEC2022, public ioh::common::AutomaticTypeRegistration<ProblemType, CEC2022>, public ioh::common::AutomaticTypeRegistration<ProblemType, RealSingleObjective>#

A template class for creating new CEC problems.

Inherit from this class when defining new CEC problems to enable automatic registration in hash maps.

Template Parameters:

ProblemType – The class representing the new CEC problem.

Public Functions

inline CEC2022(const int problem_id, const int instance, const int n_variables, const std::string &name)#

Constructs a new CEC problem instance.

Parameters:
• problem_id – Unique identifier for the problem.

• instance – The instance number of the problem (currently ignored for CEC problems).

• n_variables – The number of variables in the problem, representing the dimensionality of the search space.

• name – A unique name for the problem.

### ConstraintSet#

template<typename T>
struct ConstraintSet : public ioh::common::HasRepr#

Wrapper class for multiple constraints.

Every problem has an associated ConstrainSet, which can be empty. Constraints can be added and modified via this interface.

Template Parameters:

T – the numeric type for the Constraint

Public Functions

inline ConstraintSet(const Constraints<T> &cs = {})#

Construct a new ConstrainSet object from a set of constrains (default constructor)

Parameters:

cs – the constraints

inline ConstraintSet(const ConstraintPtr<T> &c)#

Construct a new ConstrainSet object from a single ConstraintPtr.

Parameters:

c – the constraint

inline bool hard_violation(const std::vector<T> &x)#

Calls is_feasible for every constraint in order to check whether any of the constraints is violated.

Parameters:

x – the search space value

Returns:

true when there is violation, false otherwise

inline double penalty() const#

Aggregates Contraint::penalty(), by the sum of the penalties of all the constraints in the set.

Returns:

the aggregated penalty value

inline double violation() const#

Aggregates Contraint::violation(), by the sum of the violations of all the constraints in the set.

Returns:

the aggregated violation value

inline double penalize(const double y) const#

Override voor penalize.

If any of the constraints has a OVERRIDE enforcement policy and is not feasible, the penalize method for that constraint will be returned by this method (by first occurence). Otherwise, y is penalized by y + penalty(), which is the sum of all penalty values for each constraint.

Parameters:

y – objective space value

Returns:

penalized objective value

Add a constraint to the set.

Parameters:

c – the constraint to be added.

inline void remove(const ConstraintPtr<T> &c)#

Remove a constraint for the set, if it exists.

Parameters:

c – the constraint to be removed.

inline size_t n() const#

alias for constraints.size()

Returns:

the number of constraints

inline ConstraintPtr<T> &operator[](size_t i)#

Alias for constraints.at()

Parameters:

i – index

Returns:

a reference to constraints[i]

inline virtual std::string repr() const override#

String representation.

Public Members

Constraints<T> constraints#

The set of contained constraints.

### BoxConstraint#

template<typename T>
struct BoxConstraint : public ioh::problem::Constraint<T>#

Box-BoxConstraint object.

Public Functions

inline BoxConstraint(const std::vector<T> &lower, const std::vector<T> &upper, constraint::Enforced enforced = constraint::Enforced::NOT, const double weight = 1.0, const double exponent = 1.0)#

Construct a new BoxConstraint object.

Parameters:
• lower – lower bound

• upper – upper bound

• enforced – enforcement policy

inline explicit BoxConstraint(const int size = 1, const T lower = std::numeric_limits<T>::lowest(), const T upper = std::numeric_limits<T>::max(), constraint::Enforced enforced = constraint::Enforced::NOT)#

Construct a new BoxConstraint object.

Parameters:
• size – size of the BoxConstraint

• lower – lower bound

• upper – upper bound

• enforced – enforcement policy

inline void fit(const int s)#

Initialization helper, resize the constraint.

Fills the entire constraint with the first value both the lower and upper bound.

Parameters:

s – the new size

inline virtual bool compute_violation(const std::vector<T> &x) override#

Check if the BoxConstraints are violated, override Constraint::compute_violation.

inline BoxConstraint<T> resize(const int s) const#

Return resize version of BoxConstraint.

inline virtual std::string repr() const override#

String representation.

inline bool operator==(const BoxConstraint<T> &other) const#

Public Members

std::vector<T> lb#

lower bound

std::vector<T> ub#

Upper bound.

### RegisteredProblem#

template<typename ProblemType, typename ParentType>
struct RegisteredProblem : public ParentType, public ioh::common::AutomaticTypeRegistration<ProblemType, ParentType>#

CRTP class for automatically registering problems in the apropriate factory.

you should inherit from this class when defining new real problems.

Template Parameters:
• ProblemType – The new problem type

• ParentType – The parent problem type

struct of problem meta data

Public Functions

inline MetaData(const int problem_id, const int instance, std::string name, const int n_variables, const common::OptimizationType optimization_type = common::OptimizationType::MIN)#

Construct a new Meta Data object.

Parameters:
• problem_id – The id of the problem

• instance – The instance of the problem

• name – the name of the problem

• n_variables – the dimension of the problem

• optimization_type – optimization type

inline MetaData(const int instance, const std::string &name, const int n_variables, const common::OptimizationType optimization_type = common::OptimizationType::MIN)#

Construct a new Meta Data object.

Parameters:
• instance – The instance of the problem

• name – the name of the problem

• n_variables – the dimension of the problem

• optimization_type – optimization type

inline bool operator==(const MetaData &other) const#

comparison operator

inline bool operator!=(const MetaData &other) const#

comparison operator

inline virtual std::string repr() const override#

Representation of the object.

Public Members

int instance = {}#

Instance id.

int problem_id = {}#

problem id

std::string name#

problem name

common::FOptimizationType optimization_type#

optimization type

int n_variables = {}#

problem dimension

### Solution#

template<typename T, typename R>
struct Solution#

### Solution< T, SingleObjective >#

template<typename T>
struct Solution<T, SingleObjective> : public ioh::common::HasRepr#

Solution object.

Public Functions

inline Solution(const std::vector<T> &x, const double y)#

Construct a new Solution object.

Parameters:
• x – variables

• y – objective value

inline Solution(const int n_variables, const common::OptimizationType optimization_type)#

Shorthand constructor for use with unknown optimum.

Solution() = default#

Default Constructible.

inline bool exists() const#

Returns true if the solution’s objective has been set.

inline virtual std::string repr() const override#

Representation of the object.

Public Members

std::vector<T> x = {}#

variables

double y = std::numeric_limits<double>::signaling_NaN()#

objective value

### Solution< T, MultiObjective >#

template<typename T>
struct Solution<T, MultiObjective> : public ioh::common::HasRepr#

Solution object.

Public Functions

inline Solution(const std::vector<T> &x, const std::vector<double> &y)#

Construct a new Solution object.

Parameters:
• x – variables

• y – objective values

Solution() = default#

Default constructible.

inline bool exists() const#

Returns true if the solution’s objective has been set.

inline bool operator==(const Solution<T, MultiObjective> &other) const#

Equality operator.

inline virtual std::string repr() const override#

String representation.

Public Members

std::vector<T> x = {}#

variables

std::vector<double> y = {}#

objective value

### State#

template<typename T, typename R>
struct State#

### State< T, double >#

template<typename T>
struct State<T, double> : public ioh::common::HasRepr#

Problem State`.

Public Functions

State() = default#
inline State(Solution<T, double> initial)#

Construct a new State object.

Parameters:

initial – initial objective value

inline void reset()#

reset the state

inline void update(const MetaData &meta_data, const Solution<T, double> &objective)#

Update the state.

inline virtual std::string repr() const override#

Representation of the object.

Public Members

int evaluations = 0#

Current number of evaluations.

bool optimum_found = false#

Is optimum found?

Solution<T, double> current_best_internal = {}#

Current best x-transformed, y-raw w. constraints applied.

Solution<T, double> current_best = {}#

Current best x-raw, y-transformed.

Solution<T, double> current_internal = {}#

Current x-transformed, y-raw.

Solution<T, double> current = {}#

Current x-raw, y-transformed w. constraints applied.

double y_unconstrained#

Current y transformed w.o. constraints applied.

double y_unconstrained_best#

Current y transformed w.o. constraints applied.

bool has_improved#

Tracks whether the last update has caused an improvement.

Private Members

Solution<T, double> initial_solution#

### State< T, MultiObjective >#

template<typename T>
struct State<T, MultiObjective> : public ioh::common::HasRepr#

Problem State`.

Public Functions

inline virtual std::string repr() const override#

Representation of the object.

inline void update(const MetaData &meta_data, const Solution<T, MultiObjective> &objective)#

Update the state.

inline void reset()#

Reset the state.

Public Members

int evaluations = 0#

Current number of evaluations.

bool optimum_found = false#

Is optimum found?

## Functions#

### ackley#

inline double ioh::problem::ackley(const std::vector<double> &z)#

Computes the Ackley function value for the input vector.

The Ackley function is a widely used benchmark function in optimization, characterized by a nearly flat outer region and a large hole at the centre. The function is known for its complex oscillating behavior, which is used to evaluate the performance of optimization algorithms in navigating complex landscapes.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector, representing a point in the solution space of the Ackley function.

### bent_cigar#

inline double ioh::problem::bent_cigar(const std::vector<double> &z)#

Computes the Bent Cigar function value for the input vector.

The Bent Cigar function is a unimodal function used in optimization problems. It is characterized by a narrow, curved valley. The function is known for its steepness and is used to test the performance of optimization algorithms in locating the global minimum amidst steep gradients.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector, representing a point in the solution space of the Bent Cigar function.

### discus#

inline double ioh::problem::discus(const std::vector<double> &z)#

Computes the Discus function value for the input vector.

The Discus function is a unimodal function used in optimization problems. It is characterized by a very steep descent towards the global minimum, which is surrounded by a flat area. This function calculates the Discus function value at a point specified by the input vector.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector.

### ellipse#

inline double ioh::problem::ellipse(const std::vector<double> &z)#

Computes the Ellipse function value for the input vector.

The Ellipse function is a scalable function used in optimization problems, characterized by its elliptic contours. It is used to test the performance of optimization algorithms, especially in high-dimensional spaces. This function calculates the Ellipse function value at a point specified by the input vector.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector.

### expanded_schaffer#

inline double ioh::problem::expanded_schaffer(const std::vector<double> &z)#

### fef8_f2#

inline double ioh::problem::fef8_f2(const std::vector<double> &xx)#

### get_identity_matrices#

inline std::vector<std::vector<std::vector<double>>> ioh::problem::get_identity_matrices(const size_t n_optima, const size_t dimension)#

### griewank#

inline double ioh::problem::griewank(const std::vector<double> &z)#

### griewank_rosenbrock#

inline double ioh::problem::griewank_rosenbrock(const std::vector<double> &z)#

Computes the Griewank-Rosenbrock function value for the input vector.

The Griewank-Rosenbrock function is a complex, multimodal function often used in optimization problem testing. It combines characteristics of both the Griewank and Rosenbrock functions. This function evaluates the Griewank-Rosenbrock function at a point in the domain space specified by the input vector.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector.

### happycat#

inline double ioh::problem::happycat(const std::vector<double> &z)#

Computes the HappyCat function value for the input vector.

The HappyCat function is a non-convex function used in optimization problems. It has a bowl-shaped surface with a global minimum. This implementation calculates the HappyCat function value given a vector of input values.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector.

### hgbat#

inline double ioh::problem::hgbat(const std::vector<double> &z)#

Computes the HGBat function value for the input vector.

The HGBat function is a complex, high-dimensional optimization problem characterized by a bat-shaped landscape. It is used to evaluate the performance of optimization algorithms. This function performs a series of mathematical operations including power and square root functions on the input vector to compute the function value.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector, representing a point in the solution space of the HGBat function.

### katsuura#

inline double ioh::problem::katsuura(const std::vector<double> &z)#

Computes the Katsuura function value for the input vector.

The Katsuura function is a non-separable, scalable function used in optimization problems. It is characterized by a large number of local minima and a single global minimum, making it a challenging problem for optimization algorithms. This function performs a series of mathematical operations including power and trigonometric functions on the input vector to compute the function value.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector, representing a point in the solution space of the Katsuura function.

### levy#

inline double ioh::problem::levy(const std::vector<double> &z)#

Computes the Levy function value given an input vector.

The Levy function is well known in the optimization domain, defined with a combination of sine and cosine operations along with polynomial expressions. The function calculates various terms separately which contribute to the final Levy function value.

Parameters:

z – A constant reference to a vector of doubles representing the input to the function.

Returns:

The calculated Levy function value based on the input vector.

inline InstanceBasedProblem::ConstructorTuple<cec2013::CompositionFunction, int, int> ioh::problem::load_cf(const int problem_id, const int cf_id, const size_t dimension, const std::vector<std::vector<double>> &all_optima, const std::vector<double> &sigmas, const std::vector<double> &lambdas, const std::vector<RealFunction> &functions)#

inline std::vector<std::vector<std::vector<double>>> ioh::problem::load_transformations(const size_t cf_id, const size_t dimension, const size_t n_optima)#

### rastrigin#

inline double ioh::problem::rastrigin(const std::vector<double> &z)#

Computes the Rastrigin function for a given input vector.

Parameters:

z – Input vector.

Returns:

Function value at input z.

### rosenbrock#

inline double ioh::problem::rosenbrock(const std::vector<double> &z)#

Calculates the Rosenbrock function value for the input vector.

The Rosenbrock function is commonly used for optimization algorithms testing. It is defined over an n-dimensional space. The function is computed as the sum of squares of sequential elements, with a particular transformation applied to each element before the computation.

Parameters:

z – A constant reference to a vector of doubles, which represents the input to the function.

Returns:

The computed Rosenbrock function value.

### schaffer#

inline double ioh::problem::schaffer(const std::vector<double> &y)#

Computes the Schaffer F7 function value for the input vector.

The Schaffer F7 function is a well-known benchmark function in the field of optimization. It is characterized by a rugged landscape with many local minima, making it a challenging problem for optimization algorithms. This function takes a vector input and computes the function value using a series of mathematical operations including square roots, sine functions, and power functions.

Parameters:

y – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector, which represents a point in the solution space of the Schaffer F7 function.

### schwefel#

inline double ioh::problem::schwefel(const std::vector<double> &z)#

Computes the Schwefel function value for the input vector.

The Schwefel function is a complex, non-linear, multimodal function characterized by a large number of local minima, making it a challenging problem for optimization algorithms. This function performs a series of mathematical operations including sine functions and power functions on the input vector to compute the function value.

Parameters:

z – Input vector containing the coordinates in the domain space.

Returns:

The function value at the point specified by the input vector, representing a point in the solution space of the Schwefel function.

### select_optima#

inline std::vector<std::vector<double>> ioh::problem::select_optima(std::vector<std::vector<double>> optima, const size_t n_optima, const size_t dimension)#

### sphere#

inline double ioh::problem::sphere(const std::vector<double> &x)#

### weierstrass#

inline double ioh::problem::weierstrass(const std::vector<double> &x)#

### wrap_function#

template<typename T, typename R>
void ioh::problem::wrap_function(ObjectiveFunction<T, R> f, const std::string &name, const common::OptimizationType optimization_type = common::OptimizationType::MIN, const std::optional<T> lb = std::nullopt, const std::optional<T> ub = std::nullopt, std::optional<VariablesTransformationFunction<T>> transform_variables_function = std::nullopt, std::optional<ObjectiveTransformationFunction<R>> transform_objectives_function = std::nullopt, std::optional<CalculateObjectiveFunction<T, R>> calculate_optimum = std::nullopt, ConstraintSet<T> constraints = {})#

Shorthand for wrapping function in a problem.

Template Parameters:
• T – type of the problem

• R – the returntype of the problem

Parameters:
• f – a function to be wrapped

• name – the name for the new function in the registry

• optimization_type – the type of optimization

• lb – lower bound for the BoxConstraint of the problem

• ub – upper bound for the BoxConstraint of the problem

• transform_variables_function – function which transforms the variables of the search problem prior to calling f.

• transform_objectives_function – a function which transforms the objective value of the search problem after calling f.

• calculate_optimum – a function which returns the optimum based on a given problem dimension and instance.

• constraints – the constraints

### zakharov#

inline double ioh::problem::zakharov(const std::vector<double> &x)#

Calculates the Zakharov function value for a given input vector.

The Zakharov function is used frequently in optimization problems. It involves calculating two summation terms based on the input vector, which are then used to compute the final function value.

Parameters:

x – A constant reference to a vector of doubles representing the input to the function.

Returns:

The calculated Zakharov function value for the given input vector.

## Variables#

### CEC_FOLDER#

const std::string ioh::problem::CEC_FOLDER = "cec_transformations/2022/"#