示例#1
0
        protected override void Context()
        {
            base.Context();
            var pKAnalyses = new PopulationSimulationPKAnalyses();

            _populationSimulation = new PopulationSimulation {
                PKAnalyses = pKAnalyses
            };
            var pkParameter = new QuantityPKParameter {
                QuantityPath = "Liver", Name = "P"
            };
            var dimension = A.Fake <IDimension>();
            var unit      = A.Fake <Unit>();

            A.CallTo(() => unit.Name).Returns("UNIT");
            A.CallTo(() => _displayUnitRetriever.PreferredUnitFor(pkParameter, null)).Returns(unit);

            pkParameter.Dimension = dimension;
            pkParameter.SetNumberOfIndividuals(2);
            pkParameter.SetValue(0, 10);
            pkParameter.SetValue(1, 11);

            A.CallTo(() => dimension.BaseUnitValueToUnitValue(unit, 10)).Returns(100.10);
            A.CallTo(() => dimension.BaseUnitValueToUnitValue(unit, 11)).Returns(110.20);

            pKAnalyses.AddPKAnalysis(pkParameter);
        }
示例#2
0
        private void addPKParametersForOutput(ISimulation simulation, int numberOfIndividuals, SimulationResults runResults, Action <int> performIndividualScalingAction,
                                              QuantitySelection selectedQuantity, PopulationSimulationPKAnalyses popAnalyses, string moleculeName,
                                              PKCalculationOptions pkCalculationOptions, IReadOnlyList <PKCalculationOptionsFactory.ApplicationParameters> allApplicationParameters)
        {
            var availablePKParameters = _pkParameterRepository.All().Where(p => PKParameterCanBeUsed(p, pkCalculationOptions)).ToList();

            //create pk parameter for each quantities
            foreach (var pkParameter in availablePKParameters)
            {
                var quantityPKParameter = new QuantityPKParameter {
                    Name = pkParameter.Name, QuantityPath = selectedQuantity.Path, Dimension = pkParameter.Dimension
                };
                quantityPKParameter.SetNumberOfIndividuals(numberOfIndividuals);
                popAnalyses.AddPKAnalysis(quantityPKParameter);
            }

            //add the values for each individual
            foreach (var individualResult in runResults.AllIndividualResults)
            {
                performIndividualScalingAction(individualResult.IndividualId);
                _pkCalculationOptionsFactory.UpdateAppliedDose(simulation, moleculeName, pkCalculationOptions, allApplicationParameters);

                var values   = individualResult.ValuesFor(selectedQuantity.Path);
                var pkValues = _pkValuesCalculator.CalculatePK(individualResult.Time.Values, values.Values, pkCalculationOptions);

                foreach (var pkParameter in availablePKParameters)
                {
                    var quantityPKParameter = popAnalyses.PKParameterFor(selectedQuantity.Path, pkParameter.Name);
                    quantityPKParameter.SetValue(individualResult.IndividualId, pkValues.ValueOrDefaultFor(pkParameter.Name));
                }
            }
        }
        protected override void Context()
        {
            base.Context();
            _numberOfVariations = 5;
            _pkParameter1       = new QuantityPKParameter {
                QuantityPath = "Output1", Name = "AUC"
            };
            _pkParameter1.SetNumberOfIndividuals(_numberOfVariations);
            _pkParameter1.SetValue(0, 10);
            _pkParameter1.SetValue(1, 11);
            _pkParameter1.SetValue(2, 12);
            _pkParameter1.SetValue(4, _defaultPK1Value);

            _pkParameter2 = new QuantityPKParameter {
                QuantityPath = "Output2", Name = "Cmax"
            };
            _pkParameter2.SetNumberOfIndividuals(_numberOfVariations);
            _pkParameter2.SetValue(0, 20);
            _pkParameter2.SetValue(1, 21);
            _pkParameter2.SetValue(2, 22);
            _pkParameter2.SetValue(3, 23);
            _pkParameter2.SetValue(4, _defaultPK2Value);

            _sensitivityParameter1 = A.Fake <SensitivityParameter>().WithName("SP1");
            A.CallTo(() => _sensitivityParameter1.DefaultValue).Returns(10);

            _sensitivityParameter2 = A.Fake <SensitivityParameter>().WithName("SP2");
            A.CallTo(() => _sensitivityParameter2.DefaultValue).Returns(20);

            _sensitivityParameter3 = A.Fake <SensitivityParameter>().WithName("SP3");
            A.CallTo(() => _sensitivityParameter3.DefaultValue).Returns(0);
            A.CallTo(() => _sensitivityParameter3.VariationRangeValue).Returns(0.8);

            _pkAnalyses.AddPKAnalysis(_pkParameter1);
            _pkAnalyses.AddPKAnalysis(_pkParameter2);

            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter1);
            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter2);
            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter3);

            var pv11 = new ParameterVariation {
                ParameterName = _sensitivityParameter1.Name, VariationId = 0, Variation = new[] { 15d, 200d, 300d }
            };
            var pv12 = new ParameterVariation {
                ParameterName = _sensitivityParameter1.Name, VariationId = 1, Variation = new[] { 20d, 200d, 300d }
            };
            var pv21 = new ParameterVariation {
                ParameterName = _sensitivityParameter2.Name, VariationId = 2, Variation = new[] { 100d, 21d, 300d }
            };
            var pv22 = new ParameterVariation {
                ParameterName = _sensitivityParameter2.Name, VariationId = 3, Variation = new[] { 100d, 31d, 300d }
            };

            _variationData.DefaultValues = new[] { 100d, 200d, 300d };
            _variationData.AddVariation(pv11);
            _variationData.AddVariation(pv12);
            _variationData.AddVariation(pv21);
            _variationData.AddVariation(pv22);
        }
        private QuantityPKParameter createPKAnalyses(string path)
        {
            var pk = new QuantityPKParameter {
                QuantityPath = path
            };

            pk.Name = "AUC";
            _numberOfIndividuals = 100000;
            pk.SetNumberOfIndividuals(_numberOfIndividuals);
            for (int i = 0; i < _numberOfIndividuals; i++)
            {
                pk.SetValue(i, (float)_random.NextDouble() * 100);
            }
            return(pk);
        }