public override async Task <ModelSimulation> MapToModel(SnapshotSimulation snapshot, PKSimProject project) { _logger.AddDebug(PKSimConstants.Information.LoadingSimulation(snapshot.Name), project.Name); var simulation = await createSimulationFrom(snapshot, project); simulation.Solver = await _solverSettingsMapper.MapToModel(snapshot.Solver); simulation.OutputSchema = await _outputSchemaMapper.MapToModel(snapshot.OutputSchema); simulation.OutputSelections = await _outputSelectionsMapper.MapToModel(snapshot.OutputSelections, simulation); await updateParameters(simulation, snapshot.Parameters); await updateAdvancedParameters(simulation, snapshot.AdvancedParameters); updateUsedObservedData(simulation, snapshot.ObservedData, project); await runSimulation(snapshot, simulation); simulation.AddAnalyses(await individualAnalysesFrom(simulation, snapshot.IndividualAnalyses, project)); simulation.AddAnalyses(await populationAnalysesFrom(simulation, snapshot.PopulationAnalyses, project)); _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation); return(simulation); }
public void UpdateSimulationId(Simulation simulation) { _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation); //also need to update in all buildign blocks of the simulation simulation.UsedBuildingBlocks.Each(bb => { bb.BuildingBlock.GetAllChildren <IParameter>().Each(p => p.Origin.SimulationId = simulation.Id); }); }
private void resolveReferences(IMoBiSimulation simulation) { if (simulation == null) { return; } //no need to update building block references at that stage. It will be done when the project itself is being deserialized resolveReferences(simulation.Model); _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation); }
public IMoBiSimulation CreateFrom(IMoBiBuildConfiguration buildConfiguration, IModel model) { var moBiSimulation = new MoBiSimulation() { DiagramManager = _diagramManagerFactory.Create <ISimulationDiagramManager>(), BuildConfiguration = buildConfiguration, Model = model, Creation = _creationMetaDataFactory.Create(), HasChanged = true, Id = _idGenerator.NewId(), }; _simulationParameterOriginIdUpdater.UpdateSimulationId(moBiSimulation); return(moBiSimulation); }
public override async Task <ModelSimulation> MapToModel(SnapshotSimulation snapshot, SimulationContext snapshotContext) { var project = snapshotContext.Project; _logger.AddInfo(PKSimConstants.Information.LoadingSimulation(snapshot.Name, snapshotContext.NumberOfSimulationsLoaded, snapshotContext.NumberOfSimulationsToLoad), project.Name); //Local cache of ids' that will be used to retrieve original building block parameters as the project is only registered //in global context once the whole snapshot mapping process is completed var withIdRepository = new WithIdRepository(); var registrationVisitor = new RegisterObjectVisitor(withIdRepository); var simulation = await createSimulationFrom(snapshot, snapshotContext); var contextWithSimulation = new SnapshotContextWithSimulation(simulation, snapshotContext); simulation.Solver = await _solverSettingsMapper.MapToModel(snapshot.Solver, snapshotContext); simulation.OutputSchema = await _outputSchemaMapper.MapToModel(snapshot.OutputSchema, snapshotContext); simulation.OutputSelections = await _outputSelectionsMapper.MapToModel(snapshot.OutputSelections, contextWithSimulation); registrationVisitor.Register(simulation); await updateParameters(simulation, snapshot.Parameters, withIdRepository, snapshotContext); await updateAdvancedParameters(simulation, snapshot.AdvancedParameters, snapshotContext); updateUsedObservedData(simulation, snapshot.ObservedData, project); updateAlteredBuildingBlock(simulation, snapshot.AlteredBuildingBlocks); if (snapshotContext.Run) { await runSimulation(snapshot, simulation); } simulation.AddAnalyses(await individualAnalysesFrom(simulation, snapshot.IndividualAnalyses, snapshotContext)); simulation.AddAnalyses(await populationAnalysesFrom(simulation, snapshot.PopulationAnalyses, snapshotContext)); _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation); return(simulation); }
public void should_update_the_simulation_origin_id_in_all_parameters_of_the_simulation() { A.CallTo(() => _simulationParameterOriginIdUpdater.UpdateSimulationId(_simulation)).MustHaveHappened(); }
public void UpdateSimulationId(Simulation simulation) { _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation); }