From 63e8103c4e859d8093f1698275b6a31e2ba47131 Mon Sep 17 00:00:00 2001 From: depristo Date: Fri, 21 Jan 2011 18:40:02 +0000 Subject: [PATCH] A new top-level directory to hold analysis scripts associated with specific analyses git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5046 348d0f76-0448-11de-a6fe-93d51630548a --- analysis/depristo/distributedGATK/model.R | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 analysis/depristo/distributedGATK/model.R diff --git a/analysis/depristo/distributedGATK/model.R b/analysis/depristo/distributedGATK/model.R new file mode 100644 index 000000000..572edb596 --- /dev/null +++ b/analysis/depristo/distributedGATK/model.R @@ -0,0 +1,34 @@ +JOB_START_RATE = 0.1 # chance of starting is 0.1 +WORK_UNITS = 100 +WORK_RATE = 1 +N_TICKS = 300 + +ticks <- 1:N_TICKS + +# the probability that a job starts at exactly tick i +pThreadStartAtTick <- function(i) { + dexp(i, JOB_START_RATE) +} + +jobDoneByI <- function(i) { + return(sapply(i - ticks, function(x) max(x, 0)) * WORK_RATE) + #return(pCompleteAtI(i, pStarts, ticks)) +} + +pThreadDoneByI <- function(i) { + pStarts <- pThreadStartAtTick(ticks) + workDoneByThreadStartingAtI <- jobDoneByI(i) + fracDone <- workDoneByThreadStartingAtI / WORK_UNITS + doneAtI <- fracDone >= 1 + return(sum(pStarts * doneAtI)) +} + +pThreadsDoneByI <- function(i, nThreads) { + pDone <- rep(0, N_TICKS) + for ( thread : 1:nThreads ) + pDone <- pPrevThreadsNotDoneAtI(pDone, i) + pThreadDoneByI(i) +} + +#plot(ticks, workDoneByI(100)) +plot(ticks, sapply(ticks, function(i) pThreadDoneByI(i))) +