Esempio n. 1
0
        private ISimModelBatch createSimModelBatch(ISimulation simulation)
        {
            var simModelBatch       = _simModelBatchFactory.Create();
            var modelCoreSimulation = _modelCoreSimulationMapper.MapFrom(simulation, shouldCloneModel: true);

            _timeGridUpdater.UpdateSimulationTimeGrid(modelCoreSimulation, _parameterIdentification.Configuration.RemoveLLOQMode, _parameterIdentification.AllDataRepositoryMappedFor(simulation));
            _outputSelectionUpdater.UpdateOutputsIn(modelCoreSimulation, _parameterIdentification.AllOutputsMappedFor(simulation));
            simModelBatch.InitializeWith(modelCoreSimulation, _parameterIdentification.PathOfOptimizedParameterBelongingTo(simulation), simulationResultsName: Captions.ParameterIdentification.SimulationResultsForRun(RunResult.Index));
            return(simModelBatch);
        }
        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);
        }