-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#96 #125
#96 #125
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization, spelling
|
||
|
||
#### 3. Multi-core and cluster calculations | ||
If you want to do your calculations on a cluster there are several ways to achieve it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... run your calculations ...
#### 3. Multi-core and cluster calculations | ||
If you want to do your calculations on a cluster there are several ways to achieve it. | ||
|
||
In the first case you want to parallize n internal (not overall chains) on n cores. The argument "parallel = T" in "createBayesianSetup" allows only at most parallelization on 3 cores for the SMC, DEzs and DreamsSamplers. But by setting "parallel = n" to n cores in the "createBayesianSetup" and giving the settings list a "startValue" matrix with n rows, the internal chains of DEzs and DREAMzs will be parallelized on n cores. This works only for the DEzs and DREAMzs samplers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and passing/providing the settings list ...
|
||
``` | ||
|
||
In the second case you want to parallize n internal chains on n cores with a external parallilzed likelihood function. Unlike the previous case, that way DEzs, DREAMzs, and SMC samplers can be paralllized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parallelized
likelihood <- function(X) sum(dnorm(c(1:10), mean = X, log = T)) | ||
|
||
## Definition of the likelihood which will be calculated in parallel. Instead of the parApply function, we could also define a costly parallelized likelihood | ||
Plikelihood <- function(param) parallel::parApply(cl = cl, X = param, MARGIN = 1, FUN = likelihood) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better pLikelihood or PLikelihood or something like that
out <- runMCMC(bayesianSetup, settings, sampler = "DEzs") | ||
``` | ||
|
||
In a another case your likelihood requires a costly model which is parallized. Start your cluster and export your model, the required libraries, and dlls. Now you can start your calculations with the argument "parallel = external" in createBayesianSetup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- a
parallelized
### Create Cluster with n Cores | ||
cl <- parallel::makeCluster(n) | ||
|
||
## export your model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are those commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it doesn't exist("complexModel")...all other examples can be run
# return(ll) | ||
} | ||
|
||
## create BayesianSetup and settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are sometimes writing BayesianSetup and sometimes Bayesian Setup. Maybe unify this.
cl <- parallel::makeCluster(n) | ||
parallel::clusterEvalQ(cl, library(BayesianTools)) | ||
|
||
## calculate parallel n Chains, for each Chain the likelihood will be calculated on one core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chains -> chains
In the second case you want to parallize n internal chains on n cores with a external parallilzed likelihood function. Unlike the previous case, that way DEzs, DREAMzs, and SMC samplers can be paralllized. | ||
|
||
```{r, eval = FALSE} | ||
### Create Cluster with n Cores |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalization
@@ -213,9 +213,103 @@ BS <- createBayesianSetup(likelihood, parallel = "external", ...) | |||
runMCMC(BS, sampler = "SMC", ...) | |||
``` | |||
|
|||
The in-build parallelization only allows the parallelization of the internal chains of SMC, DEzs and DREAMzs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
built-in
I hope its clear now...
check also spelling and grammar