Skip to content

Commit

Permalink
Fixes #1086 remove group_by to optimize computation and suggest paral…
Browse files Browse the repository at this point in the history
…lel (#1130)

* Fixes #1086 remove group_by to optimize computation and suggest parallel

- If parallel is not installed, the regular code is used.
- Regular code tries not to run group_by that slow down the computation by a lot
- The number of cores is identified from the SimulationSettings already set up for the PK parameter calculation task

* Remove ave which did not work as expected

* Fixes #1086 ratios data.frame is pivoted into matrix

* Remove simulation set name from test data
  • Loading branch information
pchelle authored Oct 25, 2023
1 parent 1c1fd1b commit c862b2c
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 114 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Suggests:
styler,
rClr,
crayon,
webshot
webshot,
parallel
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Expand Down
330 changes: 229 additions & 101 deletions R/utilities-ratio-comparison.R

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions man/getMonteCarloMedians.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/getPKRatioSummaryFromSettings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/getPKRatioSummaryStatistics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/summaryStatisticsToDataFrame.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions tests/testthat/test-monte-carlo-sampling.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ comparisonParams <- list(meanlog = 1, sdlog = 2)
set.seed(1111)

referenceData <- data.frame(
simulationSetName = "reference",
IndividualId = 1:popSize,
QuantityPath = "a",
Parameter = "Cmax",
Expand All @@ -21,7 +20,6 @@ referenceData <- data.frame(
)

comparisonData <- data.frame(
simulationSetName = "test",
IndividualId = 1:popSize,
QuantityPath = "a",
Parameter = "Cmax",
Expand Down Expand Up @@ -63,7 +61,7 @@ test_that("Monte Carlo Solution is close to known solution", {
referencePKData = referenceData,
simulationSetName = "test",
# With 10000 repetitions the method runs longer
settings = list(showProgress = FALSE, mcRepetitions = 200)
settings = list(showProgress = FALSE, numberOfCores = 1, mcRepetitions = 200)
)

expect_equal(
Expand All @@ -84,13 +82,13 @@ test_that("Monte Carlo Solution is repeatable", {
pkData = comparisonData,
referencePKData = referenceData,
simulationSetName = "test",
settings = list(showProgress = FALSE, mcRepetitions = 100, mcRandomSeed = 3333)
settings = list(showProgress = FALSE, numberOfCores = 1, mcRepetitions = 100, mcRandomSeed = 3333)
)
mcSolution2 <- ospsuite.reportingengine:::getPKRatioSummaryFromMCSampling(
pkData = comparisonData,
referencePKData = referenceData,
simulationSetName = "test",
settings = list(showProgress = FALSE, mcRepetitions = 100, mcRandomSeed = 3333)
settings = list(showProgress = FALSE, numberOfCores = 1, mcRepetitions = 100, mcRandomSeed = 3333)
)

expect_equal(mcSolution1, mcSolution2)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-pop-pk-parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ updatePKParameter("AUC_tEnd", displayName = "AUC_tEnd", displayUnit = "µmol*min
# Clear test workflow folders
unlink(workflowPediatric$workflowFolder, recursive = TRUE)
unlink(workflowParallel$workflowFolder, recursive = TRUE)
#unlink(workflowRatio$workflowFolder, recursive = TRUE)
unlink(workflowRatio$workflowFolder, recursive = TRUE)

0 comments on commit c862b2c

Please sign in to comment.