コード例 #1
0
        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);
        }
コード例 #2
0
        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); });
        }
コード例 #3
0
 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);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void should_update_the_simulation_origin_id_in_all_parameters_of_the_simulation()
 {
     A.CallTo(() => _simulationParameterOriginIdUpdater.UpdateSimulationId(_simulation)).MustHaveHappened();
 }
コード例 #7
0
ファイル: ParameterIdUpdater.cs プロジェクト: valdiman/PK-Sim
 public void UpdateSimulationId(Simulation simulation)
 {
     _simulationParameterOriginIdUpdater.UpdateSimulationId(simulation);
 }