mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
ClusteringStrategyInit.h
1 /***************************************************************************
2  SRC/mixmod/Clustering/ClusteringStrategyInit.h description
3  copyright : (C) MIXMOD Team - 2001-2016
4  email : contact@mixmod.org
5  ***************************************************************************/
6 
7 /***************************************************************************
8  This file is part of MIXMOD
9 
10  MIXMOD is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MIXMOD is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with MIXMOD. If not, see <http://www.gnu.org/licenses/>.
22 
23  All informations available on : http://www.mixmod.org
24 ***************************************************************************/
25 #ifndef XEMClusteringStrategyInit_H
26 #define XEMClusteringStrategyInit_H
27 
28 #include "mixmod/Utilities/Util.h"
29 
30 namespace XEM {
31 
32 // pre-declaration
33 class Data;
34 class Parameter;
35 class Partition;
36 class Model;
37 
44 
45 public:
46 
49 
51  ClusteringStrategyInit(const ClusteringStrategyInit & strategyInit);
52 
54  virtual ~ClusteringStrategyInit();
55 
57  const StrategyInitName & getStrategyInitName() const;
58 
61 
63  const int64_t getNbTry() const;
64 
66  void setNbTry(int64_t nbTry);
67 
69  const int64_t getNbIteration() const;
70 
72  void setNbIteration(int64_t nbIteration);
73 
75  const double getEpsilon() const;
76 
78  void setEpsilon(double epsilon);
79 
81  const AlgoStopName getStopName() const;
82 
84  void setStopName(AlgoStopName stopName);
85 
86  /* Parameter */
87  //-----------//
89  const int64_t & getNbInitParameter() const;
90 
92  const Parameter ** getTabInitParameter() const;
93 
95  Parameter * getInitParameter(int64_t index) const;
96 
98  void setInitParam(std::string & paramFileName, int64_t position);
99 
101  void setTabInitParameter(Parameter ** tabInitParameter, int64_t nbInitParameter);
102 
103  /* Partition */
104  //-----------//
106  const int64_t & getNbPartition() const;
107 
109  const Partition ** getTabPartition() const;
110 
112  Partition * getPartition(int64_t index) const;
113 
115  void setPartition(Partition * part, int64_t position);
116 
118  void setPartition(std::string & paramFileName, int64_t position);
119 
121  void setTabPartition(Partition ** tabPartition, int64_t nbPartition);
122 
123  /* Initialization */
124  //----------------//
125 
127  void initSMALL_EM(Model*& model);
128 
130  void initCEM_INIT(Model*& model);
131 
133  void initSEM_MAX(Model*& model);
134 
135  /* Input / Output */
136  //----------------//
137  // input
138  void input(std::ifstream & fi, Data *& data, int64_t nbNbCluster,
139  int64_t * tabNbCluster, ModelType * modelType, bool & alreadyRead);
140 
141  // verification
142  bool verify() const;
143 
144  // print out strategy initialization
145  friend std::ostream & operator << (std::ostream & fo, ClusteringStrategyInit & strategyInit);
146 
147 private:
148 
150  StrategyInitName _strategyInitName;
151 
153  int64_t _nbTry;
154 
156  AlgoStopName _stopName;
157 
159  int64_t _nbIteration;
160 
162  double _epsilon;
163 
164  /* USER */
166  int64_t _nbInitParameter;
167 
169  Parameter ** _tabInitParameter;
170 
171  /* USER_PARTITION */
173  int64_t _nbPartition;
174 
176  Partition ** _tabPartition;
177 
178  bool _deleteTabParameter ;
179 
180  void oneRunOfSmallEM(Model*& model, double & logLikelihood);
181 };
182 
184  return _strategyInitName;
185 }
186 
188  return _stopName;
189 }
190 
191 inline const int64_t & ClusteringStrategyInit::getNbInitParameter() const {
192  return _nbInitParameter;
193 }
194 
195 inline const int64_t & ClusteringStrategyInit::getNbPartition() const {
196  return _nbPartition;
197 }
198 
200  return const_cast<const Parameter**> (_tabInitParameter);
201 }
202 
204  return _tabInitParameter[index];
205 }
206 
208  return const_cast<const Partition**> (_tabPartition);
209 }
210 
211 inline Partition* ClusteringStrategyInit::getPartition(int64_t index) const {
212  return _tabPartition[index];
213 }
214 
215 inline const int64_t ClusteringStrategyInit::getNbTry() const {
216  return _nbTry;
217 }
218 
219 inline const int64_t ClusteringStrategyInit::getNbIteration() const {
220  return _nbIteration;
221 }
222 
223 inline const double ClusteringStrategyInit::getEpsilon() const {
224  return _epsilon;
225 }
226 
227 }
228 
229 #endif
void initCEM_INIT(Model *&model)
Initialization by CEM of the parameters of the model.
Definition: ClusteringStrategyInit.cpp:742
void setTabInitParameter(Parameter **tabInitParameter, int64_t nbInitParameter)
setTabInitParam
Definition: ClusteringStrategyInit.cpp:177
ClusteringStrategyInit()
Default constructor.
Definition: ClusteringStrategyInit.cpp:42
Base class for ModelType(s)
Definition: ModelType.h:37
const Partition ** getTabPartition() const
getTabPartition
Definition: ClusteringStrategyInit.h:207
Base class for StrategyInitType(s)
Definition: ClusteringStrategyInit.h:43
void setStrategyInitName(StrategyInitName initName)
setStrategyInitName
Definition: ClusteringStrategyInit.cpp:116
void initSEM_MAX(Model *&model)
Initialization by SEM of the parameters of the model.
Definition: ClusteringStrategyInit.cpp:819
Parameter * getInitParameter(int64_t index) const
getTabInitParameter
Definition: ClusteringStrategyInit.h:203
const double getEpsilon() const
getEpsilon
Definition: ClusteringStrategyInit.h:223
void setNbTry(int64_t nbTry)
setNbTry
Definition: ClusteringStrategyInit.cpp:289
Base class for Partition(s)
Definition: Partition.h:39
void initSMALL_EM(Model *&model)
Initialization by EM of the parameters of the model.
Definition: ClusteringStrategyInit.cpp:642
Definition: Model.h:50
void setStopName(AlgoStopName stopName)
setStopName
Definition: ClusteringStrategyInit.cpp:274
void setInitParam(std::string &paramFileName, int64_t position)
setInitParam
Definition: ClusteringStrategyInit.cpp:160
void setTabPartition(Partition **tabPartition, int64_t nbPartition)
setTabPartition
Definition: ClusteringStrategyInit.cpp:256
const AlgoStopName getStopName() const
getStopName
Definition: ClusteringStrategyInit.h:187
void setEpsilon(double epsilon)
setEpsilon
Definition: ClusteringStrategyInit.cpp:331
virtual ~ClusteringStrategyInit()
Destructor.
Definition: ClusteringStrategyInit.cpp:94
const StrategyInitName & getStrategyInitName() const
getStrategyInitName
Definition: ClusteringStrategyInit.h:183
Partition * getPartition(int64_t index) const
getTabPartition
Definition: ClusteringStrategyInit.h:211
Constants definitions, various utilities to describe models, and others...
StrategyInitName
Enumeration of differents strategy initialization.
Definition: Util.h:274
const int64_t & getNbPartition() const
getNbPartition
Definition: ClusteringStrategyInit.h:195
const int64_t getNbIteration() const
getNbIteration
Definition: ClusteringStrategyInit.h:219
Base class for Data.
Definition: Data.h:43
void setPartition(Partition *part, int64_t position)
set Init Partition
Definition: ClusteringStrategyInit.cpp:196
AlgoStopName
Enumeration of differents type of converge of algorithm (stop rule)
Definition: Util.h:291
void setNbIteration(int64_t nbIteration)
set NbIteration
Definition: ClusteringStrategyInit.cpp:311
Base class for XEMParameter(s)
Definition: Parameter.h:45
const int64_t & getNbInitParameter() const
getNbInitParameter
Definition: ClusteringStrategyInit.h:191
const Parameter ** getTabInitParameter() const
getTabInitParameter
Definition: ClusteringStrategyInit.h:199
const int64_t getNbTry() const
getNbTry
Definition: ClusteringStrategyInit.h:215