STK++ 0.9.13
STK::DiagGaussianMixtureManager< DataHandler > Class Template Reference

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

#include <STK_DiagGaussianMixtureManager.h>

Inheritance diagram for STK::DiagGaussianMixtureManager< DataHandler >:
Inheritance graph

Public Types

typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager >::Type Type
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager >::Data Data
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager >::DataBridgeType DataBridgeType
 
typedef IMixtureManager< DiagGaussianMixtureManagerBase
 
typedef DiagGaussianBridge< Clust::Gaussian_sjk_, DataMixtureBridge_sjk
 
typedef DiagGaussianBridge< Clust::Gaussian_sk_, DataMixtureBridge_sk
 
typedef DiagGaussianBridge< Clust::Gaussian_sj_, DataMixtureBridge_sj
 
typedef DiagGaussianBridge< Clust::Gaussian_sjsk_, DataMixtureBridge_sjsk
 
typedef DiagGaussianBridge< Clust::Gaussian_s_, DataMixtureBridge_s
 
- Public Types inherited from STK::IMixtureManager< DiagGaussianMixtureManager< DataHandler > >
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager< DataHandler > >::DataHandler DataHandler
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager< DataHandler > >::Type Type
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager< DataHandler > >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager< DataHandler > >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager< DataHandler > >::Data Data
 
typedef hidden::MixtureManagerTraits< DiagGaussianMixtureManager< DataHandler > >::DataBridgeType DataBridgeType
 

Public Member Functions

 DiagGaussianMixtureManager (DataHandler const &handler)
 Default constructor, need an instance of a DataHandler.
 
 ~DiagGaussianMixtureManager ()
 destructor
 
void getMissingValuesImpl (IMixture *p_mixture, MissingValues &missing) const
 get the missing values from an IMixture.
 
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 and initialize it.
 
void registerDataBridge (IDataBridge *p_data)
 register a data bridge to the IMixtureManager.
 
IDataBridgegetDataBridge (String const &idData) const
 Utility lookup function allowing to find a DataBridge from its idData.
 
Clust::Mixture getIdModel (String const &idData) const
 Utility function allowing to find the idModel from the idData.
 
DataHandler const *const p_handler () const
 
- Public Member Functions inherited from STK::IMixtureManager< DiagGaussianMixtureManager< DataHandler > >
 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< DiagGaussianMixtureManager< DataHandler > >
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

template<class DataHandler>
class STK::DiagGaussianMixtureManager< DataHandler >

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

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

Template Parameters
DataHandleris any concrete class from the interface DataHandlerBase

Definition at line 95 of file STK_DiagGaussianMixtureManager.h.

Member Typedef Documentation

◆ Base

◆ Data

◆ DataBridgeType

◆ MissingIndexes

◆ MissingValues

◆ MixtureBridge_s

◆ MixtureBridge_sj

◆ MixtureBridge_sjk

◆ MixtureBridge_sjsk

◆ MixtureBridge_sk

◆ Type

Constructor & Destructor Documentation

◆ DiagGaussianMixtureManager()

template<class DataHandler >
STK::DiagGaussianMixtureManager< DataHandler >::DiagGaussianMixtureManager ( DataHandler const handler)
inline

Default constructor, need an instance of a DataHandler.


Definition at line 118 of file STK_DiagGaussianMixtureManager.h.

118: Base(&handler) {}
IMixtureManager< DiagGaussianMixtureManager > Base

◆ ~DiagGaussianMixtureManager()

destructor

Definition at line 120 of file STK_DiagGaussianMixtureManager.h.

120{}

Member Function Documentation

◆ createMixtureImpl() [1/2]

template<class DataHandler >
IMixture * STK::DiagGaussianMixtureManager< DataHandler >::createMixtureImpl ( Clust::Mixture  idModel,
String const idData,
int  nbCluster 
)
inlineprivate

create a concrete mixture and initialize it.

Parameters
idModelId name of the model
idDataId name of the data
nbClusternumber of cluster of the model

Definition at line 229 of file STK_DiagGaussianMixtureManager.h.

230 {
231 switch (idModel)
232 {
233 // Gaussian models
236 break;
239 break;
242 break;
245 break;
248 break;
249 default:
250 return 0; // 0 if idModel is not implemented
251 break;
252 }
253 return 0; // 0 if idModel is not a STK++ model
254 }
#define STK_CREATE_MIXTURE(Data, Bridge)
DiagGaussianBridge< Clust::Gaussian_sj_, Data > MixtureBridge_sj
DiagGaussianBridge< Clust::Gaussian_sk_, Data > MixtureBridge_sk
DiagGaussianBridge< Clust::Gaussian_s_, Data > MixtureBridge_s
hidden::MixtureManagerTraits< DiagGaussianMixtureManager >::DataBridgeType DataBridgeType
DiagGaussianBridge< Clust::Gaussian_sjsk_, Data > MixtureBridge_sjsk
DiagGaussianBridge< Clust::Gaussian_sjk_, Data > MixtureBridge_sjk

References STK::Clust::Gaussian_s_, STK::Clust::Gaussian_sj_, STK::Clust::Gaussian_sjk_, STK::Clust::Gaussian_sjsk_, STK::Clust::Gaussian_sk_, and STK_CREATE_MIXTURE.

◆ createMixtureImpl() [2/2]

template<class DataHandler >
IMixture * STK::DiagGaussianMixtureManager< DataHandler >::createMixtureImpl ( String const modelName,
String const idData,
int  nbCluster 
)
inline

create a concrete mixture and initialize it.

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

Definition at line 219 of file STK_DiagGaussianMixtureManager.h.

220 { return createMixtureImpl(Clust::stringToMixture(modelName), idData, nbCluster);}
IMixture * createMixtureImpl(String const &modelName, String const &idData, int nbCluster)
create a concrete mixture and initialize it.
Mixture stringToMixture(String const &type)
Convert a String to a Mixture.

References STK::DiagGaussianMixtureManager< DataHandler >::createMixtureImpl(), and STK::Clust::stringToMixture().

Referenced by STK::DiagGaussianMixtureManager< DataHandler >::createMixtureImpl().

◆ getDataBridge()

template<class DataHandler >
IDataBridge * STK::IMixtureManager< Derived >::getDataBridge ( String const idData) const

Utility lookup function allowing to find a DataBridge from its idData.

Parameters
idDatathe id name of the mixture we want to get
Returns
a pointer on the DataBridge

Definition at line 151 of file STK_IMixtureManager.h.

262{
263 typedef std::vector<IDataBridge*>::const_iterator ConstDataIterator;
264 for (ConstDataIterator it = v_data_.begin(); it != v_data_.end(); ++it)
265 { if ((*it)->idData() == idData) return (*it);}
266 return 0;
267}
std::vector< IDataBridge * > v_data_
vector of pointers to the data components

◆ getIdModel()

template<class DataHandler >
Clust::Mixture STK::IMixtureManager< Derived >::getIdModel ( String const idData) const

Utility function allowing to find the idModel from the idData.

Parameters
idDatathe id name of the data we want the idModel
Returns
the idModel

Definition at line 91 of file STK_IMixtureManager.h.

173{
174 String modelName;
175 if (!p_handler()->getIdModelName( idData, modelName))
176 {
177#ifdef STK_MIXTURE_VERY_VERBOSE
178 stk_cout << _T("In IMixtureManager::getIdModel, fail to get idData = ") << idData << _T("\n");
179#endif
181 }
182#ifdef STK_MIXTURE_VERY_VERBOSE
183 stk_cout << _T("In IMixtureManager::getIdModel, success to get idData = ") << idData << _T("\n");
184 stk_cout << _T("In IMixtureManager::getIdModel, modelName = ") << modelName << _T("\n");
185#endif
186 return Clust::stringToMixture(modelName);
187}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
DataHandler const *const p_handler() const
String getIdModelName(String const &idData) const
Utility function allowing to find the idModel name from the idData.
std::basic_string< Char > String
STK fundamental type of a String.

Referenced by STK::DiagGaussianMixtureManager< DataHandler >::getMissingValuesImpl(), STK::DiagGaussianMixtureManager< DataHandler >::getParametersImpl(), and STK::DiagGaussianMixtureManager< DataHandler >::setParametersImpl().

◆ getMissingValuesImpl()

template<class DataHandler >
void STK::DiagGaussianMixtureManager< DataHandler >::getMissingValuesImpl ( IMixture p_mixture,
MissingValues missing 
) const
inline

get the missing values from an IMixture.

Parameters
p_mixturepointer on the mixture
missingstructure to return with the missing values

Definition at line 126 of file STK_DiagGaussianMixtureManager.h.

127 {
128 Clust::Mixture idModel = getIdModel(p_mixture->idData());
129 if (idModel == Clust::unknown_mixture_) return;
130 // up-cast... (Yes it's bad....;)...)
131 switch (idModel)
132 {
134 { static_cast<MixtureBridge_sjk*>(p_mixture)->getMissingValues(missing);}
135 break;
137 { static_cast<MixtureBridge_sk*>(p_mixture)->getMissingValues(missing);}
138 break;
140 { static_cast<MixtureBridge_sj*>(p_mixture)->getMissingValues(missing);}
141 break;
143 { static_cast<MixtureBridge_sjsk*>(p_mixture)->getMissingValues(missing);}
144 break;
146 { static_cast<MixtureBridge_s*>(p_mixture)->getMissingValues(missing);}
147 break;
148 default: // idModel is not implemented
149 break;
150 }
151 }
Clust::Mixture getIdModel(String const &idData) const
Utility function allowing to find the idModel from the idData.
void getMissingValues(IMixture *p_mixture, MissingValues &missing) const
get the missing values
Mixture
list of the mixtures that can be used by the composer

References STK::Clust::Gaussian_s_, STK::Clust::Gaussian_sj_, STK::Clust::Gaussian_sjk_, STK::Clust::Gaussian_sjsk_, STK::Clust::Gaussian_sk_, STK::DiagGaussianMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< DiagGaussianMixtureManager< DataHandler > >::getMissingValues(), and STK::Clust::unknown_mixture_.

◆ getParametersImpl()

template<class DataHandler >
void STK::DiagGaussianMixtureManager< DataHandler >::getParametersImpl ( IMixture p_mixture,
ArrayXX param 
) const
inline

get the parameters from an IMixture.

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

Definition at line 156 of file STK_DiagGaussianMixtureManager.h.

157 {
158 Clust::Mixture idModel = getIdModel(p_mixture->idData());
159 if (idModel == Clust::unknown_mixture_) return;
160 // up-cast... (Yes it's bad....;)...)
161 switch (idModel)
162 {
163 // Gaussian models
165 { static_cast<MixtureBridge_sjk*>(p_mixture)->getParameters(param);}
166 break;
168 { static_cast<MixtureBridge_sk*>(p_mixture)->getParameters(param);}
169 break;
171 { static_cast<MixtureBridge_sj*>(p_mixture)->getParameters(param);}
172 break;
174 { static_cast<MixtureBridge_sjsk*>(p_mixture)->getParameters(param);}
175 break;
177 { static_cast<MixtureBridge_s*>(p_mixture)->getParameters(param);}
178 break;
179 default: // idModel is not implemented
180 break;
181 }
182 }
void getParameters(IMixture *p_mixture, ArrayXX &data) const
get the parameters from an IMixture.

References STK::Clust::Gaussian_s_, STK::Clust::Gaussian_sj_, STK::Clust::Gaussian_sjk_, STK::Clust::Gaussian_sjsk_, STK::Clust::Gaussian_sk_, STK::DiagGaussianMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< DiagGaussianMixtureManager< DataHandler > >::getParameters(), and STK::Clust::unknown_mixture_.

◆ p_handler()

template<class DataHandler >
DataHandler const *const STK::IMixtureManager< Derived >::p_handler ( ) const
inline
Returns
constant pointer on the data handler

Definition at line 85 of file STK_IMixtureManager.h.

85{ return p_handler_;}
DataHandler const *const p_handler_
A pointer on the concrete instance of the data handler.

◆ registerDataBridge()

template<class DataHandler >
void STK::IMixtureManager< Derived >::registerDataBridge ( IDataBridge p_data)

register a data bridge to the IMixtureManager.

For each mixture created and registered, a data bridge is created and registered so that it will be deleted when the mixture itself is deleted.

Parameters
p_dataa pointer on the data manager

Definition at line 114 of file STK_IMixtureManager.h.

244{ v_data_.push_back(p_data);}

◆ setParametersImpl()

template<class DataHandler >
void STK::DiagGaussianMixtureManager< DataHandler >::setParametersImpl ( IMixture p_mixture,
ArrayXX const param 
) const
inline

set the parameters from an IMixture.

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

Definition at line 187 of file STK_DiagGaussianMixtureManager.h.

188 {
189 Clust::Mixture idModel = getIdModel(p_mixture->idData());
190 if (idModel == Clust::unknown_mixture_) return;
191 // up-cast... (Yes it's bad....;)...)
192 switch (idModel)
193 {
194 // Gaussian models
196 { static_cast<MixtureBridge_sjk*>(p_mixture)->setParameters(param);}
197 break;
199 { static_cast<MixtureBridge_sk*>(p_mixture)->setParameters(param);}
200 break;
202 { static_cast<MixtureBridge_sj*>(p_mixture)->setParameters(param);}
203 break;
205 { static_cast<MixtureBridge_sjsk*>(p_mixture)->setParameters(param);}
206 break;
208 { static_cast<MixtureBridge_s*>(p_mixture)->setParameters(param);}
209 break;
210 default: // idModel is not implemented
211 break;
212 }
213 }
void setParameters(IMixture *p_mixture, ArrayXX const &data) const
set the parameters from an IMixture.

References STK::Clust::Gaussian_s_, STK::Clust::Gaussian_sj_, STK::Clust::Gaussian_sjk_, STK::Clust::Gaussian_sjsk_, STK::Clust::Gaussian_sk_, STK::DiagGaussianMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< DiagGaussianMixtureManager< DataHandler > >::setParameters(), and STK::Clust::unknown_mixture_.


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