private void updatePersistableFor(IndividualSimulation simulation, bool exportAll) { if (exportAll) { _simulationPersistableUpdater.ResetPersistable(simulation); } else { _simulationPersistableUpdater.UpdatePersistableFromSettings(simulation); } }
private async Task runSimulation <TSimulation>(TSimulation simulation, Action <TSimulation> updatePersistableFromSettings) where TSimulation : Simulation { var simulationEngine = _simulationEngineFactory.Create <TSimulation>(); _simulationEngine = simulationEngine; if (_simulationRunOptions.RunForAllOutputs) { _simulationPersistableUpdater.ResetPersistable(simulation); } else { updatePersistableFromSettings(simulation); } await simulationEngine.RunAsync(simulation, _simulationRunOptions); simulation.HasChanged = true; }
private void updateSimulationAfterModelCreation(Simulation simulation) { //last step. Once the model has been created, it is necessary to set the id of the simulation //in all parameter defined in the model _parameterIdUpdater.UpdateSimulationId(simulation); //local molecule parameters parameter id need to be updated as well var allParameters = _containerTask.CacheAllChildren <IParameter>(simulation.Model.Root); var individual = simulation.Individual; individual.AllMolecules().Each(m => { var allMoleculeParameters = individual.AllMoleculeParametersFor(m); allMoleculeParameters.Each(p => { var simulationParameter = allParameters[_entityPathResolver.PathFor(p)]; if (simulationParameter != null) { updateFromIndividualParameter(simulationParameter, p, individual); } }); }); //we need to update the observer types according to their location (container observer are always of type drug, amount observer are depending on parent) var allObservers = simulation.All <IObserver>(); foreach (var observer in allObservers) { var quantity = observer.ParentContainer as IQuantity; if (quantity != null) { observer.QuantityType = QuantityType.Observer | quantity.QuantityType; } else { observer.QuantityType = QuantityType.Observer | QuantityType.Drug; } } _simulationPersistableUpdater.ResetPersistable(simulation); }
private void updateSimulationAfterModelCreation(Simulation simulation) { //last step. Once the model has been created, it is necessary to set the id of the simulation //in all paramater defined in the model _parameterIdUpdater.UpdateSimulationId(simulation); var allMoleculeAmounts = simulation.All <IMoleculeAmount>().ToList(); //local molecule parameters parameter id need to be updated as well var allIndividualMoleculeAmounts = allMoleculeAmounts.Where(m => m.IsIndividualMolecule()); var individual = simulation.Individual; var allOrganismContainers = _expressionContainersRetriever.AllOrganismContainers(individual).ToList(); hideAllUndefinedParameterForMolecules(simulation); foreach (var moleculeAmountGroup in allIndividualMoleculeAmounts.GroupBy(x => x.Name)) { var molecule = individual.MoleculeByName <IndividualMolecule>(moleculeAmountGroup.Key); var moleculeAmountPath = new PathCache <IMoleculeAmount>(_entityPathResolver).For(moleculeAmountGroup); updateAllParametersFor(simulation, individual, allOrganismContainers, molecule, moleculeAmountPath); } //we need to update the observer types according to their location (container observer are always of type drug, amount observer are depending on parent) var allObservers = simulation.All <IObserver>(); foreach (var observer in allObservers) { var quantity = observer.ParentContainer as IQuantity; if (quantity != null) { observer.QuantityType = QuantityType.Observer | quantity.QuantityType; } else { observer.QuantityType = QuantityType.Observer | QuantityType.Drug; } } _simulationPersistableUpdater.ResetPersistable(simulation); }