- range = (index-1) + seq_len(nb_series_per_chunk)
- ref_series = getRefSeries(range)
- if (is.null(ref_series))
- break
- #get medoids indices for this chunk of series
- for (i in seq_len(nrow(ref_series)))
+ # outfile=="" to see stderr/stdout on terminal
+ cl <-
+ if (verbose)
+ parallel::makeCluster(ncores_clust, outfile = "")
+ else
+ parallel::makeCluster(ncores_clust)
+ parallel::clusterExport(cl, c("getContribs","K1","verbose"), envir=environment())
+ }
+ # Iterate clustering algorithm 1 until K1 medoids are found
+ while (length(indices) > K1)
+ {
+ # Balance tasks by splitting the indices set - as evenly as possible
+ indices_workers <- .splitIndices(indices, nb_items_clust, min_size=K1+1)
+ indices <-
+ if (parll)
+ {
+ unlist( parallel::parLapply(cl, indices_workers, function(inds) {
+ require("epclust", quietly=TRUE)
+ inds[ algoClust1(getContribs(inds), K1) ]
+ }) )
+ }
+ else
+ {
+ unlist( lapply(indices_workers, function(inds)
+ inds[ algoClust1(getContribs(inds), K1) ]
+ ) )
+ }
+ if (verbose)