CluE  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
discretedoublesolution.h
Go to the documentation of this file.
1 #ifndef DISCRETEDOUBLESOLUTION_H
2 #define DISCRETEDOUBLESOLUTION_H
3 
4 #include "../base/solutionprovider.h"
5 #include "../base/discreteproxyprovider.h"
6 #include "../base/partitionprovider.h"
7 
8 #include <vector>
9 
10 //TODO Derived documentation bug
11 
12 namespace CluE
13 {
14 
22 template<typename T> struct DiscreteDoubleSolution : public SolutionProvider,
23  public DiscreteProxyProvider<T>, public PartitionProvider<T>
24 {
25 public:
27 
29  {
30  }
31 
32  virtual double computationtime() const;
33  virtual unsigned int number_of_solutions() const;
34  virtual unsigned int size_of_solution(unsigned int) const;
35 
36  virtual T* discrete_proxy(unsigned int n, unsigned int c) const;
37  virtual std::vector<T*> discrete_proxies(unsigned int n) const;
38 
39  virtual unsigned int clustersize(unsigned int, unsigned int) const;
40  virtual T* element(unsigned int, unsigned int, unsigned int) const;
41  virtual std::vector<T*> cluster(unsigned int, unsigned int) const;
42  virtual std::vector<std::vector<T*> > clustering(unsigned int) const;
43 
44  double seconds;
45  std::vector<std::vector<T*> > proxysets;
46  std::vector<std::vector<std::vector<T*> > > partitions;
47 };
48 
49 template<typename T> DiscreteDoubleSolution<T>::DiscreteDoubleSolution() : seconds()
50 {
51 }
52 
53 template<typename T> double DiscreteDoubleSolution<T>::computationtime() const
54 {
55  return seconds;
56 }
57 
58 template<typename T> unsigned int DiscreteDoubleSolution<T>::number_of_solutions() const
59 {
60  unsigned int proxynum = this->proxysets.size();
61  unsigned int partitionnum = this->partitions.size();
62  return proxynum<partitionnum?proxynum:partitionnum;
63 }
64 
65 template<typename T> unsigned int DiscreteDoubleSolution<T>::size_of_solution(unsigned int i) const
66 {
67  if (i<this->number_of_solutions())
68  {
69  unsigned int proxysize = this->proxysets[i].size();
70  unsigned int partitionsize = this->partitions[i].size();
71  return proxysize<partitionsize?proxysize:partitionsize;
72  }
73  return 0;
74 }
75 
76 template<typename T> T* DiscreteDoubleSolution<T>::discrete_proxy(unsigned int n, unsigned int c) const
77 {
78  if (n<this->proxysets.size())
79  if (c<this->proxysets[n].size())
80  return this->proxysets[n][c];
81  return NULL;
82 }
83 
84 template<typename T> std::vector<T*> DiscreteDoubleSolution<T>::discrete_proxies(unsigned int n) const
85 {
86  if (n<this->proxysets.size())
87  return this->proxysets[n];
88  return std::vector<T*>();
89 }
90 
91 template<typename T> unsigned int DiscreteDoubleSolution<T>::clustersize(unsigned int g, unsigned int c) const
92 {
93  if (g<this->partitions.size())
94  if (c<this->partitions[g].size())
95  return this->partitions[g][c].size();
96  return 0;
97 }
98 
99 template<typename T> T* DiscreteDoubleSolution<T>::element(unsigned int g, unsigned int c, unsigned int n) const
100 {
101  if (g<this->partitions.size())
102  if (c<this->partitions[g].size())
103  if (n<this->partitions[g][c].size())
104  return this->partitions[g][c][n];
105  return NULL;
106 }
107 
108 template<typename T> std::vector<T*> DiscreteDoubleSolution<T>::cluster(unsigned int g, unsigned int c) const
109 {
110  if (g<this->partitions.size())
111  if (c<this->partitions[g].size())
112  return this->partitions[g][c];
113  return std::vector<T*>();
114 }
115 
116 template<typename T> std::vector<std::vector<T*> > DiscreteDoubleSolution<T>::clustering(unsigned int g) const
117 {
118  if (g<this->partitions.size())
119  return this->partitions[g];
120  return std::vector<std::vector<T*> >();
121 }
122 
123 }
124 
125 #endif
virtual double computationtime() const
returns the time needed for the last computation
Abstract base class to access the results of proxy / center based clustering algorithms.
std::vector< std::vector< T * > > proxysets
std::vector< std::vector< std::vector< T * > > > partitions
virtual unsigned int number_of_solutions() const
returns the number of available solutions
Data structure for partitions and discrete proxies.
virtual std::vector< T * > discrete_proxies(unsigned int n) const
Returns a vector of pointers to the proxies for the specified clustering.
virtual std::vector< std::vector< T * > > clustering(unsigned int) const
Returns the specified clustering as a vector of vector of pointers to the elements.
virtual T * element(unsigned int, unsigned int, unsigned int) const
Returns a pointer to a particular element from the specified cluster and clustering.
Abstract base class to access results of partition based clustering algorithms.
virtual T * discrete_proxy(unsigned int n, unsigned int c) const
Returns a pointer to the proxy for the specified clustering and cluster.
virtual std::vector< T * > cluster(unsigned int, unsigned int) const
Returns a vector of pointers to the elements of a particular cluster from the specified clustering...
virtual unsigned int clustersize(unsigned int, unsigned int) const
Returns the cardinality of the specified cluster from the computed clustering.
Abstract base class for algorithm solutions.
virtual unsigned int size_of_solution(unsigned int) const
returns the size of a particular solution