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

Error when running simulation batch #1702

Closed
rwmcintosh opened this issue Sep 23, 2022 · 2 comments
Closed

Error when running simulation batch #1702

rwmcintosh opened this issue Sep 23, 2022 · 2 comments
Assignees

Comments

@rwmcintosh
Copy link
Member

@PavelBal commented on Fri Jul 15 2022

Vehicle.zip

Probably an errorr in core.
When seeting all molecules as variable molecules in the attached simulation, runnning the batch produces the error that some molecules do not exist in the simulation.

# Load the simulation from file - adjust the path accordingly
simulation <- loadSimulation(file.path(getwd(), "../Models/Simulations", "Vehicle.pkml"))
# Get the paths of all molecules in the simulation
moleculePaths <- getAllMoleculePathsIn(container = simulation)
# Get the current intial values of all molecules
moleculesStartValues <- getQuantityValuesByPath(quantityPaths = moleculePaths,
                                                simulation = simulation)
# Create simulation batch and define all molecules as variable
simBatch <- createSimulationBatch(simulation = simulation,
                                  moleculesOrPaths = moleculePaths)
# Add run values
simBatch$addRunValues(initialValues = moleculesStartValues)
# Try to run
results <- runSimulationBatches(simBatch)

Error:

Error in rClr::clrCall(simulationRunner, "RunConcurrently") : 
  Type:    OSPSuite.Core.Domain.InvalidArgumentException
Message: Entities 'Organism|Kidney|Urine|ADC', 'Organism|Kidney|Urine|nAb', 'Organism|Kidney|Urine|Toxophore', 'Organism|Liver|Periportal|Intracellular|Undefined Liver', 'Organism|Liver|Pericentral|Intracellular|Undefined Liver', 'Organism|EndogenousIgG|Plasma|FcRn kinetics plasma', 'Organism|EndogenousIgG|Interstitial|FcRn kinetics interstitial', 'Organism|EndogenousIgG|Endosome|FcRn kinetics endosome', 'Applications|i.v. 0.3 mg/kg|Application_1|ADC' do not exist in the simulation
Method:  Void validate(System.Collections.Generic.IReadOnlyList`1[System.String], System.Collections.Generic.IReadOnlyList`1[System.String])
Stack trace:
   at OSPSuite.R.Domain.SimulationBatch.validate(IReadOnlyList`1 entitiesToVary, IReadOnlyList`1 entitiesThatWillBeVaried)
   at OSPSuite.R.Domain.SimulationBatch.validate(SimulationBatchOptions simulationBatchOptions)
   at OSPSuite.R.Domain.SimulationBatch.Initialize(IModelCoreSimulation simu

@PavelBal commented on Fri Jul 15 2022

@abdelr Could you look into it when you have time? I can help you translating the example to .NET test if necessary.


@PavelBal commented on Thu Sep 22 2022

@rwmcintosh


@rwmcintosh commented on Thu Sep 22 2022

var moleculeToBeVaried = variableMoleculePaths.Join(

For reference.

In the attached project there is a discrepancy at this line where the two lists are not perfectly 1 to 1.

Here is the list of paths in variableMoleculePaths that is not available from SpeciesProperties. Since this list of variableMoleculePaths comes from the simulation, I thought SpeciesProperties would contain them all.

"Organism|Kidney|Urine|ADC"
"Organism|Kidney|Urine|nAb"
"Organism|Kidney|Urine|Toxophore"
"Organism|Liver|Periportal|Intracellular|Undefined Liver"
"Organism|Liver|Pericentral|Intracellular|Undefined Liver"
"Organism|EndogenousIgG|Plasma|FcRn kinetics plasma"
"Organism|EndogenousIgG|Interstitial|FcRn kinetics interstitial"
"Organism|EndogenousIgG|Endosome|FcRn kinetics endosome"
"Applications|i.v. 0.3 mg/kg|Application_1|ADC"

The paths available in SpeciesProperties that are not in variableMoleculePaths are

"Organism|Lumen|Stomach|Liquid"
"Organism|Lumen|Duodenum|Liquid"
"Organism|Lumen|Duodenum|ADC|Oral mass absorbed segment"
"Organism|Lumen|Duodenum|nAb|Oral mass absorbed segment"
"Organism|Lumen|Duodenum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|UpperJejunum|Liquid"
"Organism|Lumen|UpperJejunum|ADC|Oral mass absorbed segment"
"Organism|Lumen|UpperJejunum|nAb|Oral mass absorbed segment"
"Organism|Lumen|UpperJejunum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|LowerJejunum|Liquid"
"Organism|Lumen|LowerJejunum|ADC|Oral mass absorbed segment"
"Organism|Lumen|LowerJejunum|nAb|Oral mass absorbed segment"
"Organism|Lumen|LowerJejunum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|UpperIleum|Liquid"
"Organism|Lumen|UpperIleum|ADC|Oral mass absorbed segment"
"Organism|Lumen|UpperIleum|nAb|Oral mass absorbed segment"
"Organism|Lumen|UpperIleum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|LowerIleum|Liquid"
"Organism|Lumen|LowerIleum|ADC|Oral mass absorbed segment"
"Organism|Lumen|LowerIleum|nAb|Oral mass absorbed segment"
"Organism|Lumen|LowerIleum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|Caecum|Liquid"
"Organism|Lumen|Caecum|ADC|Oral mass absorbed segment"
"Organism|Lumen|Caecum|nAb|Oral mass absorbed segment"
"Organism|Lumen|Caecum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|ColonAscendens|Liquid"
"Organism|Lumen|ColonAscendens|ADC|Oral mass absorbed segment"
"Organism|Lumen|ColonAscendens|nAb|Oral mass absorbed segment"
"Organism|Lumen|ColonAscendens|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|ColonTransversum|Liquid"
"Organism|Lumen|ColonTransversum|ADC|Oral mass absorbed segment"
"Organism|Lumen|ColonTransversum|nAb|Oral mass absorbed segment"
"Organism|Lumen|ColonTransversum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|ColonDescendens|Liquid"
"Organism|Lumen|ColonDescendens|ADC|Oral mass absorbed segment"
"Organism|Lumen|ColonDescendens|nAb|Oral mass absorbed segment"
"Organism|Lumen|ColonDescendens|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|ColonSigmoid|Liquid"
"Organism|Lumen|ColonSigmoid|ADC|Oral mass absorbed segment"
"Organism|Lumen|ColonSigmoid|nAb|Oral mass absorbed segment"
"Organism|Lumen|ColonSigmoid|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|Rectum|Liquid"
"Organism|Lumen|Rectum|ADC|Oral mass absorbed segment"
"Organism|Lumen|Rectum|nAb|Oral mass absorbed segment"
"Organism|Lumen|Rectum|Toxophore|Oral mass absorbed segment"
"Organism|Lumen|Feces|Liquid"
"Organism|Tumor|Intracellular|x1"
"Organism|Tumor|Intracellular|x2"
"Organism|Tumor|Intracellular|x3"
"Organism|Tumor|Intracellular|x4"

From the R code, the variableMoleculePaths are retrieved by

_containerTask.AllMoleculesPathsIn(_simulation);

@Yuri05 @msevestre Any idea why these two lists are not matching?


@rwmcintosh commented on Thu Sep 22 2022

See my unit test which translates the R code

https://github.com/rwmcintosh/OSPSuite.Core/blob/3b152081707894657df5449668bf15021093c4a4/tests/OSPSuite.R.Tests/Services/ConcurrentSimulationRunnerSpecs.cs#L56


@rwmcintosh commented on Fri Sep 23 2022

After discussion with @msevestre and @Yuri05 today, we decided that the bug itself can be fixed meaning - if the list of variable molecules is not a precise match we will only try to vary the intersection of the lists. The issue is caused because SimModel optimizes the molecules that won't be varied into parameters. The list in this example is created before the SimModel initialization, so there is no way for the application to know this will happen.

To enable the steady state use case, some more reorganization will be required in SimModel and OSPSuite.Core so that the list of variable molecules and variable parameters are actually known by the caller.


@rwmcintosh commented on Fri Sep 23 2022

Will have to revisit when SimModel supports the fix.

@Yuri05
Copy link
Member

Yuri05 commented Dec 27, 2022

not sure if the issue was fixed. @rwmcintosh

With ospsuite-R 11.1.115 I don't get any error, but the results are empty:

> simulation=loadSimulation("C:/Temp/Vehicle.pkml")
> moleculePaths <- getAllMoleculePathsIn(container = simulation)
> moleculesStartValues <- getQuantityValuesByPath(quantityPaths = moleculePaths,simulation = simulation)
> simBatch <- createSimulationBatch(simulation = simulation,moleculesOrPaths = moleculePaths)
> simBatch$addRunValues(initialValues = moleculesStartValues)
[1] "6278a07f-de5a-4d99-a35b-2820b36fe7aa"
> results <- runSimulationBatches(simBatch)
Warning message:
In .getConcurrentSimulationRunnerResults(results = results, resultsIdSimulationIdMap = resultsIdSimulationBatchIdMap,  :
  Initial value of Vehicle|Organism|Liver|Pericentral|Interstitial|TMEFF2 was not set
> results
$`d081efc9-56c6-486c-9659-353c7611f75c`
$`d081efc9-56c6-486c-9659-353c7611f75c`$`6278a07f-de5a-4d99-a35b-2820b36fe7aa`
NULL

> results$`d081efc9-56c6-486c-9659-353c7611f75c`
$`6278a07f-de5a-4d99-a35b-2820b36fe7aa`
NULL

results$d081efc9-56c6-486c-9659-353c7611f75c$6278a07f-de5a-4d99-a35b-2820b36fe7aa
NULL

@Yuri05 Yuri05 reopened this Dec 27, 2022
@Yuri05 Yuri05 moved this from Done to In Progress in V11 - Update 1 Dec 27, 2022
@PavelBal
Copy link
Member

PavelBal commented Jan 9, 2023

@Yuri05 with the latest version the error is thrown. Probably the Core dlls were not updated.

@PavelBal PavelBal closed this as completed Jan 9, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in V11 - Update 1 Jan 9, 2023
@Yuri05 Yuri05 moved this from Done to Verified in V11 - Update 1 Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Verified
Development

No branches or pull requests

3 participants