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

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

#include <STK_CategoricalMixtureManager.h>

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

Public Types

typedef hidden::MixtureManagerTraits< CategoricalMixtureManager >::Type Type
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager >::Data Data
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager >::DataBridgeType DataBridgeType
 
typedef IMixtureManager< CategoricalMixtureManagerBase
 
typedef CategoricalBridge< Clust::Categorical_pjk_, DataMixtureBridge_pjk
 
typedef CategoricalBridge< Clust::Categorical_pk_, DataMixtureBridge_pk
 
- Public Types inherited from STK::IMixtureManager< CategoricalMixtureManager< DataHandler > >
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager< DataHandler > >::DataHandler DataHandler
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager< DataHandler > >::Type Type
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager< DataHandler > >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager< DataHandler > >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager< DataHandler > >::Data Data
 
typedef hidden::MixtureManagerTraits< CategoricalMixtureManager< DataHandler > >::DataBridgeType DataBridgeType
 

Public Member Functions

 CategoricalMixtureManager (DataHandler const &handler)
 Default constructor, need an instance of a DataHandler.
 
 ~CategoricalMixtureManager ()
 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.
 
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< CategoricalMixtureManager< 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< CategoricalMixtureManager< 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::CategoricalMixtureManager< DataHandler >

A mixture manager is a factory class for injection dependency in the STK++ derived class of the IMixtureComposer interface 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 93 of file STK_CategoricalMixtureManager.h.

Member Typedef Documentation

◆ Base

◆ Data

◆ DataBridgeType

◆ MissingIndexes

◆ MissingValues

◆ MixtureBridge_pjk

◆ MixtureBridge_pk

◆ Type

Constructor & Destructor Documentation

◆ CategoricalMixtureManager()

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

Default constructor, need an instance of a DataHandler.


Definition at line 113 of file STK_CategoricalMixtureManager.h.

113: Base(&handler) {}
IMixtureManager< CategoricalMixtureManager > Base

◆ ~CategoricalMixtureManager()

destructor

Definition at line 115 of file STK_CategoricalMixtureManager.h.

115{}

Member Function Documentation

◆ createMixtureImpl() [1/2]

template<class DataHandler >
IMixture * STK::CategoricalMixtureManager< 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 197 of file STK_CategoricalMixtureManager.h.

198 {
199 switch (idModel)
200 {
203 break;
206 break;
207 default:
208 return 0; // 0 if idModel is not implemented
209 break;
210 }
211 return 0; // 0 if idModel is not a STK++ model
212 }
#define STK_CREATE_MIXTURE(Data, Bridge)
hidden::MixtureManagerTraits< CategoricalMixtureManager >::DataBridgeType DataBridgeType
CategoricalBridge< Clust::Categorical_pjk_, Data > MixtureBridge_pjk
CategoricalBridge< Clust::Categorical_pk_, Data > MixtureBridge_pk

References STK::Clust::Categorical_pjk_, STK::Clust::Categorical_pk_, and STK_CREATE_MIXTURE.

◆ createMixtureImpl() [2/2]

template<class DataHandler >
IMixture * STK::CategoricalMixtureManager< 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 185 of file STK_CategoricalMixtureManager.h.

186 {
187 Clust::Mixture idModel = Clust::stringToMixture(modelName);
188 return createMixtureImpl(idModel, idData, nbCluster);
189 }
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::CategoricalMixtureManager< DataHandler >::createMixtureImpl(), and STK::Clust::stringToMixture().

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

◆ getMissingValuesImpl()

template<class DataHandler >
void STK::CategoricalMixtureManager< 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 121 of file STK_CategoricalMixtureManager.h.

122 {
123 Clust::Mixture idModel = getIdModel(p_mixture->idData());
124 if (idModel == Clust::unknown_mixture_) return;
125 // up-cast... (Yes it's bad....;)...)
126 switch (idModel)
127 {
129 { static_cast<MixtureBridge_pjk*>(p_mixture)->getMissingValues(missing);}
130 break;
132 { static_cast<MixtureBridge_pk*>(p_mixture)->getMissingValues(missing);}
133 break;
134 default: // idModel is not implemented
135 break;
136 }
137 }
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

References STK::Clust::Categorical_pjk_, STK::Clust::Categorical_pk_, STK::CategoricalMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< CategoricalMixtureManager< DataHandler > >::getMissingValues(), and STK::Clust::unknown_mixture_.

◆ getParametersImpl()

template<class DataHandler >
void STK::CategoricalMixtureManager< 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 142 of file STK_CategoricalMixtureManager.h.

143 {
144 Clust::Mixture idModel = getIdModel(p_mixture->idData());
145 if (idModel == Clust::unknown_mixture_) return;
146 // up-cast... (Yes it's bad....;)...)
147 switch (idModel)
148 {
150 { static_cast<MixtureBridge_pjk*>(p_mixture)->getParameters(param);}
151 break;
153 { static_cast<MixtureBridge_pk*>(p_mixture)->getParameters(param);}
154 break;
155 default: // idModel is not implemented
156 break;
157 }
158 }
void getParameters(IMixture *p_mixture, ArrayXX &data) const
get the parameters from an IMixture.

References STK::Clust::Categorical_pjk_, STK::Clust::Categorical_pk_, STK::CategoricalMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< CategoricalMixtureManager< 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::CategoricalMixtureManager< 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 163 of file STK_CategoricalMixtureManager.h.

164 {
165 Clust::Mixture idModel = getIdModel(p_mixture->idData());
166 if (idModel == Clust::unknown_mixture_) return;
167 // up-cast... (Yes it's bad....;)...)
168 switch (idModel)
169 {
171 { static_cast<MixtureBridge_pjk*>(p_mixture)->setParameters(param);}
172 break;
174 { static_cast<MixtureBridge_pk*>(p_mixture)->setParameters(param);}
175 break;
176 default: // idModel is not implemented
177 break;
178 }
179 }
void setParameters(IMixture *p_mixture, ArrayXX const &data) const
set the parameters from an IMixture.

References STK::Clust::Categorical_pjk_, STK::Clust::Categorical_pk_, STK::CategoricalMixtureManager< DataHandler >::getIdModel(), STK::IMixtureManager< CategoricalMixtureManager< DataHandler > >::setParameters(), and STK::Clust::unknown_mixture_.


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