private async Task <SimulationResults> runAsync( IModelCoreSimulation simulation, IndividualValuesCache population, AgingData agingData = null, SimulationRunOptions simulationRunOptions = null) { var options = simulationRunOptions ?? new SimulationRunOptions(); initializeProgress(options); _simulationPersistableUpdater.UpdateSimulationPersistable(simulation); try { var populationRunResults = await _populationRunner.RunPopulationAsync( simulation, options, populationData : _populationTask.PopulationTableFrom(population, simulation), agingData : agingData?.ToDataTable() ); return(populationRunResults.Results); } finally { simulationTerminated(); } }
public void Initialize(IModelCoreSimulation simulation, SimulationBatchOptions simulationBatchOptions) { _simulationPersistableUpdater.UpdateSimulationPersistable(simulation); //SimModel optionally caches XML used for loading a simulation as string. //This XML string was used e.g. by the old Matlab-/R-Toolbox when saving a simulation to XML. //C++ export also depends on the original XML string at the moment (not quite clear why). //Because per default XML is NOT cached, we need to set the KeepXML-option to true BEFORE loading a simulation. _simModelBatch.KeepXMLNodeInSimModelSimulation = true; _simModelBatch.InitializeWith(simulation, simulationBatchOptions.Parameters, simulationBatchOptions.Molecules, simulationBatchOptions.CalculateSensitivity); //This needs to be done after initialization of the SimModelBatch so that we can check parameters validate(simulationBatchOptions); _simulationBatchOptions = simulationBatchOptions; }
public void UpdateOutputsIn(IModelCoreSimulation simulation, IEnumerable <QuantitySelection> usedOutputsForSimulation) { var outputSelection = simulation.SimulationSettings.OutputSelections; var usedOutputsList = usedOutputsForSimulation.ToList(); //Remove the one mapped in the simulation that are not used foreach (var simulationOutput in outputSelection.AllOutputs.ToList().Where(output => !usedOutputsList.Contains(output))) { outputSelection.RemoveOutput(simulationOutput); } //Adds the one that are missing foreach (var usedOutput in usedOutputsList.Where(output => !outputSelection.AllOutputs.Contains(output))) { outputSelection.AddOutput(usedOutput); } //Now that the settings were updated, update the persistable flag _simulationPersistableUpdater.UpdateSimulationPersistable(simulation); }
public async Task StartAsync(SensitivityAnalysis sensitivityAnalysis, SensitivityAnalysisRunOptions runOptions) { _sensitivityAnalysis = sensitivityAnalysis; _eventPublisher.PublishEvent(new SensitivityAnalysisStartedEvent(sensitivityAnalysis)); try { var modelCoreSimulation = _modelCoreSimulationMapper.MapFrom(sensitivityAnalysis.Simulation, shouldCloneModel: true); _simulationPersistableUpdater.UpdateSimulationPersistable(modelCoreSimulation); var variationData = _sensitivityAnalysisVariationDataCreator.CreateForRun(sensitivityAnalysis); var runResults = await _populationRunner.RunPopulationAsync(modelCoreSimulation, runOptions, variationData.ToDataTable()); sensitivityAnalysis.Results = await calculateSensitivityBasedOn(sensitivityAnalysis, variationData, runResults, runOptions); _eventPublisher.PublishEvent(new SensitivityAnalysisResultsUpdatedEvent(sensitivityAnalysis)); } finally { _eventPublisher.PublishEvent(new SensitivityAnalysisTerminatedEvent(sensitivityAnalysis)); _sensitivityAnalysis = null; } }