/usr/include/shogun/modelselection/ParameterCombination.h is in libshogun-dev 1.1.0-4ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2011 Heiko Strathmann
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/
#ifndef __PARAMETERCOMBINATION_H__
#define __PARAMETERCOMBINATION_H__
#include <shogun/lib/DynamicObjectArray.h>
namespace shogun
{
class CModelSelectionParameters;
class CMachine;
class Parameter;
/**
* @brief class that holds ONE combination of parameters for a learning machine.
* The structure is organized as a tree. Every node may hold a name or an
* instance of a Parameter class. Nodes may have children. The nodes are
* organized in such way, that every parameter of a model for model selection
* has one node and sub-parameters are stored in sub-nodes. Using a tree of this
* class, parameters of models may easily be set.
* There are these types of nodes:
*
* -root node: no name and no Parameter instance, every tree has such a node as
* root. Has children.
*
* -Parameter node: a node with no name and an instance of Parameter, filled
* with one or more values. There may be different elements in these Parameter
* instances. Parameter nodes may have children with sub-parameters.
*
* Again: Leafs of the tree may only be Parameter nodes.
*
*/
class CParameterCombination : public CSGObject
{
friend class CModelSelectionParameters;
public:
/** constructor for a root node */
CParameterCombination();
/** Prints a representation of the current node
*
* @param prefix_num number of tabs that will be prefixed for every output.
* At each recursion level, one is added.
*/
void print_tree(int prefix_num=0) const;
/** constructor for a Parameter node */
CParameterCombination(Parameter* param);
/** destructor
* also recursively destroys complete tree (SG_UNREF of child nodes) */
virtual ~CParameterCombination();
/** applies this parameter tree to a parameter instance
* Recursively iterates over all children of the tree and sets model
* selection parameters of children to sub-parameters
*
* @param parameter Parameter instance to apply parameter tree to
*/
void apply_to_modsel_parameter(Parameter* parameter) const;
/**applies this parameter tree to a learning machine
* (wrapper for apply_to_modesel_parameter() method)
*
* @param machine learning machine to apply parameter tree to
*/
void apply_to_machine(CMachine* machine) const;
/** appends a child to this node
*
* @param child child to append
*/
void append_child(CParameterCombination* child);
/** Copies the complete tree of this node. Note that nodes are actually
* copied. If this is a parameter node, a NEW Parameter instance to the same
* data is created in the copy
*
* @return copy of the tree with this node as root as described above
*/
CParameterCombination* copy_tree() const;
/** Takes a set of sets of leafs nodes (!) and produces a set of instances
* of this class that contain every combination of the parameters in the leaf
* nodes in their Parameter variables. All combinations are put into a newly
* created tree. The root of this tree will be a copy of a specified node
*
* created Parameter instances are added to the result set.
*
* @param sets Set of sets of leafs to combine
* @param new_root root node that is copied and put as root into all result
* trees
* @result result set of tree combinations
*/
static CDynamicObjectArray<CParameterCombination>* leaf_sets_multiplication(
const CDynamicObjectArray<CDynamicObjectArray<CParameterCombination> >& sets,
const CParameterCombination* new_root);
/** checks whether this node has children
*
* @return true if node has children
*/
bool has_children() const
{
return m_child_nodes->get_num_elements()>0;
}
/** Returns a newly created array with pointers to newly created Parameter
* instances, which contain all combinations of the provided Parameters.
*
* @param set_1 array of Parameter instances
* @param set_2 array of Parameter instances
* @return result array with all combinations
*/
static DynArray<Parameter*>* parameter_set_multiplication(
const DynArray<Parameter*>& set_1,
const DynArray<Parameter*>& set_2);
/** @return name of the SGSerializable */
inline virtual const char* get_name() const
{
return "ParameterCombination";
}
private:
void init();
private:
Parameter* m_param;
CDynamicObjectArray<CParameterCombination>* m_child_nodes;
};
}
#endif /* __PARAMETERCOMBINATION_H__ */
|