{"action":"created","issue":{"url":"https://api.github.com/repos/SEEG-Oxford/movement/issues/98","labels_url":"https://api.github.com/repos/SEEG-Oxford/movement/issues/98/labels{/name}","comments_url":"https://api.github.com/repos/SEEG-Oxford/movement/issues/98/comments","events_url":"https://api.github.com/repos/SEEG-Oxford/movement/issues/98/events","html_url":"https://github.com/SEEG-Oxford/movement/issues/98","id":114851911,"number":98,"title":"Add parallel prediction","user":{"login":"goldingn","id":4450731,"avatar_url":"https://avatars.githubusercontent.com/u/4450731?v=3","gravatar_id":"","url":"https://api.github.com/users/goldingn","html_url":"https://github.com/goldingn","followers_url":"https://api.github.com/users/goldingn/followers","following_url":"https://api.github.com/users/goldingn/following{/other_user}","gists_url":"https://api.github.com/users/goldingn/gists{/gist_id}","starred_url":"https://api.github.com/users/goldingn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldingn/subscriptions","organizations_url":"https://api.github.com/users/goldingn/orgs","repos_url":"https://api.github.com/users/goldingn/repos","events_url":"https://api.github.com/users/goldingn/events{/privacy}","received_events_url":"https://api.github.com/users/goldingn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-11-03T16:17:34Z","updated_at":"2015-11-09T14:50:42Z","closed_at":null,"body":"The sequential for loop in `movement.predict` https://github.com/SEEG-Oxford/movement/blob/master/R/movement.R#L1478-L1511 should be parallelisable.\r\n\r\nWe should:\r\n\r\n**1)** expose a `parallel` argument to the user so that they can choose whether to run prediction in parallel:\r\n```r\r\npredict(obj, parallel = TRUE)\r\n```\r\nThis can be passed up through all functions that make movement predictions (`movement`, `predict.prediction_model`, `predict.flux`, `predict.movement_model`, `fittingwrapper` & `attemptoptimisation`)\r\n\r\n**2)** Provide a simple utility function to set up the parallel backend using `doSnow` if they want parallelism:\r\n```r\r\nparallel(n = 20)\r\n```\r\n\r\n**3)** Make sure a progress bar is still provided. See here for how to include progress bars in a foreach parallel implementation: http://www.r-bloggers.com/updates-to-the-foreach-package-and-its-friends/\r\n\r\n---\r\n\r\nHere's a function that works for **2)** (with three new `importFrom` calls required):\r\n\r\n```r\r\nparallel <- function(n = NULL) {\r\n  if (is.null(n)) {\r\n    n <- parallel::detectCores()\r\n  }\r\n  cl <- snow::makeSOCKcluster(n)\r\n  doSNOW::registerDoSNOW(cl)\r\n  message(sprintf('parallel backend registered on %i cores', n))\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/SEEG-Oxford/movement/issues/comments/155084399","html_url":"https://github.com/SEEG-Oxford/movement/issues/98#issuecomment-155084399","issue_url":"https://api.github.com/repos/SEEG-Oxford/movement/issues/98","id":155084399,"user":{"login":"goldingn","id":4450731,"avatar_url":"https://avatars.githubusercontent.com/u/4450731?v=3","gravatar_id":"","url":"https://api.github.com/users/goldingn","html_url":"https://github.com/goldingn","followers_url":"https://api.github.com/users/goldingn/followers","following_url":"https://api.github.com/users/goldingn/following{/other_user}","gists_url":"https://api.github.com/users/goldingn/gists{/gist_id}","starred_url":"https://api.github.com/users/goldingn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldingn/subscriptions","organizations_url":"https://api.github.com/users/goldingn/orgs","repos_url":"https://api.github.com/users/goldingn/repos","events_url":"https://api.github.com/users/goldingn/events{/privacy}","received_events_url":"https://api.github.com/users/goldingn/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T14:50:42Z","updated_at":"2015-11-09T14:50:42Z","body":"Great! No need to PR now, I'll have a test run with your branch"}}