protected override void Context()
 {
     sut               = new OutputMappingToOutputMappingDTOMapper();
     _simulation       = A.Fake <ISimulation>();
     _availableOutputs = new List <SimulationQuantitySelectionDTO>();
     _outputMapping    = new OutputMapping();
 }
        protected override void Context()
        {
            _view = A.Fake <IParameterIdentificationChartFeedbackView>();
            _chartDisplayPresenter           = A.Fake <IChartDisplayPresenter>();
            _dimensionFactory                = A.Fake <IDimensionFactory>();
            _predictedVsObservedChartService = A.Fake <IPredictedVsObservedChartService>();
            _displayUnitRetriever            = A.Fake <IDisplayUnitRetriever>();
            _parameterIdentification         = A.Fake <ParameterIdentification>();
            _observationColumns              = new List <DataColumn>();
            _curveList     = new List <Curve>();
            _baseGrid      = DomainHelperForSpecs.ObservedData().BaseGrid;
            _outputMapping = new OutputMapping();

            sut = new ParameterIdentificationPredictedVsObservedFeedbackPresenter(_view, _chartDisplayPresenter, _dimensionFactory, _displayUnitRetriever, _predictedVsObservedChartService);

            A.CallTo(() => _parameterIdentification.AllOutputMappings).Returns(new[] { _outputMapping });
            A.CallTo(() => _parameterIdentification.AllObservationColumnsFor(A <string> ._)).Returns(_observationColumns);
            _observationColumns.Add(new DataColumn());
            _observationColumns.Add(new DataColumn());

            A.CallTo(() => _predictedVsObservedChartService.AddCurvesFor(_observationColumns, A <DataColumn> ._, A <ParameterIdentificationPredictedVsObservedChart> ._, A <Action <DataColumn, Curve> > ._)).Invokes(x =>
            {
                var action = x.Arguments.Get <Action <DataColumn, Curve> >(3);
                _observationColumns.Each(observation =>
                {
                    var curve = new Curve {
                        Name = "Best"
                    };

                    action(new DataColumn(ShortGuid.NewGuid(), A.Fake <IDimension>(), _baseGrid), curve);
                    _curveList.Add(curve);
                });
                _chart = x.GetArgument <ParameterIdentificationPredictedVsObservedChart>(2);
            });
        }
        private double[] confidanceIntervalFor(OutputMapping outputMapping, Func <Scalings, double, double, double, double> intervalCalculation, bool requiresActiveOutput)
        {
            var fullOutputPath           = outputMapping.FullOutputPath;
            var simulationResult         = _runResult.BestResult.SimulationResultFor(fullOutputPath);
            var residualResults          = _runResult.BestResult.ResidualsResult.AllOutputResidualsFor(fullOutputPath);
            var jacobian                 = _runResult.JacobianMatrix;
            var outputPartialDerivatives = jacobian.PartialDerivativesFor(fullOutputPath);
            var w = meanWeightStrictPositiveFor(residualResults);

            if (requiresActiveOutput && w == 0)
            {
                return(null);
            }

            var sigmaE = _sigma / w;

            var confidenceIntervalValues = new double[simulationResult.Values.Count];

            simulationResult.Values.Each((outputValue, index0) =>
            {
                var partialDerivatives = outputPartialDerivatives.PartialDerivativeAt(index0);
                var grad         = Matrix <double> .Build.DenseOfColumnArrays(partialDerivatives);
                var sigmaPMatrix = grad.Transpose().Multiply(_covP).Multiply(grad);
                sigmaPMatrix     = sigmaPMatrix.PointwisePower(0.5);
                var sigmaP       = sigmaPMatrix[0, 0];

                confidenceIntervalValues[index0] = intervalCalculation(outputMapping.Scaling, sigmaE, sigmaP, outputValue);
            });

            return(confidenceIntervalValues);
        }
Exemple #4
0
        protected override void Context()
        {
            _view                               = A.Fake <IParameterIdentificationSimulationSelectionView>();
            _treeNodeFactory                    = A.Fake <ITreeNodeFactory>();
            _applicationController              = A.Fake <IApplicationController>();
            _lazyLoadTask                       = A.Fake <ILazyLoadTask>();
            _treeNodeContextMenuFactory         = A.Fake <ITreeNodeContextMenuFactory>();
            _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>();
            _dialogCreator                      = A.Fake <IDialogCreator>();
            _parameterIdentificationTask        = A.Fake <IParameterIdentificationTask>();
            sut = new ParameterIdentificationSimulationSelectionPresenter(_view, _treeNodeFactory, _applicationController, _lazyLoadTask, _treeNodeContextMenuFactory,
                                                                          _multipleTreeNodeContextMenuFactory, _dialogCreator, _parameterIdentificationTask);

            _parameterIdentification = new ParameterIdentification();
            _simulation = A.Fake <ISimulation>().WithId("Id").WithName("S");
            _parameterIdentification.AddSimulation(_simulation);
            _outputMapping = new OutputMapping
            {
                OutputSelection = new SimulationQuantitySelection(_simulation, new QuantitySelection("PATH", QuantityType.Drug))
            };
            _parameterIdentification.AddOutputMapping(_outputMapping);

            _simulationNode = A.Fake <ITreeNode>();
            A.CallTo(() => _treeNodeFactory.CreateFor(_simulation)).Returns(_simulationNode);

            _simulationSelectionPresenter = A.Fake <ISelectionSimulationPresenter>();
            A.CallTo(() => _applicationController.Start <ISelectionSimulationPresenter>()).Returns(_simulationSelectionPresenter);

            sut.EditParameterIdentification(_parameterIdentification);
        }
 public OutputMappingDTO MapFrom(OutputMapping outputMapping, IEnumerable <SimulationQuantitySelectionDTO> allOutputs)
 {
     return(new OutputMappingDTO(outputMapping)
     {
         Output = allOutputs.FirstOrDefault(x => matches(outputMapping, x))
     });
 }
Exemple #6
0
        protected override void Context()
        {
            base.Context();
            _outputMapping1 = A.Fake <OutputMapping>();
            _outputMapping2 = A.Fake <OutputMapping>();
            _outputMapping3 = A.Fake <OutputMapping>();

            var observation1 = DomainHelperForSpecs.ObservedData("OBS1");

            A.CallTo(() => _outputMapping1.WeightedObservedData.ObservedData).Returns(observation1);
            var observation2 = DomainHelperForSpecs.ObservedData("OBS2");

            A.CallTo(() => _outputMapping2.WeightedObservedData.ObservedData).Returns(observation2);
            var observation3 = DomainHelperForSpecs.ObservedData("OBS3");

            A.CallTo(() => _outputMapping3.WeightedObservedData.ObservedData).Returns(observation3);


            _outputResiduals1 = new OutputResiduals("OutputPath1", _outputMapping1.WeightedObservedData, new[] { new Residual(11f, 12f, 1), new Residual(21f, 22f, 1) });
            _outputResiduals2 = new OutputResiduals("OutputPath2", _outputMapping2.WeightedObservedData, new[] { new Residual(31f, 32f, 1), new Residual(41f, 42f, 1) });
            _outputResiduals3 = new OutputResiduals("OutputPath1", _outputMapping3.WeightedObservedData, new[] { new Residual(51f, 52f, 1), new Residual(61f, 62f, 1) });

            _residualResults.AddOutputResiduals(_outputResiduals1);
            _residualResults.AddOutputResiduals(_outputResiduals2);
            _residualResults.AddOutputResiduals(_outputResiduals3);


            A.CallTo(() => _outputMapping1.FullOutputPath).Returns("OutputPath1");
            A.CallTo(() => _outputMapping2.FullOutputPath).Returns("OutputPath2");
            A.CallTo(() => _outputMapping3.FullOutputPath).Returns("OutputPath1");


            A.CallTo(() => _parameterIdentification.AllOutputMappings).Returns(new[] { _outputMapping1, _outputMapping2, _outputMapping3 });
            A.CallTo(() => _parameterIdentification.AllObservedData).Returns(new[] { observation3, observation1, observation2 });
        }
Exemple #7
0
        public void AddOutputMapping()
        {
            var newOutputMapping = new OutputMapping();

            _parameterIdentification.AddOutputMapping(newOutputMapping);
            _allOutputMappingDTOs.Add(mapFrom(newOutputMapping));
            OnStatusChanged();
        }
        private Func <float, float, float, double> residualMethodFor(OutputMapping outputMapping)
        {
            if (outputMapping.Scaling == Scalings.Log)
            {
                return(LogResidual);
            }

            return(LinResidual);
        }
Exemple #9
0
        protected void ConfigureOutputMapping(OutputMapping outputMapping)
        {
            outputMapping.WeightedObservedData = new WeightedObservedData(DomainHelperForSpecs.ObservedData());
            var quantity = A.Fake <IQuantity>();

            quantity.Dimension = outputMapping.WeightedObservedData.ObservedData.FirstDataColumn().Dimension;

            A.CallTo(() => outputMapping.Output).Returns(quantity);
            A.CallTo(() => outputMapping.IsValid).Returns(true);
        }
 protected override void Context()
 {
     sut                = new ParameterIdentification();
     _observedData      = new WeightedObservedData(DomainHelperForSpecs.ObservedData());
     _simulation        = A.Fake <ISimulation>().WithName("Sim").WithId("Id");
     _quantitySelection = new QuantitySelection("Organism|Liver|Cell|Asprin|Concentration", QuantityType.Drug);
     _outputMapping     = new OutputMapping {
         WeightedObservedData = _observedData, OutputSelection = new SimulationQuantitySelection(_simulation, _quantitySelection)
     };
 }
Exemple #11
0
 public async Task <IActionResult> Put([FromBody] OutputMapping data)
 {
     return(await ValidateEditOutputMapping(data)
            .MapT(async d =>
     {
         await _outputMappingRepository.UpdateAsync(d);
         return d;
     })
            .ToActionResultAsync());
 }
        protected override void Context()
        {
            base.Context();
            sut = new ResidualCalculatorForOnlyObservedData(_timeGridRestrictor, _dimensionFactory);
            _outputMapping.Scaling = Scalings.Linear;

            _outputMapping2 = A.Fake <OutputMapping>();
            A.CallTo(() => _outputMapping2.FullOutputPath).Returns(_fullOutputPath);
            _observedData2 = DomainHelperForSpecs.ObservedData().WithName("OBS2");
            _outputMapping2.WeightedObservedData = new WeightedObservedData(_observedData2);
            _outputMappings.Add(_outputMapping2);
        }
 protected override void Context()
 {
     _observedData  = DomainHelperForSpecs.ObservedData("TOTO");
     _outputMapping = new OutputMapping {
         WeightedObservedData = new WeightedObservedData(_observedData)
         {
             Id = 5
         }
     };
     _outputMappingDTO = new OutputMappingDTO(_outputMapping);
     sut = new WeightedObservedDataFormatter(_outputMappingDTO);
 }
        public IMergeDataBuilderOutputFinal Output(OutputMapping <TTable> mapping)
        {
            var outputSetter = new OutputSetter();

            mapping.AssertArgumentNotNull(nameof(mapping)).Invoke(this._table, this._sourceTableAlias, outputSetter);

            var cols = outputSetter.Columns.AssertNotEmpty("Output column list cannot be empty");

            this._output = new ExprOutput(cols);

            return(this);
        }
        public virtual void EditParameterIdentification(ParameterIdentification parameterIdentification)
        {
            _parameterIdentification = parameterIdentification;
            _selectedOutput          = parameterIdentification.AllOutputMappings.First();
            _bestRepository          = CreateRepositoryFor(Captions.ParameterIdentification.Best);
            _bestColumn        = _bestRepository.FirstDataColumn();
            _currentRepository = CreateRepositoryFor(Captions.ParameterIdentification.Current);
            _currentColumn     = _currentRepository.FirstDataColumn();

            AddBestAndCurrent();

            UpdateChartAxesScalings();
        }
        private void validateScalingForSharedOutputMappings(OutputMapping mapping, ParameterIdentification parameterIdentification, ValidationResult validationResult)
        {
            var allOutputScalings = scalingsMappedForOutput(mapping, parameterIdentification);

            if (allOutputScalings.Count() == 1)
            {
                return;
            }

            var displayPathAsString = _fullPathDisplayResolver.FullPathFor(parameterIdentification, addSimulationName: true);

            validationResult.AddMessage(NotificationType.Error, parameterIdentification, Error.OutputsDoNotAllHaveTheSameScaling(displayPathAsString));
        }
        protected override void Context()
        {
            _newSimulation           = A.Fake <ISimulation>();
            _oldSimulation           = A.Fake <ISimulation>();
            _parameterIdentification = A.Fake <ParameterIdentification>();
            _outputMapping           = A.Fake <OutputMapping>();
            _outputMappings          = new[] { _outputMapping };
            _identificationParameter = new IdentificationParameter();
            _linkedParameter         = new ParameterSelection(_oldSimulation, "parameter|path");

            A.CallTo(() => _outputMapping.UsesSimulation(_oldSimulation)).Returns(true);

            sut = new ParameterIdentificationSimulationSwapValidator(new SimulationQuantitySelectionFinder());
        }
Exemple #18
0
        protected override void Context()
        {
            _presentationSettingsTask = A.Fake <IPresentationSettingsTask>();
            _view = A.Fake <IParameterIdentificationMultipleRunsAnalysisView>();
            _chartEditorAndDisplayPresenter = A.Fake <IChartEditorAndDisplayPresenter>();
            _curveNamer            = A.Fake <ICurveNamer>();
            _pathElementsMapper    = A.Fake <IDataColumnToPathElementsMapper>();
            _chartTemplatingTask   = A.Fake <IChartTemplatingTask>();
            _dimensionFactory      = A.Fake <IDimensionFactory>();
            _displayUnitRetriever  = A.Fake <IDisplayUnitRetriever>();
            _chartEditorLayoutTask = A.Fake <IChartEditorLayoutTask>();
            _projectRetreiver      = A.Fake <IProjectRetriever>();


            _chartPresenterContext = A.Fake <ChartPresenterContext>();
            A.CallTo(() => _chartPresenterContext.EditorAndDisplayPresenter).Returns(_chartEditorAndDisplayPresenter);
            A.CallTo(() => _chartPresenterContext.CurveNamer).Returns(_curveNamer);
            A.CallTo(() => _chartPresenterContext.DataColumnToPathElementsMapper).Returns(_pathElementsMapper);
            A.CallTo(() => _chartPresenterContext.TemplatingTask).Returns(_chartTemplatingTask);
            A.CallTo(() => _chartPresenterContext.PresenterSettingsTask).Returns(_presentationSettingsTask);
            A.CallTo(() => _chartPresenterContext.DimensionFactory).Returns(_dimensionFactory);
            A.CallTo(() => _chartPresenterContext.EditorLayoutTask).Returns(_chartEditorLayoutTask);
            A.CallTo(() => _chartPresenterContext.ProjectRetriever).Returns(_projectRetreiver);


            sut = new ParameterIdentificationTimeProfileChartPresenter(_view, _chartPresenterContext, _displayUnitRetriever);

            _timeProfileAnalysis = new ParameterIdentificationTimeProfileChart();
            _outputMapping1      = A.Fake <OutputMapping>();
            _outputMapping2      = A.Fake <OutputMapping>();
            _observedData1       = DomainHelperForSpecs.ObservedData();
            _observedData2       = DomainHelperForSpecs.ObservedData();
            A.CallTo(() => _outputMapping1.WeightedObservedData).Returns(new WeightedObservedData(_observedData1));
            A.CallTo(() => _outputMapping2.WeightedObservedData).Returns(new WeightedObservedData(_observedData2));
            _parameterIdentification = new ParameterIdentification();
            _parameterIdentification.AddOutputMapping(_outputMapping1);
            _parameterIdentification.AddOutputMapping(_outputMapping2);

            _parameterIdentificationRunResult = A.Fake <ParameterIdentificationRunResult>();
            _parameterIdentification.AddResult(_parameterIdentificationRunResult);

            _optimizationRunResult = new OptimizationRunResult();
            _parameterIdentificationRunResult.BestResult = _optimizationRunResult;

            _parameterIdentificationRunResult = A.Fake <ParameterIdentificationRunResult>();
            _parameterIdentification.AddResult(_parameterIdentificationRunResult);
            _optimizationRunResult2 = new OptimizationRunResult();
            _parameterIdentificationRunResult.BestResult = _optimizationRunResult2;
        }
        protected override void Context()
        {
            base.Context();

            _outputMapping2 = A.Fake <OutputMapping>();
            A.CallTo(() => _outputMapping2.UsesSimulation(_simulation2)).Returns(true);

            _simulation2 = A.Fake <ISimulation>();
            _parameterIdentification.AddSimulation(_simulation2);

            _parameterIdentification.AddOutputMapping(_outputMapping2);

            _modelCoreSimulation2 = A.Fake <IModelCoreSimulation>();
            A.CallTo(() => _modelCoreSimulationMapper.MapFrom(_simulation2, true)).Returns(_modelCoreSimulation2);
        }
Exemple #20
0
        protected void CompareValues(OutputMapping outputMapping, double[] expectedConfidenceIntervals)
        {
            var calculatedConfidenceIntervals = _confidenceIntervals[outputMapping.FullOutputPath];

            double[] expectedValues = expectedConfidenceIntervals;
            if (outputMapping.Scaling == Scalings.Log)
            {
                expectedValues = expectedValues.Select(x => Math.Pow(10, x)).ToArray();
            }

            calculatedConfidenceIntervals.Length.ShouldBeEqualTo(expectedValues.Length);
            for (int i = 0; i < calculatedConfidenceIntervals.Length; i++)
            {
                calculatedConfidenceIntervals[i].ShouldBeEqualTo(expectedValues[i], 1e-3);
            }
        }
Exemple #21
0
        protected override void Context()
        {
            _eventPublisher        = A.Fake <IEventPublisher>();
            _view                  = A.Fake <IParameterIdentificationWeightedObservedDataCollectorView>();
            _applicationController = A.Fake <IApplicationController>();
            sut = new ParameterIdentificationWeightedObservedDataCollectorPresenter(_view, _applicationController, _eventPublisher);

            _parameterIdentification = new ParameterIdentification();
            _weightedObservedData    = new WeightedObservedData(DomainHelperForSpecs.ObservedData());
            _outputMapping           = new OutputMapping {
                WeightedObservedData = _weightedObservedData
            };
            _parameterIdentification.AddOutputMapping(_outputMapping);

            _presenter = A.Fake <IParameterIdentificationWeightedObservedDataPresenter>();
            A.CallTo(() => _applicationController.Start <IParameterIdentificationWeightedObservedDataPresenter>()).Returns(_presenter);
        }
Exemple #22
0
        protected override void Context()
        {
            _newSimulation           = A.Fake <ISimulation>();
            _oldSimulation           = A.Fake <ISimulation>();
            _anotherSimulation       = A.Fake <ISimulation>();
            _parameterIdentification = A.Fake <ParameterIdentification>();
            _outputMapping           = A.Fake <OutputMapping>();
            _outputMappings          = new[] { _outputMapping };
            _identificationParameter = new IdentificationParameter();
            _linkedParameter         = new ParameterSelection(_oldSimulation, "parameter|path");
            _anotherParameter        = new ParameterSelection(_anotherSimulation, "parameter|path");

            A.CallTo(() => _parameterIdentification.AllOutputMappingsFor(_oldSimulation)).Returns(_outputMappings);

            var simulationQuantitySelectionFinder = new SimulationQuantitySelectionFinder();

            sut = new ParameterIdentificationSimulationSwapCorrector(simulationQuantitySelectionFinder);
        }
        protected override void Context()
        {
            //Only testing the common behavior of Residual Calculator. Specific tests needs to be written for each calculator implementation
            //sut = new ResidualCalculatorForOnlyObservedData(_timeGridRestrictor, _dimensionFactory);

            _simulationResults        = DomainHelperForSpecs.SimulationDataRepositoryFor("Sim");
            _simulationDataColumn     = _simulationResults.AllButBaseGrid().First();
            _simulationRunResultsList = new List <SimulationRunResults> {
                new SimulationRunResults(true, Enumerable.Empty <SolverWarning>(), _simulationResults)
            };

            _observedData       = DomainHelperForSpecs.ObservedDataRepository2WithLLOQ().WithName("Obs");
            _observedDataColumn = _observedData.AllButBaseGrid().First();

            UpdateObservedDataValues();

            _timeGridRestrictor = A.Fake <ITimeGridRestrictor>();
            //Returns all values of the observed data array. We do not test the time grid restrictor here!
            A.CallTo(_timeGridRestrictor).WithReturnType <IReadOnlyList <int> >().Returns(Enumerable.Range(0, _observedDataColumn.Values.Count).ToList());

            _mergedDimension  = A.Fake <IDimension>();
            _dimensionFactory = A.Fake <IDimensionFactory>();
            A.CallTo(() => _dimensionFactory.MergedDimensionFor(_simulationDataColumn)).Returns(_mergedDimension);


            _outputMappings = new List <OutputMapping>();
            _outputMapping  = A.Fake <OutputMapping>();
            _fullOutputPath = _simulationDataColumn.QuantityInfo.PathAsString;
            A.CallTo(() => _outputMapping.FullOutputPath).Returns(_fullOutputPath);

            _outputMapping.Weight = 1f;
            _outputMapping.WeightedObservedData = new WeightedObservedData(_observedData);
            _weights = _outputMapping.WeightedObservedData.Weights;

            _outputMappings.Add(_outputMapping);
            for (int i = 0; i < _observedDataColumn.Values.Count; i++)
            {
                _outputMapping.WeightedObservedData.Weights[i] = 1f;
                A.CallTo(() => _mergedDimension.UnitValueToBaseUnitValue(_observedDataColumn.Dimension.BaseUnit, _observedDataColumn.Values[i])).Returns(_observedDataColumn.Values[i]);
            }

            A.CallTo(() => _mergedDimension.UnitValueToBaseUnitValue(_observedDataColumn.Dimension.BaseUnit, float.NaN)).Returns(float.NaN);
            A.CallTo(() => _mergedDimension.UnitValueToBaseUnitValue(_observedDataColumn.Dimension.BaseUnit, _observedDataColumn.DataInfo.LLOQ.Value)).Returns(_observedDataColumn.DataInfo.LLOQ.Value);
        }
Exemple #24
0
        protected override void Context()
        {
            base.Context();
            _project = A.Fake <IProject>();
            _parameterIdentification = new ParameterIdentification();

            A.CallTo(() => _executionContext.Project).Returns(_project);
            A.CallTo(() => _project.AllParameterIdentifications).Returns(new List <ParameterIdentification> {
                _parameterIdentification
            });

            _simulation = A.Fake <ISimulation>();

            _sensitivityAnalysis = new SensitivityAnalysis {
                Simulation = _simulation, IsLoaded = true
            };
            _sensitivityAnalysis.AddSensitivityParameter(new SensitivityParameter());
            A.CallTo(() => _project.AllSensitivityAnalyses).Returns(new List <SensitivityAnalysis> {
                _sensitivityAnalysis
            });
            _secondSimulation = A.Fake <ISimulation>();
            _parameterIdentification.AddSimulation(_simulation);
            _parameterIdentification.AddSimulation(_secondSimulation);

            _outputMapping = new OutputMapping {
                OutputSelection = new ParameterSelection(_simulation, "a|path")
            };
            _secondOutputMapping = new OutputMapping {
                OutputSelection = new ParameterSelection(_secondSimulation, "a|path")
            };
            _identificationParameter = new IdentificationParameter();
            _linkedParameter         = new ParameterSelection(_simulation, "a|path");
            _secondLinkedParameter   = new ParameterSelection(_secondSimulation, "a|path");

            _identificationParameter.AddLinkedParameter(_linkedParameter);
            _identificationParameter.AddLinkedParameter(_secondLinkedParameter);
            _parameterIdentification.AddIdentificationParameter(_identificationParameter);
            _parameterIdentification.AddOutputMapping(_outputMapping);
            _parameterIdentification.AddOutputMapping(_secondOutputMapping);
            _parameterIdentification.IsLoaded = true;
        }
        protected override void Context()
        {
            base.Context();
            var otherSimulationDataColumn = new DataColumn("Col", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), _simulationDataColumn.BaseGrid)
            {
                Values       = new[] { 0f, 2.5f, 0.9f, 0.9f, 0.5f },
                DataInfo     = { Origin = ColumnOrigins.Calculation },
                QuantityInfo = new QuantityInfo("Concentration", new[] { "Sim", "Organism", "Liver", "Plasma", "Concentration" }, QuantityType.Drug)
            };

            _simulationResults.Add(otherSimulationDataColumn);

            _outputMapping2 = A.Fake <OutputMapping>();
            A.CallTo(() => _outputMapping2.FullOutputPath).Returns(otherSimulationDataColumn.PathAsString);
            var observedData2 = DomainHelperForSpecs.ObservedData().WithName("OBS2");

            _outputMapping2.WeightedObservedData = new WeightedObservedData(observedData2);
            _outputMappings.Add(_outputMapping2);

            sut = new ResidualCalculatorForOnlyObservedData(_timeGridRestrictor, _dimensionFactory);
        }
Exemple #26
0
        protected override void Context()
        {
            base.Context();
            _runResult     = A.Fake <OptimizationRunResult>();
            _outputMapping = A.Fake <OutputMapping>();
            A.CallTo(() => _outputMapping.FullOutputPath).Returns("A|B|C");
            _outputMapping.Scaling = Scalings.Linear;
            var outputTime = new BaseGrid("Time", DomainHelperForSpecs.TimeDimensionForSpecs())
            {
                Values = new [] { 1f, 2f, 3f }
            };

            _outputValues = new DataColumn("Output", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), outputTime)
            {
                Values   = new[] { 15f, 16f, 17f },
                DataInfo = { MolWeight = 150 }
            };

            A.CallTo(() => _runResult.SimulationResultFor(_outputMapping.FullOutputPath)).Returns(_outputValues);
            _confidenceInterval = new[] { 10d, 20d, 30d };
        }
Exemple #27
0
        protected override void Context()
        {
            base.Context();
            _simulation = A.Fake <ISimulation>();
            _project    = A.Fake <IProject>();
            _parameterIdentification = new ParameterIdentification();

            A.CallTo(() => _executionContext.Project).Returns(_project);
            A.CallTo(() => _project.AllParameterIdentifications).Returns(new[] { _parameterIdentification });

            _parameterIdentification.AddSimulation(_simulation);

            _initialObjectPath = new ObjectPath("oldName", "path");
            var parameterIdentificationRunResult = new ParameterIdentificationRunResult {
                BestResult = new OptimizationRunResult()
            };

            _simulationDataRepository  = DomainHelperForSpecs.SimulationDataRepositoryFor("oldName");
            _observationDataRepository = DomainHelperForSpecs.ObservedData();

            _observationDataRepository.AllButBaseGrid().Each(x => x.QuantityInfo.Path = _initialObjectPath);
            _simulationDataRepository.AllButBaseGrid().Each(x => x.QuantityInfo.Path  = _initialObjectPath);

            parameterIdentificationRunResult.BestResult.AddResult(_simulationDataRepository);
            _residualsResult = new ResidualsResult();
            _residualsResult.AddOutputResiduals(_initialObjectPath.PathAsString, _observationDataRepository, new List <Residual> {
                new Residual(0, 1, 1)
            });

            parameterIdentificationRunResult.BestResult.ResidualsResult = _residualsResult;
            _parameterIdentification.AddResult(parameterIdentificationRunResult);

            var outputMapping = new OutputMapping
            {
                WeightedObservedData = new WeightedObservedData(_observationDataRepository),
                OutputSelection      = new ParameterSelection(_simulation, _initialObjectPath.PathAsString)
            };

            _parameterIdentification.AddOutputMapping(outputMapping);
        }
Exemple #28
0
        protected override void Context()
        {
            _view = A.Fake <IParameterIdentificationChartFeedbackView>();
            _chartDisplayPresenter = A.Fake <IChartDisplayPresenter>();
            _dimensionFactory      = A.Fake <IDimensionFactory>();
            _displayUnitRetriever  = A.Fake <IDisplayUnitRetriever>();

            sut = new ParameterIdentificationTimeProfileFeedbackPresenter(_view, _chartDisplayPresenter, _dimensionFactory, _displayUnitRetriever);

            _runState      = A.Fake <ParameterIdentificationRunState>();
            _bestResult    = A.Fake <OptimizationRunResult>();
            _currentResult = A.Fake <OptimizationRunResult>();

            A.CallTo(() => _runState.BestResult).Returns(_bestResult);
            A.CallTo(() => _runState.CurrentResult).Returns(_currentResult);

            _parameterIdentification = A.Fake <ParameterIdentification>();
            _outputMapping1          = A.Fake <OutputMapping>();
            _outputMapping2          = A.Fake <OutputMapping>();
            _outputMapping3          = A.Fake <OutputMapping>();
            A.CallTo(() => _outputMapping1.FullOutputPath).Returns("A|B|C");
            A.CallTo(() => _outputMapping2.FullOutputPath).Returns("A|B|C");
            A.CallTo(() => _outputMapping3.FullOutputPath).Returns("A|B|C|D");
            A.CallTo(() => _parameterIdentification.AllOutputMappings).Returns(new[] { _outputMapping1, _outputMapping2, _outputMapping3 });

            var baseGrid1 = new BaseGrid("TimeCol1", DomainHelperForSpecs.TimeDimensionForSpecs());

            _obsCol1 = new DataColumn("ObsCol1", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), baseGrid1);

            var baseGrid2 = new BaseGrid("TimeCol2", DomainHelperForSpecs.TimeDimensionForSpecs());

            _obsCol2 = new DataColumn("ObsCol2", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), baseGrid2);

            var baseGrid3 = new BaseGrid("TimeCol3", DomainHelperForSpecs.TimeDimensionForSpecs());

            _obsCol3 = new DataColumn("ObsCol3", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), baseGrid3);

            A.CallTo(() => _parameterIdentification.AllObservationColumnsFor(_outputMapping1.FullOutputPath)).Returns(new[] { _obsCol1, _obsCol2 });
            A.CallTo(() => _parameterIdentification.AllObservationColumnsFor(_outputMapping3.FullOutputPath)).Returns(new[] { _obsCol3 });
        }
        protected override void Context()
        {
            base.Context();
            _noDimensionColumnForSimulation.Dimension = DomainHelperForSpecs.NoDimension();
            _concentrationColumnForSimulation         = DomainHelperForSpecs.ConcentrationColumnForSimulation("Simulation", _simulationData.BaseGrid);
            _simulationData.Add(_concentrationColumnForSimulation);


            _quantityWithNoDimension   = A.Fake <IQuantity>();
            _quantityWithConcentration = A.Fake <IQuantity>();
            A.CallTo(() => _quantityWithNoDimension.Dimension).Returns(DomainHelperForSpecs.NoDimension());
            A.CallTo(() => _quantityWithConcentration.Dimension).Returns(DomainHelperForSpecs.ConcentrationDimensionForSpecs());

            var simulationQuantitySelection = A.Fake <SimulationQuantitySelection>();
            var anotherQuantitySelection    = A.Fake <SimulationQuantitySelection>();
            var noDimensionOutputMapping    = new OutputMapping {
                OutputSelection = simulationQuantitySelection
            };
            var concentrationOutputMapping = new OutputMapping {
                OutputSelection = anotherQuantitySelection
            };

            A.CallTo(() => simulationQuantitySelection.Quantity).Returns(_quantityWithNoDimension);
            A.CallTo(() => anotherQuantitySelection.Quantity).Returns(_quantityWithConcentration);


            _outputMappings = new[] { noDimensionOutputMapping, concentrationOutputMapping };
            A.CallTo(() => _parameterIdentification.AllOutputMappings).Returns(_outputMappings);
            _noDimensionDataColumn           = _observationData.FirstDataColumn();
            _noDimensionDataColumn.Dimension = DomainHelperForSpecs.NoDimension();

            _concentrationDataColumn = new DataColumn("newColumn", DomainHelperForSpecs.ConcentrationDimensionForSpecs(), _observationData.BaseGrid);
            _observationData.Add(_concentrationDataColumn);

            A.CallTo(() => _parameterIdentification.AllObservationColumnsFor(_noDimensionColumnForSimulation.QuantityInfo.PathAsString)).Returns(new List <DataColumn> {
                _noDimensionDataColumn, _concentrationDataColumn
            });
            A.CallTo(() => _parameterIdentification.AllObservedData).Returns(new[] { _observationData });
        }
Exemple #30
0
        protected override Task Context()
        {
            sut = new OutputMappingMapper(_logger);

            _simulation            = A.Fake <Simulation>().WithName("S");
            _output                = new Observer().WithName("OBS");
            _simulation.Model.Root = new Container {
                _output
            };
            _logger         = A.Fake <IOSPSuiteLogger>();
            _dataRepository = DomainHelperForSpecs.ObservedData("OBS_DATA");
            _outputMapping  = new OutputMapping
            {
                Scaling              = Scalings.Log,
                Weight               = 5,
                OutputSelection      = new SimulationQuantitySelection(_simulation, new QuantitySelection(_output.Name, QuantityType.Observer)),
                WeightedObservedData = new WeightedObservedData(_dataRepository)
            };

            _outputMapping.WeightedObservedData.Weights[1] = 2f;

            return(_completed);
        }