tests/testthat/test-simulate_init.R

library(testthat)

context("Test the simulate method with initial conditions")

seed <- 1
source(file.path(getwd(), test_path(), "test-utils.R"))

test_that("Simulate initial conditions, observations starting at 0", {
  model <- model_suite$testing$nonmem$advan3_trans4
  model <- model %>% add(InitialCondition(compartment = 1, rhs = "1000"))

  regFilename <- "initial_conditions"

  dataset <- Dataset(3) %>%
    add(Observations(times = seq(0, 72, by = 1)))

  simulation <- expression(simulate(model = model, dataset = dataset, dest = destEngine, seed = seed))
  test <- expression(
    output_regression_test(results %>% dplyr::filter(TIME >= 5), output = "CP", filename = regFilename)
  )
  campsis_test(simulation, test, env = environment())
})

test_that("Simulate initial conditions, observations starting at 5", {
  model <- model_suite$testing$nonmem$advan3_trans4
  model <- model %>% add(InitialCondition(compartment = 1, rhs = "1000"))

  regFilename <- "initial_conditions"

  dataset <- Dataset(3) %>%
    add(Observations(times = seq(5, 72, by = 1)))

  simulation <- expression(simulate(model = model, dataset = dataset, dest = destEngine, seed = seed))
  test <- expression(
    output_regression_test(results, output = "CP", filename = regFilename)
  )
  campsis_test(simulation, test, env = environment())
})

Try the campsis package in your browser

Any scripts or data that you put into this service are public.

campsis documentation built on Aug. 5, 2026, 9:07 a.m.