STK++ 0.9.13
STK::KernelMixtureManager Class Reference

A mixture manager is a factory class for injection dependency in the STK++ derived class of the MixtureComposer class. More...

#include <STK_KernelMixtureManager.h>

Inheritance diagram for STK::KernelMixtureManager:
Inheritance graph

Public Types

typedef hidden::MixtureManagerTraits< KernelMixtureManager >::DataHandler DataHandler
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::Type Type
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::Data Data
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::DataBridgeType DataBridgeType
 
typedef IMixtureManager< KernelMixtureManagerBase
 
typedef KmmBridge< Clust::Kmm_sk_, CSquareXKmmBridge_sk
 
typedef KmmBridge< Clust::Kmm_s_, CSquareXKmmBridge_s
 
- Public Types inherited from STK::IMixtureManager< KernelMixtureManager >
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::DataHandler DataHandler
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::Type Type
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::Data Data
 
typedef hidden::MixtureManagerTraits< KernelMixtureManager >::DataBridgeType DataBridgeType
 

Public Member Functions

 KernelMixtureManager (KernelHandler const &handler)
 Default constructor, need an instance of a KernelHandler.
 
 ~KernelMixtureManager ()
 destructor
 
void setDim (IMixture *p_mixture, Real const &dim) const
 set the dimension of the kernel mixture model
 
template<class Vector >
void setDim (IMixture *p_mixture, ExprBase< Vector > const &dim) const
 set the dimension of the kernel mixture model
 
void getParametersImpl (IMixture *p_mixture, ArrayXX &param) const
 get the parameters from an IMixture.
 
void setParametersImpl (IMixture *p_mixture, ArrayXX const &param) const
 set the parameters from an IMixture.
 
IMixturecreateMixtureImpl (String const &modelName, String const &idData, int nbCluster)
 create a concrete mixture from its string name and initialize it.
 
- Public Member Functions inherited from STK::IMixtureManager< KernelMixtureManager >
 IMixtureManager (DataHandler const *const p_handler)
 Default constructor, need an instance of a DataHandler.
 
 ~IMixtureManager ()
 destructor
 
DataHandler const *const p_handler () const
 
Clust::Mixture getIdModel (String const &idData) const
 Utility function allowing to find the idModel from the idData.
 
String getIdModelName (String const &idData) const
 Utility function allowing to find the idModel name from the idData.
 
IMixturecreateMixture (String const &idData, int nbCluster)
 create a mixture and initialize it.
 
void registerDataBridge (IDataBridge *p_data)
 register a data bridge to the IMixtureManager.
 
void releaseDataBridge (String const &idData)
 release a data bridge from v_data_.
 
Data constgetData (String const &idData) const
 get the wrapper for any kind of data set using its Id
 
void getMissingValues (IMixture *p_mixture, MissingValues &missing) const
 get the missing values
 
void getParameters (IMixture *p_mixture, ArrayXX &data) const
 get the parameters from an IMixture.
 
void setParameters (IMixture *p_mixture, ArrayXX const &data) const
 set the parameters from an IMixture.
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Private Member Functions

IMixturecreateMixtureImpl (Clust::Mixture idModel, String const &idData, int nbCluster)
 create a concrete mixture and initialize it.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IMixtureManager< KernelMixtureManager >
IDataBridgegetDataBridge (String const &idData) const
 Utility lookup function allowing to find a DataBridge from its idData.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 

Detailed Description

A mixture manager is a factory class for injection dependency in the STK++ derived class of the MixtureComposer class.

It allows to handle all the creation and initialization stuff needed by the (bridged) mixture models of the stkpp library.

Definition at line 89 of file STK_KernelMixtureManager.h.

Member Typedef Documentation

◆ Base

◆ Data

◆ DataBridgeType

◆ DataHandler

◆ KmmBridge_s

◆ KmmBridge_sk

◆ MissingIndexes

◆ MissingValues

◆ Type

Constructor & Destructor Documentation

◆ KernelMixtureManager()

STK::KernelMixtureManager::KernelMixtureManager ( KernelHandler const handler)

Default constructor, need an instance of a KernelHandler.


Definition at line 42 of file STK_KernelMixtureManager.cpp.

42: Base(&handler) {}
IMixtureManager< KernelMixtureManager > Base

◆ ~KernelMixtureManager()

STK::KernelMixtureManager::~KernelMixtureManager ( )

destructor

Definition at line 44 of file STK_KernelMixtureManager.cpp.

44{}

Member Function Documentation

◆ createMixtureImpl() [1/2]

IMixture * STK::KernelMixtureManager::createMixtureImpl ( Clust::Mixture  idModel,
String const idData,
int  nbCluster 
)
private

create a concrete mixture and initialize it.

Parameters
idModel,idDataId of the model and the data
nbClusternumber of cluster of the model

Definition at line 124 of file STK_KernelMixtureManager.cpp.

125{
126 Kernel::IKernel const* p_kernel = p_handler()->getKernel(idData);
127 switch (idModel)
128 {
129 case Clust::Kmm_sk_:
130 {
131 KmmBridge_sk* p_mixture = new KmmBridge_sk( 0, idData, nbCluster);
132 p_mixture->setKernel(p_kernel);
133 return p_mixture;
134 break;
135 }
136 case Clust::Kmm_s_:
137 {
138 KmmBridge_s* p_mixture = new KmmBridge_s( 0, idData, nbCluster);
139 p_mixture->setKernel(p_kernel);
140 return p_mixture;
141 break;
142 }
143 default:
144 return 0; // 0 if idModel does not exists
145 break;
146 }
147 return 0; // 0 if idModel is not a STK++ model
148}
DataHandler const *const p_handler() const
KmmBridge< Clust::Kmm_s_, CSquareX > KmmBridge_s
KmmBridge< Clust::Kmm_sk_, CSquareX > KmmBridge_sk

References STK::Clust::Kmm_s_, STK::Clust::Kmm_sk_, and STK::IMixtureManager< KernelMixtureManager >::p_handler().

◆ createMixtureImpl() [2/2]

IMixture * STK::KernelMixtureManager::createMixtureImpl ( String const modelName,
String const idData,
int  nbCluster 
)

create a concrete mixture from its string name and initialize it.

Parameters
modelNamea valid model name
idDataId of the data
nbClusternumber of cluster of the model

Definition at line 111 of file STK_KernelMixtureManager.cpp.

112{
113#ifdef STK_MIXTURE_VERY_VERBOSE
114 stk_cout << _T("KernelMixtureManager::Entering createMixtureImpl(") << modelName
115 << _T(",") << idData << _T(",") << nbCluster << _T(")\n");
116#endif
117 Clust::Mixture idModel = Clust::stringToMixture(modelName);
118 return createMixtureImpl(idModel, idData, nbCluster);
119}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
IMixture * createMixtureImpl(String const &modelName, String const &idData, int nbCluster)
create a concrete mixture from its string name and initialize it.
Mixture stringToMixture(String const &type)
Convert a String to a Mixture.
Mixture
list of the mixtures that can be used by the composer

References _T, createMixtureImpl(), stk_cout, and STK::Clust::stringToMixture().

Referenced by createMixtureImpl().

◆ getParametersImpl()

void STK::KernelMixtureManager::getParametersImpl ( IMixture p_mixture,
ArrayXX param 
) const

get the parameters from an IMixture.

Parameters
p_mixturepointer on the mixture
paramthe array to return with the parameters

Definition at line 70 of file STK_KernelMixtureManager.cpp.

71{
72 if (!p_mixture) return;
73 Clust::Mixture idModel = getIdModel(p_mixture->idData());
74 // up-cast... (Yes it's bad....;)...)
75 switch (idModel)
76 {
77 // Kernel models
78 case Clust::Kmm_sk_:
79 { static_cast<KmmBridge_sk*>(p_mixture)->getParameters(param);}
80 break;
81 case Clust::Kmm_s_:
82 { static_cast<KmmBridge_s*>(p_mixture)->getParameters(param);}
83 break;
84 default: // idModel is not implemented
85 break;
86 }
87}
Clust::Mixture getIdModel(String const &idData) const
Utility function allowing to find the idModel from the idData.
void getParameters(IMixture *p_mixture, ArrayXX &data) const
get the parameters from an IMixture.

References STK::IMixtureManager< KernelMixtureManager >::getIdModel(), STK::IMixtureManager< KernelMixtureManager >::getParameters(), STK::Clust::Kmm_s_, and STK::Clust::Kmm_sk_.

◆ setDim() [1/2]

template<class Vector >
void STK::KernelMixtureManager::setDim ( IMixture p_mixture,
ExprBase< Vector > const dim 
) const

set the dimension of the kernel mixture model

Definition at line 142 of file STK_KernelMixtureManager.h.

143{
145 if (!p_mixture) return;
146 Clust::Mixture idModel = getIdModel(p_mixture->idData());
147 // up-cast... (Yes it's bad....;)...)
148 switch (idModel)
149 {
150 // Kernel models
151 case Clust::Kmm_sk_:
152 { static_cast<KmmBridge_sk*>(p_mixture)->setDim(dim.asDerived());}
153 break;
154 case Clust::Kmm_s_:
155 { static_cast<KmmBridge_s*>(p_mixture)->setDim(dim.asDerived());}
156 break;
157 default: // idModel is not implemented
158 break;
159 }
160}
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
void setDim(IMixture *p_mixture, Real const &dim) const
set the dimension of the kernel mixture model
Array2DVector< Real > Vector
final class for a Real vertical container.

References STK::IMixtureManager< KernelMixtureManager >::getIdModel(), STK::Clust::Kmm_s_, STK::Clust::Kmm_sk_, setDim(), and STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ setDim() [2/2]

void STK::KernelMixtureManager::setDim ( IMixture p_mixture,
Real const dim 
) const

set the dimension of the kernel mixture model

Definition at line 47 of file STK_KernelMixtureManager.cpp.

48{
49 if (!p_mixture) return;
50 Clust::Mixture idModel = getIdModel(p_mixture->idData());
51 // up-cast... (Yes it's bad....;)...)
52 switch (idModel)
53 {
54 // Kernel models
55 case Clust::Kmm_sk_:
56 { static_cast<KmmBridge_sk*>(p_mixture)->setDim(dim);}
57 break;
58 case Clust::Kmm_s_:
59 { static_cast<KmmBridge_s*>(p_mixture)->setDim(dim);}
60 break;
61 default: // idModel is not implemented
62 break;
63 }
64}

References STK::IMixtureManager< KernelMixtureManager >::getIdModel(), STK::Clust::Kmm_s_, STK::Clust::Kmm_sk_, and setDim().

Referenced by setDim(), and setDim().

◆ setParametersImpl()

void STK::KernelMixtureManager::setParametersImpl ( IMixture p_mixture,
ArrayXX const param 
) const

set the parameters from an IMixture.

Parameters
p_mixturepointer on the mixture
paramthe array with the parameters to set

Definition at line 92 of file STK_KernelMixtureManager.cpp.

93{
94 if (!p_mixture) return;
95 Clust::Mixture idModel = getIdModel(p_mixture->idData());
96 // up-cast... (Yes it's bad....;)...)
97 switch (idModel)
98 {
99 // Kernel models
100 case Clust::Kmm_sk_:
101 { static_cast<KmmBridge_sk*>(p_mixture)->setParameters(param);}
102 break;
103 case Clust::Kmm_s_:
104 { static_cast<KmmBridge_s*>(p_mixture)->setParameters(param);}
105 break;
106 default: // idModel is not implemented
107 break;
108 }
109}
void setParameters(IMixture *p_mixture, ArrayXX const &data) const
set the parameters from an IMixture.

References STK::IMixtureManager< KernelMixtureManager >::getIdModel(), STK::Clust::Kmm_s_, STK::Clust::Kmm_sk_, and STK::IMixtureManager< KernelMixtureManager >::setParameters().


The documentation for this class was generated from the following files: