mixmod  3.2.0
Mixture models for clustering and classification
 All Classes Namespaces Files Functions Variables Enumerations Friends
Algo.h
1 /***************************************************************************
2  SRC/mixmod/Kernel/Algo/Algo.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 XEMALGO_H
26 #define XEMALGO_H
27 
28 #include "mixmod/Utilities/Util.h"
29 
30 namespace XEM {
31 
32 // pre-declaration
33 class Model;
34 
40 class Algo {
41 
42 public:
43 
45  Algo();
46 
48  Algo(const Algo & algo);
49 
51  Algo(AlgoStopName algoStopName, double epsilon, int64_t nbIteration);
52 
54  virtual ~Algo();
55 
57  virtual Algo * clone() = 0;
58 
60  virtual void run(Model *& model) = 0;
61 
62  //void edit(std::ofstream & oFile);
63  void edit(std::ostream & out);
64 
65  virtual const AlgoStopName getAlgoStopName() const;
66 
67  virtual const AlgoName getAlgoName() const = 0;
68 
69  virtual void setAlgoStopName(AlgoStopName algoStopName);
70 
71  virtual void setNbIteration(int64_t nbIteration);
72 
73  virtual const int64_t getNbIteration() const;
74 
75  virtual void setEpsilon(double epsilon);
76 
77  virtual const double getEpsilon() const;
78 
79  friend std::ostream & operator <<(std::ostream & fo, Algo & algo);
80 
81 protected:
82 
84  AlgoStopName _algoStopName;
85 
87  int64_t _nbIteration;
88 
90  int64_t _indexIteration;
91 
93  double _epsilon;
94 
98  bool continueAgain();
99 
100  double _xml_old;
101 
102  double _xml;
103 
104 #if SAVE_ALL_MODELS
105  Model ** _tabModel; // aggregate
106 #endif
107 };
108 
109 inline void Algo::setAlgoStopName(AlgoStopName algoStopName) {
110  _algoStopName = algoStopName;
111 }
112 
113 inline void Algo::setNbIteration(int64_t nbIteration) {
114  if (nbIteration < minNbIteration) {
115  THROW(InputException, nbIterationTooSmall);
116  }
117  else if (nbIteration > maxNbIteration) {
118  THROW(InputException, nbIterationTooLarge);
119  }
120  else {
121  _nbIteration = nbIteration;
122  }
123 }
124 
125 inline const int64_t Algo::getNbIteration() const {
126  return _nbIteration;
127 }
128 
129 inline const double Algo::getEpsilon() const {
130  return _epsilon;
131 }
132 
133 inline const AlgoStopName Algo::getAlgoStopName() const {
134  return _algoStopName;
135 }
136 
137 // others functions
138 Algo * createDefaultClusteringAlgo();
139 }
140 
141 #endif
virtual void run(Model *&model)=0
Run method.
Algo()
Default constructor.
Definition: Algo.cpp:33
virtual ~Algo()
Destructor.
Definition: Algo.cpp:64
AlgoName
Enumeration of Algo type.
Definition: Util.h:319
Definition: Model.h:50
Constants definitions, various utilities to describe models, and others...
virtual Algo * clone()=0
clone
bool continueAgain()
Selector.
Definition: Algo.cpp:83
Base class for Algorithm(s)
Definition: Algo.h:40
AlgoStopName
Enumeration of differents type of converge of algorithm (stop rule)
Definition: Util.h:291