mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
ClusteringStrategy.h
1 /***************************************************************************
2  SRC/mixmod/Clustering/ClusteringStrategy.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 XEMClusteringStrategy_H
26 #define XEMClusteringStrategy_H
27 
28 #include "mixmod/Utilities/Util.h"
29 
30 namespace XEM {
31 
32 // pre-declaration
33 class ClusteringStrategyInit;
34 class ModelType;
35 class Parameter;
36 class Data;
37 class Model;
38 class Partition;
39 
48 
49 public:
50 
53 
55  ClusteringStrategy(const ClusteringStrategy & strategy);
56 
59 
63 
66 
68  void setStrategyInit(ClusteringStrategyInit * iStrategyInit);
69 
71  void setStrategyInit(StrategyInitName initName, Data *& data, int64_t nbNbCluster,
72  int64_t * tabNbCluster, ModelType * modelType);
73 
76 
78  void setInitParam(std::string & paramFileName, int64_t position);
79 
81  void setTabInitParameter(Parameter ** tabInitParameter, int64_t nbInitParameter);
82 
84  void setInitPartition(std::string & partitionFileName, int64_t position);
85 
87  void setInitPartition(Partition * part, int64_t position);
88 
90  void setTabPartition(Partition ** tabPartition, int64_t nbPartition);
91 
93  const int64_t getNbTryInInit() const;
94 
96  void setNbTryInInit(int64_t nbTry);
97 
99  const int64_t getNbIterationInInit() const;
100 
102  void setNbIterationInInit(int64_t nbIteration);
103 
105  const double getEpsilonInInit() const;
106 
108  void setEpsilonInInit(double epsilon);
109 
111  const AlgoStopName getStopNameInInit() const;
112 
114  void setStopNameInInit(AlgoStopName stopName);
115 
119 
121  const Algo * getAlgo(int64_t index) const;
122 
124  void setAlgo(AlgoName algoName, int64_t position);
125 
127  void addAlgo(AlgoName algoName);
128 
130  void removeAlgo(unsigned int position);
131 
133  std::vector<Algo*> const & getTabAlgo() const;
134  std::vector<Algo*> & getTabAlgo();
135 
137  void insertAlgo(AlgoName algoName, int64_t position);
138 
140  void setAlgoStopRule(AlgoStopName stopName, int64_t position);
141  void setAlgoIteration( int64_t position, int64_t nbIterationValue);
142  void setAlgoEpsilon( int64_t position, double epsilonValue);
143 
145  const int64_t getNbTry()const;
146  void setNbTry(int64_t nbTry);
147 
148  const int64_t getNbAlgo() const;
149 
151  // TODO XEMInput : a enlever
152  void input_FLAT_FORMAT(std::ifstream & fi, Data *& data, int64_t nbNbCluster,
153  int64_t * tabNbCluster, ModelType * modelType);
154 
156  void run(Model *& model) const;
157 
158  bool verify();
159 
160  //void edit(std::ofstream & oFile);
161  void edit(std::ostream & out);
162 
163  friend std::ostream & operator << (std::ostream & fo, ClusteringStrategy & strategy);
164 
165 private:
166 
168  int64_t _nbTry;
169 
171  ClusteringStrategyInit * _strategyInit;
172 
174  int64_t _nbAlgo;
175 
177  std::vector<Algo*> _tabAlgo; // aggregate
178 
180  void oneTry(Model *& model, bool doThrow=false) const;
181 };
182 
184  return _strategyInit;
185 }
186 
187 inline const Algo * ClusteringStrategy::getAlgo(int64_t index) const {
188  return _tabAlgo[index];
189 }
190 
191 inline std::vector<Algo*> const & ClusteringStrategy::getTabAlgo() const {
192  return _tabAlgo;
193 }
194 
195 inline std::vector<Algo*> & ClusteringStrategy::getTabAlgo() {
196  return _tabAlgo;
197 }
198 
199 inline const int64_t ClusteringStrategy::getNbAlgo() const {
200  return _nbAlgo;
201 }
202 
203 inline const int64_t ClusteringStrategy::getNbTry()const {
204  return _nbTry;
205 }
206 
207 }
208 
209 #endif
void setNbIterationInInit(int64_t nbIteration)
set NbIterationInInit
Definition: ClusteringStrategy.cpp:685
Base class for ModelType(s)
Definition: ModelType.h:37
const int64_t getNbTryInInit() const
getNbTryInInit
Definition: ClusteringStrategy.cpp:665
void setEpsilonInInit(double epsilon)
setEpsilonInInit
Definition: ClusteringStrategy.cpp:689
const ClusteringStrategyInit * getStrategyInit() const
getStrategyInit
Definition: ClusteringStrategy.h:183
Base class for StrategyInitType(s)
Definition: ClusteringStrategyInit.h:43
void setTabPartition(Partition **tabPartition, int64_t nbPartition)
setTabPartition
Definition: ClusteringStrategy.cpp:156
const int64_t getNbTry() const
nbTry
Definition: ClusteringStrategy.h:203
void setStrategyInitName(StrategyInitName initName)
setStrategyInitName
Definition: ClusteringStrategy.cpp:681
void setStopNameInInit(AlgoStopName stopName)
setStopNameInInit
Definition: ClusteringStrategy.cpp:697
void setNbTryInInit(int64_t nbTry)
setNbTryInInit
Definition: ClusteringStrategy.cpp:677
void setAlgo(AlgoName algoName, int64_t position)
setAlgo
Definition: ClusteringStrategy.cpp:97
AlgoName
Enumeration of Algo type.
Definition: Util.h:319
Base class for Partition(s)
Definition: Partition.h:39
Definition: Model.h:50
const int64_t getNbIterationInInit() const
getNbIterationInInit
Definition: ClusteringStrategy.cpp:669
void removeAlgo(unsigned int position)
removeAlgo
Definition: ClusteringStrategy.cpp:179
Definition: ClusteringStrategy.h:47
std::vector< Algo * > const & getTabAlgo() const
getTabAlgo
Definition: ClusteringStrategy.h:191
const AlgoStopName getStopNameInInit() const
getStopNameInInit
Definition: ClusteringStrategy.cpp:693
const Algo * getAlgo(int64_t index) const
getAlgo[i]
Definition: ClusteringStrategy.h:187
void addAlgo(AlgoName algoName)
addAlgo (and the end of the list)
Definition: ClusteringStrategy.cpp:117
void setAlgoStopRule(AlgoStopName stopName, int64_t position)
setAlgoStopRuleTypeValue
Definition: ClusteringStrategy.cpp:88
Constants definitions, various utilities to describe models, and others...
StrategyInitName
Enumeration of differents strategy initialization.
Definition: Util.h:274
void setTabInitParameter(Parameter **tabInitParameter, int64_t nbInitParameter)
setInitParam
Definition: ClusteringStrategy.cpp:140
void run(Model *&model) const
Run method.
Definition: ClusteringStrategy.cpp:276
~ClusteringStrategy()
Destructor.
Definition: ClusteringStrategy.cpp:74
ClusteringStrategy()
Default constructor.
Definition: ClusteringStrategy.cpp:47
void setStrategyInit(ClusteringStrategyInit *iStrategyInit)
setStrategyInit
Definition: ClusteringStrategy.cpp:190
Base class for Data.
Definition: Data.h:43
void setInitPartition(std::string &partitionFileName, int64_t position)
setInitPartition
Definition: ClusteringStrategy.cpp:147
const double getEpsilonInInit() const
getEpsilonInInit
Definition: ClusteringStrategy.cpp:673
Base class for Algorithm(s)
Definition: Algo.h:40
void input_FLAT_FORMAT(std::ifstream &fi, Data *&data, int64_t nbNbCluster, int64_t *tabNbCluster, ModelType *modelType)
Input strategy (FLAT FORMAT)
Definition: ClusteringStrategy.cpp:493
void setInitParam(std::string &paramFileName, int64_t position)
setInitParam
Definition: ClusteringStrategy.cpp:136
AlgoStopName
Enumeration of differents type of converge of algorithm (stop rule)
Definition: Util.h:291
Base class for XEMParameter(s)
Definition: Parameter.h:45
void insertAlgo(AlgoName algoName, int64_t position)
insertAlgo
Definition: ClusteringStrategy.cpp:161