- cl = parallel::makeCluster(ncores_tasks)
- # 1000*K1 indices [if WER=="end"], or empty vector [if WER=="mix"] --> series on file
- indices = unlist( parallel::parLapply(cl, indices_tasks, function(inds) {
- require("epclust", quietly=TRUE)
- indices_medoids = clusteringTask(inds,getCoefs,K1,nb_series_per_chunk,ncores_clust)
+
+ if (parll && ntasks>1)
+ {
+ # Initialize parallel runs: outfile="" allow to output verbose traces in the console
+ # under Linux. All necessary variables are passed to the workers.
+ cl = parallel::makeCluster(ncores_tasks, outfile="")
+ varlist = c("getSeries","getContribs","K1","K2","algo_clust1","algo_clust2",
+ "nb_per_chunk","nb_items_clust","ncores_clust","sep","nbytes","endian",
+ "verbose","parll")
+ if (WER=="mix")
+ varlist = c(varlist, "medoids_file")
+ parallel::clusterExport(cl, varlist, envir = environment())
+ }
+
+ # This function achieves one complete clustering task, divided in stage 1 + stage 2.
+ # stage 1: n indices --> clusteringTask1(...) --> K1 medoids
+ # stage 2: K1 medoids --> clusteringTask2(...) --> K2 medoids,
+ # where n = N / ntasks, N being the total number of curves.
+ runTwoStepClustering = function(inds)
+ {
+ # When running in parallel, the environment is blank: we need to load required
+ # packages, and pass useful variables.
+ if (parll && ntasks>1)
+ require("epclust", quietly=TRUE)
+ indices_medoids = clusteringTask1(
+ inds, getContribs, K1, nb_series_per_chunk, ncores_clust, verbose, parll)