OPTK  0.1.2
Toolkit for global optimisation algorithms
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
types.hpp File Reference

Defines the main types used in the program. More...

#include <cstdlib>
#include <cmath>
#include <memory>
#include <random>
#include <stdexcept>
#include <string>
#include <tuple>
#include <vector>
#include <unordered_map>
#include <sys/types.h>

Go to the source code of this file.

Classes

struct  optk::ctx_t
 
class  inst::param
 
class  inst::int_val
 
class  inst::dbl_val
 
class  inst::str_val
 
class  inst::node
 
class  sspace::param_t
 
class  sspace::categorical< T >
 
class  sspace::choice
 
class  sspace::randint
 
class  sspace::uniform
 
class  sspace::quniform
 
class  sspace::loguniform
 
class  sspace::qloguniform
 
class  sspace::normal
 
class  sspace::qnormal
 
class  sspace::lognormal
 
class  sspace::qlognormal
 

Namespaces

 inst
 

Macros

#define GETINT(dest, src, key)   inst::int_val *dest = static_cast<inst::int_val *>((src)->get_item (key))
 
#define GETDBL(dest, src, key)   inst::dbl_val *dest = static_cast<inst::dbl_val *>((src)->get_item (key))
 
#define GETSTR(dest, src, key)   inst::str_val *dest = static_cast<inst::str_val *>((src)->get_item (key))
 
#define GETNODE(dest, src, key)   inst::node *dest = static_cast<inst::node *>((src)->get_item (key))
 

Typedefs

typedef node * inst::set
 
typedef std::unordered_map< std::string, param * > inst::value_map
 
typedef std::vector< param_t * > sspace::sspace_t
 

Enumerations

enum  inst::inst_t : char { inst::inst_t::node, inst::inst_t::int_val, inst::inst_t::dbl_val, inst::inst_t::str_val }
 
enum  pt : char {
  pt::categorical_int, pt::categorical_dbl, pt::categorical_str, pt::choice,
  pt::randint, pt::uniform, pt::quniform, pt::loguniform,
  pt::qloguniform, pt::normal, pt::qnormal, pt::lognormal,
  pt::qlognormal
}
 

Functions

template<class T >
inst::get (node *n, const std::string &k)
 
void inst::free_node (node *n)
 
void sspace::validate_param_values (inst::value_map *vals, sspace::sspace_t *sspace)
 
void sspace::free_ss (sspace_t *ss)
 

Detailed Description

Defines the main types used in the program.

Copyright (C) 2020 Maxime Robeyns maxim.nosp@m.erob.nosp@m.eyns@.nosp@m.gmai.nosp@m.l.com

Written for the ACRC, University of Bristol

Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.osedu.org/licenses/ECL-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the LIcense For The Specific Language Governing permissions and limitations under the License.

Todo:
defer the problem of turning categorical parameters of strings and enumerating them to the compatability layer which allows problems defined in python to be run on the optimisers from OPTK. This is the component which will be responsible for mapping numeric values to their non-numeric counterparts which the python program needs to evaluate.

Typedef Documentation

◆ sspace_t

typedef std::vector<param_t *> sspace::sspace_t

sspace_t represents the search space or parameter space in which the parameters must be optimised.

Enumeration Type Documentation

◆ pt

enum pt : char
strong

pt ('param type') enumerates the types available for defining a parameter space, and is compatible with NNI.

Enumerator
categorical_int 

Represents a choice between a finite list of integer values. See optk::categorical.

categorical_dbl 

Represents a choice between a finite list of double values. See optk::categorical.

categorical_str 

Represents a choice between a finite list of string values. See optk::categorical.

choice 

A choice between parameters; possibly of different types. Allows for nested search spaces. See optk::choice.

randint 

Random integer sampled within a range. See optk::randint.

uniform 

Real-valued parameter sampled uniformly at random. See optk::uniform.

quniform 

Quantised uniform parameter. See optk::quniform.

loguniform 

Real-valued parameter drawn from a loguniform distribution. See optk::loguniform.

qloguniform 

Quantised log-uniform distribution. See optk::qloguniform.

normal 

Parameter drawn from a Guassian distribution. See optk::normal.

qnormal 

Quantised normal parameter. See optk::qnormal.

lognormal 

Real-valued parameter drawn from a lognormal distribution. See optk::lognormal.

qlognormal 

Quantised log-normal parameter. See optk::qlognormal.

Function Documentation

◆ free_ss()

void sspace::free_ss ( sspace::sspace_t ss)

A convenience method to delete a search space description which was allocated on the heap. This function is often used in class destructors.

Parameters
ssThe heap-allocated search space description to free.

◆ validate_param_values()

void sspace::validate_param_values ( inst::value_map vals,
sspace::sspace_t sspace 
)

This function takes a set of concrete parameters, and the corresponding description of the parameter space, and ensures that each concrete value is a valid instance of the description.

Parameters
valsThe set of concrete values; this usually comes from the optimisation algorithm.
sspaceThe description of the search space
Exceptions
std::invalid_argumentThis is thrown when a discrepency between an instance of a parameter and its description is detected.