Ejemplo n.º 1
0
        protected override IAttemptResult TryVariant()
        {
            var mutated = (MicrobeSpecies)species.Clone();

            mutations.CreateMutatedSpecies((MicrobeSpecies)species, mutated);

            var config = new SimulationConfiguration(map, Constants.AUTO_EVO_VARIANT_SIMULATION_STEPS);

            config.ExcludedSpecies.Add(species);
            config.ExtraSpecies.Add(mutated);

            PopulationSimulation.Simulate(config);

            var population = config.Results.GetGlobalPopulation(mutated);

            return(new AttemptResult(mutated, population));
        }
Ejemplo n.º 2
0
        private void addAgingDataToPopulationSimulation <TParameter>(
            PopulationSimulation populationSimulation,
            string parameterPath,
            TParameter parameter,
            Func <TableFormulaParameter <TParameter>, TableFormula> tableFormulaRetriever) where TParameter : IParameter
        {
            if (populationSimulation == null || !_createAgingDataInPopulationSimulation)
            {
                return;
            }

            var originData     = _baseOriginData.Clone();
            var allAges        = populationSimulation.AllOrganismValuesFor(CoreConstants.Parameters.AGE, _entityPathResolver);
            var allGAs         = populationSimulation.AllOrganismValuesFor(Constants.Parameters.GESTATIONAL_AGE, _entityPathResolver);
            var allHeights     = populationSimulation.AllOrganismValuesFor(CoreConstants.Parameters.HEIGHT, _entityPathResolver);
            var allGender      = populationSimulation.AllGenders(_genderRepository).ToList();
            var allValues      = populationSimulation.AllValuesFor(parameterPath).ToList();
            var allPercentiles = populationSimulation.AllPercentilesFor(parameterPath)
                                 .Select(x => x.CorrectedPercentileValue()).ToList();

            var tableFormulaParameter = new TableFormulaParameter <TParameter> {
                OriginData = originData, Parameter = parameter
            };

            for (int individualIndex = 0; individualIndex < populationSimulation.NumberOfItems; individualIndex++)
            {
                //create origin data for individual i
                originData.Age.Value            = allAges[individualIndex];
                originData.GestationalAge.Value = allGAs[individualIndex];
                originData.Height.Value         = allHeights[individualIndex];
                originData.Gender                = allGender[individualIndex];
                tableFormulaParameter.Value      = allValues[individualIndex];
                tableFormulaParameter.Percentile = allPercentiles[individualIndex];

                var tableFormula = tableFormulaRetriever(tableFormulaParameter);
                if (tableFormula == null)
                {
                    continue;
                }

                populationSimulation.AddAgingTableFormula(parameterPath, individualIndex, tableFormula);
            }
        }
Ejemplo n.º 3
0
        private void createPopulationHeightTableParameter(
            string heightParameterPath,
            IDistributedParameter meanHeightParameter,
            PopulationSimulation populationSimulation
            )
        {
            if (populationSimulation == null || !_createAgingDataInPopulationSimulation)
            {
                return;
            }

            var originData = _baseOriginData.Clone();
            var allAges    = populationSimulation.AllOrganismValuesFor(CoreConstants.Parameters.AGE, _entityPathResolver);
            var allGAs     = populationSimulation.AllOrganismValuesFor(Constants.Parameters.GESTATIONAL_AGE, _entityPathResolver);
            var allHeights = populationSimulation.AllOrganismValuesFor(CoreConstants.Parameters.HEIGHT, _entityPathResolver);
            var allGender  = populationSimulation.AllGenders(_genderRepository).ToList();

            var tableFormulaParameter = new TableFormulaParameter <IDistributedParameter> {
                OriginData = originData, Parameter = meanHeightParameter
            };

            for (int individualIndex = 0; individualIndex < populationSimulation.NumberOfItems; individualIndex++)
            {
                //create origin data for individual i
                originData.Age.Value            = allAges[individualIndex];
                originData.GestationalAge.Value = allGAs[individualIndex];
                originData.Height.Value         = allHeights[individualIndex];
                originData.Gender           = allGender[individualIndex];
                tableFormulaParameter.Value = originData.Height.Value;

                var heightDistributions = heightDistributionsFor(originData);
                tableFormulaParameter.Percentile = heightDistributions.currentPercentile;

                var distributions = allDistributionsWithAgeStrictBiggerThanOriginData(_allHeightDistributionMaleParameters, _allHeightDistributionFemaleParameters, tableFormulaParameter.OriginData);
                var tableFormula  = createTableFormulaFrom(tableFormulaParameter, distributions);
                if (tableFormula == null)
                {
                    continue;
                }

                populationSimulation.AddAgingTableFormula(heightParameterPath, individualIndex, tableFormula);
            }
        }
Ejemplo n.º 4
0
        private void createPopulationTableParameter(
            string individualParameterPath,
            IDistributedParameter individualParameter,
            PopulationSimulation populationSimulation,
            IReadOnlyList <ParameterDistributionMetaData> allDistributionsForMaleParameter,
            IReadOnlyList <ParameterDistributionMetaData> allDistributionsForFemaleParameter)
        {
            if (populationSimulation == null)
            {
                return;
            }

            addAgingDataToPopulationSimulation(populationSimulation, individualParameterPath, individualParameter,
                                               p =>
            {
                var distributions = allDistributionsWithAgeStrictBiggerThanOriginData(allDistributionsForMaleParameter, allDistributionsForFemaleParameter, p.OriginData);
                return(createTableFormulaFrom(p, distributions));
            });
        }
Ejemplo n.º 5
0
 protected override void Context()
 {
     base.Context();
     _parameter             = A.Fake <IDistributedParameter>();
     _distributedParameters = new PathCacheForSpecs <IParameter> {
         { "P1", _parameter }
     };
     _populationSimulation = A.Fake <PopulationSimulation>();
     _mobiPopulation       = A.Fake <MoBiPopulation>();
     _advancedParameter    = A.Fake <IAdvancedParameter>();
     _randomValues         = new List <RandomValue>();
     _parameterValueCache  = A.Fake <ParameterValuesCache>();
     A.CallTo(() => _populationSimulation.ParameterValuesCache).Returns(_parameterValueCache);
     A.CallTo(_simulationFactory).WithReturnType <PopulationSimulation>().Returns(_populationSimulation);
     A.CallTo(() => _objectBaseFactory.Create <MoBiPopulation>()).Returns(_mobiPopulation);
     A.CallTo(() => _objectBaseFactory.Create <IAdvancedParameter>()).Returns(_advancedParameter);
     A.CallTo(_parameterRetriever).WithReturnType <PathCache <IParameter> >().Returns(_distributedParameters);
     A.CallTo(_advancedParameter).WithReturnType <IEnumerable <RandomValue> >().Returns(_randomValues);
 }
Ejemplo n.º 6
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_populationSimulation, _project);

            var populationSimulation = new PopulationSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            A.CallTo(() => _simulationFactory.CreateFrom(_population, A <IReadOnlyList <Compound> > ._, A <ModelProperties> ._, null)).Returns(populationSimulation);

            A.CallTo(() => _populationAnalysisChartMapper.MapToModel(_snapshotPopulationAnalysisChart, A <SimulationAnalysisContext> ._))
            .Invokes(x => _context = x.GetArgument <SimulationAnalysisContext>(1))
            .Returns(_populationSimulationAnalysisChart);
        }
Ejemplo n.º 7
0
        protected override void Context()
        {
            base.Context();
            _populationSimulation            = new PopulationSimulation();
            _populationSimulation.Model      = new OSPSuite.Core.Domain.Model();
            _populationSimulation.Model.Root = new Container();
            var randomPopulation = new RandomPopulation();

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("id", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = randomPopulation
            });
            _populationSimulation.SetAdvancedParameters(new AdvancedParameterCollection());
            _populationSimulation.Add(new Parameter().WithName("Param1"));
            _advancedParameter = new AdvancedParameter {
                ParameterPath = "OLD|Param1"
            };
            _populationSimulation.AddAdvancedParameter(_advancedParameter);
            _populationSimulation.Name = "NEW";
        }
Ejemplo n.º 8
0
        protected override void Context()
        {
            base.Context();
            _populationSimulation = A.Fake <PopulationSimulation>().WithName("ClusterSim");
            var agingData = new DataTable();

            agingData.Columns.Add(new DataColumn("name"));
            var row = agingData.NewRow();

            row["name"] = "Age";
            agingData.Rows.Add(row);
            A.CallTo(() => _populationSimulation.AgingData.ToDataTable()).Returns(agingData);
            _clusterExport = new FileSelection()
            {
                Description = "Desc", FilePath = _clusterInputDirectory
            };
            A.CallTo(() => _selectFilePresenter.SelectDirectory(PKSimConstants.UI.ExportForClusterSimulationTitle, Constants.DirectoryKey.SIM_MODEL_XML)).Returns(_clusterExport);
            _coreSimulation = A.Fake <IModelCoreSimulation>();
            A.CallTo(() => _modelCoreSimulationMapper.MapFrom(_populationSimulation, false)).Returns(_coreSimulation);
        }
        public PopulationSimulationPKAnalyses CalculateFor(PopulationSimulation populationSimulation)
        {
            _lazyLoadTask.LoadResults(populationSimulation);
            if (!populationSimulation.HasResults)
            {
                return(new NullPopulationSimulationPKAnalyses());
            }

            var bodyWeightParameter     = populationSimulation.BodyWeight;
            var bodyWeightParameterPath = bodyWeightParameterPathFrom(bodyWeightParameter);
            var allBodyWeights          = populationSimulation.AllValuesFor(bodyWeightParameterPath);

            try
            {
                return(base.CalculateFor(populationSimulation, populationSimulation.Results, (individualId) => { updateBodyWeightFromCurrentIndividual(bodyWeightParameter, allBodyWeights, individualId); }));
            }
            finally
            {
                bodyWeightParameter?.ResetToDefault();
            }
        }
Ejemplo n.º 10
0
        public async Task <PopulationRunResults> RunAsync(PopulationSimulation populationSimulation, SimulationRunOptions simulationRunOptions)
        {
            _progressUpdater = _progressManager.Create();
            _progressUpdater.Initialize(populationSimulation.NumberOfItems, PKSimConstants.UI.Calculating);

            var begin = SystemTime.UtcNow();

            try
            {
                var populationData      = _populationExporter.CreatePopulationDataFor(populationSimulation);
                var modelCoreSimulation = _modelCoreSimulationMapper.MapFrom(populationSimulation, shouldCloneModel: false);
                var runOptions          = new RunOptions {
                    NumberOfCoresToUse = _userSettings.MaximumNumberOfCoresToUse
                };
                _eventPublisher.PublishEvent(new SimulationRunStartedEvent());
                var populationRunResults = await _populationRunner.RunPopulationAsync(modelCoreSimulation, runOptions, populationData, populationSimulation.AgingData.ToDataTable());

                _simulationResultsSynchronizer.Synchronize(populationSimulation, populationRunResults.Results);
                _populationSimulationAnalysisSynchronizer.UpdateAnalysesDefinedIn(populationSimulation);
                _eventPublisher.PublishEvent(new SimulationResultsUpdatedEvent(populationSimulation));

                return(populationRunResults);
            }
            catch (OperationCanceledException)
            {
                simulationTerminated();
                return(null);
            }
            catch (Exception)
            {
                simulationTerminated();
                throw;
            }
            finally
            {
                var end       = SystemTime.UtcNow();
                var timeSpent = end - begin;
                _eventPublisher.PublishEvent(new SimulationRunFinishedEvent(populationSimulation, timeSpent));
            }
        }
        protected override void Context()
        {
            _view = A.Fake <IPopulationSimulationSettingsView>();
            _quantitySelectionPresenter   = A.Fake <IQuantitySelectionPresenter>();
            _simulationPersistableUpdater = A.Fake <ISimulationPersistableUpdater>();
            _projectRetriever             = A.Fake <IProjectRetriever>();
            _dialogCreator = A.Fake <IDialogCreator>();
            _userSettings  = A.Fake <IUserSettings>();

            _populationSimulation = A.Fake <PopulationSimulation>();
            A.CallTo(() => _populationSimulation.NumberOfItems).Returns(10);
            _populationSimulation.Model = new Model {
                Root = new Container()
            };
            _originalSettings = A.Fake <OutputSelections>();
            _editedSettings   = A.Fake <OutputSelections>();
            A.CallTo(() => _originalSettings.Clone()).Returns(_editedSettings);
            A.CallTo(() => _populationSimulation.OutputSelections).Returns(_originalSettings);
            _selectedQuantities = new List <QuantitySelection>();
            A.CallTo(() => _quantitySelectionPresenter.SelectedQuantities()).Returns(_selectedQuantities);
            sut = new PopulationSimulationSettingsPresenter(_view, _quantitySelectionPresenter, _simulationPersistableUpdater, _projectRetriever, _dialogCreator, _userSettings);
        }
Ejemplo n.º 12
0
        protected override void Context()
        {
            _dialogCreator = A.Fake <IDialogCreator>();
            _view          = A.Fake <IImportSimulationResultsView>();
            _simulationResultsImportTask = A.Fake <ISimulationResultsImportTask>();
            _populationSimulation        = A.Fake <PopulationSimulation>();
            _importedResults             = A.Fake <SimulationResultsImport>();
            _simulationResults           = new SimulationResults();

            sut = new ImportSimulationResultsPresenter(_view, _simulationResultsImportTask, _dialogCreator);

            A.CallTo(() => _view.BindTo(A <ImportSimulationResultsDTO> ._))
            .Invokes(x => _dto = x.GetArgument <ImportSimulationResultsDTO>(0));

            A.CallTo(() => _simulationResultsImportTask.ImportResults(_populationSimulation, A <IReadOnlyCollection <string> > ._, A <CancellationToken> ._))
            .Returns(_importedResults);

            A.CallTo(() => _importedResults.SimulationResults).Returns(_simulationResults);
            A.CallTo(() => _importedResults.SimulationResultsFiles).Returns(_simulationResultsFiles);


            sut.ImportResultsFor(_populationSimulation);
        }
        private DataTable createPKAnalysesDataToExport(PopulationSimulation populationSimulation)
        {
            var dataTable = new DataTable(populationSimulation.Name);

            if (!populationSimulation.HasPKAnalyses)
            {
                return(dataTable);
            }

            var pkAnalyses = populationSimulation.PKAnalyses;

            dataTable.AddColumn <int>(CoreConstants.SimulationResults.INDIVIDUAL_ID);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.QUANTITY_PATH);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.PARAMETER);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.VALUE);
            dataTable.AddColumn <string>(CoreConstants.SimulationResults.UNIT);

            dataTable.BeginLoadData();
            foreach (var pkParameter in pkAnalyses.All())
            {
                var parameter = pkParameter;
                var unit      = _displayUnitRetriever.PreferredUnitFor(parameter);
                parameter.Values.Each((value, index) =>
                {
                    var row = dataTable.NewRow();
                    row[CoreConstants.SimulationResults.INDIVIDUAL_ID] = index;
                    row[CoreConstants.SimulationResults.QUANTITY_PATH] = parameter.QuantityPath;
                    row[CoreConstants.SimulationResults.PARAMETER]     = parameter.Name;
                    row[CoreConstants.SimulationResults.VALUE]         = parameter.ConvertToUnit(value, unit).ConvertedTo <string>();
                    row[CoreConstants.SimulationResults.UNIT]          = unit.Name;
                    dataTable.Rows.Add(row);
                });
            }
            dataTable.EndLoadData();
            return(dataTable);
        }
 protected override void Context()
 {
     base.Context();
     _populationSimulation = A.Fake <PopulationSimulation>();
     A.CallTo(() => _activeSubjectRetriever.Active <PopulationSimulation>()).Returns(_populationSimulation);
 }
 protected override void Context()
 {
     base.Context();
     _populationSimulation = A.Fake <PopulationSimulation>();
     sut.For(_populationSimulation);
 }
Ejemplo n.º 16
0
 public void Visit(PopulationSimulation populationSimulation)
 {
     convertSimulation(populationSimulation);
     _converted = true;
 }
 protected override void Context()
 {
     _populationSimulation = A.Fake <PopulationSimulation>();
     _simulationResults    = A.Fake <SimulationResults>();
     sut = new SetPopulationSimulationResultsCommand(_populationSimulation, _simulationResults);
 }
 public Task <DataTable> PKAnalysesToDataTable(PopulationSimulation populationSimulation)
 {
     return(Task.Run(() => createPKAnalysesDataToExport(populationSimulation)));
 }
Ejemplo n.º 19
0
        protected override Task Context()
        {
            _solverSettingsMapper               = A.Fake <SolverSettingsMapper>();
            _outputSchemaMapper                 = A.Fake <OutputSchemaMapper>();
            _outputSelectionMapper              = A.Fake <OutputSelectionsMapper>();
            _parameterMapper                    = A.Fake <ParameterMapper>();
            _compoundPropertiesMapper           = A.Fake <CompoundPropertiesMapper>();
            _advancedParameterMapper            = A.Fake <AdvancedParameterMapper>();
            _eventMappingMapper                 = A.Fake <EventMappingMapper>();
            _observerSetMappingMapper           = A.Fake <ObserverSetMappingMapper>();
            _curveChartMapper                   = A.Fake <SimulationTimeProfileChartMapper>();
            _processMappingMapper               = A.Fake <ProcessMappingMapper>();
            _simulationFactory                  = A.Fake <ISimulationFactory>();
            _executionContext                   = A.Fake <IExecutionContext>();
            _simulationModelCreator             = A.Fake <ISimulationModelCreator>();
            _simulationBuildingBlockUpdater     = A.Fake <ISimulationBuildingBlockUpdater>();
            _modelPropertiesTask                = A.Fake <IModelPropertiesTask>();
            _simulationRunner                   = A.Fake <ISimulationRunner>();
            _populationAnalysisChartMapper      = A.Fake <PopulationAnalysisChartMapper>();
            _simulationParameterOriginIdUpdater = A.Fake <ISimulationParameterOriginIdUpdater>();
            _logger             = A.Fake <ILogger>();
            _containerTask      = A.Fake <IContainerTask>();
            _entityPathResolver = A.Fake <IEntityPathResolver>();

            sut = new SimulationMapper(_solverSettingsMapper, _outputSchemaMapper,
                                       _outputSelectionMapper, _compoundPropertiesMapper, _parameterMapper,
                                       _advancedParameterMapper, _eventMappingMapper, _observerSetMappingMapper, _curveChartMapper,
                                       _populationAnalysisChartMapper, _processMappingMapper,
                                       _simulationFactory, _executionContext, _simulationModelCreator,
                                       _simulationBuildingBlockUpdater, _modelPropertiesTask,
                                       _simulationRunner, _simulationParameterOriginIdUpdater,
                                       _logger, _containerTask, _entityPathResolver
                                       );

            _project    = new PKSimProject();
            _individual = new Individual {
                Name = "IND", Id = "IND"
            };
            _compound = new Compound {
                Name = "COMP", Id = "COMP"
            };
            _observerSet = new ObserverSet {
                Name = "OBS_SET", Id = "OBS_SET"
            };
            _protocol = new SimpleProtocol {
                Name = "PROT", Id = "PROT"
            };
            _inductionProcess = new InductionProcess().WithName("Interaction process");
            _compound.AddProcess(_inductionProcess);


            _event = new PKSimEvent {
                Name = "Event"
            };
            _population = new RandomPopulation()
            {
                Name = "POP"
            };
            _observedData = new DataRepository("OBS_ID").WithName("OBS");
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_population);
            _project.AddBuildingBlock(_observerSet);
            _project.AddObservedData(_observedData);

            _simulationProperties = new SimulationProperties
            {
                ModelProperties = new ModelProperties
                {
                    ModelConfiguration = new ModelConfiguration {
                        ModelName = "4Comp"
                    }
                }
            };
            _interactionSelection = new InteractionSelection {
                ProcessName = _inductionProcess.Name
            };
            _noInteractionSelection = new InteractionSelection {
                MoleculeName = "CYP2D6"
            };

            _simulationProperties.InteractionProperties.AddInteraction(_interactionSelection);
            _simulationProperties.InteractionProperties.AddInteraction(_noInteractionSelection);

            _settings      = new SimulationSettings();
            _rootContainer = new Container().WithName("Sim");
            _model         = new OSPSuite.Core.Domain.Model {
                Root = _rootContainer
            };

            _individualSimulation = new IndividualSimulation
            {
                Name               = "S1",
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Description        = "Simulation Description",
                Model              = _model
            };

            _simulationTimeProfile         = new SimulationTimeProfileChart();
            _snapshotSimulationTimeProfile = new CurveChart();
            _individualSimulation.AddAnalysis(_simulationTimeProfile);

            A.CallTo(() => _curveChartMapper.MapToSnapshot(_simulationTimeProfile)).Returns(_snapshotSimulationTimeProfile);


            _populationSimulation = new PopulationSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            _advancedParameterCollection       = new AdvancedParameterCollection();
            _populationSimulationAnalysisChart = new BoxWhiskerAnalysisChart();
            _populationSimulation.SetAdvancedParameters(_advancedParameterCollection);
            _populationSimulation.AddAnalysis(_populationSimulationAnalysisChart);
            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });

            _snapshotPopulationAnalysisChart = new Snapshots.PopulationAnalysisChart();

            A.CallTo(() => _populationAnalysisChartMapper.MapToSnapshot(_populationSimulationAnalysisChart)).Returns(_snapshotPopulationAnalysisChart);

            _snapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_interactionSelection)).Returns(_snapshotInteraction);
            _snapshotInteraction.CompoundName = _compound.Name;
            _snapshotInteraction.Name         = _inductionProcess.Name;

            _noSelectionSnapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noInteractionSelection)).Returns(_noSelectionSnapshotInteraction);
            _noSelectionSnapshotInteraction.MoleculeName = _noInteractionSelection.MoleculeName;

            _compoundProperties         = new CompoundProperties();
            _snapshotCompoundProperties = new Snapshots.CompoundProperties {
                Name = _compound.Name
            };
            _individualSimulation.Properties.AddCompoundProperties(_compoundProperties);

            _eventMapping = new EventMapping();
            _individualSimulation.EventProperties.AddEventMapping(_eventMapping);

            _observerSetMapping = new ObserverSetMapping();
            _individualSimulation.ObserverSetProperties.AddObserverSetMapping(_observerSetMapping);

            A.CallTo(() => _compoundPropertiesMapper.MapToSnapshot(_compoundProperties, _project)).Returns(_snapshotCompoundProperties);


            _eventSelection = new EventSelection
            {
                Name = _event.Name,
            };

            _observerSetSelection = new ObserverSetSelection
            {
                Name = _observerSet.Name,
            };

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual,

                Altered = true
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompTemplateId", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ProtTemplateId", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ObserveSetTemplateId", PKSimBuildingBlockType.ObserverSet)
            {
                BuildingBlock = _observerSet
            });

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("PopTemplateId", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = _population
            });


            _individualSimulation.AddUsedObservedData(_observedData);

            A.CallTo(() => _eventMappingMapper.MapToSnapshot(_eventMapping, _project)).Returns(_eventSelection);
            A.CallTo(() => _observerSetMappingMapper.MapToSnapshot(_observerSetMapping, _project)).Returns(_observerSetSelection);

            _outputSelectionSnapshot = new OutputSelections();
            A.CallTo(() => _outputSelectionMapper.MapToSnapshot(_individualSimulation.OutputSelections)).Returns(_outputSelectionSnapshot);

            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotInteraction, _inductionProcess)).Returns(_interactionSelection);

            return(_completed);
        }
 public void Visit(PopulationSimulation populationSimulation)
 {
     _metaData = _simulationMetaDataMapper.MapFrom(populationSimulation);
     serializeContentFor(populationSimulation);
 }
 public PathCache <IQuantity> QuantitiesFrom(PopulationSimulation populationSimulation)
 {
     return(QuantitiesFrom(populationSimulation.DowncastTo <Simulation>()));
 }
Ejemplo n.º 22
0
 public void ExportToCSV(PopulationSimulation populationSimulation)
 {
     exportVectorialParametersContainerToCSV(populationSimulation, x => CreatePopulationDataFor(x, includeUnitsInHeader: true));
 }
Ejemplo n.º 23
0
        public void ExportForCluster(PopulationSimulation populationSimulation)
        {
            _lazyLoadTask.Load(populationSimulation);

            if (settingsRequired(populationSimulation))
            {
                var outputSelections = _simulationSettingsRetriever.SettingsFor(populationSimulation);
                if (outputSelections == null)
                {
                    return;
                }

                populationSimulation.OutputSelections.UpdatePropertiesFrom(outputSelections, _cloner);
            }

            FileSelection populationExport;

            using (var presenter = _applicationController.Start <ISelectFilePresenter>())
            {
                populationExport = presenter.SelectDirectory(PKSimConstants.UI.ExportForClusterSimulationTitle, Constants.DirectoryKey.SIM_MODEL_XML);
            }
            if (populationExport == null)
            {
                return;
            }

            var populationFolder = populationExport.FilePath;
            var existingFiles    = Directory.GetFiles(populationFolder);

            if (existingFiles.Any())
            {
                if (_dialogCreator.MessageBoxYesNo(PKSimConstants.UI.DeleteFilesIn(populationFolder)).Equals(ViewResult.No))
                {
                    return;
                }

                existingFiles.Each(FileHelper.DeleteFile);
            }

            var fileName                      = populationSimulation.Name;
            var modelFileFullPath             = Path.Combine(populationFolder, $"{fileName}.xml");
            var agingFileFullPath             = Path.Combine(populationFolder, $"{fileName}{CoreConstants.Population.TableParameterExport}.csv");
            var outputDeffinitionFileFullPath = Path.Combine(populationFolder, $"{fileName}{CoreConstants.Population.OutputDefinitionExport}.csv");

            //Model
            _simModelExporter.Export(_modelCoreSimulationMapper.MapFrom(populationSimulation, shouldCloneModel: false), modelFileFullPath);
            // Outputs

            var outputSelection = populationSimulation.OutputSelections;

            exportOutputDefiniton(outputSelection, outputDeffinitionFileFullPath);

            //all values
            var dataTable = CreatePopulationDataFor(populationSimulation);

            dataTable.ExportToCSV(Path.Combine(populationFolder, $"{fileName}.csv"), comments: getProjectMetaInfo(populationExport.Description));

            //all aging data
            var agingData = populationSimulation.AgingData.ToDataTable();

            if (agingData.Rows.Count > 0)
            {
                agingData.ExportToCSV(agingFileFullPath, comments: getProjectMetaInfo(populationExport.Description));
            }
        }
Ejemplo n.º 24
0
 public void Visit(PopulationSimulation simulation)
 {
     Visit(simulation.Population);
 }
Ejemplo n.º 25
0
 public void Visit(PopulationSimulation populationSimulation)
 {
     Visit(populationSimulation.Population);
 }
Ejemplo n.º 26
0
 protected override void Context()
 {
     _populationSimulation = First <PopulationSimulation>();
     _individual           = _populationSimulation.BuildingBlock <Individual>();
     _population           = _populationSimulation.BuildingBlock <RandomPopulation>();
 }
 public PathCache <IParameter> ParametersFrom(PopulationSimulation populationSimulation)
 {
     return(ParametersFrom(populationSimulation.DowncastTo <ISimulation>()));
 }
Ejemplo n.º 28
0
 public override void GlobalContext()
 {
     base.GlobalContext();
     LoadProject("Simple_MoBi_531");
     _populationSimulation = First <PopulationSimulation>();
 }
Ejemplo n.º 29
0
 protected override void Context()
 {
     base.Context();
     _populationSimulation = A.Fake <PopulationSimulation>();
     sut.Subject           = _populationSimulation;
 }
Ejemplo n.º 30
0
 public void UpdatePersistableFromSettings(PopulationSimulation populationSimulation)
 {
     UpdateSimulationPersistable(populationSimulation);
 }