SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
modelselection
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
14
#include <
shogun/lib/DynamicObjectArray.h
>
15
16
namespace
shogun
17
{
18
19
class
CModelSelectionParameters;
20
class
CMachine;
21
class
Parameter;
22
42
class
CParameterCombination
:
public
CSGObject
43
{
44
45
friend
class
CModelSelectionParameters
;
46
47
public
:
49
CParameterCombination
();
50
56
void
print_tree
(
int
prefix_num=0)
const
;
57
59
CParameterCombination
(
Parameter
* param);
60
63
virtual
~CParameterCombination
();
64
71
void
apply_to_modsel_parameter
(
Parameter
* parameter)
const
;
72
78
void
apply_to_machine
(
CMachine
* machine)
const
;
79
84
void
append_child
(
CParameterCombination
* child);
85
90
void
merge_with
(
CParameterCombination
*
node
);
91
98
CParameterCombination
*
copy_tree
()
const
;
99
112
static
CDynamicObjectArray
*
leaf_sets_multiplication
(
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
137
if
(
m_param
->
get_parameter
(i)->
m_datatype
.
m_ptype
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
{
152
CParameterCombination
* child = (
CParameterCombination
*)
153
m_child_nodes
->
get_element
(i);
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
193
static
DynArray<Parameter*>
*
parameter_set_multiplication
(
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
:
214
static
CDynamicObjectArray
*
non_value_tree_multiplication
(
215
const
CDynamicObjectArray
* sets,
216
const
CParameterCombination
* new_root);
217
226
static
CDynamicObjectArray
*
extract_trees_with_name
(
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
272
Parameter
*
m_param
;
273
275
CDynamicObjectArray
*
m_child_nodes
;
276
};
277
}
278
279
#endif
/* __PARAMETERCOMBINATION_H__ */
SHOGUN
Machine Learning Toolbox - Documentation