From f0ef23a7598e5d19648ae4edc2b74e0fba27a41c Mon Sep 17 00:00:00 2001
From: Johannes Ranke
mmkin( models = c("SFO", "FOMC", "DFOP"), datasets, - cores = detectCores(), + cores = parallel::detectCores(), cluster = NULL, ... )@@ -210,37 +210,36 @@ plotting.
-- cgit v1.2.1# \dontrun{ -m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), - M1 = mkinsub("SFO", "M2"), - M2 = mkinsub("SFO"), use_of_ff = "max") -#>-m_synth_FOMC_lin <- mkinmod(parent = mkinsub("FOMC", "M1"), - M1 = mkinsub("SFO", "M2"), - M2 = mkinsub("SFO"), use_of_ff = "max") -#>+m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), + M1 = mkinsub("SFO", "M2"), + M2 = mkinsub("SFO"), use_of_ff = "max") +#>+m_synth_FOMC_lin <- mkinmod(parent = mkinsub("FOMC", "M1"), + M1 = mkinsub("SFO", "M2"), + M2 = mkinsub("SFO"), use_of_ff = "max") +#>models <- list(SFO_lin = m_synth_SFO_lin, FOMC_lin = m_synth_FOMC_lin) datasets <- lapply(synthetic_data_for_UBA_2014[1:3], function(x) x$data) names(datasets) <- paste("Dataset", 1:3) time_default <- system.time(fits.0 <- mmkin(models, datasets, quiet = TRUE)) time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE)) -#> Warning: Optimisation did not converge: -#> false convergence (8)#> Warning: Shapiro-Wilk test for standardized residuals: p = 0.0117#> Warning: Shapiro-Wilk test for standardized residuals: p = 0.0174+ time_default#> user system elapsed -#> 4.828 0.413 1.467time_1 +#> 4.869 0.357 1.415time_1#> user system elapsed -#> 5.228 0.000 5.231+#> 5.502 0.002 5.507#> $ff #> parent_M1 parent_sink M1_M2 M1_sink -#> 0.7340478 0.2659522 0.7505691 0.2494309 +#> 0.7340478 0.2659522 0.7505687 0.2494313 #> #> $distimes -#> DT50 DT90 -#> parent 0.8777688 2.915885 -#> M1 2.3257466 7.725963 -#> M2 33.7200800 112.015681 +#> DT50 DT90 +#> parent 0.877769 2.915885 +#> M1 2.325746 7.725960 +#> M2 33.720083 112.015691 #># plot.mkinfit handles rows or columns of mmkin result objects plot(fits.0[1, ]) @@ -253,7 +252,29 @@ plotting.# Plotting with mmkin (single brackets, extracting an mmkin object) does not # allow to plot the observed variables separately plot(fits.0[1, 1]) -# } ++# On Windows, we can use multiple cores by making a cluster using the parallel +# package, which gets loaded with mkin, and passing it to mmkin, e.g. +cl <- makePSOCKcluster(12) +f <- mmkin(c("SFO", "FOMC", "DFOP"), + list(A = FOCUS_2006_A, B = FOCUS_2006_B, C = FOCUS_2006_C, D = FOCUS_2006_D), + cluster = cl, quiet = TRUE) +print(f) +#> <mmkin> object +#> Status of individual fits: +#> +#> dataset +#> model A B C D +#> SFO OK OK OK OK +#> FOMC C OK OK OK +#> DFOP OK OK OK OK +#> +#> OK: No warnings +#> C: Optimisation did not converge: +#> false convergence (8)# We get false convergence for the FOMC fit to FOCUS_2006_A because this +# dataset is really SFO, and the FOMC fit is overparameterised +stopCluster(cl) +# }