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")
102 m_values_length=values.
vlen;
103 m_value_type=value_type;
118 m_vector_length = size;
131 ERangeType type, int32_t step, int32_t type_base)
142 m_vector_length = size;
147 ERangeType type,
void* vector, int32_t step, int32_t type_base)
159 SG_ERROR(
"unable to set range for an CSGObject model selection "
167 m_value_type=value_type;
180 m_values=values.vector;
181 m_values_length=values.vlen;
192 *((int32_t*)type_base));
194 m_values=values.vector;
195 m_values_length=values.vlen;
199 SG_ERROR(
"Value node has no type!\n")
203 SG_ERROR(
"Unknown type for model selection parameter!\n")
222 switch (m_value_type)
232 (*param_vect)[j] = ((
float64_t*)m_values)[i];
234 p->
add(param_vect, m_node_name);
241 for (
index_t j = 0; j < *m_vector_length; j++)
245 (param_vect)[j] = ((
float64_t*)m_values)[i];
247 p->
add_vector(¶m_vect, m_vector_length, m_node_name);
258 (*param_vect)[j] = ((int32_t*)m_values)[i];
260 p->
add(param_vect, m_node_name);
265 int32_t* param_vect = (int32_t*)m_vector;
267 for (
index_t j = 0; j < *m_vector_length; j++)
271 (param_vect)[j] = ((int32_t*)m_values)[i];
273 p->
add_vector(¶m_vect, m_vector_length, m_node_name);
280 p->
add(&((int32_t*)m_values)[i], m_node_name);;
283 SG_ERROR(
"Value node has no type!\n")
286 SG_ERROR(
"Unknown type for model selection parameter!\n")
296 if (!((m_sgobject && m_node_name) || (!m_node_name && !m_sgobject)))
297 SG_ERROR(
"Illegal CModelSelectionParameters node type.\n")
306 p->
add(&m_sgobject, m_node_name);
335 p->
add(&m_sgobject, m_node_name);
353 char* prefix=SG_MALLOC(
char, num_prefix+1);
354 prefix[num_prefix]=
'\0';
355 for (
index_t i=0; i<num_prefix; ++i)
358 SG_DEBUG(
"%s------>entering CModelSelectionParameters::get_combinations() "
359 "for \"%s\"\n", prefix, m_node_name ? m_node_name :
"root");
368 for (
index_t i=0; i<m_values_length; ++i)
373 switch (m_value_type)
379 p->
add(&((int32_t*)m_values)[i], m_node_name);;
382 SG_ERROR(
"%sValue node has no type!\n", prefix)
385 SG_ERROR(
"%sUnknown type for model selection parameter!\n",
393 SG_DEBUG(
"%s------>leaving CModelSelectionParameters::get_combinations()"
394 "for \"%s\"\n", prefix, m_node_name ? m_node_name :
"root");
407 if (!((m_sgobject && m_node_name) || (!m_node_name && !m_sgobject)))
408 SG_ERROR(
"%sIllegal CModelSelectionParameters node type.\n", prefix)
423 if (current->m_values)
450 p->
add(&m_sgobject, m_node_name);
465 *result=*value_combinations;
513 p->
add(&m_sgobject, m_node_name);
521 non_value_combinations, new_root);
526 non_value_combinations=non_value_products;
545 p->
add(&m_sgobject, m_node_name);
553 non_value_combinations, new_root);
558 non_value_combinations=non_value_products;
578 value_copy->
merge_with(current_non_value_tree);
602 p->
add(&m_sgobject, m_node_name);
617 SG_DEBUG(
"%s------>leaving CModelSelectionParameters::get_combinations()"
618 "for \"%s\"\n", prefix, m_node_name ? m_node_name :
"root");
626 char* prefix=SG_MALLOC(
char, prefix_num+1);
627 for (
index_t i=0; i<prefix_num; ++i)
630 prefix[prefix_num]=
'\0';
637 SG_PRINT(
"%s%s with\n", prefix, m_node_name ? m_node_name :
"root")
663 SG_PRINT(
"%s%s with values: ", prefix, m_node_name)
665 switch (m_value_type)
680 SG_ERROR(
"Value node has no type!\n")
683 SG_ERROR(
"Unknown type for model selection parameter!\n")
695 void CModelSelectionParameters::delete_values()
699 switch (m_value_type)
709 SG_FREE((int32_t*)m_values);
712 SG_ERROR(
"Value node has no type!\n")
715 SG_ERROR(
"Unknown type for model selection parameter!\n")
virtual const char * get_name() const =0
~CModelSelectionParameters()
int32_t get_num_elements() const
CParameterCombination * copy_tree() const
CModelSelectionParameters()
Class to select parameters and their ranges for model selection. The structure is organized as a tree...
void display_vector(const char *name="vector", const char *prefix="") const
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 set_values(const SGVector< T > &values, EMSParamType value_type)
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...
Class that holds ONE combination of parameters for a learning machine. The structure is organized as ...
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)
CSGObject * get_element(int32_t index) const
bool has_children() const
Matrix::Scalar max(Matrix m)
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)