- nb_workers = max( 1, round( length(indices_clust) / nb_series_per_chunk ) )
- indices_workers = list()
- #indices[[i]] == (start_index,number_of_elements)
- for (i in 1:nb_workers)
- {
- upper_bound = ifelse( i<nb_workers,
- min(nb_series_per_chunk*i,length(indices_clust)), length(indices_clust) )
- indices_workers[[i]] = indices_clust[(nb_series_per_chunk*(i-1)+1):upper_bound]
- }
- indices_clust = parallel::parSapply(cl, indices_workers, processChunk, K1, K2*(WER=="mix"))
- if ( (WER=="end" && length(indices_clust) == K1) ||
- (WER=="mix" && length(indices_clust) == K2) )
- {
- break
- }
+ upper_bound = ifelse( i<nb_workers,
+ min(nb_series_per_chunk*i,length(indices_clust)), length(indices_clust) )
+ indices_workers[[i]] = indices_clust[(nb_series_per_chunk*(i-1)+1):upper_bound]