CluE  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
proxysolution.h
Go to the documentation of this file.
1 #ifndef PROXYSOLUTION_H
2 #define PROXYSOLUTION_H
3 
4 #include "../base/solutionprovider.h"
5 #include "../base/proxyprovider.h"
6 
7 #include <vector>
8 
9 namespace CluE
10 {
11 
19 template<typename T> struct ProxySolution : public SolutionProvider, public ProxyProvider<T>
20 {
21 public:
22 
23  ProxySolution();
24 
25  virtual ~ProxySolution()
26  {
27  }
28 
29  virtual double computationtime() const;
30  virtual unsigned int number_of_solutions() const;
31  virtual unsigned int size_of_solution(unsigned int) const;
32 
33  virtual T proxy(unsigned int n, unsigned int c) const;
34  virtual std::vector<T> proxies(unsigned int n) const;
35 
36  double seconds;
37  std::vector<std::vector<T>> proxysets;
38 };
39 
40 template<typename T> ProxySolution<T>::ProxySolution() : seconds()
41 {
42 }
43 
44 template<typename T> double ProxySolution<T>::computationtime() const
45 {
46  return seconds;
47 }
48 
49 template<typename T> unsigned int ProxySolution<T>::number_of_solutions() const
50 {
51  return this->proxysets.size();
52 }
53 
54 template<typename T> unsigned int ProxySolution<T>::size_of_solution(unsigned int i) const
55 {
56  if (i<this->proxysets.size())
57  return this->proxysets[i].size();
58  return 0;
59 }
60 
61 template<typename T> T ProxySolution<T>::proxy(unsigned int n, unsigned int c) const
62 {
63  if (n<this->proxysets.size())
64  if (c<this->proxysets[n].size())
65  return this->proxysets[n][c];
66 
67  std::cerr << "ProxySolution<T>::proxy(" << n << "," << c << "): requested proxy not available" << std::endl;
68  throw "ILLEGAL STATE";
69 }
70 
71 template<typename T> std::vector<T> ProxySolution<T>::proxies(unsigned int n) const
72 {
73  if (n<this->proxysets.size())
74  return this->proxysets[n];
75  return std::vector<T>();
76 }
77 
78 }
79 
80 #endif
Abstract base class to access results of proxy / center based clustering algorithms.
Definition: proxyprovider.h:14
std::vector< std::vector< T > > proxysets
Definition: proxysolution.h:37
virtual std::vector< T > proxies(unsigned int n) const
returns the proxies for the specified clustering
Definition: proxysolution.h:71
virtual T proxy(unsigned int n, unsigned int c) const
returns the proxy for the specified clustering and cluster
Definition: proxysolution.h:61
virtual double computationtime() const
returns the time needed for the last computation
Definition: proxysolution.h:44
virtual unsigned int number_of_solutions() const
returns the number of available solutions
Definition: proxysolution.h:49
Data structure for proxies.
Definition: proxysolution.h:19
virtual ~ProxySolution()
Definition: proxysolution.h:25
virtual unsigned int size_of_solution(unsigned int) const
returns the size of a particular solution
Definition: proxysolution.h:54
Abstract base class for algorithm solutions.