Skip to content
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

Dev #335

Merged
merged 221 commits into from
Sep 12, 2024
Merged

Dev #335

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
fd58ea6
Specify timesteps in create process
pwinskill Jul 12, 2023
1ba67c0
Documentation updates
giovannic Aug 15, 2022
08b1f62
mixing matrix row sums == 1 error -> warning
htopazian Aug 26, 2022
c5a7bec
Reduce mixed transmission with testing
giovannic Oct 3, 2022
4e14e50
rebase rdt_mixing to time_varying_metapop
htopazian Oct 5, 2022
4b54e80
Reduce mixed transmission with testing
giovannic Oct 3, 2022
4a58966
Remove platform specific build files
giovannic Oct 6, 2022
3236f76
Add new formula for border test and treat:
giovannic Oct 6, 2022
8e759c1
Update documentation for border check model
giovannic Oct 6, 2022
247432c
fixing metapopulation vignette error
htopazian Oct 7, 2022
f3669f5
Change test and treat coefficients
giovannic Oct 13, 2022
1d4f4a2
Update RDT detection model
giovannic Oct 13, 2022
e568127
Fix regression tests
giovannic Oct 13, 2022
0057fda
RDT+
giovannic Oct 13, 2022
a591eb0
Add test case for completely removing transmission
giovannic Oct 14, 2022
7fa7ea3
Merge pull request #258 from mrc-ide/bug/progress_bar_timesteps
giovannic Jul 19, 2023
ba4bedc
Add asymmetric transmission in mixing:
giovannic Sep 6, 2023
a7c7dd1
Fix competing hazards for mass and EPI pev:
giovannic Sep 18, 2023
efd3dfc
Merge pull request #265 from mrc-ide/bug/competing_vaccination
giovannic Sep 22, 2023
e7b5c4d
Fix bug with pev min_wait:
giovannic Sep 15, 2023
8e0e76e
Merge pull request #264 from mrc-ide/bug/min_wait
giovannic Nov 3, 2023
5f174c4
Custom carrying capacity is set as a relative scaler, not absolute value
pwinskill Nov 23, 2023
a109246
Document and make suggested changes to carrying capacity vignette for…
pwinskill Dec 4, 2023
dc922d7
Merge pull request #272 from mrc-ide/carrying_capacity_relative
giovannic Dec 6, 2023
73cbfb4
Implement time varying coverage for PEV boosters:
giovannic Nov 16, 2023
d49c8dd
Fix PEV EPI parameterisation bug
giovannic Dec 6, 2023
91247b4
Implement simplified pev booster interface:
giovannic Jan 4, 2024
45486ad
Check that booster_spacing is monotonically increasing
giovannic Jan 9, 2024
f1039ea
Changed the calculation of birth_ivm in sample_maternal_immunity(). T…
tbreweric Jan 15, 2024
b0ad081
Merge pull request #270 from mrc-ide/feat/time_boosters
giovannic Jan 16, 2024
01a0a1e
Merge branch 'dev' into bug/maternal_immunity_sampling
giovannic Jan 18, 2024
0359cec
Merge pull request #279 from mrc-ide/bug/maternal_immunity_sampling
giovannic Jan 22, 2024
d8930d8
Opened sub-branch of feat/antimalarial_resistance for developing the …
Jun 6, 2023
8efb863
Added first iteration of the set_antimalarial_resistance() function d…
tbreweric Jul 6, 2023
74a2a3b
Updated the set_antimalarial_resistance() function to allow for multi…
Jul 11, 2023
acf145e
Removed the else{} arguments on the checks, condensed the first check…
Jul 13, 2023
856ec1e
Added additional section for testing different versions of ETF versio…
Jul 13, 2023
da94206
removed the extra versions of calculate_treated() from human_infectio…
Jul 13, 2023
571a20c
removed all but resistance first, efficacy second version of calculat…
tbreweric Jul 14, 2023
bfb6aa0
Deleting the development script from the branch (will store developme…
tbreweric Jul 14, 2023
02e4916
Amended the calculate_treated() function to remove the loop when assi…
tbreweric Jul 17, 2023
7be84ee
Added check to number of clinical_infections in calculate_treated() a…
tbreweric Jul 22, 2023
fea9da2
Removed typos/spaces from antimalarial_resistance.R. Added check for …
Aug 1, 2023
0b1adb6
removed comments from calculate_treated() function
tbreweric Aug 4, 2023
731899e
removed unnecessary spacing and comments from the calculate_treated()…
tbreweric Aug 17, 2023
578c9e5
Create test-antimalarial-resistance.R and added six tests for the set…
tbreweric Aug 17, 2023
ded0251
Added test file for new antimalarial resistance functions and added n…
tbreweric Aug 17, 2023
d4db8f9
Commiting all changes recommended by Pete/Giovanni except those that …
tbreweric Sep 20, 2023
11e61e1
Commiting the final set of changes and corrections in response to com…
tbreweric Oct 10, 2023
de29495
Implemented the second round of changes requested in the pull request
Feb 8, 2024
4d75b2e
Implented the second round of changes requested in the pull request
Feb 8, 2024
d51bbf7
Re-adding the changes recommended by Pete following a reversion to 4d…
tbreweric Feb 12, 2024
2adf823
Corrected drugs documentation for get_antimalarial_resistance_paramet…
tbreweric Feb 13, 2024
3ea8ee3
Merge pull request #263 from mrc-ide/antimalarial_resistance/etf
tbreweric Feb 14, 2024
d16978e
Added check for undeveloped antimalarial resistance features (SPC/LPF…
Feb 15, 2024
1a5f00a
Merge pull request #282 from mrc-ide/feat/resistance_unused_feature_e…
tbreweric Feb 15, 2024
c42e2c5
Add initial support for saving and restoring simulation state. (#280)
plietar Feb 27, 2024
b3376d3
Rewrite the exponential decay process in C++. (#285)
plietar Mar 21, 2024
2c9932b
Combined ETF and SPC. Need to fix testthat files before PR
tbreweric Mar 26, 2024
2a3d4cc
Improve correlation tests. (#287)
plietar Apr 3, 2024
952108c
Fixed errors in unit tests which included amending the create_mortali…
Apr 3, 2024
0cef273
Added section modelling early treatment failure and slow parasite cle…
tbreweric Apr 4, 2024
5123d6e
Made clearer the antimalarial resistance parameter names in set_antim…
tbreweric Apr 4, 2024
54456df
Merge branch 'dev' into feat/spc
tbreweric Apr 8, 2024
462b0fe
Merge pull request #277 from mrc-ide/feat/metapop_asym
htopazian Apr 9, 2024
d9ce4a6
Implemented the changes recommended by in first round of PR comments
tbreweric Apr 11, 2024
086956a
Merge branch 'feat/spc' of https://github.com/mrc-ide/malariasimulati…
tbreweric Apr 11, 2024
5077d4b
Moved mortality to the end of processes to resolve order of competing…
RJSheppard Apr 15, 2024
f58d48f
Altered check for rate data type in create_disease_progression() func…
tbreweric Apr 18, 2024
e9d46e7
Update description of the dt parameter. (#288)
plietar Apr 25, 2024
5900751
Merge branch 'dev' into feat/spc
tbreweric Apr 26, 2024
380d113
Merge pull request #289 from mrc-ide/feat/spc
tbreweric Apr 26, 2024
9debd7f
Clarify some intervention parametrization documentation. (#291)
plietar Apr 26, 2024
e534db7
Allow simulation to be restored with new interventions. (#286)
plietar Feb 13, 2024
1111500
Allow correlations to be extended when resuming. (#293)
plietar Apr 30, 2024
a9b495c
Merging dev branch back before merging into main dev branch.
RJSheppard May 1, 2024
7e62cc9
Merge pull request #292 from mrc-ide/competing_hazards_mortality_order
RJSheppard May 2, 2024
610c5cb
Function for setting age-structured outputs for incidence, prevalence…
RJSheppard May 8, 2024
b8f3c27
I think the calculation for initial EIR values isn't quite right. I d…
RJSheppard May 8, 2024
b9b923c
Added PCR rendering to prevalence rendering function, adjusting tests…
RJSheppard May 8, 2024
1a70ff2
Removed overhanging changes associated with EIR calculation correctio…
RJSheppard May 8, 2024
6ec5e3d
There are a few parameter documentation things I think it would be go…
RJSheppard May 8, 2024
55d83ea
Added immunity parameter info to documentation of epi outputs function.
RJSheppard May 9, 2024
d0854db
Older age groups (older than equilibrium age object) are not correctl…
RJSheppard May 9, 2024
d1bd2af
Added proper links to the relevant function documentation in the get_…
RJSheppard May 9, 2024
69fc17f
Improved robustness of calculate initial EIR test.
RJSheppard May 9, 2024
b36be83
competing_hazards.R: Giovanni designed two objects: CompetingOutcome …
RJSheppard May 9, 2024
435180d
Correcting typo in parameter documentation: set_betnets -> set_bednets.
RJSheppard May 9, 2024
0e05f75
Added a stash source_human function to the competing hazards function…
RJSheppard May 9, 2024
6804095
Merge pull request #296 from mrc-ide/initial_eir_calculation_correction
RJSheppard May 20, 2024
c62decc
Corrected vignettes to reflect changes in n_detect_lm outputs.
RJSheppard May 20, 2024
ed29688
Removed epi_outputs function from documentation so that tests can pas…
RJSheppard May 20, 2024
254bce2
Depend on dqrng from CRAN again.
plietar May 15, 2024
75a0332
Fix warnings and deprecations.
plietar May 15, 2024
25c0956
Merge pull request #305 from mrc-ide/dqrng-release
plietar May 21, 2024
40e4f87
Changed the initial age distribution to a truncated exponential to re…
RJSheppard May 21, 2024
6008a8a
adding in n_spray output
htopazian May 21, 2024
b0ef327
fix typo renderer
htopazian May 21, 2024
7a9966b
update documentation
htopazian May 21, 2024
f1eb68c
Update test-vector-control.R
htopazian May 21, 2024
7c5232c
add whitespace back in
htopazian May 21, 2024
d868e19
Added PCR rendering to prevalence rendering function, adjusting tests…
RJSheppard May 8, 2024
2f9dd12
Removed overhanging changes associated with EIR calculation correctio…
RJSheppard May 8, 2024
d28bd2b
Corrected vignettes to reflect changes in n_detect_lm outputs.
RJSheppard May 20, 2024
5d95b83
Removed second psi multiplier from calculate_eir to allow tests to co…
RJSheppard May 22, 2024
21d8f9a
Merge branch 'lm_pcr_prevalence_explicit' of https://github.com/mrc-i…
RJSheppard May 22, 2024
2c1dab3
Removed mean(psi) multiplier from calculate_eir to allow tests to pass.
RJSheppard May 22, 2024
5e559a7
There are a few parameter documentation things I think it would be go…
RJSheppard May 8, 2024
7f12172
Added proper links to the relevant function documentation in the get_…
RJSheppard May 9, 2024
ec16cf6
Correcting typo in parameter documentation: set_betnets -> set_bednets.
RJSheppard May 9, 2024
288e428
Removed epi_outputs function from documentation so that tests can pas…
RJSheppard May 20, 2024
6c256ae
Merge branch 'parameter_documentation_ordering' of https://github.com…
RJSheppard May 22, 2024
f47bb3e
competing_hazards.R: Giovanni designed two objects: CompetingOutcome …
RJSheppard May 9, 2024
c8c3245
Added a stash source_human function to the competing hazards function…
RJSheppard May 9, 2024
c5947ef
To correctly render ages and incidence, given the competing hazards s…
RJSheppard May 23, 2024
4820186
Removed "age" from age outputs in tests and vignettes.
RJSheppard May 23, 2024
d563f6e
Swap back to explicitly labelled age outputs.
RJSheppard May 23, 2024
69ea7b6
Merge pull request #298 from mrc-ide/lm_pcr_prevalence_explicit
RJSheppard May 23, 2024
abdcef0
Function for setting age-structured outputs for incidence, prevalence…
RJSheppard May 8, 2024
8786b81
Added immunity parameter info to documentation of epi outputs function.
RJSheppard May 9, 2024
a542d10
Changed age limits back to continuous groups (no discrete age groups …
RJSheppard May 23, 2024
482fc83
Rebased with latest dev branch, merging with detect pcr/lm outputs.
RJSheppard May 23, 2024
c9c90f5
Merged tip with remote counterpart.
RJSheppard May 23, 2024
23827d2
There are a few parameter documentation things I think it would be go…
RJSheppard May 8, 2024
8a86bee
Added proper links to the relevant function documentation in the get_…
RJSheppard May 9, 2024
7dae339
Correcting typo in parameter documentation: set_betnets -> set_bednets.
RJSheppard May 9, 2024
52cc8b5
Removed epi_outputs function from documentation so that tests can pas…
RJSheppard May 20, 2024
702fcc4
Merge branch 'parameter_documentation_ordering' of https://github.com…
RJSheppard May 23, 2024
4994b82
Merge branch 'dev' into older_age_state_immunity_init
RJSheppard May 24, 2024
98a7482
Merge pull request #299 from mrc-ide/parameter_documentation_ordering
RJSheppard May 24, 2024
b8980c1
Merge branch 'dev' into competing_hazards_recovery_infection_resolution
RJSheppard May 24, 2024
5eb21fa
Merge branch 'dev' into older_age_state_immunity_init
RJSheppard May 24, 2024
8f11a06
Merge branch 'dev' into new_epi_outputs_function
RJSheppard May 24, 2024
62791a2
Removed missed merge commit line.
RJSheppard May 24, 2024
ab030d7
Merge pull request #301 from mrc-ide/older_age_state_immunity_init
RJSheppard May 24, 2024
09a8c3e
Merge branch 'dev' into new_epi_outputs_function
RJSheppard May 24, 2024
1b30562
Correcting rendering tests (merging error).
RJSheppard May 24, 2024
47a1741
adding in n_spray output
htopazian May 21, 2024
cde259c
fix typo renderer
htopazian May 21, 2024
189041b
update documentation
htopazian May 21, 2024
c3be9c9
Update test-vector-control.R
htopazian May 21, 2024
c2aea71
add whitespace back in
htopazian May 21, 2024
9922527
fixing test, removing mortality changes
htopazian May 28, 2024
732bc0c
Merge branch 'bug/spraying' of https://github.com/mrc-ide/malariasimu…
htopazian May 28, 2024
030b36e
fixing test, reverting mortality changes
htopazian May 28, 2024
46b8311
Merge pull request #310 from mrc-ide/bug/spraying
htopazian May 28, 2024
3943de1
Add GitHub workflow for continuous benchmarking.
plietar May 15, 2024
770f5e4
Remove raw data upload.
plietar May 22, 2024
1d40ae0
Fix reporting of cancelled jobs
plietar May 23, 2024
de27f13
Downgrade ubuntu back to 22.04.
plietar May 23, 2024
bfa9656
Add R_GC_MEM_GROW
plietar May 30, 2024
3ecb72a
Merge pull request #304 from mrc-ide/continuous-benchmarking
plietar May 30, 2024
5746a6b
Merge branch 'dev' into feat/metapopulation_model
htopazian Jun 6, 2024
b852847
update documentation
htopazian Jun 6, 2024
24a0253
fix metapop vignette
htopazian Jun 6, 2024
3989fdc
Merge branch 'dev' into new_epi_outputs_function
RJSheppard Jun 12, 2024
352fbae
biting_process renamed as create_biting_process, where functionality …
RJSheppard Jun 24, 2024
8866b5a
competing_hazards.R: Giovanni designed two objects: CompetingOutcome …
RJSheppard May 9, 2024
7702e19
Added a stash source_human function to the competing hazards function…
RJSheppard May 9, 2024
479c26e
To correctly render ages and incidence, given the competing hazards s…
RJSheppard May 23, 2024
6a4311a
Removed "age" from age outputs in tests and vignettes.
RJSheppard May 23, 2024
13748fd
competing_hazards.R: Giovanni designed two objects: CompetingOutcome …
RJSheppard May 9, 2024
98c982f
Added a stash source_human function to the competing hazards function…
RJSheppard May 9, 2024
16d83d3
Removed missed merge commit line.
RJSheppard May 24, 2024
c649292
biting_process renamed as create_biting_process, where functionality …
RJSheppard Jun 24, 2024
c85ca93
Re-added "age" to age outputs.
RJSheppard Jun 24, 2024
a6692e3
Merge branch 'competing_hazards_recovery_infection_resolution' of htt…
RJSheppard Jun 24, 2024
9142c58
Corrected age output names in Demography vignette to enable it to run…
RJSheppard Jun 26, 2024
7bd8c0d
Update R/mixing.R
htopazian Jul 1, 2024
6d34636
Update R/mixing.R
htopazian Jul 1, 2024
b6787f7
Removed redundant commented lines.
RJSheppard Jul 3, 2024
06c1e8d
Remove unnecessary gitignore i386
giovannic Jul 3, 2024
5fec286
Add print step to touchstone workflow
giovannic Jul 3, 2024
598ade0
Revert "Add print step to touchstone workflow"
giovannic Jul 3, 2024
91f8270
Export the run_resumable_simulation
plietar Jul 3, 2024
d05b335
Merge pull request #323 from mrc-ide/export_resumable_simulation
plietar Jul 3, 2024
a4f66e2
Merge branch 'dev' into feat/metapopulation_model
giovannic Jul 4, 2024
e51c6bc
Merge pull request #259 from mrc-ide/feat/metapopulation_model
giovannic Jul 4, 2024
09e6e8c
Improve cumsum performance
plietar Jul 4, 2024
0f21bbc
Remove outlining of function
plietar Jul 4, 2024
a58e064
Optimize competing hazards.
plietar Jul 4, 2024
1f7310b
Fix empty occurs case.
plietar Jul 4, 2024
e2242b2
Simplify competing hazards as a single random draw.
plietar Jul 10, 2024
4c98559
Try to optimize competing hazards
plietar Jul 10, 2024
0bd7c10
All all states but S to create_recovery_rates_process
plietar Jul 10, 2024
91697ba
Merge remote-tracking branch 'origin/dev' into competing_hazards_reco…
plietar Jul 10, 2024
ded6876
Add a bitset_at implementation that works with a logical index.
plietar Jul 10, 2024
8f9bcfc
Fix tests
plietar Jul 10, 2024
f363b94
Fix more tests
plietar Jul 11, 2024
b339b7a
Add tests
plietar Jul 12, 2024
b4825c7
Function for setting age-structured outputs for incidence, prevalence…
RJSheppard May 8, 2024
4701748
Added immunity parameter info to documentation of epi outputs function.
RJSheppard May 9, 2024
e004d5b
Changed age limits back to continuous groups (no discrete age groups …
RJSheppard May 23, 2024
65e5899
Rebased with latest dev branch, merging with detect pcr/lm outputs.
RJSheppard May 23, 2024
0ff9f95
Function for setting age-structured outputs for incidence, prevalence…
RJSheppard May 8, 2024
1886755
Merge branch 'new_epi_outputs_function' of github.com:mrc-ide/malaria…
RJSheppard Jul 16, 2024
36c4301
Merge pull request #297 from mrc-ide/new_epi_outputs_function
RJSheppard Jul 16, 2024
1fda585
Default average age is currently 7663. The deterministic model averag…
RJSheppard Jul 16, 2024
342799e
Merge pull request #326 from mrc-ide/corrected_average_age
RJSheppard Jul 17, 2024
52f4aa0
Assign names to all processes.
plietar Jul 11, 2024
e3091a4
Fixes for latest individual.
plietar Jul 25, 2024
8bb953c
Merge pull request #325 from mrc-ide/named-processes
plietar Jul 25, 2024
f2cacfb
Use new individual features
plietar Jul 27, 2024
e1bc3c1
Merge remote-tracking branch 'origin/dev' into competing_hazards_reco…
plietar Jul 27, 2024
babc34b
Fix output test
plietar Jul 27, 2024
3e76ce8
Merge pull request #300 from mrc-ide/competing_hazards_recovery_infec…
RJSheppard Aug 20, 2024
4913f03
Add a range check to bitset_index.
plietar Aug 29, 2024
83375fe
Merge pull request #331 from mrc-ide/bitset_index_bounds_check
plietar Sep 4, 2024
6ecab00
pushed R21 profiles
lmhaile Sep 9, 2024
0932eb7
Merge branch 'r21_profiles' of https://github.com/mrc-ide/malariasimu…
pwinskill Sep 10, 2024
c02b450
Redocument and tidy reference for vaccine profiles
pwinskill Sep 10, 2024
4bebd42
recovery_rates variable has been renamed as (disease) progression_rates.
RJSheppard Sep 10, 2024
2556bd6
Minor documentation and performance fixed.
RJSheppard Sep 10, 2024
9eef099
Merge pull request #334 from mrc-ide/progression_rates_mass_admin
RJSheppard Sep 11, 2024
8648c38
Bump to version 2.0.0
giovannic Sep 11, 2024
2d84551
Merge branch 'dev' into r21_profiles
giovannic Sep 11, 2024
db57035
Merge pull request #333 from mrc-ide/r21_profiles
giovannic Sep 12, 2024
31d8188
Update readme with hex in same style as malariaverse updates
pwinskill Sep 12, 2024
0207954
format adjustment
pwinskill Sep 12, 2024
485ab22
format adjustment
pwinskill Sep 12, 2024
9cc9141
Merge pull request #336 from mrc-ide/hex
giovannic Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: malariasimulation
Title: An individual based model for malaria
Version: 1.6.0
Version: 2.0.0
Authors@R: c(
person(
given = "Giovanni",
Expand Down Expand Up @@ -70,12 +70,12 @@ Remotes:
mrc-ide/malariaEquilibrium,
mrc-ide/individual
Imports:
individual (>= 0.1.7),
individual (>= 0.1.17),
malariaEquilibrium (>= 1.0.1),
Rcpp,
statmod,
MASS,
dqrng,
dqrng (>= 0.4),
sitmo,
BH,
R6,
Expand All @@ -91,7 +91,7 @@ Suggests:
ggplot2,
covr,
mgcv
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
LinkingTo:
Rcpp,
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ export(get_parameters)
export(parameterise_mosquito_equilibrium)
export(parameterise_total_M)
export(peak_season_offset)
export(r21_booster_profile)
export(r21_profile)
export(rtss_booster_profile)
export(rtss_profile)
export(run_metapop_simulation)
export(run_resumable_simulation)
export(run_simulation)
export(run_simulation_with_repetitions)
export(set_antimalarial_resistance)
export(set_bednets)
export(set_carrying_capacity)
export(set_clinical_treatment)
export(set_demography)
export(set_drugs)
export(set_epi_outputs)
export(set_equilibrium)
export(set_mass_pev)
export(set_mda)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# malariasimulation 1.6.1 (wip)

* Fix bug in competing hazards between mass and EPI vaccines. Where individuals
can be enrolled onto both strategies if applied on the same timestep.
* Fix bug with min_wait. Min wait was working off of the final primary dose. It
now works of of the first dose.

# malariasimulation 1.6.0

* Fix MDA bug where undetectable asymptomatics are treated
Expand Down
32 changes: 32 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ adult_mosquito_model_update <- function(model, mu, foim, susceptible, f) {
invisible(.Call(`_malariasimulation_adult_mosquito_model_update`, model, mu, foim, susceptible, f))
}

adult_mosquito_model_save_state <- function(model) {
.Call(`_malariasimulation_adult_mosquito_model_save_state`, model)
}

adult_mosquito_model_restore_state <- function(model, state) {
invisible(.Call(`_malariasimulation_adult_mosquito_model_restore_state`, model, state))
}

create_adult_solver <- function(model, init, r_tol, a_tol, max_steps) {
.Call(`_malariasimulation_create_adult_solver`, model, init, r_tol, a_tol, max_steps)
}
Expand Down Expand Up @@ -37,10 +45,18 @@ rainfall <- function(t, g0, g, h, floor) {
.Call(`_malariasimulation_rainfall`, t, g0, g, h, floor)
}

exponential_process_cpp <- function(variable, rate) {
.Call(`_malariasimulation_exponential_process_cpp`, variable, rate)
}

solver_get_states <- function(solver) {
.Call(`_malariasimulation_solver_get_states`, solver)
}

solver_set_states <- function(solver, t, state) {
invisible(.Call(`_malariasimulation_solver_set_states`, solver, t, state))
}

solver_step <- function(solver) {
invisible(.Call(`_malariasimulation_solver_step`, solver))
}
Expand All @@ -57,10 +73,26 @@ timeseries_push <- function(timeseries, value, timestep) {
invisible(.Call(`_malariasimulation_timeseries_push`, timeseries, value, timestep))
}

timeseries_save_state <- function(timeseries) {
.Call(`_malariasimulation_timeseries_save_state`, timeseries)
}

timeseries_restore_state <- function(timeseries, state) {
invisible(.Call(`_malariasimulation_timeseries_restore_state`, timeseries, state))
}

random_seed <- function(seed) {
invisible(.Call(`_malariasimulation_random_seed`, seed))
}

random_save_state <- function() {
.Call(`_malariasimulation_random_save_state`)
}

random_restore_state <- function(state) {
invisible(.Call(`_malariasimulation_random_restore_state`, state))
}

bernoulli_multi_p_cpp <- function(p) {
.Call(`_malariasimulation_bernoulli_multi_p_cpp`, p)
}
Expand Down
146 changes: 146 additions & 0 deletions R/antimalarial_resistance.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#' @title Parameterise antimalarial resistance
#' @description
#' Parameterise antimalarial resistance
#'
#' @param parameters the model parameters
#' @param drug the index of the drug which resistance is being set, as set by the set_drugs() function, in the parameter list
#' @param timesteps vector of time steps for each update to resistance proportion and resistance outcome probability
#' @param artemisinin_resistance_proportion vector of updates to the proportions of infections that are artemisinin resistant at time t
#' @param partner_drug_resistance_proportion vector of updates to the proportions of infections that are partner-drug resistant at time t
#' @param slow_parasite_clearance_probability vector of updates to the proportion of artemisinin-resistant infections that result in early treatment failure
#' @param early_treatment_failure_probability vector of updates to the proportion of artemisinin-resistant infections that result in slow parasite clearance
#' @param late_clinical_failure_probability vector of updates to the proportion of partner-drug-resistant infections that result in late clinical failure
#' @param late_parasitological_failure_probability vector of updates to the proportion of partner-drug-resistant infections that result in late parasitological failure
#' @param reinfection_during_prophylaxis_probability vector of updates to the proportion of partner-drug-resistant infections that result in reinfection during prophylaxis
#' @param slow_parasite_clearance_time single value representing the mean time individual's experiencing slow parasite clearance reside in the treated state
#' @export
set_antimalarial_resistance <- function(parameters,
drug,
timesteps,
artemisinin_resistance_proportion,
partner_drug_resistance_proportion,
slow_parasite_clearance_probability,
early_treatment_failure_probability,
late_clinical_failure_probability,
late_parasitological_failure_probability,
reinfection_during_prophylaxis_probability,
slow_parasite_clearance_time) {

if(any(partner_drug_resistance_proportion > 0,
late_clinical_failure_probability > 0,
late_parasitological_failure_probability > 0,
reinfection_during_prophylaxis_probability > 0)) {
stop("Parameters set for unimplemented feature - late clinical failure, late parasitological failure, or reinfection during prophylaxis")
}

if(any(c(length(artemisinin_resistance_proportion),
length(partner_drug_resistance_proportion),
length(slow_parasite_clearance_probability),
length(early_treatment_failure_probability),
length(late_clinical_failure_probability),
length(late_parasitological_failure_probability),
length(reinfection_during_prophylaxis_probability)) != length(timesteps))) {
stop("Length of one or more resistance parameter vectors does not match time steps specified for update")
}

if(any(artemisinin_resistance_proportion < 0 | artemisinin_resistance_proportion > 1 |
partner_drug_resistance_proportion < 0 | partner_drug_resistance_proportion > 1)) {
stop("Artemisinin and partner-drug resistance proportions must fall between 0 and 1")
}

if(any(slow_parasite_clearance_probability < 0 | slow_parasite_clearance_probability > 1 |
early_treatment_failure_probability < 0 | early_treatment_failure_probability > 1 |
late_clinical_failure_probability < 0 | late_clinical_failure_probability > 1 |
late_parasitological_failure_probability < 0 | late_parasitological_failure_probability > 1 |
reinfection_during_prophylaxis_probability < 0 | reinfection_during_prophylaxis_probability > 1)) {
stop("Resistance outcome probabilities must fall between 0 and 1")
}

if(length(slow_parasite_clearance_time) != 1) {
stop("Error: length of slow_parasite_clearance_time not equal to 1")
}

if(slow_parasite_clearance_time <= 0) {
stop("Error: slow_parasite_clearance_time is non-positive")
}

parameters$antimalarial_resistance <- TRUE

n_drugs <- length(parameters$drug_efficacy)

if (drug < 1 | drug > n_drugs) {
stop('Drug index is invalid, please set drugs using set_drugs')
}

drug_index <- which(parameters$antimalarial_resistance_drug == drug)

if (length(drug_index) == 0) {
drug_index <- length(parameters$antimalarial_resistance_drug) + 1
}

parameters$antimalarial_resistance_drug[[drug_index]] <- drug
parameters$antimalarial_resistance_timesteps[[drug_index]] <- timesteps
parameters$artemisinin_resistance_proportion[[drug_index]] <- artemisinin_resistance_proportion
parameters$partner_drug_resistance_proportion[[drug_index]] <- partner_drug_resistance_proportion
parameters$slow_parasite_clearance_probability[[drug_index]] <- slow_parasite_clearance_probability
parameters$early_treatment_failure_probability[[drug_index]] <- early_treatment_failure_probability
parameters$late_clinical_failure_probability[[drug_index]] <- late_clinical_failure_probability
parameters$late_parasitological_failure_probability[[drug_index]] <- late_parasitological_failure_probability
parameters$reinfection_during_prophylaxis_probability[[drug_index]] <- reinfection_during_prophylaxis_probability
parameters$dt_slow_parasite_clearance[[drug_index]] <- slow_parasite_clearance_time

return(parameters)

}

#' @title Retrieve resistance parameters
#' @description
#' Retrieve the resistance parameters associated with the drug each individual receiving clinical
#' treatment has been administered in the current time step.
#'
#' @param parameters the model parameters
#' @param drugs vector of integers representing the drugs administered to each individual receiving treatment
#' @param timestep the current time step
get_antimalarial_resistance_parameters <- function(parameters, drugs, timestep) {

if(!parameters$antimalarial_resistance) {
stop("Error: Antimalarial resistance has not been parameterised; antimalarial_resistance = FALSE")
}

blank_vector <- numeric(length = length(drugs))
artemisinin_resistance_proportion <- blank_vector
partner_drug_resistance_proportion <- blank_vector
slow_parasite_clearance_probability <- blank_vector
early_treatment_failure_probability <- blank_vector
late_clinical_failure_probability <- blank_vector
late_parasitological_failure_probability <- blank_vector
reinfection_during_prophylaxis_probability <- blank_vector
dt_slow_parasite_clearance <- rep(parameters$dt, length = length(drugs))

for(i in seq_along(parameters$antimalarial_resistance_drug)) {
drug <- parameters$antimalarial_resistance_drug[[i]]
treated_with_drug <- which(drugs == drug)
resistance_timestep <- match_timestep(ts = parameters$antimalarial_resistance_timesteps[[i]], t = timestep)
artemisinin_resistance_proportion[treated_with_drug] <- parameters$artemisinin_resistance_proportion[[i]][resistance_timestep]
partner_drug_resistance_proportion[treated_with_drug] <- parameters$partner_drug_resistance_proportion[[i]][resistance_timestep]
slow_parasite_clearance_probability[treated_with_drug] <- parameters$slow_parasite_clearance_probability[[i]][resistance_timestep]
early_treatment_failure_probability[treated_with_drug] <- parameters$early_treatment_failure_probability[[i]][resistance_timestep]
late_clinical_failure_probability[treated_with_drug] <- parameters$late_clinical_failure_probability[[i]][resistance_timestep]
late_parasitological_failure_probability[treated_with_drug] <- parameters$late_parasitological_failure_probability[[i]][resistance_timestep]
reinfection_during_prophylaxis_probability[treated_with_drug] <- parameters$reinfection_during_prophylaxis_probability[[i]][resistance_timestep]
dt_slow_parasite_clearance[treated_with_drug] <- parameters$dt_slow_parasite_clearance[[i]]
}

resistance_parameters <- list()
resistance_parameters$artemisinin_resistance_proportion <- artemisinin_resistance_proportion
resistance_parameters$partner_drug_resistance_proportion <- partner_drug_resistance_proportion
resistance_parameters$slow_parasite_clearance_probability <- slow_parasite_clearance_probability
resistance_parameters$early_treatment_failure_probability <- early_treatment_failure_probability
resistance_parameters$late_clinical_failure_probability <- late_clinical_failure_probability
resistance_parameters$late_parasitological_failure_probability <- late_parasitological_failure_probability
resistance_parameters$reinfection_during_prophylaxis_probability <- reinfection_during_prophylaxis_probability
resistance_parameters$dt_slow_parasite_clearance <- dt_slow_parasite_clearance

return(resistance_parameters)

}
Loading
Loading