Open-Systems-Pharmacology / OSPSuite-R

R package for the OSPSuite
https://www.open-systems-pharmacology.org/OSPSuite-R/
Other
29 stars 12 forks source link

Updating simulation but not simulationResult breaks PKAnalysis calculation #1485

Open pchelle opened 2 months ago

pchelle commented 2 months ago

In a Reporting Engine simulation, the initial endTime was 14400 min. Updating the endTime in the simulation and not the results leads to this odd crash. I was just wondering if the error message could be more helpful (maybe asking if the simulation and the results do actually match).

library(ospsuite, warn.conflicts = FALSE)
#> Loading required package: rSharp

# Get initial simulation results
sim <- loadSimulation("simulation.pkml")
simResults <- runSimulations(sim)[[1]]
# Update simulation endTime without re-running
sim$outputSchema$intervals[[1]]$endTime$setValue(value = 14400+1, unit = "min")
pkAnalysis <- calculatePKAnalyses(simResults)
#> Error in do.call(".External", c(list("r_call_method", self$pointer, methodName), : Type:    System.ArgumentOutOfRangeException
#> Message: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
#> Method:  Void ThrowArgumentOutOfRange_IndexMustBeLessException()
#> Stack trace:
#>    at System.Collections.Generic.List`1.get_Item(Int32 index)
#>    at OSPSuite.Core.Domain.Services.PKValuesCalculator.setMultipleDosingPKValues(ICache`2 pk, IReadOnlyList`1 allIntervals, PKCalculationOptions options)
#>    at OSPSuite.Core.Domain.Services.PKValuesCalculator.CalculatePK(IReadOnlyList`1 time, IReadOnlyList`1 concentration, PKCalculationOptions options, IReadOnlyList`1 userDefinedPKParameters)
#>    at OSPSuite.Core.Domain.Services.PKAnalysesTask.<>c__DisplayClass8_0.<addPKParametersForOutput>b__1(IndividualResults individualResult)
#>    at OSPSuite.Core.Domain.Services.PKAnalysesTask.scaledIndividualIteration(IModelCoreSimulation simulation, SimulationResults simulationResults, Action`1 performIndividualScalingAction, String moleculeName, PKCalc

Created on 2024-09-03 with reprex v2.1.0