4 #include "../base/algorithm.h"
5 #include "../base/inputsetter.h"
6 #include "../base/measuresetter.h"
7 #include "../datastructure/discretedoublesolution.h"
8 #include "../sampling/farthestfirsttraversal.h"
10 #include "../exception/invalidruntimeconfigurationexception.h"
50 virtual void setInput(std::vector<T*>
const*);
78 measure(measure==0 ? 0 : measure->clone()),
86 measure(gon.measure == 0 ? 0 : gon.measure->clone()),
88 numberOfClusters(gon.numberOfClusters),
89 first_point(gon.first_point)
98 Algorithm::operator= (gon);
117 unsigned int numOfPoints = this->input->size();
121 if(this->measure == 0)
123 if(this->numberOfClusters > numOfPoints)
132 unsigned int numOfProxies = dps->
proxysets[0].size();
138 solution->
partitions.push_back(std::vector<std::vector<T*> >());
139 for(
unsigned int i = 0; i < numOfProxies; i++)
140 solution->
partitions[0].push_back(std::vector<T*>());
143 for(
unsigned int i = 0; i < numOfPoints; i++)
145 T* point = (*input)[i];
147 double min = this->measure->dissimilarity(*point, * (dps->
proxysets[0][0]));
148 int assignedProxy = 0;
149 for(
unsigned int j = 1; j < numOfProxies; j++)
152 double candidate = this->measure->dissimilarity(*point, *proxy);
160 solution->
partitions[0][assignedProxy].push_back(point);
173 this->first_point = s;
183 this->numberOfClusters = nc;
188 if(this->measure != 0)
189 delete this->measure;
194 this->measure = measure->
clone();
DissimilarityMeasure< T > * measure
unsigned int numberOfClusters
Data structure for discrete proxies.
std::vector< std::vector< T * > > proxysets
std::vector< std::vector< std::vector< T * > > > partitions
Data structure for partitions and discrete proxies.
std::vector< std::vector< T * > > proxysets
virtual SolutionProvider * compute()
virtual void setMeasure(DissimilarityMeasure< T > const *measure)
virtual DissimilarityMeasure< T > * clone() const =0
static Gonzales< T > * toGonzales(Algorithm *s)
does a dynamic cast of the given Algorithm to Gonzales
void setNumberOfClusters(unsigned int number)
Sets the desired number of clusters.
Abstract base class for algorithms.
Interface to propagate the ability to set a DissimilarityMeasure.
Gonzales< T > & operator=(const Gonzales< T > &)
Farthest first traversal algorithm.
std::vector< T * > const * input
Gonzales(DissimilarityMeasure< T > const *measure=0, std::vector< T * > const *input=0, unsigned int numberOfClusters=1, unsigned int firstPoint=0)
Constructor for general use.
Abstract base class for dissimilarity measurement.
void setFirstPoint(unsigned int index)
Sets the starting point for farthest first traversal.
Indicates that a computation entered an invalid configuration state.
virtual SolutionProvider * compute()
Returns an ordered DiscretesProxySolution. The first point is the starting point. ...
Abstract base class for algorithm solutions.
virtual void setInput(std::vector< T * > const *)