X-Git-Url: https://git.auder.net/?p=epclust.git;a=blobdiff_plain;f=epclust%2FR%2Fclustering.R;fp=epclust%2FR%2Fstage2.R;h=e27ea353e479fb8185afb124f02fbcab56c9d4e0;hp=3ccbbad10903b256c005b0476b418bf3bbfdd9a3;hb=5c6529795907ba1b34d4552cbfd0e0cbb77cac0f;hpb=db6fc17ddd53fb0c64cf957296dc615ba830db56 diff --git a/epclust/R/stage2.R b/epclust/R/clustering.R similarity index 53% rename from epclust/R/stage2.R rename to epclust/R/clustering.R index 3ccbbad..e27ea35 100644 --- a/epclust/R/stage2.R +++ b/epclust/R/clustering.R @@ -1,8 +1,66 @@ -library("Rwave") +oneIteration = function(..........) +{ + cl_clust = parallel::makeCluster(ncores_clust) + parallel::clusterExport(cl_clust, .............., envir=........) + indices_clust = indices_task[[i]] + repeat + { + 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 0) + { + curves = computeSynchrones(cl) + dists = computeWerDists(curves) + cl = computeClusters(dists, K2) + } + cl +} + +computeClusters = function(data, K) +{ + library(cluster) + pam_output = cluster::pam(data, K) + return ( list( clusts=pam_output$clustering, medoids=pam_output$medoids, + ranks=pam_output$id.med ) ) +} + +#TODO: appendCoeffs() en C --> serialize et append to file + +computeSynchrones = function(...) +{ + +} #Entrée : courbes synchrones, soit après étape 1 itérée, soit après chaqure étape 1 -step2 = function(conso) +computeWerDist = function(conso) { + if (!require("Rwave", quietly=TRUE)) + stop("Unable to load Rwave library") n <- nrow(conso) delta <- ncol(conso) #TODO: automatic tune of all these parameters ? (for other users)