SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParameterCombination.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011-2012 Heiko Strathmann
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
11 #ifndef __PARAMETERCOMBINATION_H__
12 #define __PARAMETERCOMBINATION_H__
13 
15 
16 namespace shogun
17 {
18 
19 class CModelSelectionParameters;
20 class CMachine;
21 class Parameter;
22 
43 {
44 
46 
47 public:
50 
56  void print_tree(int prefix_num=0) const;
57 
60 
63  virtual ~CParameterCombination();
64 
71  void apply_to_modsel_parameter(Parameter* parameter) const;
72 
78  void apply_to_machine(CMachine* machine) const;
79 
85 
91 
99 
113  const CDynamicObjectArray& sets,
114  const CParameterCombination* new_root);
115 
125  template <typename T>
126  bool set_parameter(const char* name,
127  T value, CSGObject* parent, index_t index = -1)
128  {
129  bool match = false;
130 
131  if (m_param)
132  {
133  for (index_t i = 0; i < m_param->get_num_parameters(); ++i)
134  {
135  void* param = m_param->get_parameter(i)->m_parameter;
136 
138  ==PT_SGOBJECT)
139  {
140  if (parent == (*((CSGObject**)param)))
141  match = true;
142  }
143 
144  }
145 
146  }
147 
148  bool result = false;
149 
150  for (index_t i = 0; i < m_child_nodes->get_num_elements(); ++i)
151  {
154 
155  if (!match)
156  result |= child->set_parameter(name, value, parent, index);
157 
158  else
159  result |= child->set_parameter_helper(name, value, index);
160 
161  SG_UNREF(child);
162 
163  }
164 
165  return result;
166  }
167 
175  TParameter* get_parameter(const char* name, CSGObject* parent);
176 
181  bool has_children() const
182  {
183  return m_child_nodes->get_num_elements()>0;
184  }
185 
194  const DynArray<Parameter*>& set_1,
195  const DynArray<Parameter*>& set_2);
196 
198  inline virtual const char* get_name() const
199  {
200  return "ParameterCombination";
201  }
202 
203 protected:
215  const CDynamicObjectArray* sets,
216  const CParameterCombination* new_root);
217 
227  const CDynamicObjectArray* sets, const char* desired_name);
228 
234  TParameter* get_parameter_helper(const char* name);
235 
244  bool set_parameter_helper(const char* name, bool value, index_t index);
245 
254  bool set_parameter_helper(const char* name, int32_t value, index_t index);
255 
264  bool set_parameter_helper(const char* name, float64_t value, index_t index);
265 
266 private:
267  void init();
268 
269 protected:
270 
273 
276 };
277 }
278 
279 #endif /* __PARAMETERCOMBINATION_H__ */

SHOGUN Machine Learning Toolbox - Documentation