//System.out.println("New clusters: "+nPieces);
//System.out.println("Reassignment table: "+IntArrays.toString(reassign));
// assignment
IDiscretization assignment = this.clusterMethodLeaves.getClusterAssignment();
IDataSequence centers = this.clusterMethodLeaves.getClusterCenters();
IIntArray micro2macroLeaf = cluster.discretize(subset, assignment);
// update global assignment
for (int i=0; i<leaf.indexes.size(); i++)
{
int globalIndex = leaf.indexes.get(i);
int newClusterIndex = reassign[micro2macroLeaf.get(i)];
micro2macro.set(globalIndex, newClusterIndex);
}
// create new leaves
IIntArray[] newLeaveIndexes = new IIntArray[nPieces];
for (int i=0; i<nPieces; i++)
{
newLeaveIndexes[i] = ints.findAll(micro2macroLeaf, i);
// change local to global index
for (int j=0; j<newLeaveIndexes[i].size(); j++)
newLeaveIndexes[i].set(j, leaf.indexes.get(newLeaveIndexes[i].get(j)));
}
// add other leaves to end
leaves.set(leafIndex, new Leaf(centers.get(0), newLeaveIndexes[0]));
for (int i=1; i<nPieces; i++)
{
leaves.add(new Leaf(centers.get(i), newLeaveIndexes[i]));
}
System.out.print(
" splitted indexes: "+leafIndex+" -> ("+IntsPrimitive.util.toString(reassign,",")+")"+
"\n nstates: "+leaf.indexes.size()+" -> (");