OPTK  0.1.2
Toolkit for global optimisation algorithms
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
optk::optimiser Class Reference

#include <optimiser.hpp>

Inheritance diagram for optk::optimiser:
gp_opt gridsearch random_search

Public Member Functions

 optimiser (std::string name)
 
 ~optimiser ()
 
virtual void clear ()
 
std::string get_name ()
 
virtual void update_search_space (sspace::sspace_t *space)
 
virtual inst::set generate_parameters (int param_id)
 
virtual void receive_trial_results (int param_id, inst::set params, double value)
 
void accept (optimisers *o)
 

Protected Member Functions

void add_to_trials (int param_id, inst::node *n)
 

Protected Attributes

std::unordered_map< int, inst::settrials
 

Private Attributes

std::string m_name
 
uint stepidx
 
double best_val
 
inst::setbest_params
 

Detailed Description

This is the base class that every optimisation algorithm will inherit.

Constructor & Destructor Documentation

◆ optimiser()

optk::optimiser::optimiser ( std::string  name)

The constructor

Parameters
nameThe identifiying name of this optimisation algorithm.

◆ ~optimiser()

optk::optimiser::~optimiser ( )

The destructor will free any generated parameter instances not freed by explicit calls to receive_trial_results.

Member Function Documentation

◆ accept()

void optk::optimiser::accept ( optimisers o)

Uses the visitor pattern to register an optimiser with the optimisers class.

Parameters
oA pointer to the optimisers class with which to register this optimiser.
Todo:
is this method necessary?

◆ add_to_trials()

void optk::optimiser::add_to_trials ( int  param_id,
inst::node n 
)
protected

This will add a parameter configuration allocated on the heap to the optimiser::trials map, so that it may be freed later by the optimiser's destructor. If a trial configuration already exists with the same param_id, those values will be freed, and the value in the map will be replaced.

Parameters
param_idThe identifier for this trial.
nThe root node of the concrete parameter settings.

◆ clear()

void optk::optimiser::clear ( )
virtual

Clears / resets this optimiser. This should be the same as calling the destructor and then the constructor.

Reimplemented in gridsearch.

◆ generate_parameters()

virtual inst::set optk::optimiser::generate_parameters ( int  param_id)
inlinevirtual

This is the method invoked to generate the next trial's parameters for the benchmark or program being optimised.

Parameters
param_idAn identifier for this parameter trial; this may or may not be used by the optimistaion algorithm.
Returns
A pointer to an inst::node, or a NULL pointer if there are no more parameters to return.

Reimplemented in gridsearch, gp_opt, and random_search.

◆ get_name()

std::string optk::optimiser::get_name ( )
inline
Returns
the optimiser's name

◆ receive_trial_results()

virtual void optk::optimiser::receive_trial_results ( int  param_id,
inst::set  params,
double  value 
)
inlinevirtual

Allows the benchmark or program being optimised to communicate back the value of the cost function for a parameter set.

Parameters
param_idThis parameter id is used to identify the parameters used to generate the result.
parametersFor increased flexibility, the actual parameters used to generate the result are also copied back.
valueThe actual value of the objective function.

Reimplemented in gridsearch, gp_opt, and random_search.

◆ update_search_space()

virtual void optk::optimiser::update_search_space ( sspace::sspace_t space)
inlinevirtual

This updates the search space defined by the optimiser.

Parameters
spaceThe new search space to use

Reimplemented in gridsearch, gp_opt, and random_search.

Member Data Documentation

◆ best_params

inst::set* optk::optimiser::best_params
private

The parameters which gave rise to the best_val

◆ best_val

double optk::optimiser::best_val
private

The best found value of the function

◆ m_name

std::string optk::optimiser::m_name
private

The optimisation algorithm's name

◆ stepidx

uint optk::optimiser::stepidx
private

stepidx is used to generate sequential parameter IDs during step

◆ trials

std::unordered_map<int, inst::set> optk::optimiser::trials
protected

This is used to keep track of previously generated instances or settings of the parameters, identified by the parameter id passed to the generate_parameters method. Contains elements stored on the heap.


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