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); }); }
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); }
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; }
public void AddSimulationTo(ParameterIdentification parameterIdentification, ISimulation simulation) { if (parameterIdentification.UsesSimulation(simulation)) { return; } _executionContext.Load(simulation); parameterIdentification.AddSimulation(simulation); addOutputMappingsFor(simulation, parameterIdentification); }
protected override void Context() { _journalTask = A.Fake <IJournalTask>(); _activeSubjectRetriever = A.Fake <IActiveSubjectRetriever>(); _observedDataRepository = A.Fake <IObservedDataRepository>(); _executionContext = A.Fake <IOSPSuiteExecutionContext>(); sut = new AddParameterAnalysableToActiveJournalPageUICommand(_journalTask, _observedDataRepository, _executionContext, _activeSubjectRetriever); _parameterIdentification = new ParameterIdentification(); sut.Subject = _parameterIdentification; _simulation1 = A.Fake <ISimulation>(); _simulation2 = A.Fake <ISimulation>(); _parameterIdentification.AddSimulation(_simulation1); _parameterIdentification.AddSimulation(_simulation2); _obs1 = new DataRepository("OBS1"); _obs2 = new DataRepository("OBS2"); A.CallTo(() => _observedDataRepository.AllObservedDataUsedBy(_parameterIdentification)).Returns(new[] { _obs1, _obs2 }); }
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); }
protected override void Context() { _view = A.Fake <IParameterIdentificationDataSelectionView>(); _simulationSelectionPresenter = A.Fake <IParameterIdentificationSimulationSelectionPresenter>(); _outputMappingPresenter = A.Fake <IParameterIdentificationOutputMappingPresenter>(); _weightedObservedDataCollectorPresenter = A.Fake <IParameterIdentificationWeightedObservedDataCollectorPresenter>(); sut = new ParameterIdentificationDataSelectionPresenter(_view, _simulationSelectionPresenter, _outputMappingPresenter, _weightedObservedDataCollectorPresenter); _simulation = A.Fake <ISimulation>().WithId("Sim"); _parameterIdentification = new ParameterIdentification(); _parameterIdentification.AddSimulation(_simulation); sut.EditParameterIdentification(_parameterIdentification); }
protected override void Context() { base.Context(); _project = A.Fake <IProject>(); _parameterIdentification = A.Fake <ParameterIdentification>(); _context = A.Fake <IMoBiContext>(); _simulationReferenceUpdater = A.Fake <ISimulationReferenceUpdater>(); _simulationParameterOriginIdUpdater = A.Fake <ISimulationParameterOriginIdUpdater>(); A.CallTo(() => _context.PublishEvent(A <SimulationUnloadEvent> ._)) .Invokes(x => _event = x.GetArgument <SimulationUnloadEvent>(0)); A.CallTo(() => _context.Project).Returns(_project); A.CallTo(() => _context.Resolve <ISimulationReferenceUpdater>()).Returns(_simulationReferenceUpdater); A.CallTo(() => _context.Resolve <ISimulationParameterOriginIdUpdater>()).Returns(_simulationParameterOriginIdUpdater); A.CallTo(() => _project.AllParameterIdentifications).Returns(new[] { _parameterIdentification }); _parameterIdentification.AddSimulation(_simulation); }
protected override void Context() { _entitiesInSimulationRetriever = A.Fake <IEntitiesInSimulationRetriever>(); _view = A.Fake <ISimulationParametersView>(); _simulationParameterSelectionDTOMapper = A.Fake <IQuantityToSimulationParameterSelectionDTOMapper>(); _groupRepository = A.Fake <IGroupRepository>(); _parameterSelector = A.Fake <IParameterAnalysableParameterSelector>(); sut = new SimulationParametersPresenter(_view, _entitiesInSimulationRetriever, _simulationParameterSelectionDTOMapper, _groupRepository, _parameterSelector); _allParameters = new PathCacheForSpecs <IParameter>(); _parameterIdentification = new ParameterIdentification(); _simulation = A.Fake <ISimulation>(); _parameterIdentification.AddSimulation(_simulation); A.CallTo(() => _entitiesInSimulationRetriever.ParametersFrom(_simulation, A <Func <IParameter, bool> > ._)).Returns(_allParameters); A.CallTo(() => _view.BindTo(A <IEnumerable <SimulationParameterSelectionDTO> > ._)) .Invokes(x => _allQuantitySelectionDTO = x.GetArgument <IEnumerable <SimulationParameterSelectionDTO> >(0)); }
protected override void Context() { _view = A.Fake <IEditParameterIdentificationView>(); _subPresenterItemManager = SubPresenterHelper.Create <IParameterIdentificationItemPresenter>(); _parameterIdentificationDataSelectionPresenter = _subPresenterItemManager.CreateFake(ParameterIdentificationItems.Data); _parameterIdentificationParameterSelectionPresenter = _subPresenterItemManager.CreateFake(ParameterIdentificationItems.Parameters); _parameterIdentificationConfigurationPresenter = _subPresenterItemManager.CreateFake(ParameterIdentificationItems.Configuration); _simulationAnalysisPresenterFactory = A.Fake <ISimulationAnalysisPresenterFactory>(); _contextMenuFactory = A.Fake <ISimulationAnalysisPresenterContextMenuFactory>(); _presentationSettingsTask = A.Fake <IPresentationSettingsTask>(); _simulationAnalysisCreator = A.Fake <IParameterIdentificationAnalysisCreator>(); _executionContext = A.Fake <IOSPSuiteExecutionContext>(); _simulation = A.Fake <ISimulation>(); sut = new EditParameterIdentificationPresenter(_view, _subPresenterItemManager, _executionContext, _simulationAnalysisPresenterFactory, _contextMenuFactory, _presentationSettingsTask, _simulationAnalysisCreator); sut.InitializeWith(A.Fake <ICommandCollector>()); _parameterIdentification = new ParameterIdentification(); _parameterIdentification.AddSimulation(_simulation); }
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() { _containerTask = A.Fake <IContainerTask>(); _identificationParameterTask = A.Fake <IIdentificationParameterTask>(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); sut = new IdentificationParameterFactory(_objectBaseFactory, _containerTask, _identificationParameterTask); _simulationParameterSelection = new List <ParameterSelection>(); _parameterIdentification = new ParameterIdentification(); _simulation = A.Fake <ISimulation>(); _simulation.Model.Root = new Container(); A.CallTo(() => _objectBaseFactory.Create <IdentificationParameter>()).Returns(new IdentificationParameter()); _parameterIdentification.AddSimulation(_simulation); _lengthLiver = A.Fake <IParameter>().WithName("Length").WithDimension(DomainHelperForSpecs.LengthDimensionForSpecs()); _fractionLiver = A.Fake <IParameter>().WithName("Fraction").WithDimension(DomainHelperForSpecs.FractionDimensionForSpecs()); _lengthKidney = A.Fake <IParameter>().WithName("Length").WithDimension(DomainHelperForSpecs.LengthDimensionForSpecs()); var logDimension = A.Fake <IDimension>(); A.CallTo(() => logDimension.Name).Returns(Constants.Dimension.LOG_UNITS); _lipoKidney = A.Fake <IParameter>().WithName("Lipo").WithDimension(logDimension); _fracKidney = A.Fake <IParameter>().WithName("Frac").WithDimension(DomainHelperForSpecs.FractionDimensionForSpecs()); var liver = new Container().WithName("Liver"); var kidney = new Container().WithName("Kidney"); liver.Add(_lengthLiver); liver.Add(_fractionLiver); kidney.Add(_lengthKidney); kidney.Add(_lipoKidney); kidney.Add(_fracKidney); _simulation.Model.Root.Add(liver); _simulation.Model.Root.Add(kidney); _simulationParameterSelection.Add(new ParameterSelection(_simulation, new QuantitySelection("Liver|Length", QuantityType.Parameter))); }
protected override void Context() { _view = A.Fake <IParameterIdentificationOutputMappingView>(); _observedDataRepository = A.Fake <IObservedDataRepository>(); _entitiesInSimulationRetriever = A.Fake <IEntitiesInSimulationRetriever>(); _outputMappingDTOMapper = A.Fake <IOutputMappingToOutputMappingDTOMapper>(); _simulationQuantitySelectionDTOMapper = A.Fake <IQuantityToSimulationQuantitySelectionDTOMapper>(); _parameterIdentificationTask = A.Fake <IParameterIdentificationTask>(); sut = new ParameterIdentificationOutputMappingPresenter(_view, _entitiesInSimulationRetriever, _observedDataRepository, _outputMappingDTOMapper, _simulationQuantitySelectionDTOMapper, _parameterIdentificationTask); _observedData1 = DomainHelperForSpecs.ObservedData("Obs1").WithName("Obs1"); _weightedObservedData1 = new WeightedObservedData(_observedData1); _observedData2 = DomainHelperForSpecs.ObservedData("Obs2").WithName("Obs2"); _weightedObservedData2 = new WeightedObservedData(_observedData2); _parameterIdentification = new ParameterIdentification(); _simulation1 = A.Fake <ISimulation>().WithId("Id1"); _simulation2 = A.Fake <ISimulation>().WithId("Id2"); _usedObservedData1 = new UsedObservedData { Id = "Obs1" }; _usedObservedData2 = new UsedObservedData { Id = "Obs2" }; A.CallTo(() => _observedDataRepository.All()).Returns(new[] { _observedData1, _observedData2 }); A.CallTo(() => _observedDataRepository.AllObservedDataUsedBy(_simulation1)).Returns(new[] { _observedData2 }); A.CallTo(() => _observedDataRepository.AllObservedDataUsedBy(_simulation2)).Returns(new[] { _observedData1, _observedData2 }); _parameterIdentification.AddSimulation(_simulation1); _parameterIdentification.AddSimulation(_simulation2); _quantity1 = A.Fake <IQuantity>(); _quantity2 = A.Fake <IQuantity>(); _output1 = A.Fake <SimulationQuantitySelectionDTO>(); A.CallTo(() => _output1.Simulation).Returns(_simulation1); _output2 = A.Fake <SimulationQuantitySelectionDTO>(); A.CallTo(() => _output2.Simulation).Returns(_simulation2); A.CallTo(() => _entitiesInSimulationRetriever.OutputsFrom(_simulation1)).Returns(new PathCache <IQuantity>(new EntityPathResolverForSpecs()) { { "AA", _quantity1 } }); A.CallTo(() => _entitiesInSimulationRetriever.OutputsFrom(_simulation2)).Returns(new PathCache <IQuantity>(new EntityPathResolverForSpecs()) { { "BB", _quantity2 } }); A.CallTo(() => _simulationQuantitySelectionDTOMapper.MapFrom(_simulation1, _quantity1)).Returns(_output1); A.CallTo(() => _simulationQuantitySelectionDTOMapper.MapFrom(_simulation2, _quantity2)).Returns(_output2); A.CallTo(() => _view.BindTo(A <IEnumerable <OutputMappingDTO> > ._)) .Invokes(x => _allOutputMappingDTOs = x.GetArgument <IEnumerable <OutputMappingDTO> >(0)); sut.EditParameterIdentification(_parameterIdentification); _outputMapping1 = A.Fake <OutputMapping>(); _outputMapping2 = A.Fake <OutputMapping>(); _outputMappingDTO1 = new OutputMappingDTO(_outputMapping1) { Output = _output1 }; _outputMappingDTO2 = new OutputMappingDTO(_outputMapping2) { Output = _output2 }; A.CallTo(() => _outputMapping1.Simulation).Returns(_simulation1); A.CallTo(() => _outputMapping2.Simulation).Returns(_simulation2); A.CallTo(() => _outputMappingDTOMapper.MapFrom(_outputMapping1, A <IEnumerable <SimulationQuantitySelectionDTO> > ._)).Returns(_outputMappingDTO1); A.CallTo(() => _outputMappingDTOMapper.MapFrom(_outputMapping2, A <IEnumerable <SimulationQuantitySelectionDTO> > ._)).Returns(_outputMappingDTO2); }
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); }
public void should_not_add_the_simulation_twice() { A.CallTo(() => _parameterIdentification.AddSimulation(_simulation)).MustNotHaveHappened(); }