several fixes; still some issues db,bin != ascii,csv
[epclust.git] / epclust / R / clustering.R
index 1774b19..3e7fd38 100644 (file)
@@ -25,6 +25,12 @@ NULL
 clusteringTask1 <- function(indices, getContribs, K1, algoClust1, nb_items_clust,
        ncores_clust=3, verbose=FALSE, parll=TRUE)
 {
+       if (verbose)
+               cat(paste("*** Clustering task 1 on ",length(indices)," series\n", sep=""))
+
+       if (length(indices) <= K1)
+               return (indices)
+
        if (parll)
        {
                # outfile=="" to see stderr/stdout on terminal
@@ -40,8 +46,6 @@ clusteringTask1 <- function(indices, getContribs, K1, algoClust1, nb_items_clust
        {
                # Balance tasks by splitting the indices set - as evenly as possible
                indices_workers <- .splitIndices(indices, nb_items_clust, min_size=K1+1)
-               if (verbose)
-                       cat(paste("*** [iterated] Clustering task 1 on ",length(indices)," series\n", sep=""))
                indices <-
                        if (parll)
                        {
@@ -56,6 +60,11 @@ clusteringTask1 <- function(indices, getContribs, K1, algoClust1, nb_items_clust
                                        inds[ algoClust1(getContribs(inds), K1) ]
                                ) )
                        }
+               if (verbose)
+               {
+                       cat(paste("*** [iterated] Clustering task 1: now ",
+                               length(indices)," medoids\n", sep=""))
+               }
        }
        if (parll)
                parallel::stopCluster(cl)