OPTK  0.1.2
Toolkit for global optimisation algorithms
gridsearch.hpp
Go to the documentation of this file.
1 
22 #ifndef __GRIDSEARCH_H_
23 #define __GRIDSEARCH_H_
24 
25 #include <unordered_map>
26 #include <vector>
27 #include <tuple>
28 
29 #include <optk/optimiser.hpp>
30 #include <optk/types.hpp>
31 
32 namespace __gs {
33 
34 enum class pspace_t: char {
35  node,
36  int_val,
37  dbl_val,
38  str_val
39 };
40 
41 class param {
42  public:
43  param (const std::string &k, pspace_t t);
44  pspace_t get_type () { return m_type; }
45  std::string get_key () { return m_key; }
46 
47  private:
48  const std::string m_key;
49  const pspace_t m_type;
50 };
51 
52 // classes inheriting __gs::param are declared / defined in the gridsearch.cpp
53 
54 } // end namespace gs
55 
56 class gridsearch: public optk::optimiser {
57 
58  public:
59 
64  gridsearch ();
65 
69  ~gridsearch ();
70 
74  void clear () override;
75 
84  void update_search_space (sspace::sspace_t *space) override;
85 
93  sspace::sspace_t *convert_synthetic_ss (sspace::sspace_t *ss, double q);
94 
107  void update_search_space_s (sspace::sspace_t *space, double q);
108 
114  inst::set generate_parameters (int param_id) override;
115 
124  void receive_trial_results (
125  int param_id, inst::set params, double value
126  ) override;
127 
128 #ifdef __OPTK_TESTING
129  __gs::param *get_root () {
130  return m_root;
131  }
132 #endif
133 
134  private:
138 
140  bool fst_gen;
141 
147  std::vector<sspace::sspace_t *> m_syn_spaces;
148 };
149 
150 #ifdef __OPTK_TESTING
151 #include <assert.h>
152 #include <tests/testutils.hpp>
153 
154 void test_update_search_space();
155 #endif // __OPTK_TESTING
156 
157 #endif // __GRIDSEARCH_H_
__gs::param * m_root
Definition: gridsearch.hpp:137
std::vector< param_t * > sspace_t
Definition: types.hpp:318
Definition: types.hpp:150
std::vector< sspace::sspace_t * > m_syn_spaces
Definition: gridsearch.hpp:147
Some utility functions for running tests.
std::vector< std::tuple< std::string, param * > > params
Definition: gridsearch.cpp:37
Definition: gridsearch.hpp:41
Defines the main types used in the program.
Definition: optimiser.hpp:39
Definition: gridsearch.cpp:27
bool fst_gen
Definition: gridsearch.hpp:140
Definition: gridsearch.hpp:56
This file defines the base class for optimisers.