Exemplo n.º 1
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()
        {
            _cloneManager               = A.Fake <ICloneManagerForModel>();
            _simulationFactory          = A.Fake <ICoreSimulationFactory>();
            _parameterIdentificationRun = A.Fake <IParameterIdentificationRun>();
            _coreUserSettings           = A.Fake <ICoreUserSettings>();
            _descriptionCreator         = A.Fake <ICategorialParameterIdentificationDescriptionCreator>();
            _container = A.Fake <Utility.Container.IContainer>();
            A.CallTo(() => _container.Resolve <ICoreSimulationFactory>()).Returns(_simulationFactory);
            _coreUserSettings.MaximumNumberOfCoresToUse = 1;
            sut = new CategorialParameterIdentificationRunInitializer(_cloneManager, _parameterIdentificationRun, _container, _descriptionCreator, _coreUserSettings);

            _parameterIdentification = new ParameterIdentification();
            _parameterIdentification.Configuration.RunMode = new CategorialParameterIdentificationRunMode();

            _simulation       = A.Fake <ISimulation>();
            _clonedSimulation = A.Fake <ISimulation>();

            A.CallTo(() => _simulationFactory.CreateWithCalculationMethodsFrom(_simulation, A <IEnumerable <CalculationMethodWithCompoundName> > ._)).Returns(_clonedSimulation);
            A.CallTo(() => _cloneManager.Clone(_parameterIdentification)).ReturnsLazily(() =>
            {
                var pi = new ParameterIdentification();
                pi.AddSimulation(_simulation);
                var identificationParameter = new IdentificationParameter();
                identificationParameter.AddLinkedParameter(new ParameterSelection(_simulation, A.Fake <QuantitySelection>()));
                pi.AddIdentificationParameter(identificationParameter);
                pi.AddOutputMapping(new OutputMapping
                {
                    OutputSelection = new SimulationQuantitySelection(_simulation, A.Fake <QuantitySelection>())
                });
                pi.Configuration.RunMode = new CategorialParameterIdentificationRunMode();
                return(pi);
            });
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void AddOutputMapping()
        {
            var newOutputMapping = new OutputMapping();

            _parameterIdentification.AddOutputMapping(newOutputMapping);
            _allOutputMappingDTOs.Add(mapFrom(newOutputMapping));
            OnStatusChanged();
        }
Exemplo n.º 5
0
        protected override void Context()
        {
            base.Context();
            _parameterIdentification = new ParameterIdentification();
            var outputMapping = A.Fake <OutputMapping>();

            _parameterIdentification.AddOutputMapping(outputMapping);
            _parameterIdentification.AddIdentificationParameter(DomainHelperForSpecs.IdentificationParameter(min: 10, max: 20, startValue: 30));
            _parameterIdentification.Configuration.AlgorithmProperties = new OptimizationAlgorithmProperties("XX");
        }
Exemplo n.º 6
0
        protected override void Context()
        {
            base.Context();
            _parameterIdentification = new ParameterIdentification();
            var outputMapping = A.Fake <OutputMapping>();

            ConfigureOutputMapping(outputMapping);
            _parameterIdentification.AddOutputMapping(outputMapping);
            _parameterIdentification.AddIdentificationParameter(DomainHelperForSpecs.IdentificationParameter());
        }
Exemplo n.º 7
0
        protected override void Context()
        {
            base.Context();
            _parameterIdentification = new ParameterIdentification();
            var outputMapping = A.Fake <OutputMapping>();

            ConfigureOutputMapping(outputMapping);
            _parameterIdentification.AddOutputMapping(outputMapping);
            _parameterIdentification.Configuration.AlgorithmProperties = new OptimizationAlgorithmProperties("XX");
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        protected override void Context()
        {
            base.Context();
            _parameterIdentification = new ParameterIdentification();
            _parameterIdentification.AddIdentificationParameter(DomainHelperForSpecs.IdentificationParameter());
            var outputMapping = A.Fake <OutputMapping>();

            ConfigureOutputMapping(outputMapping);
            _parameterIdentification.AddOutputMapping(outputMapping);
            outputMapping.Scaling = Scalings.Log;

            var outputMapping2 = A.Fake <OutputMapping>();

            ConfigureOutputMapping(outputMapping2);
            _parameterIdentification.AddOutputMapping(outputMapping2);
            outputMapping2.Scaling = Scalings.Linear;

            A.CallTo(() => outputMapping2.Output).Returns(outputMapping.Output);

            _parameterIdentification.Configuration.AlgorithmProperties = new OptimizationAlgorithmProperties("XX");
        }
        protected override void Context()
        {
            base.Context();
            _sourceParameterIdentification  = new ParameterIdentification();
            _identificationParameter        = new IdentificationParameter();
            _cloneOfIdentificationParameter = new IdentificationParameter();
            _sourceParameterIdentification.AddSimulation(_simulation);
            _sourceParameterIdentification.AddOutputMapping(_outputMapping);
            _sourceParameterIdentification.AddIdentificationParameter(_identificationParameter);

            _cloneManager = A.Fake <ICloneManager>();
            A.CallTo(() => _cloneManager.Clone(_identificationParameter)).Returns(_cloneOfIdentificationParameter);
        }
Exemplo n.º 11
0
        protected override void Context()
        {
            base.Context();
            _parameterIdentification = new ParameterIdentification();
            var outputMapping = A.Fake <OutputMapping>();

            ConfigureOutputMapping(outputMapping);

            _parameterIdentification.AddOutputMapping(outputMapping);
            _parameterIdentification.AddIdentificationParameter(DomainHelperForSpecs.IdentificationParameter());
            _parameterIdentification.Configuration.AlgorithmProperties = new OptimizationAlgorithmProperties("XX");
            outputMapping.Output.Dimension = DomainHelperForSpecs.FractionDimensionForSpecs();
        }
Exemplo n.º 12
0
        protected override void Context()
        {
            base.Context();
            _dataRepository           = A.Fake <DataRepository>();
            _parameterIdentification  = new ParameterIdentification();
            _parameterIdentifications = new List <ParameterIdentification> {
                _parameterIdentification, new ParameterIdentification()
            };
            A.CallTo(() => _executionContext.Project.AllParameterIdentifications).Returns(_parameterIdentifications);

            _parameterIdentification.AddOutputMapping(new OutputMapping {
                WeightedObservedData = new WeightedObservedData(_dataRepository)
            });
        }
Exemplo n.º 13
0
        protected override void Context()
        {
            base.Context();
            _parameterIdentification = new ParameterIdentification();
            var outputMapping = A.Fake <OutputMapping>();

            ConfigureOutputMapping(outputMapping);
            outputMapping.WeightedObservedData = null;
            A.CallTo(() => outputMapping.IsValid).Returns(true);

            _parameterIdentification.AddOutputMapping(outputMapping);
            _parameterIdentification.Configuration.AlgorithmProperties = new OptimizationAlgorithmProperties("XX");
            _parameterIdentification.AddIdentificationParameter(DomainHelperForSpecs.IdentificationParameter());
        }
        private void addOutputMapping(IQuantity output, string outputPath, DataRepository observedData, ISimulation simulation, ParameterIdentification parameterIdentification)
        {
            if (parameterIdentification.UsesObservedData(observedData))
            {
                return;
            }

            parameterIdentification.AddOutputMapping(new OutputMapping
            {
                OutputSelection      = new SimulationQuantitySelection(simulation, new QuantitySelection(outputPath, output.QuantityType)),
                WeightedObservedData = new WeightedObservedData(observedData),
                Scaling = DefaultScalingFor(output)
            });
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        protected override void Context()
        {
            base.Context();
            _simulation       = new IndividualSimulation();
            _usedObservedData = new UsedObservedData {
                Id = "dataRepositoryId", Simulation = _simulation
            };
            _dataRepository = new DataRepository(_usedObservedData.Id);
            _simulation.AddUsedObservedData(_usedObservedData);
            _parameterIdentification = new ParameterIdentification();
            _project.AddObservedData(_dataRepository);
            _project.AddParameterIdentification(_parameterIdentification);

            var outputMapping = A.Fake <OutputMapping>();

            A.CallTo(() => outputMapping.UsesObservedData(_dataRepository)).Returns(true);
            A.CallTo(() => outputMapping.UsesSimulation(_simulation)).Returns(false);
            _parameterIdentification.AddOutputMapping(outputMapping);
        }
Exemplo n.º 17
0
        protected override void Context()
        {
            base.Context();
            _outputPath = "Liver|Cell|Drug";
            _simulation = A.Fake <ISimulation>().WithId("Sim");
            _parameterIdentification = new ParameterIdentification();

            _output1 = A.Fake <IQuantity>();

            var allOutputs = new PathCacheForSpecs <IQuantity> {
                { _outputPath, _output1 }
            };

            A.CallTo(() => _entitiesInSimulationRetriever.OutputsFrom(_simulation)).Returns(allOutputs);

            _observedData1 = DomainHelperForSpecs.ObservedData("OBS1");
            _observedData2 = DomainHelperForSpecs.ObservedData("OBS2");
            _observedData3 = DomainHelperForSpecs.ObservedData("OBS3");

            A.CallTo(() => _observedDataRepository.AllObservedDataUsedBy(_simulation)).Returns(new[] { _observedData1, _observedData2 });

            var simulationQuantitySelection = A.Fake <SimulationQuantitySelection>();

            A.CallTo(() => simulationQuantitySelection.Path).Returns(_outputPath);
            _parameterIdentification.AddOutputMapping(new OutputMapping {
                WeightedObservedData = new WeightedObservedData(_observedData2), OutputSelection = simulationQuantitySelection
            });

            _observedData1.ExtendedProperties.Add(new ExtendedProperty <string> {
                Name = ObservedData.MOLECULE, Value = "Drug"
            });
            _observedData1.ExtendedProperties.Add(new ExtendedProperty <string> {
                Name = ObservedData.ORGAN, Value = "Liver"
            });
            _observedData1.ExtendedProperties.Add(new ExtendedProperty <string> {
                Name = ObservedData.COMPARTMENT, Value = "Cell"
            });

            _observedData3.ExtendedProperties.Add(new ExtendedProperty <string> {
                Name = ObservedData.ORGAN, Value = "Kidney"
            });
        }
Exemplo n.º 18
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);
        }
        protected override void Context()
        {
            _modelCoreSimulationMapper   = A.Fake <ISimulationToModelCoreSimulationMapper>();
            _residualCalculatorFactory   = A.Fake <IResidualCalculatorFactory>();
            _timeGridUpdater             = A.Fake <ITimeGridUpdater>();
            _simModelBatchFactory        = A.Fake <ISimModelBatchFactory>();
            _optimizationAlgorithmMapper = A.Fake <IParameterIdentificationAlgorithmToOptmizationAlgorithmMapper>();
            _outputSelectionUpdater      = A.Fake <IOutputSelectionUpdater>();
            _coreUserSettings            = A.Fake <ICoreUserSettings>();
            _jacobianMatrixCalculator    = A.Fake <IJacobianMatrixCalculator>();

            _coreUserSettings.MaximumNumberOfCoresToUse = 2;
            sut = new ParameterIdentificationRun(_residualCalculatorFactory, _timeGridUpdater, _simModelBatchFactory, _modelCoreSimulationMapper,
                                                 _optimizationAlgorithmMapper, _outputSelectionUpdater, _coreUserSettings, _jacobianMatrixCalculator);

            _simulation           = A.Fake <ISimulation>();
            _parameter1           = A.Fake <IParameter>();
            _parameter1.Dimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            _parameter1.Value     = 15;
            _parameter2           = A.Fake <IParameter>();
            _parameter2.Value     = 35;
            _parameter2.Dimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();

            _parameterIdentification = new ParameterIdentification();
            _parameterIdentification.Configuration.LLOQMode       = LLOQModes.OnlyObservedData;
            _parameterIdentification.Configuration.RemoveLLOQMode = RemoveLLOQModes.NoTrailing;

            _parameterIdentification.AddSimulation(_simulation);

            _parameterSelection1 = ParameterSelectionFor(_parameter1, "ParameterPath1");
            _parameterSelection2 = ParameterSelectionFor(_parameter2, "ParameterPath2");

            _identificationParameter = DomainHelperForSpecs.IdentificationParameter("IdParam", min: 10, max: 20, startValue: 15);

            _identificationParameter.AddLinkedParameter(_parameterSelection1);
            _identificationParameter.AddLinkedParameter(_parameterSelection2);

            _modelCoreSimulation = A.Fake <IModelCoreSimulation>();

            A.CallTo(() => _modelCoreSimulationMapper.MapFrom(_simulation, true)).Returns(_modelCoreSimulation);

            _outputMapping = A.Fake <OutputMapping>();
            A.CallTo(() => _outputMapping.UsesSimulation(_simulation)).Returns(true);
            A.CallTo(() => _outputMapping.WeightedObservedData.ObservedData).Returns(DomainHelperForSpecs.ObservedData());
            _parameterIdentification.AddOutputMapping(_outputMapping);

            _simModelBatch = A.Fake <ISimModelBatch>();
            A.CallTo(() => _simModelBatchFactory.Create()).Returns(_simModelBatch);

            _parameterIdentification.AddIdentificationParameter(_identificationParameter);

            _residualCalculator = A.Fake <IResidualCalculator>();
            A.CallTo(_residualCalculatorFactory).WithReturnType <IResidualCalculator>().Returns(_residualCalculator);

            _algorithm = A.Fake <IOptimizationAlgorithm>();
            A.CallTo(() => _optimizationAlgorithmMapper.MapFrom(_parameterIdentification.AlgorithmProperties)).Returns(_algorithm);

            _cancellationTokenSource = new CancellationTokenSource();
            _cancellationToken       = _cancellationTokenSource.Token;

            _runInitializer = A.Fake <IParameterIdentifcationRunInitializer>();
            A.CallTo(() => _runInitializer.InitializeRun()).ReturnsAsync(_parameterIdentification);

            PerformExtraInitializationSteps();
            sut.InitializeWith(_runInitializer);
        }