knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
simlandr
: Simulation-Based Landscape Construction for Dynamical Systems A toolbox for constructing potential landscapes for dynamical systems using Monte Carlo simulation. The method is based on the potential landscape definition by Wang et al. (2008) (also see Zhou & Li, 2016, for further mathematical discussions) and can be used for a large variety of models.
simlandr
can help to:
hash_big_matrix
class, and perform out-of-memory calculation;You can install the released version of simlandr
from CRAN with:
install.packages("simlandr")
And you can install the development version from GitHub with:
install.packages("devtools") devtools::install_github("Sciurus365/simlandr") devtools::install_github("Sciurus365/simlandr", build_vignettes = TRUE) # Use this command if you want to build vignettes
library(simlandr) # Simulation ## Single simulation single_output_grad <- sim_fun_grad(length = 1e4, seed = 1614) ## Batch simulation: simulate a set of models with different parameter values batch_arg_set_grad <- new_arg_set() batch_arg_set_grad <- batch_arg_set_grad %>% add_arg_ele( arg_name = "parameter", ele_name = "a", start = -6, end = -1, by = 1 ) batch_grid_grad <- make_arg_grid(batch_arg_set_grad) batch_output_grad <- batch_simulation(batch_grid_grad, sim_fun_grad, default_list = list( initial = list(x = 0, y = 0), parameter = list(a = -4, b = 0, c = 0, sigmasq = 1) ), length = 1e4, seed = 1614, bigmemory = FALSE ) batch_output_grad
# Construct landscapes ## Example 1. 2D (x, y as U) landscape l_single_grad_2d <- make_2d_static(single_output_grad, x = "x") plot(l_single_grad_2d) ### To make the landscape smoother make_2d_static(single_output_grad, x = "x", adjust = 5) %>% plot() ## Example 2. 3D (x, y, color as U) landscape l_single_grad_3d <- make_3d_static(single_output_grad, x = "x", y = "y", adjust = 5) plot(l_single_grad_3d, 2) ### plot(l_single_grad_3d) # to show the landscape in 3D (x, y, z) ## Example 3. 4D (x, y, z, color as U) landscape set.seed(1614) single_output_grad <- matrix(runif(nrow(single_output_grad), min = 0, max = 5), ncol = 1, dimnames = list(NULL, "z")) %>% cbind(single_output_grad) l_single_grad_4d <- make_4d_static(single_output_grad, x = "x", y = "y", z = "z", n = 50) ### plot(l_single_grad_4d) # to show the landscape in 4D (x, y, z, color as U) ## Example 4. 2D (x, y as U) matrix (by a) l_batch_grad_2d <- make_2d_matrix(batch_output_grad, x = "x", cols = "a", Umax = 8, adjust = 2) plot(l_batch_grad_2d) ## Example 5. 3D (x, y, color as U) matrix (by a) l_batch_grad_3d <- make_3d_matrix(batch_output_grad, x = "x", y = "y", cols = "a") plot(l_batch_grad_3d) ## Example 6. 3D (x, y, z/color as U) animation (by a) l_batch_grad_3d_animation <- make_3d_animation(batch_output_grad, x = "x", y = "y", fr = "a") ### plot(l_batch_grad_3d_animation) # to show the landscape animation in 3D (x, y, z as U) ### plot(l_batch_grad_3d_animation, 2) # to show the landscape animation in 3D (x, y, color as U)
# Calculate energy barriers ## Example 1. Energy barrier for the 2D landscape b_single_grad_2d <- calculate_barrier(l_single_grad_2d, start_location_value = -1, end_location_value = 1, start_r = 0.3, end_r = 0.3 ) summary(b_single_grad_2d) plot(l_single_grad_2d) + autolayer(b_single_grad_2d) ## Example 2. Energy barrier for the 3D landscape b_single_grad_3d <- calculate_barrier(l_single_grad_3d, start_location_value = c(-1, -1), end_location_value = c(1, 1), start_r = 0.3, end_r = 0.3 ) summary(b_single_grad_3d) plot(l_single_grad_3d, 2) + autolayer(b_single_grad_3d) ## Example 3. Energy barrier for many 2D landscapes b_batch_grad_2d <- calculate_barrier(l_batch_grad_2d, start_location_value = -1, end_location_value = 1, start_r = 0.3, end_r = 0.3 ) summary(b_batch_grad_2d) plot(l_batch_grad_2d) + autolayer(b_batch_grad_2d) ## Example 4. Energy barrier for many 3D landscapes b_batch_grad_3d <- calculate_barrier(l_batch_grad_3d, start_location_value = c(-1, -1), end_location_value = c(1, 1), start_r = 0.3, end_r = 0.3 ) summary(b_batch_grad_3d) plot(l_batch_grad_3d) + autolayer(b_batch_grad_3d)
See the vignettes of this package (browseVignettes("simlandr")
or https://doi.org/10.31234/osf.io/pzva3) for more examples and explanations. Also see https://doi.org/10.1080/00273171.2022.2119927 for our recent work using simlandr
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.