31 m_node_name=node_name;
39 m_node_name=node_name;
44 void CModelSelectionParameters::init()
69 SG_ERROR(
"not possible to append child: there already is a range\n")
77 if (child->m_node_name)
81 SG_ERROR(
"Not possible to add child, node with CSGObject \"%s\"" 82 " does not contain a parameter called \"%s\"\n",
83 m_sgobject->
get_name(), child->m_node_name);
88 SG_ERROR(
"Not possible to add child which has no name.\n")
107 m_vector_length = size;
120 ERangeType type, int32_t step, int32_t type_base)
131 m_vector_length = size;
136 ERangeType type,
void* vector, int32_t step, int32_t type_base)
148 SG_ERROR(
"unable to set range for an CSGObject model selection " 156 m_value_type=value_type;
170 m_values_length=values.
vlen;
181 *((int32_t*)type_base));
184 m_values_length=values.
vlen;
188 SG_ERROR(
"Value node has no type!\n")
192 SG_ERROR(
"Unknown type for model selection parameter!\n")
211 switch (m_value_type)
221 (*param_vect)[j] = ((
float64_t*)m_values)[i];
223 p->
add(param_vect, m_node_name);
230 for (
index_t j = 0; j < *m_vector_length; j++)
234 (param_vect)[j] = ((
float64_t*)m_values)[i];
236 p->
add_vector(¶m_vect, m_vector_length, m_node_name);
247 (*param_vect)[j] = ((int32_t*)m_values)[i];
249 p->
add(param_vect, m_node_name);
254 int32_t* param_vect = (int32_t*)m_vector;
256 for (
index_t j = 0; j < *m_vector_length; j++)
260 (param_vect)[j] = ((int32_t*)m_values)[i];
262 p->
add_vector(¶m_vect, m_vector_length, m_node_name);
269 p->
add(&((int32_t*)m_values)[i], m_node_name);;
272 SG_ERROR(
"Value node has no type!\n")
275 SG_ERROR(
"Unknown type for model selection parameter!\n")
285 if (!((m_sgobject && m_node_name) || (!m_node_name && !m_sgobject)))
286 SG_ERROR(
"Illegal CModelSelectionParameters node type.\n")
295 p->
add(&m_sgobject, m_node_name);
324 p->
add(&m_sgobject, m_node_name);
342 char* prefix=SG_MALLOC(
char, num_prefix+1);
343 prefix[num_prefix]=
'\0';
344 for (
index_t i=0; i<num_prefix; ++i)
347 SG_DEBUG(
"%s------>entering CModelSelectionParameters::get_combinations() " 348 "for \"%s\"\n", prefix, m_node_name ? m_node_name :
"root");
357 for (
index_t i=0; i<m_values_length; ++i)
362 switch (m_value_type)
368 p->
add(&((int32_t*)m_values)[i], m_node_name);;
371 SG_ERROR(
"%sValue node has no type!\n", prefix)
374 SG_ERROR(
"%sUnknown type for model selection parameter!\n",
382 SG_DEBUG(
"%s------>leaving CModelSelectionParameters::get_combinations()" 383 "for \"%s\"\n", prefix, m_node_name ? m_node_name :
"root");
396 if (!((m_sgobject && m_node_name) || (!m_node_name && !m_sgobject)))
397 SG_ERROR(
"%sIllegal CModelSelectionParameters node type.\n", prefix)
412 if (current->m_values)
439 p->
add(&m_sgobject, m_node_name);
454 *result=*value_combinations;
502 p->
add(&m_sgobject, m_node_name);
510 non_value_combinations, new_root);
515 non_value_combinations=non_value_products;
534 p->
add(&m_sgobject, m_node_name);
542 non_value_combinations, new_root);
547 non_value_combinations=non_value_products;
567 value_copy->
merge_with(current_non_value_tree);
591 p->
add(&m_sgobject, m_node_name);
606 SG_DEBUG(
"%s------>leaving CModelSelectionParameters::get_combinations()" 607 "for \"%s\"\n", prefix, m_node_name ? m_node_name :
"root");
615 char* prefix=SG_MALLOC(
char, prefix_num+1);
616 for (
index_t i=0; i<prefix_num; ++i)
619 prefix[prefix_num]=
'\0';
626 SG_PRINT(
"%s%s with\n", prefix, m_node_name ? m_node_name :
"root")
652 SG_PRINT(
"%s%s with values: ", prefix, m_node_name)
654 switch (m_value_type)
669 SG_ERROR(
"Value node has no type!\n")
672 SG_ERROR(
"Unknown type for model selection parameter!\n")
684 void CModelSelectionParameters::delete_values()
688 switch (m_value_type)
698 SG_FREE((int32_t*)m_values);
701 SG_ERROR(
"Value node has no type!\n")
704 SG_ERROR(
"Unknown type for model selection parameter!\n")
virtual const char * get_name() const =0
bool has_children() const
~CModelSelectionParameters()
CSGObject * get_element(int32_t index) const
CModelSelectionParameters()
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 merge_with(CParameterCombination *node)
void print_tree(int prefix_num=0)
void append_child(CParameterCombination *child)
void build_values_vector(float64_t min, float64_t max, ERangeType type, void *vector, index_t *size, float64_t step=1.0, float64_t type_base=2.0)
void build_values(float64_t min, float64_t max, ERangeType type, float64_t step=1.0, float64_t type_base=2.0)
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
int32_t get_num_elements() const
Class that holds ONE combination of parameters for a learning machine. The structure is organized as ...
CParameterCombination * copy_tree() const
CParameterCombination * get_single_combination(bool rand=true)
void build_values_sgvector(float64_t min, float64_t max, ERangeType type, void *vector, float64_t step=1.0, float64_t type_base=2.0)
bool contains_parameter(const char *name)
void add_vector(bool **param, index_t *length, const char *name, const char *description="")
all of classes and functions are contained in the shogun namespace
CDynamicObjectArray * get_combinations(index_t prefix_num=1)
T max(const Container< T > &a)
void append_child(CModelSelectionParameters *child)
static CDynamicObjectArray * non_value_tree_multiplication(const CDynamicObjectArray *sets, const CParameterCombination *new_root)
bool append_element(CSGObject *e)
static CDynamicObjectArray * leaf_sets_multiplication(const CDynamicObjectArray &sets, const CParameterCombination *new_root)
void display_vector(const char *name="vector", const char *prefix="") const