From e2da94fcd14dd6f45547b11e3b44e0ca52309e7f Mon Sep 17 00:00:00 2001 From: jsnelgro Date: Sun, 9 Aug 2015 14:04:38 -0400 Subject: [PATCH 1/2] annealing runs should be running in parallel now --- runAnnealBayes.m | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/runAnnealBayes.m b/runAnnealBayes.m index 83c950d92..74e747991 100644 --- a/runAnnealBayes.m +++ b/runAnnealBayes.m @@ -26,26 +26,44 @@ end end -for t = 1:T +erdosAnnealRes = cell(I, J, T); +wishAnnealRes = cell(J, T); + +parfor t = 1:T disp(['cur t:' num2str(t) ' out of ' num2str(T)]); for j = 1:J - load(files{(t-1)*J+j}); + da = load(files{(t-1)*J+j}); + data = da.data; + dslice = erdosAnnealRes(:,:,t); for k=1:length(erdosPs) [covMat bestLP] = simAnnealErdos(@erdosPost,data,numOptRuns,erdosPs(k),.4); + dslice{j,k} = covMat; + erdosAnnealRes(:,:,t) = dslice; + end + if runWish + [wishCovMat bestLP] = simAnneal(@wishPost,data,numOptRuns,b,10*eye(N)); + wishAnnealRes{j,t} = wishCovMat; + end + end +end + +% add to bayesSigs +disp('processing annealing results...'); +for t = 1:T + for j = 1:J + for k = 1:length(erdosPs) + covMat = erdosAnnealRes{k,j,t}; bayesSigs{k,j}(:,:,t) = reshape(covMat, [ N N 1]); tBDists(k,j,t) = covMatDist(reshape(bayesSigs{k,j}(:,:,t), [N N]), ... - reshape(trueSigs{j}(:,:,t), [N N])); + reshape(trueSigs{j}(:,:,t), [N N])); end if runWish - [covMat bestLP] = simAnneal(@wishPost,data,numOptRuns,b,10*eye(N)); - bayesSigs{length(erdosPs)+1,j}(:,:,t) = reshape(covMat, [N N 1]); + wishCovMat = wishAnnealRes{j,t}; + bayesSigs{length(erdosPs)+1,j}(:,:,t) = reshape(wishCovMat, [N N 1]); tBDists(length(erdosPs)+1,j,t) = covMatDist(reshape(bayesSigs{length(erdosPs)+1,j}(:,:,t), [N N]), ... - reshape(trueSigs{j}(:,:,t), [N N])); + reshape(trueSigs{j}(:,:,t), [N N])); end end end - - -end - +disp('finished processing annealing runs'); From 9bf91cad4ba318c110a395c6ff1fa72cda674e8c Mon Sep 17 00:00:00 2001 From: jsnelgro Date: Fri, 4 Sep 2015 18:28:32 -0400 Subject: [PATCH 2/2] add matlabpool to actually use workers --- README.md | 2 +- runAnnealBayes.m | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3511db7f2..a8573e0c6 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,4 @@ from the command line: 3. `sh install_.sh` -4. `matlab2011 -nodesktop -nosplash -nojvm -r runFullSims` *(if you're on brie. Otherwise it's just `matlab -nodesktop -nosplash -r runFullSims`)* +4. `matlab2011 -nodesktop -nosplash -r runFullSims` *(if you're on brie. Otherwise it's just `matlab -nodesktop -nosplash -r runFullSims`)* diff --git a/runAnnealBayes.m b/runAnnealBayes.m index 74e747991..9a0b11cf6 100644 --- a/runAnnealBayes.m +++ b/runAnnealBayes.m @@ -28,7 +28,7 @@ erdosAnnealRes = cell(I, J, T); wishAnnealRes = cell(J, T); - +matlabpool(4) parfor t = 1:T disp(['cur t:' num2str(t) ' out of ' num2str(T)]); for j = 1:J @@ -45,7 +45,9 @@ wishAnnealRes{j,t} = wishCovMat; end end + disp(['t:' num2str(t) ' finished.']); end +matlabpool close % add to bayesSigs disp('processing annealing results...');