17 using namespace shogun;
28 m_node_name=node_name;
36 m_node_name=node_name;
41 void CModelSelectionParameters::init()
51 "CSGObject of this node");
53 "children of this node");
70 SG_ERROR(
"not possible to append child: there already is a range\n");
78 if (child->m_node_name)
82 SG_ERROR(
"Not possible to add child, node with CSGObject \"%s\""
83 " does not contain a parameter called \"%s\"\n",
84 m_sgobject->
get_name(), child->m_node_name);
89 SG_ERROR(
"Not possible to add child which has no name.\n");
93 m_child_nodes->append_element(child);
112 ERangeType type, int32_t step, int32_t type_base)
119 void* max,
ERangeType type,
void* step,
void* type_base)
123 SG_ERROR(
"unable to set range for an CSGObject model selection "
131 m_value_type=value_type;
142 m_values.
vector=(
char*)values.vector;
143 m_values.
vlen=values.vlen;
152 *((int32_t*)type_base));
154 m_values.
vector=(
char*)values.vector;
155 m_values.
vlen=values.vlen;
159 SG_ERROR(
"Value node has no type!\n");
163 SG_ERROR(
"Unknown type for model selection parameter!\n");
183 switch (m_value_type)
189 p->
add(&((int32_t*)m_values.
vector)[i], m_node_name);;
192 SG_ERROR(
"Value node has no type!\n");
195 SG_ERROR(
"Unknown type for model selection parameter!\n");
212 if (!((m_sgobject && m_node_name) || (!m_node_name && !m_sgobject)))
213 SG_ERROR(
"Illegal CModelSelectionParameters node type.\n");
216 if (m_child_nodes->get_num_elements())
222 for (
index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
227 if (current->m_values.
vector)
253 p->
add(&m_sgobject, m_node_name);
269 *result=*value_combinations;
276 non_value_combinations;
375 p->
add(&m_sgobject, m_node_name);
386 char* prefix=
SG_MALLOC(
char, prefix_num+1);
387 for (
index_t i=0; i<prefix_num; ++i)
390 prefix[prefix_num]=
'\0';
397 SG_PRINT(
"%s%s with\n", prefix, m_node_name ? m_node_name :
"root");
402 for (
index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
422 SG_PRINT(
"%s%s with values: ", prefix, m_node_name);
424 switch (m_value_type)
433 SG_ERROR(
"Value node has no type!\n");
436 SG_ERROR(
"Unknown type for model selection parameter!\n");
448 void CModelSelectionParameters::delete_values()
452 switch (m_value_type)
461 SG_ERROR(
"Value node has no type!\n");
464 SG_ERROR(
"Unknown type for model selection parameter!\n");
virtual const char * get_name() const =0
T * get_element(int32_t index) const
void set_values(SGVector< T > values)
~CModelSelectionParameters()
int32_t get_num_elements() const
CParameterCombination * copy_tree() const
CModelSelectionParameters()
CDynamicObjectArray< CParameterCombination > * get_combinations()
Class to select parameters and their ranges for model selection. The structure is organized as a tree...
void add(bool *param, const char *name, const char *description="")
Class SGObject is the base class of all shogun objects.
void print_tree(int prefix_num=0)
void append_child(CParameterCombination *child)
void build_values(float64_t min, float64_t max, ERangeType type, float64_t step=1.0, float64_t type_base=2.0)
static void display_vector(const T *vector, int32_t n, const char *name="vector")
display vector (useful for debugging)
Template Dynamic array class that creates an array that can be used like a list or an array...
class that holds ONE combination of parameters for a learning machine. The structure is organized as ...
bool contains_parameter(const char *name)
bool has_children() const
bool append_element(T *element)
static CDynamicObjectArray< CParameterCombination > * leaf_sets_multiplication(const CDynamicObjectArray< CDynamicObjectArray< CParameterCombination > > &sets, const CParameterCombination *new_root)
void append_child(CModelSelectionParameters *child)
#define SG_MALLOC(type, len)