common#

Namespaces#

Classes#

FOptimizationType#

class FOptimizationType : public ioh::common::HasRepr#

Wrapper class for optimization type, contains comparison operator.

Public Functions

inline FOptimizationType(const OptimizationType type = OptimizationType::MAX)#

Construct a new FOptimizationType object.

Parameters:

type – The optimization type

FOptimizationType(const FOptimizationType&) = default#

Copy constructor.

inline OptimizationType type() const#

Accessor for type_.

inline double initial_value() const#

Accesor for initial_value_.

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

String representation.

inline bool operator()(const double v1, const double v2) const#

Comparison operator between two values v1 & v2.

> When OptimizationType is MAX, < otherwise.

Returns:

true if v1 is better than v2

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

Equality operato.

Parameters:

other – an FOptimizationType

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

Equality operato.

Parameters:

other – an OptimizationType

FOptimizationType &operator=(const FOptimizationType&) = default#

Copy.

Private Members

OptimizationType type_#

The underlying optimization type.

std::function<bool(double, double)> comparator_#

The comparison operator.

double initial_value_#

Default (worst possible value)

CpuTimer#

class CpuTimer#

A simple timer class, logging elapsed CPU time to stdout.

Public Functions

inline explicit CpuTimer(std::string info_msg = "")#

Constructs a timer, sets start time.

Parameters:

info_msg – The value for info_msg_

inline ~CpuTimer()#

Destructs a timer, prints time elapsed to stdout.

Private Types

using Clock = std::chrono::high_resolution_clock#

The start time of the timer.

Private Members

std::string info_msg_#

A info message to be logged to stdout when the timer completes.

Clock::time_point start_time_#

Structs#

Permutation#

struct Permutation#

Permutation struct.

Public Functions

inline bool operator<(const Permutation &b) const#

sort operator

Public Members

double value#

value

int index#

index

Public Static Functions

static inline std::vector<Permutation> sorted(const int n, const int seed)#

sort a set of random permutations

Factory#

template<class AbstractType, typename ...Args>
struct Factory#

Class for generating classes for a given abtract type.

Template Parameters:
  • AbstractType – the parent type of the classes to be generator

  • Args – the arguments of the common constructor for children of AbtractType

Public Types

using Type = std::shared_ptr<AbstractType>#

A shared ptr to AbstractType.

using Creator = std::function<Type(Args&&...)>#

Creator method for instances of Type.

Public Functions

inline void include(const std::string &name, const int id, Creator creator)#

Include a new element to the factory.

inline int check_or_get_next_available(const int id) const#

Get the next available id.

inline int check_or_get_next_available(const int id, const std::string &name) const#

Get the next available id.

inline std::vector<std::string> names() const#

Accessor for the list of registered names.

inline std::vector<int> ids() const#

Accessor for the list of registered ids.

inline std::map<int, std::string> map() const#

Accessor for the map from id to name.

inline Type create(const std::string &name, Args... params) const#

Create a new instance of Type using the Creator registered.

inline Type create(const int id, Args... params) const#

Create a new instance of Type using the Creator registered.

Public Static Functions

static inline Factory &instance()#

Accessor to static instance.

Private Functions

Factory() = default#
Factory(const Factory&) = delete#

Private Members

std::map<std::string, Creator> name_map#
std::map<int, std::string> id_map#

FactoryID#

struct FactoryID#

Public Members

int id#
std::string name#

IdGetter#

template<bool IsProblem>
struct IdGetter#

Helper to get a new ID for a given class.

IdGetter< true >#

template<>
struct IdGetter<true>#

Helper to get a new ID for a problem class.

Public Static Functions

template<typename T>
static inline FactoryID get_id(const std::vector<int>&)#

Gets an from the class meta_data.

IdGetter< false >#

template<>
struct IdGetter<false>#

Helper to get a new ID for a non problem class.

Public Static Functions

template<typename T>
static inline FactoryID get_id(const std::vector<int> &ids)#

Gets an id.

RegisterWithFactory#

template<typename Parent, typename ...Args>
struct RegisterWithFactory#

Base factory registry.

Template Parameters:
  • Parent – Abstract type

  • Args – Parent constructor args

Public Types

using InstanceBasedProblem = ioh::problem::InstanceBasedProblem#

Typedef for instance based problems.

Public Static Functions

template<class T>
static inline std::enable_if<!std::is_base_of<InstanceBasedProblem, T>::value, void>::type include()#

Include Parent in the factory.

template<class T>
static inline std::enable_if<std::is_base_of<InstanceBasedProblem, T>::value, void>::type include()#

Include specific for instance based problems.

static inline Factory<Parent, Args...> &instance()#

Accessor to static instance.

InvokeApplyOnConstruction#

template<class Type, class Factory>
struct InvokeApplyOnConstruction#

Helper for factory system.

Public Functions

inline InvokeApplyOnConstruction()#

RegistrationInvoker#

template<class Type, class Factory>
struct RegistrationInvoker#

Helper for factory system.

Subclassed by ioh::common::AutomaticTypeRegistration< Type, Factory >

Public Static Attributes

static InvokeApplyOnConstruction<Type, Factory> registration_invoker = InvokeApplyOnConstruction<Type, Factory>()#

Forces creation of registration_invoker

AutomaticTypeRegistration#

template<class Type, class Factory>
struct AutomaticTypeRegistration : public ioh::common::RegistrationInvoker<Type, Factory>#

Helper for factory system.

Subclassed by ioh::problem::BBOProblem< Schaffers1000 >, ioh::problem::BBOProblem< Schaffers1000 >, ioh::problem::BBOProblem< Schaffers1000 >, ioh::problem::BBOProblem< Schaffers10 >, ioh::problem::BBOProblem< Schaffers10 >, ioh::problem::BBOProblem< Schaffers10 >, ioh::problem::BBOProblem< Gallagher101 >, ioh::problem::BBOProblem< Gallagher101 >, ioh::problem::BBOProblem< Gallagher101 >, ioh::problem::BBOProblem< DifferentPowers >, ioh::problem::BBOProblem< DifferentPowers >, ioh::problem::BBOProblem< DifferentPowers >, ioh::problem::BBOProblem< BuecheRastrigin >, ioh::problem::BBOProblem< BuecheRastrigin >, ioh::problem::BBOProblem< BuecheRastrigin >, ioh::problem::BBOProblem< EllipsoidRotated >, ioh::problem::BBOProblem< EllipsoidRotated >, ioh::problem::BBOProblem< EllipsoidRotated >, ioh::problem::BBOProblem< LunacekBiRastrigin >, ioh::problem::BBOProblem< LunacekBiRastrigin >, ioh::problem::BBOProblem< LunacekBiRastrigin >, ioh::problem::BBOProblem< BentCigar >, ioh::problem::BBOProblem< BentCigar >, ioh::problem::BBOProblem< BentCigar >, ioh::problem::BBOProblem< Rosenbrock >, ioh::problem::BBOProblem< Rosenbrock >, ioh::problem::BBOProblem< Rosenbrock >, ioh::problem::BBOProblem< RastriginRotated >, ioh::problem::BBOProblem< RastriginRotated >, ioh::problem::BBOProblem< RastriginRotated >, ioh::problem::BBOProblem< Discus >, ioh::problem::BBOProblem< Discus >, ioh::problem::BBOProblem< Discus >, ioh::problem::BBOProblem< Rastrigin >, ioh::problem::BBOProblem< Rastrigin >, ioh::problem::BBOProblem< Rastrigin >, ioh::problem::BBOProblem< Katsuura >, ioh::problem::BBOProblem< Katsuura >, ioh::problem::BBOProblem< Katsuura >, ioh::problem::BBOProblem< Sphere >, ioh::problem::BBOProblem< Sphere >, ioh::problem::BBOProblem< Sphere >, ioh::problem::BBOProblem< SharpRidge >, ioh::problem::BBOProblem< SharpRidge >, ioh::problem::BBOProblem< SharpRidge >, ioh::problem::BBOProblem< Schwefel >, ioh::problem::BBOProblem< Schwefel >, ioh::problem::BBOProblem< Schwefel >, ioh::problem::BBOProblem< GriewankRosenbrock >, ioh::problem::BBOProblem< GriewankRosenbrock >, ioh::problem::BBOProblem< GriewankRosenbrock >, ioh::problem::BBOProblem< Weierstrass >, ioh::problem::BBOProblem< Weierstrass >, ioh::problem::BBOProblem< Weierstrass >, ioh::problem::BBOProblem< LinearSlope >, ioh::problem::BBOProblem< LinearSlope >, ioh::problem::BBOProblem< LinearSlope >, ioh::problem::BBOProblem< Ellipsoid >, ioh::problem::BBOProblem< Ellipsoid >, ioh::problem::BBOProblem< Ellipsoid >, ioh::problem::BBOProblem< StepEllipsoid >, ioh::problem::BBOProblem< StepEllipsoid >, ioh::problem::BBOProblem< StepEllipsoid >, ioh::problem::BBOProblem< AttractiveSector >, ioh::problem::BBOProblem< AttractiveSector >, ioh::problem::BBOProblem< AttractiveSector >, ioh::problem::BBOProblem< Gallagher21 >, ioh::problem::BBOProblem< Gallagher21 >, ioh::problem::BBOProblem< Gallagher21 >, ioh::problem::BBOProblem< RosenbrockRotated >, ioh::problem::BBOProblem< RosenbrockRotated >, ioh::problem::BBOProblem< RosenbrockRotated >, ioh::problem::CEC2013Problem< EqualMaxima >, ioh::problem::CEC2013Problem< EqualMaxima >, ioh::problem::CEC2013Problem< Himmelblau >, ioh::problem::CEC2013Problem< Himmelblau >, ioh::problem::CEC2013Problem< Vincent >, ioh::problem::CEC2013Problem< Vincent >, ioh::problem::CEC2013Problem< Shubert >, ioh::problem::CEC2013Problem< Shubert >, ioh::problem::CEC2013Problem< SixHumpCamelback >, ioh::problem::CEC2013Problem< SixHumpCamelback >, ioh::problem::CEC2013Problem< ModifiedRastrigin >, ioh::problem::CEC2013Problem< ModifiedRastrigin >, ioh::problem::CEC2013Problem< CompositionFunction >, ioh::problem::CEC2013Problem< CompositionFunction >, ioh::problem::CEC2013Problem< FivePeaks >, ioh::problem::CEC2013Problem< FivePeaks >, ioh::problem::CEC2013Problem< UnevenEqualMaxima >, ioh::problem::CEC2013Problem< UnevenEqualMaxima >, ioh::problem::CEC2022Problem< CompositionFunction3 >, ioh::problem::CEC2022Problem< CompositionFunction3 >, ioh::problem::CEC2022Problem< CompositionFunction4 >, ioh::problem::CEC2022Problem< CompositionFunction4 >, ioh::problem::CEC2022Problem< HybridFunction1 >, ioh::problem::CEC2022Problem< HybridFunction1 >, ioh::problem::CEC2022Problem< SchafferF7 >, ioh::problem::CEC2022Problem< SchafferF7 >, ioh::problem::CEC2022Problem< Rosenbrock >, ioh::problem::CEC2022Problem< Rosenbrock >, ioh::problem::CEC2022Problem< Rastrigin >, ioh::problem::CEC2022Problem< Rastrigin >, ioh::problem::CEC2022Problem< Zakharov >, ioh::problem::CEC2022Problem< Zakharov >, ioh::problem::CEC2022Problem< Levy >, ioh::problem::CEC2022Problem< Levy >, ioh::problem::CEC2022Problem< HybridFunction3 >, ioh::problem::CEC2022Problem< HybridFunction3 >, ioh::problem::CEC2022Problem< HybridFunction2 >, ioh::problem::CEC2022Problem< HybridFunction2 >, ioh::problem::CEC2022Problem< CompositionFunction1 >, ioh::problem::CEC2022Problem< CompositionFunction1 >, ioh::problem::CEC2022Problem< CompositionFunction2 >, ioh::problem::CEC2022Problem< CompositionFunction2 >, ioh::problem::PBOProblem< NQueens >, ioh::problem::PBOProblem< NQueens >, ioh::problem::PBOProblem< IsingTorus >, ioh::problem::PBOProblem< IsingTorus >, ioh::problem::PBOProblem< OneMaxRuggedness1 >, ioh::problem::PBOProblem< OneMaxRuggedness1 >, ioh::problem::PBOProblem< LeadingOnesRuggedness2 >, ioh::problem::PBOProblem< LeadingOnesRuggedness2 >, ioh::problem::PBOProblem< LeadingOnesRuggedness3 >, ioh::problem::PBOProblem< LeadingOnesRuggedness3 >, ioh::problem::PBOProblem< ConcatenatedTrap >, ioh::problem::PBOProblem< ConcatenatedTrap >, ioh::problem::PBOProblem< LeadingOnesRuggedness1 >, ioh::problem::PBOProblem< LeadingOnesRuggedness1 >, ioh::problem::PBOProblem< LeadingOnesEpistasis >, ioh::problem::PBOProblem< LeadingOnesEpistasis >, ioh::problem::PBOProblem< OneMaxNeutrality >, ioh::problem::PBOProblem< OneMaxNeutrality >, ioh::problem::PBOProblem< LeadingOnesDummy2 >, ioh::problem::PBOProblem< LeadingOnesDummy2 >, ioh::problem::PBOProblem< LABS >, ioh::problem::PBOProblem< LABS >, ioh::problem::PBOProblem< IsingRing >, ioh::problem::PBOProblem< IsingRing >, ioh::problem::PBOProblem< OneMaxDummy1 >, ioh::problem::PBOProblem< OneMaxDummy1 >, ioh::problem::PBOProblem< OneMax >, ioh::problem::PBOProblem< OneMax >, ioh::problem::PBOProblem< NKLandscapes >, ioh::problem::PBOProblem< NKLandscapes >, ioh::problem::PBOProblem< LeadingOnesNeutrality >, ioh::problem::PBOProblem< LeadingOnesNeutrality >, ioh::problem::PBOProblem< LeadingOnes >, ioh::problem::PBOProblem< LeadingOnes >, ioh::problem::PBOProblem< IsingTriangular >, ioh::problem::PBOProblem< IsingTriangular >, ioh::problem::PBOProblem< Linear >, ioh::problem::PBOProblem< Linear >, ioh::problem::PBOProblem< OneMaxRuggedness3 >, ioh::problem::PBOProblem< OneMaxRuggedness3 >, ioh::problem::PBOProblem< OneMaxEpistasis >, ioh::problem::PBOProblem< OneMaxEpistasis >, ioh::problem::PBOProblem< OneMaxDummy2 >, ioh::problem::PBOProblem< OneMaxDummy2 >, ioh::problem::PBOProblem< MIS >, ioh::problem::PBOProblem< MIS >, ioh::problem::PBOProblem< LeadingOnesDummy1 >, ioh::problem::PBOProblem< LeadingOnesDummy1 >, ioh::problem::PBOProblem< OneMaxRuggedness2 >, ioh::problem::PBOProblem< OneMaxRuggedness2 >, ioh::problem::submodular::GraphProblemType< PackWhileTravel >, ioh::problem::submodular::GraphProblemType< PackWhileTravel >, ioh::problem::submodular::GraphProblemType< MaxCut >, ioh::problem::submodular::GraphProblemType< MaxCut >, ioh::problem::submodular::GraphProblemType< MaxCoverage >, ioh::problem::submodular::GraphProblemType< MaxCoverage >, ioh::problem::submodular::GraphProblemType< MaxInfluence >, ioh::problem::submodular::GraphProblemType< MaxInfluence >, ioh::suite::IntegerSuite< PBO >, ioh::suite::IntegerSuite< Integer >, ioh::suite::IntegerSuite< IntegerStarDiscrepancy >, ioh::suite::IntegerSuite< Submodular >, ioh::suite::RealSuite< RealStarDiscrepancy >, ioh::suite::RealSuite< BBOB >, ioh::suite::RealSuite< SBOX >, ioh::suite::RealSuite< Real >, ioh::problem::BBOProblem< ProblemType >, ioh::problem::BBOProblem< ProblemType >, ioh::problem::BBOProblem< ProblemType >, ioh::problem::CEC2013Problem< ProblemType >, ioh::problem::CEC2013Problem< ProblemType >, ioh::problem::CEC2022Problem< ProblemType >, ioh::problem::CEC2022Problem< ProblemType >, ioh::problem::PBOProblem< ProblemType >, ioh::problem::PBOProblem< ProblemType >, ioh::problem::RegisteredProblem< ProblemType, ParentType >, ioh::problem::star_discrepancy::integer::StarDiscrepancy, ioh::problem::star_discrepancy::integer::StarDiscrepancy, ioh::problem::star_discrepancy::real::StarDiscrepancy, ioh::problem::star_discrepancy::real::StarDiscrepancy, ioh::problem::submodular::GraphProblemType< ProblemType >, ioh::problem::submodular::GraphProblemType< ProblemType >, ioh::suite::IntegerSuite< Derived >, ioh::suite::RealSuite< Derived >

Public Members

InvokeApplyOnConstruction<Type, Factory> &invoker = RegistrationInvoker<Type, Factory>::registration_invoker#

Forces creation of invoker

HasRepr#

struct HasRepr#

Interface which defines a repr method.

Subclassed by ioh::problem::Constraint< int >, ioh::common::FOptimizationType, ioh::logger::analyzer::structures::AlgorithmInfo, ioh::logger::analyzer::structures::Attribute< T >, ioh::logger::analyzer::structures::BestPoint, ioh::logger::analyzer::structures::ExperimentInfo, ioh::logger::analyzer::structures::RunInfo, ioh::logger::analyzer::structures::ScenarioInfo, ioh::problem::Constraint< T >, ioh::problem::ConstraintSet< T >, ioh::problem::MetaData, ioh::problem::Solution< T, MultiObjective >, ioh::problem::Solution< T, SingleObjective >, ioh::problem::State< T, MultiObjective >, ioh::problem::State< T, double >, ioh::problem::submodular::graph::Graph

Public Functions

virtual std::string repr() const = 0#

Representation of the object.

Friends

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

Default string stream method.

Enumerations#

OptimizationType#

enum class ioh::common::OptimizationType#

Enum containing minimization = 0 and maximization = 1 flags.

Values:

enumerator MIN#
enumerator MAX#

Functions#

all_finite#

inline bool ioh::common::all_finite(const std::vector<double> &x)#

Checks a vector of doubles for nan values.

Parameters:

x – vector to be checked

Returns:

true if x contains a nan value

as_vector#

Warning

doxygenfunction: Unable to resolve function “ioh::common::as_vector” with arguments None in doxygen xml output for project “iohcpp” from directory: ../../build/xml/. Potential matches:

- template<typename K, typename V, typename P = std::pair<K, V>> std::vector<P> as_vector(const std::map<K, V*> &m)
- template<typename K, typename V, typename P = std::pair<K, V>> std::vector<P> as_vector(const std::map<K, V> &m)

class_name#

template<typename T>
std::string ioh::common::class_name()#

Get the type name of the problem.

Template Parameters:

T – the template of the Problem

Returns:

the name of T

concatenate#

template<typename T>
std::vector<T> ioh::common::concatenate(std::vector<T> a, const std::vector<T> &b)#

concatenates two vectors

Template Parameters:

T – the type of the vectors

Parameters:
  • a – the first vector

  • b – the second vector

Returns:

the resulting vector, containing the elements of both a and b

erase_substring#

inline void ioh::common::erase_substring(std::string &str, const std::string &substr)#

Inplace remove substring from string.

Parameters:
  • str – string to remove substr from

  • substr – the substring to remove

eye#

inline std::vector<std::vector<double>> ioh::common::eye(const size_t n)#

Create an identity n x n matrix.

Parameters:

n – the size of the matrix

Returns:

an identity matrix

fill_array#

template<typename T, size_t N>
std::array<T, N> ioh::common::fill_array(const T value)#

Makes an array and fills it with a specific value.

Template Parameters:
  • T – the type of the elements

  • N – the number of elements

Parameters:

value – the value

Returns:

std::array<T, N> the filled array

from_vector#

template<typename T, size_t N>
std::array<T, N> ioh::common::from_vector(const std::vector<T> &v)#

Convert vector into a std::array.

Template Parameters:
  • T – the type of the elements

  • N – the number of elements

Parameters:

v – the vector to convert from

Returns:

std::array<T, N> the array

get_next_id#

inline int ioh::common::get_next_id(const std::vector<int> &ids)#

Function to get the next non zero value in an array of integers.

has_inf#

inline bool ioh::common::has_inf(const std::vector<double> &x)#

Checks a vector of doubles for inf values.

Parameters:

x – vector to be checked

Returns:

true if x contains a nan value

has_nan#

inline bool ioh::common::has_nan(const std::vector<double> &x)#

Checks a vector of doubles for nan values.

Parameters:

x – vector to be checked

Returns:

true if x contains a nan value

is_equal#

template<typename T>
bool ioh::common::is_equal(const std::vector<T> &x, const std::vector<T> &y)#

Checks if two vectors are equal.

Parameters:
  • x – vector to be checked

  • y – vector to be checked

Returns:

true if all elements of x == y

keys#

template<typename K, typename V>
std::vector<K> ioh::common::keys(const std::map<K, V> &m)#

Retrieve the keys from a map.

ltrim#

inline void ioh::common::ltrim(std::string &s)#

trim leading whitespace (in place)

Parameters:

s – the string to trim

print#

template<typename Iterator>
void ioh::common::print(const Iterator x, const std::string &del = " ")#

Helper to print the contents of iterator to stdout.

Template Parameters:

Iterator

Parameters:
  • x – the iterators to print, for example a std::vector

  • del – the delimeter between each element

range#

inline std::vector<int> ioh::common::range(const int start, const int stop, const int step = 1)#

Returns a range of integers.

Parameters:
  • start – start of the range

  • stop – end of the range

  • step – stepsize of the range

Returns:

a vector filled with numbers

rtrim#

inline void ioh::common::rtrim(std::string &s)#

trim from end (in place)

Parameters:

s – the string to trim

sort_colwise#

template<typename T>
std::vector<std::vector<T>> ioh::common::sort_colwise(const std::vector<std::vector<T>> &vect)#

Sort a 2D vector colwise (copy), assumes constant length rows.

Template Parameters:

T – the type of the vector elements

Parameters:

vect – the vector to be sorted

Returns:

std::vector<std::vector<T>> a copy of the vector with each column sorted

to_matrix#

Warning

doxygenfunction: Unable to resolve function “ioh::common::to_matrix” with arguments None in doxygen xml output for project “iohcpp” from directory: ../../build/xml/. Potential matches:

- template<typename T> std::vector<std::vector<T>> to_matrix(const std::vector<T> &v)
- template<typename T> std::vector<std::vector<T>> to_matrix(const std::vector<T> &v, const size_t n, const size_t m)

trim#

inline void ioh::common::trim(std::string &s)#

trim from both ends (in pla0ce)

Parameters:

s – the string to trim

type_name#

template<typename T>
std::string ioh::common::type_name()#

Get the type name of a given template T.

Template Parameters:

T – a type

Returns:

the name of T

values#

template<typename K, typename V>
std::vector<V> ioh::common::values(const std::map<K, V> &m)#

Retrieve the values from a map.