-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicholas Brazeau
committed
May 11, 2024
1 parent
4fc6f1c
commit a96e2da
Showing
6 changed files
with
148 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
test_that("PSO respects bounds", { | ||
|
||
# sim data | ||
data("IBD_simulation_data", package = "discent") | ||
dat <- IBD_simulation_data | ||
# run model | ||
inputdisc <- dat %>% | ||
dplyr::filter(deme1 != deme2) | ||
mod <- deme_inbreeding_spcoef_pso(discdat = inputdisc, | ||
m_lowerbound = 100, | ||
m_upperbound = 101, | ||
fi_lowerbound= 0.1, | ||
fi_upperbound = 0.11, | ||
flearn_lowerbound = 1e-3, | ||
flearn_upperbound = 1e-1, | ||
mlearn_lowerbound = 1e-3, | ||
mlearn_upperbound = 1e-1, | ||
c1 = 0.1, | ||
c2 = 0.1, | ||
w = 0.25, | ||
b1 = 0.9, | ||
b2 = 0.999, | ||
e = 1e-8, | ||
steps = 1e3, | ||
searchsteps = 1e2, | ||
swarmsize = 5, | ||
swarmsteps = 10, | ||
normalize_geodist = F, | ||
report_progress = F, | ||
return_verbose = F) | ||
#...................... | ||
# check that bounds are respect | ||
#...................... | ||
testthat::expect_gte(min(mod$m_run), 100) | ||
testthat::expect_lte(max(mod$m_run), 101) | ||
testthat::expect_gte(min(mod$fi_run[,1]), 0.1) | ||
testthat::expect_lte(max(mod$fi_run[,1]), 0.11) | ||
testthat::expect_gte(min(mod$fi_run[,2]), 0.1) | ||
testthat::expect_lte(max(mod$fi_run[,2]), 0.11) | ||
testthat::expect_gte(min(mod$fi_run[,3]), 0.1) | ||
testthat::expect_lte(max(mod$fi_run[,3]), 0.11) | ||
|
||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: "Running the `DISCent` Model with Particle Swarm Optimizer Metaheuristic Search" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{psoextension} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(discent) | ||
``` | ||
|
||
|
||
# Overview | ||
- PSO is being used to find best start parameters | ||
- Swarm made up of particles | ||
- Swarm object | ||
- swarm steps = time limit of search/swarm moves | ||
- swarm size = number of particles | ||
- for each particle, there is a grad descent step considered |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
title: "Running the Basic Model" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Running the Model} | ||
%\VignetteEncoding{UTF-8} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
editor_options: | ||
chunk_output_type: console | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(discent) | ||
``` | ||
|
||
# *** | ||
|
||
```{r} | ||
data("IBD_simulation_data") | ||
start_params <- rep(0.3, 3) | ||
names(start_params) <- 1:3 | ||
start_params <- c(start_params, "m"= 250) | ||
#run | ||
ret <- discent::deme_inbreeding_spcoef_vanilla(discdat = IBD_simulation_data, | ||
start_params = start_params, | ||
f_learningrate = 0.001, | ||
m_learningrate = 1e-6, | ||
m_lowerbound = 0, | ||
m_upperbound = Inf, | ||
b1 = 0.9, | ||
b2 = 0.999, | ||
e = 1e-8, | ||
steps = 1e4, | ||
thin = 1, | ||
normalize_geodist = TRUE, | ||
report_progress = TRUE, | ||
return_verbose = TRUE) | ||
``` |