66 else if (type.
m_ctype==CT_SCALAR)
72 m_parameters_length++;
76 SG_WARNING(
"Parameter %s.%s was not added to parameter combination, "
77 "since it isn't a type currently supported\n", obj->
get_name(),
83 SG_WARNING(
"Parameter %s.%s was not added to parameter combination, "
84 "since it isn't of floating point type\n", obj->
get_name(),
110 m_child_nodes->append_element(comb);
122 void CParameterCombination::init()
124 m_parameters_length=0;
129 SG_ADD((
CSGObject**)&m_child_nodes,
"child_nodes",
"Children of this node",
141 m_child_nodes->append_element(child);
145 const char* name,
bool value,
index_t index)
149 for (
index_t i = 0; i < m_param->get_num_parameters(); ++i)
151 void* param = m_param->get_parameter(i)->m_parameter;
153 if (!strcmp(m_param->get_parameter(i)->m_name, name))
155 if (m_param->get_parameter(i)->m_datatype.m_ptype
157 SG_ERROR(
"Parameter %s not a boolean parameter", name)
160 *((
bool*)(param)) = value;
163 (*((
bool**)(param)))[index] = value;
175 const char* name, int32_t value,
index_t index)
179 for (
index_t i = 0; i < m_param->get_num_parameters(); ++i)
181 void* param = m_param->get_parameter(i)->m_parameter;
183 if (!strcmp(m_param->get_parameter(i)->m_name, name))
185 if (m_param->get_parameter(i)->m_datatype.m_ptype
187 SG_ERROR(
"Parameter %s not a integer parameter", name)
190 *((int32_t*)(param)) = value;
193 (*((int32_t**)(param)))[index] = value;
208 for (
index_t i = 0; i < m_param->get_num_parameters(); ++i)
210 void* param = m_param->get_parameter(i)->m_parameter;
212 if (!strcmp(m_param->get_parameter(i)->m_name, name))
214 if (m_param->get_parameter(i)->m_datatype.m_ptype
216 SG_ERROR(
"Parameter %s not a double parameter", name)
222 (*((
float64_t**)(param)))[index] = value;
238 for (
index_t i = 0; i < m_param->get_num_parameters(); i++)
240 if (!strcmp(m_param->get_parameter(i)->m_name, name))
241 return m_param->get_parameter(i);
257 for (
index_t i = 0; i < m_param->get_num_parameters(); i++)
259 if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_SGOBJECT)
262 (*((
CSGObject**)m_param->get_parameter(i)->m_parameter));
270 for (
index_t i = 0; i < m_child_nodes->get_num_elements(); ++i)
273 m_child_nodes->get_element(i);
310 char* prefix=SG_MALLOC(
char, prefix_num+1);
311 for (
index_t i=0; i<prefix_num; ++i)
314 prefix[prefix_num]=
'\0';
324 for (
index_t i=0; i<m_param->get_num_parameters(); ++i)
326 EContainerType ctype = m_param->get_parameter(i)->m_datatype.m_ctype;
329 if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_SGOBJECT)
334 current_sgobject->
get_name(), current_sgobject);
336 else if (ctype==CT_SGVECTOR || ctype==CT_VECTOR || ctype==CT_SGMATRIX || ctype==CT_MATRIX)
338 SG_SPRINT(
"\"%s\"=", m_param->get_parameter(i)->m_name)
340 get_parameter(i)->m_parameter);
342 index_t length = m_param->get_parameter(i)->m_datatype.get_num_elements();
344 for (
index_t j = 0; j < length; j++)
350 SG_SPRINT(
"\"%s\"=", m_param->get_parameter(i)->m_name)
351 void* param=m_param->get_parameter(i)->m_parameter;
353 if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_FLOAT64)
355 else if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_INT32)
357 else if (m_param->get_parameter(i)->m_datatype.m_ptype==PT_BOOL)
358 SG_SPRINT(
"%s ", *((
bool*)param ?
"true" :
"false"))
371 for (
index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
374 m_child_nodes->get_element(i);
385 SG_SDEBUG(
"entering CParameterCombination::parameter_set_multiplication()\n")
410 result->append_element(p);
414 SG_SDEBUG(
"leaving CParameterCombination::parameter_set_multiplication()\n")
431 *result=*current_set;
467 SG_SERROR(
"leaf sets multiplication only possible if all "
477 SG_SERROR(
"leaf sets multiplication only possible if all "
478 "leafs have non-NULL Parameter instances\n");
489 *param_sets[0], *param_sets[1]);
491 delete param_sets[0];
492 delete param_sets[1];
499 param_product=parameter_set_multiplication(*param_product,
507 delete old_temp_result;
508 delete param_sets[i];
533 delete param_product;
543 SG_SDEBUG(
"entering CParameterCombination::non_value_tree_multiplication()\n")
547 std::set<string> names;
571 for (std::set<string>::iterator it=names.begin(); it!=names.end(); ++it)
583 const char* first_name=(*(names.begin())).c_str();
587 SG_SDEBUG(
"adding trees for first name \"%s\":\n", first_name)
603 SG_SDEBUG(
"building products with remaining trees:\n")
604 std::set<string>::iterator it=names.begin();
605 for (++it; it!=names.end(); ++it)
607 SG_SDEBUG(
"processing \"%s\"\n", (*it).c_str())
610 const char* current_name=(*it).c_str();
647 SG_SDEBUG(
"leaving CParameterCombination::non_value_tree_multiplication()\n")
669 if (!strcmp(current_name, desired_name))
696 for (
index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
699 m_child_nodes->get_element(i);
721 for (
index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
724 m_child_nodes->get_element(i);
740 if (m_param->get_num_parameters()>1 ||
741 m_param->get_parameter(0)->m_datatype.m_ptype!=PT_SGOBJECT)
743 SG_SERROR(
"invalid CParameterCombination node type, has children"
744 " and more than one parameter or is not a "
750 *((
CSGObject**)(m_param->get_parameter(0)->m_parameter));
754 for (
index_t i=0; i<m_child_nodes->get_num_elements(); ++i)
757 m_child_nodes->get_element(i);
765 SG_SERROR(
"CParameterCombination node has illegal type.\n")
773 for (
index_t i=0; i<m_param->get_num_parameters(); i++)
786 dict->
add(param, value);
788 else if (type.
m_ctype==CT_SCALAR)
792 dict->add(param, value);
798 for (
index_t i=0; i<m_child_nodes->get_num_elements(); i++)
801 m_child_nodes->get_element(i);
814 for (
index_t i=0; i<m_param->get_num_parameters(); i++)
834 for (
index_t i=0; i<m_child_nodes->get_num_elements(); i++)
837 m_child_nodes->get_element(i);
857 dict->
add(param, parent);
virtual const char * get_name() const =0
T get_element(int32_t index) const
bool append_element(T element)
virtual int32_t get_num_parameters()
void apply_to_modsel_parameter(Parameter *parameter) const
TParameter * get_parameter(const char *name, CSGObject *parent)
TParameter * get_parameter(int32_t idx)
#define SG_NOTIMPLEMENTED
int64_t get_num_elements()
int32_t get_num_elements() const
void print_tree(int prefix_num=0) const
int32_t get_num_elements() const
CParameterCombination * copy_tree() const
bool set_element(CSGObject *e, int32_t idx1, int32_t idx2=0, int32_t idx3=0)
Datatypes that shogun supports.
A generic learning machine interface.
uint32_t m_parameters_length
int32_t add(const K &key, const T &data)
void add(bool *param, const char *name, const char *description="")
CDynamicObjectArray * m_child_nodes
Class SGObject is the base class of all shogun objects.
void merge_with(CParameterCombination *node)
Template Dynamic array class that creates an array that can be used like a list or an array...
static CDynamicObjectArray * extract_trees_with_name(const CDynamicObjectArray *sets, const char *desired_name)
void append_child(CParameterCombination *child)
bool set_parameter_helper(const char *name, bool value, index_t index)
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 ...
Parameter * m_model_selection_parameters
virtual void build_parameter_parent_map(CMap< TParameter *, CSGObject * > *parent_map)
void set_from_parameters(Parameter *params)
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
TParameter * get_parameter_helper(const char *name)
void add_parameters(Parameter *params)
CSGObject * get_element(int32_t index) const
virtual void build_parameter_values_map(CMap< TParameter *, SGVector< float64_t > > *values_map)
virtual ~CParameterCombination()
Parameter * m_gradient_parameters
void apply_to_machine(CMachine *machine) const
static CDynamicObjectArray * non_value_tree_multiplication(const CDynamicObjectArray *sets, const CParameterCombination *new_root)
void add_matrix(bool **param, index_t *length_y, index_t *length_x, const char *name, const char *description="")
static DynArray< Parameter * > * parameter_set_multiplication(const DynArray< Parameter * > &set_1, const DynArray< Parameter * > &set_2)
void set_const(T const_elem)
void add(const SGVector< T > x)
bool append_element(CSGObject *e)
the class CMap, a map based on the hash-table. w: http://en.wikipedia.org/wiki/Hash_table ...
static CDynamicObjectArray * leaf_sets_multiplication(const CDynamicObjectArray &sets, const CParameterCombination *new_root)