data

Namespaces

Structs

data_error

struct data_error : public std::runtime_error

The data directory or a data file is missing.

ManifestEntry

struct ManifestEntry

A registry entry defined by data, from the manifest (static/manifest.json) the library is built with.

Public Members

int id

The id in the registry.

std::string name

The name in the registry.

std::string meta_name

The name the problem reports (for the CEC2013 problems it differs from the registry name)

std::string problem_class

The class of a graph problem: MaxCut, MaxCoverage, MaxInfluence or PackWhileTravel.

std::string definition

The definition of a graph problem’s graph (its files)

Functions

cached

template<typename T, typename Loader>
std::shared_ptr<const T> ioh::data::cached(const std::string &key, Loader &&loader)

The value that loader returns for key, loaded once and shared: the first call with a key calls loader (once, also when several threads ask at the same time), later calls get the same object.

If loader throws, the next call tries again. The values of each type T are kept until the program ends.

Parameters:
  • key – the key, e.g. the path of a data file (see file)

  • loader – the function that loads the value

data_version

std::string ioh::data::data_version()

The data version the library is built with, which the manifest.json of the data directory must have.

file

fs::path ioh::data::file(const fs::path &relative)

The path of a data file.

Throws data_error when it does not exist, when the data directory does not have the data version of the library (see data_version), or see root.

Parameters:

relative – the path of the file relative to the data directory

in_manifest

bool ioh::data::in_manifest(const fs::path &relative)

Whether the manifest lists a data file.

manifest_entries

std::vector<ManifestEntry> ioh::data::manifest_entries(const std::string &family)

The entries of a problem family in the manifest: GraphProblem or CEC2013.

root

fs::path ioh::data::root()

The data directory: the one given to set_root, otherwise the IOH_RESOURCES environment variable, otherwise the first existing of the build’s defaults: the static folder of the source tree it was built from, and share/ioh of its installation (the Python package sets its own).

Throws data_error, saying where it looked and how to set it, when the directory given by set_root or IOH_RESOURCES does not exist, or none is set and no default exists.

set_root

void ioh::data::set_root(const fs::path &path)

Sets the data directory, which comes before the IOH_RESOURCES environment variable and the defaults of the build (see root).

An empty path unsets it.

Parameters:

path – the data directory