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

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

#include <STK_PoissonMixtureManager.h>

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

Public Types

typedef hidden::MixtureManagerTraits< PoissonMixtureManager >::Type Type
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager >::Data Data
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager >::DataBridgeType DataBridgeType
 
typedef IMixtureManager< PoissonMixtureManagerBase
 
typedef PoissonBridge< Clust::Poisson_ljk_, DataMixtureBridge_ljk
 
typedef PoissonBridge< Clust::Poisson_lk_, DataMixtureBridge_lk
 
typedef PoissonBridge< Clust::Poisson_ljlk_, DataMixtureBridge_ljlk
 
- Public Types inherited from STK::IMixtureManager< PoissonMixtureManager< DataHandler > >
typedef hidden::MixtureManagerTraits< PoissonMixtureManager< DataHandler > >::DataHandler DataHandler
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager< DataHandler > >::Type Type
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager< DataHandler > >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager< DataHandler > >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager< DataHandler > >::Data Data
 
typedef hidden::MixtureManagerTraits< PoissonMixtureManager< DataHandler > >::DataBridgeType DataBridgeType
 

Public Member Functions

 PoissonMixtureManager (DataHandler const &handler)
 Default constructor, need an instance of a DataHandler.
 
 ~PoissonMixtureManager ()
 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 to an IMixture.
 
IMixturecreateMixtureImpl (String const &modelName, String const &idData, int nbCluster)
 create a concrete mixture and initialize it.
 
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.
 
void registerDataBridge (IDataBridge *p_data)
 register a data bridge to the IMixtureManager.
 
DataHandler const *const p_handler () const
 
- Public Member Functions inherited from STK::IMixtureManager< PoissonMixtureManager< 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< PoissonMixtureManager< 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::PoissonMixtureManager< DataHandler >

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.

Template Parameters
DataHandleris any concrete class from the interface DataHandlerBase

Definition at line 97 of file STK_PoissonMixtureManager.h.

Member Typedef Documentation

◆ Base

◆ Data

◆ DataBridgeType

◆ MissingIndexes

◆ MissingValues

◆ MixtureBridge_ljk

◆ MixtureBridge_ljlk

◆ MixtureBridge_lk

◆ Type

Constructor & Destructor Documentation

◆ PoissonMixtureManager()

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

Default constructor, need an instance of a DataHandler.


Definition at line 118 of file STK_PoissonMixtureManager.h.

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

◆ ~PoissonMixtureManager()

destructor

Definition at line 120 of file STK_PoissonMixtureManager.h.

120{}

Member Function Documentation

◆ createMixtureImpl() [1/2]

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

create a concrete mixture and initialize it.

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

Definition at line 211 of file STK_PoissonMixtureManager.h.

212 {
213 DataBridgeType* p_dataBridge = new DataBridgeType(idData);
214 p_handler()->getData(idData, p_dataBridge->dataij() );
215 registerDataBridge(p_dataBridge);
216 switch (idModel)
217 {
219 {
220 MixtureBridge_ljk* p_mixt = new MixtureBridge_ljk( &(p_dataBridge->dataij()), idData, nbCluster);
221 return p_mixt;
222 }
223 break;
225 { return new MixtureBridge_lk( &(p_dataBridge->dataij()), idData, nbCluster);}
226 break;
228 { return new MixtureBridge_ljlk( &(p_dataBridge->dataij()), idData, nbCluster);}
229 break;
230 default:
231 return 0; // 0 if idModel is not implemented
232 break;
233 }
234 return 0; // 0 if idModel is not a STK++ model
235 }
PoissonBridge< Clust::Poisson_ljlk_, Data > MixtureBridge_ljlk
void registerDataBridge(IDataBridge *p_data)
register a data bridge to the IMixtureManager.
DataHandler const *const p_handler() const
PoissonBridge< Clust::Poisson_ljk_, Data > MixtureBridge_ljk
PoissonBridge< Clust::Poisson_lk_, Data > MixtureBridge_lk
hidden::MixtureManagerTraits< PoissonMixtureManager >::DataBridgeType DataBridgeType

References STK::PoissonMixtureManager< DataHandler >::p_handler(), STK::Clust::Poisson_ljk_, STK::Clust::Poisson_ljlk_, STK::Clust::Poisson_lk_, and STK::PoissonMixtureManager< DataHandler >::registerDataBridge().

◆ createMixtureImpl() [2/2]

template<class DataHandler >
IMixture * STK::PoissonMixtureManager< 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 199 of file STK_PoissonMixtureManager.h.

200 {
201 Clust::Mixture idModel = Clust::stringToMixture(modelName);
202 return createMixtureImpl(idModel, idData, nbCluster);
203 }
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.
Mixture
list of the mixtures that can be used by the composer

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

Referenced by STK::PoissonMixtureManager< 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.
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::PoissonMixtureManager< DataHandler >::getMissingValuesImpl(), STK::PoissonMixtureManager< DataHandler >::getParametersImpl(), and STK::PoissonMixtureManager< DataHandler >::setParametersImpl().

◆ getMissingValuesImpl()

template<class DataHandler >
void STK::PoissonMixtureManager< 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_PoissonMixtureManager.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_ljk*>(p_mixture)->getMissingValues(missing);}
135 break;
137 { static_cast<MixtureBridge_lk*>(p_mixture)->getMissingValues(missing);}
138 break;
140 { static_cast<MixtureBridge_ljlk*>(p_mixture)->getMissingValues(missing);}
141 break;
142 default: // idModel is not implemented
143 break;
144 }
145 }
void getMissingValues(IMixture *p_mixture, MissingValues &missing) const
get the missing values
Clust::Mixture getIdModel(String const &idData) const
Utility function allowing to find the idModel from the idData.

References STK::PoissonMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< PoissonMixtureManager< DataHandler > >::getMissingValues(), STK::Clust::Poisson_ljk_, STK::Clust::Poisson_ljlk_, STK::Clust::Poisson_lk_, and STK::Clust::unknown_mixture_.

◆ getParametersImpl()

template<class DataHandler >
void STK::PoissonMixtureManager< 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 150 of file STK_PoissonMixtureManager.h.

151 {
152 Clust::Mixture idModel = getIdModel(p_mixture->idData());
153 if (idModel == Clust::unknown_mixture_) return;
154 // up-cast... (Yes it's bad....;)...)
155 switch (idModel)
156 {
158 { static_cast<MixtureBridge_ljk*>(p_mixture)->getParameters(param);}
159 break;
161 { static_cast<MixtureBridge_lk*>(p_mixture)->getParameters(param);}
162 break;
164 { static_cast<MixtureBridge_ljlk*>(p_mixture)->getParameters(param);}
165 break;
166 default: // idModel is not implemented
167 break;
168 }
169 }
void getParameters(IMixture *p_mixture, ArrayXX &data) const
get the parameters from an IMixture.

References STK::PoissonMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< PoissonMixtureManager< DataHandler > >::getParameters(), STK::Clust::Poisson_ljk_, STK::Clust::Poisson_ljlk_, STK::Clust::Poisson_lk_, 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.

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

◆ 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);}

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

◆ setParametersImpl()

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

set the parameters to an IMixture.

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

Definition at line 174 of file STK_PoissonMixtureManager.h.

175 {
176 Clust::Mixture idModel = getIdModel(p_mixture->idData());
177 if (idModel == Clust::unknown_mixture_) return;
178 // up-cast... (Yes it's bad....;)...)
179 switch (idModel)
180 {
182 { static_cast<MixtureBridge_ljk*>(p_mixture)->setParameters(param);}
183 break;
185 { static_cast<MixtureBridge_lk*>(p_mixture)->setParameters(param);}
186 break;
188 { static_cast<MixtureBridge_ljlk*>(p_mixture)->setParameters(param);}
189 break;
190 default: // idModel is not implemented
191 break;
192 }
193 }
void setParameters(IMixture *p_mixture, ArrayXX const &data) const
set the parameters from an IMixture.

References STK::PoissonMixtureManager< DataHandler >::getIdModel(), STK::Clust::Poisson_ljk_, STK::Clust::Poisson_ljlk_, STK::Clust::Poisson_lk_, STK::IMixtureManager< PoissonMixtureManager< DataHandler > >::setParameters(), and STK::Clust::unknown_mixture_.


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