1 つのタスクが終了した場合 (他のタスクを待ちたくない)、クラスター計算を中止し、最速の計算の戻り値を取得したい:
require(snow)
library(parallel)
tasks = list(
job1 = function(y, cl){
EMGMM(y=y, startMy = 0)
},
job2 = function(y, cl){
EMGMM(y=y, startMy = 1)
},
job3 = function(y, cl){
EMGMM(y=y, startMy = 2)
}
)
cl = makeCluster( length(tasks) )
clusterExport(cl, "dmvnorm") #needed in EMGMM()
res = clusterApply(cl, tasks, function(f) f(y))
これを実行するres
と、3 つのジョブの 3 つの結果が格納されます。しかし、私は断食の仕事の結果だけが欲しい.
:)