ClusteringModel.h
Go to the documentation of this file.
1 //===========================================================================
2 /*!
3  *
4  *
5  * \brief Super class for clustering models.
6  *
7  *
8  *
9  * \author T. Glasmachers
10  * \date 2011
11  *
12  *
13  * \par Copyright 1995-2017 Shark Development Team
14  *
15  * <BR><HR>
16  * This file is part of Shark.
17  * <http://shark-ml.org/>
18  *
19  * Shark is free software: you can redistribute it and/or modify
20  * it under the terms of the GNU Lesser General Public License as published
21  * by the Free Software Foundation, either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * Shark is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public License
30  * along with Shark. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
33 //===========================================================================
34 
35 #ifndef SHARK_MODELS_CLUSTERING_CLUSTERINGMODEL_H
36 #define SHARK_MODELS_CLUSTERING_CLUSTERINGMODEL_H
37 
38 
41 
42 
43 namespace shark {
44 
45 
46 /// \brief Abstract model with associated clustering object.
47 ///
48 /// See HardClusteringModel and SoftClusteringModel for details.
49 template <class InputT, class OutputT>
50 class ClusteringModel : public AbstractModel<InputT, OutputT>
51 {
52 public:
57 
58  /// Constructor.
59  ClusteringModel(ClusteringType* clustering)
60  : mep_clustering(clustering)
61  { SHARK_RUNTIME_CHECK(clustering, "[ClusteringModel] Clustering must not be NULL"); }
62 
63 
64  /// Redirect parameter access to the clustering object
65  RealVector parameterVector() const
66  { return mep_clustering->parameterVector(); }
67 
68  /// Redirect parameter access to the clustering object
69  void setParameterVector(RealVector const& newParameters)
70  { mep_clustering->setParameterVector(newParameters); }
71 
72  /// Redirect parameter access to the clustering object
73  std::size_t numberOfParameters() const
74  { return mep_clustering->numberOfParameters(); }
75 
76  /// From ISerializable, reads a model from an archive.
77  void read(InArchive& archive)
78  { archive & *mep_clustering; }
79 
80  /// From ISerializable, writes a model to an archive.
81  void write(OutArchive& archive) const
82  { archive & *mep_clustering; }
83 
84  using base_type::eval;
85  void eval(BatchInputType const& patterns, BatchOutputType& outputs, State& state)const{
86  eval(patterns,outputs);
87  }
88 
89 protected:
90  /// Clustering object, see class AbstractClustering
91  ClusteringType* mep_clustering;
92 };
93 
94 
95 }
96 #endif