-# Cluster one full task (nb_curves / ntasks series)
-clusteringTask = function(indices,getSeries,getSeriesForSynchrones,synchrones_file,
- getCoefs,K1,K2,nb_series_per_chunk,ncores,to_file,ftype)
-{
- cl = parallel::makeCluster(ncores)
- repeat
- {
- nb_workers = max( 1, round( length(indices) / nb_series_per_chunk ) )
- indices_workers = lapply(seq_len(nb_workers), function(i) {
- upper_bound = ifelse( i<nb_workers,
- min(nb_series_per_chunk*i,length(indices)), length(indices) )
- indices[(nb_series_per_chunk*(i-1)+1):upper_bound]
- })
- indices = unlist( parallel::parLapply(cl, indices_workers, function(inds)
- computeClusters1(inds, getCoefs, K1)) )
- if (length(indices_clust) == K1)
- break
- }
- parallel::stopCluster(cl)
- if (K2 == 0)
- return (indices)
- computeClusters2(indices, K2, getSeries, getSeriesForSynchrones, to_file,
- nb_series_per_chunk,ftype)
- vector("integer",0)
-}
+#' @name clustering
+#' @rdname clustering
+#' @aliases clusteringTask1 clusteringTask2 computeClusters1 computeClusters2
+#'
+#' @title Two-stage clustering, withing one task (see \code{claws()})
+#'
+#' @description \code{clusteringTask1()} runs one full stage-1 task, which consists in
+#' iterated stage 1 clustering on nb_curves / ntasks energy contributions, computed
+#' through discrete wavelets coefficients.
+#' \code{clusteringTask2()} runs a full stage-2 task, which consists in
+#' WER distances computations between medoids indices output from stage 1,
+#' before applying the second clustering algorithm, on the distances matrix.
+#'
+#' @param indices Range of series indices to cluster
+#' @param getContribs Function to retrieve contributions from initial series indices:
+#' \code{getContribs(indices)} outputs a contributions matrix
+#' @inheritParams claws
+#' @inheritParams computeSynchrones
+#'
+#' @return For \code{clusteringTask1()}, the indices of the computed (K1) medoids.
+#' Indices are irrelevant for stage 2 clustering, thus \code{clusteringTask2()}
+#' outputs a big.matrix of medoids (of size LxK2, K2 = final number of clusters)
+NULL