STK++ 0.9.13
STK::IMixtureManager< Derived > Class Template Reference

Interface base class for mixture managers. More...

#include <STK_IMixtureManager.h>

Inheritance diagram for STK::IMixtureManager< Derived >:
Inheritance graph

Public Types

typedef hidden::MixtureManagerTraits< Derived >::DataHandler DataHandler
 
typedef hidden::MixtureManagerTraits< Derived >::Type Type
 
typedef hidden::MixtureManagerTraits< Derived >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureManagerTraits< Derived >::MissingValues MissingValues
 
typedef hidden::MixtureManagerTraits< Derived >::Data Data
 
typedef hidden::MixtureManagerTraits< Derived >::DataBridgeType DataBridgeType
 

Public Member Functions

 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.
 

Protected Member Functions

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.
 

Private Member Functions

IMixturecreateMixture (String const &modelName, String const &idData, int nbCluster)
 create a concrete mixture and initialize it.
 

Private Attributes

DataHandler const *const p_handler_
 A pointer on the concrete instance of the data handler.
 
std::vector< IDataBridge * > v_data_
 vector of pointers to the data components
 

Detailed Description

template<class Derived>
class STK::IMixtureManager< Derived >

Interface base class for mixture managers.

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

  • It handles all the creation and initialization stuff needed by mixture models,
  • It allows to get parameters and imputed missing values from specific mixtures,
  • It allows also to set parameters to a specific mixture,
  • all data set are enclosed in a DataBridge structure and stored in vector v_data_

The pseudo pure virtual method to implement in derived classes are

void getMissingValuesImpl(IMixture* p_mixture, MissingValues& missing) const;
void getParametersImpl(IMixture* p_mixture, ArrayXX& data) const;
void setParametersImpl(IMixture* p_mixture, ArrayXX const& data) const;
IMixture* createMixtureImpl(String const& modelName, String const& idData, int nbCluster);
hidden::MixtureManagerTraits< Derived >::MissingValues MissingValues
Interface base class for all the mixture models that will be processed by the composer.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
std::basic_string< Char > String
STK fundamental type of a String.
Template Parameters
Derivedany concrete class derived from this interface

Definition at line 69 of file STK_IMixtureManager.h.

Member Typedef Documentation

◆ Data

template<class Derived >
typedef hidden::MixtureManagerTraits<Derived>::Data STK::IMixtureManager< Derived >::Data

Definition at line 76 of file STK_IMixtureManager.h.

◆ DataBridgeType

template<class Derived >
typedef hidden::MixtureManagerTraits<Derived>::DataBridgeType STK::IMixtureManager< Derived >::DataBridgeType

Definition at line 77 of file STK_IMixtureManager.h.

◆ DataHandler

template<class Derived >
typedef hidden::MixtureManagerTraits<Derived>::DataHandler STK::IMixtureManager< Derived >::DataHandler

Definition at line 72 of file STK_IMixtureManager.h.

◆ MissingIndexes

template<class Derived >
typedef hidden::MixtureManagerTraits<Derived>::MissingIndexes STK::IMixtureManager< Derived >::MissingIndexes

Definition at line 74 of file STK_IMixtureManager.h.

◆ MissingValues

template<class Derived >
typedef hidden::MixtureManagerTraits<Derived>::MissingValues STK::IMixtureManager< Derived >::MissingValues

Definition at line 75 of file STK_IMixtureManager.h.

◆ Type

template<class Derived >
typedef hidden::MixtureManagerTraits<Derived>::Type STK::IMixtureManager< Derived >::Type

Definition at line 73 of file STK_IMixtureManager.h.

Constructor & Destructor Documentation

◆ IMixtureManager()

template<class Derived >
STK::IMixtureManager< Derived >::IMixtureManager ( DataHandler const *const  p_handler)

Default constructor, need an instance of a DataHandler.

Definition at line 191 of file STK_IMixtureManager.h.

193{}
DataHandler const *const p_handler() const
DataHandler const *const p_handler_
A pointer on the concrete instance of the data handler.

◆ ~IMixtureManager()

template<class Derived >
STK::IMixtureManager< Derived >::~IMixtureManager ( )

destructor

Definition at line 196 of file STK_IMixtureManager.h.

197{
198 typedef std::vector<IDataBridge*>::iterator DataIterator;
199 for (DataIterator it = v_data_.begin() ; it != v_data_.end(); ++it)
200 { delete (*it);}
201}
std::vector< IDataBridge * > v_data_
vector of pointers to the data components

Member Function Documentation

◆ createMixture() [1/2]

template<class Derived >
IMixture * STK::IMixtureManager< Derived >::createMixture ( String const idData,
int  nbCluster 
)

create a mixture and initialize it.

This method get the modelName from the DataHandler and then delegate the concrete creation to derived class using the pseudo pure virtual method createMixture( modelName, idData, nbCluster).

Parameters
idDataname of the model
nbClusternumber of cluster of the model
Returns
0 if the idData is not find, the result of createMixture( modelName, idData, nbCluster) otherwise.

Definition at line 230 of file STK_IMixtureManager.h.

231{
232 String modelName;
233 if (!p_handler_->getIdModelName( idData, modelName)) { return 0;};
234 return createMixture( modelName, idData, nbCluster);
235}
IMixture * createMixture(String const &idData, int nbCluster)
create a mixture and initialize it.

◆ createMixture() [2/2]

template<class Derived >
IMixture * STK::IMixtureManager< Derived >::createMixture ( String const modelName,
String const idData,
int  nbCluster 
)
inlineprivate

create a concrete mixture and initialize it.

Parameters
modelName,idDatastrings with the Id name of the model and of the data
nbClusternumber of cluster of the model

Definition at line 163 of file STK_IMixtureManager.h.

164 { return this->asDerived().createMixtureImpl(modelName, idData, nbCluster);}
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ getData()

template<class Derived >
hidden::MixtureManagerTraits< Derived >::Data const & STK::IMixtureManager< Derived >::getData ( String const idData) const

get the wrapper for any kind of data set using its Id

Parameters
idDataId name of the data set attached to the mixture
Returns
a constant reference on the array with the data set

Definition at line 274 of file STK_IMixtureManager.h.

275{
276 IDataBridge* p_bridge = getDataBridge(idData);
277 if (p_bridge)
278 return static_cast<DataBridgeType*>(p_bridge)->dataij();
279 else
280 STKRUNTIME_ERROR_1ARG(IMixtureManager::getData,idData,data bridge does not exist);
281}
#define STKRUNTIME_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:129
Data const & getData(String const &idData) const
get the wrapper for any kind of data set using its Id
hidden::MixtureManagerTraits< Derived >::DataBridgeType DataBridgeType
IDataBridge * getDataBridge(String const &idData) const
Utility lookup function allowing to find a DataBridge from its idData.

References STK::IMixtureManager< Derived >::getData(), and STKRUNTIME_ERROR_1ARG.

Referenced by STK::IMixtureManager< Derived >::getData().

◆ getDataBridge()

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

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 261 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}

◆ getIdModel()

template<class Derived >
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 172 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.
Mixture stringToMixture(String const &type)
Convert a String to a Mixture.

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

◆ getIdModelName()

template<class Derived >
String STK::IMixtureManager< Derived >::getIdModelName ( String const idData) const

Utility function allowing to find the idModel name from the idData.

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

Definition at line 207 of file STK_IMixtureManager.h.

208{
209 String modelName;
210 if (!p_handler_->getIdModelName( idData, modelName))
211 {
212#ifdef STK_MIXTURE_VERY_VERBOSE
213 stk_cout << _T("In IMixtureManager::getIdModelName, fail to get idData = ") << idData << _T("\n");
214#endif
215 }
216#ifdef STK_MIXTURE_VERY_VERBOSE
217 stk_cout << _T("In IMixtureManager::getIdModeName, success to get idData = ") << idData << _T("\n");
218 stk_cout << _T("In IMixtureManager::getIdModel, modelName = ") << modelName << _T("\n");
219#endif
220 return modelName;
221}

References _T, and stk_cout.

◆ getMissingValues()

template<class Derived >
void STK::IMixtureManager< Derived >::getMissingValues ( IMixture p_mixture,
MissingValues missing 
) const
inline

get the missing values

Parameters
p_mixturepointer on the mixture
missingarray with the indexes and the missing values

Definition at line 131 of file STK_IMixtureManager.h.

132 {this->asDerived().getMissingValuesImpl(p_mixture, missing);}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ getParameters()

template<class Derived >
void STK::IMixtureManager< Derived >::getParameters ( IMixture p_mixture,
ArrayXX data 
) const
inline

get the parameters from an IMixture.

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

Definition at line 137 of file STK_IMixtureManager.h.

138 { this->asDerived().getParametersImpl(p_mixture, data);}

References STK::IRecursiveTemplate< Derived >::asDerived().

◆ p_handler()

template<class Derived >
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_;}

References STK::IMixtureManager< Derived >::p_handler_.

◆ registerDataBridge()

template<class Derived >
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 243 of file STK_IMixtureManager.h.

244{ v_data_.push_back(p_data);}

◆ releaseDataBridge()

template<class Derived >
void STK::IMixtureManager< Derived >::releaseDataBridge ( String const idData)

release a data bridge from v_data_.

Parameters
idDataname of the data set to release

Definition at line 249 of file STK_IMixtureManager.h.

250{
251 typedef std::vector<IDataBridge*>::iterator DataIterator;
252 for (DataIterator it = v_data_.begin(); it != v_data_.end(); ++it)
253 { if ((*it)->idData() == idData) {delete (*it); v_data_.erase(it); break;}}
254}

◆ setParameters()

template<class Derived >
void STK::IMixtureManager< Derived >::setParameters ( IMixture p_mixture,
ArrayXX const data 
) const
inline

set the parameters from an IMixture.

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

Definition at line 143 of file STK_IMixtureManager.h.

144 { this->asDerived().setParametersImpl(p_mixture, data);}

References STK::IRecursiveTemplate< Derived >::asDerived().

Member Data Documentation

◆ p_handler_

template<class Derived >
DataHandler const* const STK::IMixtureManager< Derived >::p_handler_
private

A pointer on the concrete instance of the data handler.

Definition at line 155 of file STK_IMixtureManager.h.

Referenced by STK::IMixtureManager< Derived >::p_handler().

◆ v_data_

template<class Derived >
std::vector<IDataBridge*> STK::IMixtureManager< Derived >::v_data_
private

vector of pointers to the data components

Definition at line 157 of file STK_IMixtureManager.h.


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