throw new UnableToComplyException("Cluster dimensions do not agree.");
}
}
}
// Vector factory. TODO: make configurable
final DoubleVector factory = new DoubleVector(new double[dim]);
// Prepare result bundle
MultipleObjectsBundle bundle = new MultipleObjectsBundle();
VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, dim, factory);
bundle.appendColumn(type, new ArrayList<Object>());
bundle.appendColumn(TypeUtil.CLASSLABEL, new ArrayList<Object>());
bundle.appendColumn(TypeUtil.MODEL, new ArrayList<Model>());
// generate clusters
for(GeneratorInterface curclus : generators) {
ClassLabel l = new SimpleClassLabel(curclus.getName());
Model model = curclus.makeModel();
int kept = 0;
while(kept < curclus.getSize()) {
// generate the "missing" number of points
List<Vector> newp = curclus.generate(curclus.getSize() - kept);
if(curclus instanceof GeneratorInterfaceDynamic) {
GeneratorInterfaceDynamic cursclus = (GeneratorInterfaceDynamic) curclus;
for(Vector p : newp) {
boolean keep = true;
if(testAgainstModel) {
double max = 0.0;
double is = 0.0;
for(GeneratorInterface other : generators) {
double d = other.getDensity(p) * other.getSize();
if(other == curclus) {
is = d;
}
else if(d > max) {
max = d;
}
}
// Only keep the point if the largest density was the cluster it
// was generated for
if(is < max) {
keep = false;
}
}
if(keep) {
DoubleVector dv = new DoubleVector(p);
bundle.appendSimple(dv, l, model);
++kept;
}
else {
cursclus.incrementDiscarded();