Open PavelBal opened 1 year ago
Write a test to check if this is still the case.
Here how to test:
test_that("First iteration produces NaN", {
simulation <- loadSimulation(system.file("extdata", "Aciclovir.pkml", package = "ospsuite"))
# Define optimization para,eter
parameterPath <- c("Aciclovir|Lipophilicity")
modelParam <- ospsuite::getParameter(path = parameterPath, container = simulation)
piParameter <- PIParameters$new(parameters = modelParam)
# Load data and create output mapping
filePath <- testthat::test_path("../data/AciclovirLaskinData.xlsx")
dataConfiguration <- createImporterConfigurationForFile(filePath = filePath)
dataConfiguration$sheets <- "Laskin 1982.Group A"
dataConfiguration$namingPattern <- "{Source}.{Sheet}"
observedData <- loadDataSetsFromExcel(
xlsFilePath = filePath,
importerConfigurationOrPath = dataConfiguration
)
outputMapping <- PIOutputMapping$new(
quantity = getQuantity("Organism|PeripheralVenousBlood|Aciclovir|Plasma (Peripheral Venous Blood)",
container = simulation
)
)
outputMapping$addObservedDataSets(observedData$`AciclovirLaskinData.Laskin 1982.Group A`)
# Set solver tolerance to a high value so the simulation will definitely fail
simulation$solver$mxStep <- 1
# Create PI Task
piTask <- ParameterIdentification$new(
simulations = simulation,
parameters = piParameter,
outputMappings = outputMapping
)
piTask$run()
})
Setting this:
simulation$solver$mxStep <- 1
ensures that simulation fails.
But it seems that the optimization stops already, so all good?
If the very first iteration produces a NaN, stop the PI. Otherwise, the PI can run forever.