PoonLab / Kaphi

Kernel-embedded ABC-SMC for phylodynamic inference
GNU Affero General Public License v3.0
4 stars 2 forks source link

Stochastic subscript out of bounds error (parallelized run.smc) #103

Closed gtng92 closed 7 years ago

gtng92 commented 7 years ago

Currently working on the error below:

Error in i[[2]] : subscript out of bounds
Calls: run.smc -> .perturb.particles
Execution halted

This is from the new code block:

  # accept or reject the proposal
  for (i in .) {
    if (length(i) == 0) {     #checking for any items that are a returned NULL ?
      next
    }
    if (NaN %in% i) {
      next
    }
    else {
      i <- i[[1]]
      mh.ratio <- i[[2]]
      new.particle <- i[[3]]
      new.trees <- i[[4]]
      new.dists <- i[[5]]
      if (runif(1) < mh.ratio) {     # always accept if ratio > 1     # mh.ratio
        ws$accept[i] <- TRUE
        ws$particles[i,] <- new.particle
        ws$dists[,i] <- new.dists             
        ws$sim.trees[[i]] <- new.trees
      }
      else {
        ws$accept[i] <- FALSE
      }
    }
  }
gtng92 commented 7 years ago

Oops, when cleaning up code, I reassigned i <- i[[1]] before accessing mh.ratio. I changed the resulting i values to iter