diff --git a/07_final_assignment/.RData b/07_final_assignment/.RData index 754a4bb..ea2c0c1 100644 --- a/07_final_assignment/.RData +++ b/07_final_assignment/.RData Binary files differ diff --git a/07_final_assignment/baboonSimulation.R b/07_final_assignment/baboonSimulation.R index c011387..b05d853 100644 --- a/07_final_assignment/baboonSimulation.R +++ b/07_final_assignment/baboonSimulation.R @@ -347,7 +347,10 @@ # Goal: Being able to run without a shared data structure # and thus avoiding conflicts with critical sections -print.iterations = TRUE +print.iterations = FALSE #Note: Not meaningful for parallel execution, +#see http://blog.revolutionanalytics.com/2015/02/monitoring-progress-of-a-foreach-parallel-job.html +#for a discussion + num.cores = 15 #Can NOT be changed without further code adjustment monkeys.per.core = 8 #Can NOT be changed without further code adjustment @@ -355,7 +358,7 @@ start.of.a.and.b = 0.001 #Can be changed with no further code adjustment end.of.a.and.b = 0.300 #Can be changed with no further code adjustment -debug = FALSE +debug = TRUE #8 experiments for each core, 15 cores @@ -384,13 +387,24 @@ do.experiment <- function(i) { filename <- paste("resultdat", i, ".txt", sep="") - resultdat <- data.frame(alpha=numeric(1), beta=numeric(1), - NumTrials=numeric(1), - NumWordsLearned=numeric(1), - NumNonwordsPresented=numeric(1), - GeneralAccuracy=numeric(1), - WordAccuracy=numeric(1), - NonwordAccuracy=numeric(1)) + + if(debug) { + resultdat <- data.frame(alpha=numeric(1), beta=numeric(1), + Time=character(1), + NumWordsLearned=numeric(1), + NumNonwordsPresented=numeric(1), + GeneralAccuracy=numeric(1), + WordAccuracy=numeric(1), + NonwordAccuracy=numeric(1)) + } else { + resultdat <- data.frame(alpha=numeric(1), beta=numeric(1), + NumTrials=numeric(1), + NumWordsLearned=numeric(1), + NumNonwordsPresented=numeric(1), + GeneralAccuracy=numeric(1), + WordAccuracy=numeric(1), + NonwordAccuracy=numeric(1)) + } write.table(resultdat, file=filename, col.names=names(resultdat)) trialCount <- 50000 @@ -406,9 +420,10 @@ } if(debug) { - + Sys.sleep(1) + current.time = Sys.time() debug.frame = data.frame(alpha=a, beta=b, - NumTrials=numeric(1), + Time=as.character(current.time), NumWordsLearned=numeric(1), NumNonwordsPresented=numeric(1), GeneralAccuracy=numeric(1), @@ -444,8 +459,8 @@ ##new version: #...RUN, MONKEY, RUN! -registerDoParallel(cores=num.cores) -foreach(i=1:num.cores) %dopar% do.experiment(i) +#registerDoParallel(cores=num.cores) +#foreach(i=1:num.cores) %dopar% do.experiment(i) ########################################################################################