OPTK  0.1.2
Toolkit for global optimisation algorithms
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sspace::categorical< T > Class Template Reference

#include <types.hpp>

Inheritance diagram for sspace::categorical< T >:
sspace::param_t

Public Member Functions

 categorical (std::string n, std::vector< int > *options)
 
 categorical (std::string n, std::vector< double > *options)
 
 categorical (std::string n, std::vector< std::string > *options)
 
std::vector< T > * values ()
 
long unsigned int count ()
 
get (long unsigned int i)
 
sample ()
 
- Public Member Functions inherited from sspace::param_t
 param_t (std::string n, pt t)
 
virtual ~param_t ()
 
virtual pt get_type ()
 
virtual std::string get_name ()
 

Private Member Functions

void init_rand ()
 

Private Attributes

std::vector< T > m_options
 
std::random_device rd
 
std::mt19937 generator
 
std::uniform_int_distribution< int > dist
 

Detailed Description

template<typename T>
class sspace::categorical< T >

A class to represent the choice between a finite list of static values.

Common choices of value types include integers, double-precision floating point numbers, as well as strings. These are all used to model categorical paramteters.

This type also serves to terminate the recursion for a choice type (see below).

Constructor & Destructor Documentation

◆ categorical() [1/3]

template<typename T >
sspace::categorical< T >::categorical ( std::string  n,
std::vector< int > *  options 
)
inline

Constructor for integer-valued categorical parameter.

Parameters
nthe parameter's name
optionsan array of doubles (passed by value)

◆ categorical() [2/3]

template<typename T >
sspace::categorical< T >::categorical ( std::string  n,
std::vector< double > *  options 
)
inline

Constructor for double-valued categorical parameter.

Parameters
nthe parameter's name
optionsan array of doubles (passed by value)

◆ categorical() [3/3]

template<typename T >
sspace::categorical< T >::categorical ( std::string  n,
std::vector< std::string > *  options 
)
inline

Constructor for string-valued categorical parameter.

Parameters
nthe parameter's name
optionsan array of doubles (passed by value)

Member Function Documentation

◆ count()

template<typename T >
long unsigned int sspace::categorical< T >::count ( )
inline

Counts the number of options.

◆ get()

template<typename T >
T sspace::categorical< T >::get ( long unsigned int  i)
inline

Retreives the value of the ith element

Parameters
ithe index of the option
Returns
The ith option
Exceptions
std::range_error

◆ init_rand()

template<typename T >
void sspace::categorical< T >::init_rand ( )
inlineprivate

Called from constructors; initialises the random number generator.

◆ sample()

template<typename T >
T sspace::categorical< T >::sample ( )
inline

Sample a random value uniformly at random from the list of values.

◆ values()

template<typename T >
std::vector<T>* sspace::categorical< T >::values ( )
inline

values


The documentation for this class was generated from the following file: