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 <IParameterIdentificationParametersFeedbackView>();
            _exportTask = A.Fake <IParameterIdentificationExportTask>();
            sut         = new ParameterIdentificationParametersFeedbackPresenter(_view, _exportTask);

            _paramterIdentification           = new ParameterIdentification();
            _identificationParameter1         = createIdentificationParameter("P1", 10, 0, 20);
            _identificationParameter2         = createIdentificationParameter("P2", 20, 5, 40);
            _identificationParameter3         = createIdentificationParameter("P3", 20, 5, 40);
            _identificationParameter3.IsFixed = true;

            _paramterIdentification.AddIdentificationParameter(_identificationParameter1);
            _paramterIdentification.AddIdentificationParameter(_identificationParameter2);
            _paramterIdentification.AddIdentificationParameter(_identificationParameter3);

            A.CallTo(() => _view.BindTo(A <IEnumerable <ParameterFeedbackDTO> > ._, A <IEnumerable <IRunPropertyDTO> > ._))
            .Invokes(x =>
            {
                _allParameterFeedbackDTO = x.GetArgument <IEnumerable <ParameterFeedbackDTO> >(0).ToList();
                _allPropertiesDTO        = x.GetArgument <IEnumerable <IRunPropertyDTO> >(1).ToList();
            });

            sut.EditParameterIdentification(_paramterIdentification);
        }
        public void UpdateParameterRange(IdentificationParameter identificationParameter)
        {
            var linkedParmaeter = identificationParameter.AllLinkedParameters.FirstOrDefault();
            var parameter       = linkedParmaeter?.Parameter;

            updateParameterRange(identificationParameter, parameter);
        }
Ejemplo n.º 4
0
        protected override void Context()
        {
            base.Context();
            _simulation = A.Fake <ISimulation>().WithName("S");
            _parameter1 = A.Fake <IParameter>();
            _parameter2 = A.Fake <IParameter>();
            _parameter1.Origin.SimulationId = "S";
            _parameter2.Origin.SimulationId = "S";

            A.CallTo(() => _withIdRepository.Get <ISimulation>(_parameter1.Origin.SimulationId)).Returns(_simulation);
            A.CallTo(() => _withIdRepository.Get <ISimulation>(_parameter2.Origin.SimulationId)).Returns(_simulation);
            A.CallTo(() => _parameterIdentificationFactory.Create()).Returns(new ParameterIdentification());
            A.CallTo(() => _executionContext.Project).Returns(A.Fake <IProject>());

            var parameterCache = new PathCacheForSpecs <IParameter> {
                { _parameterPath1, _parameter1 }, { _parameterPath2, _parameter2 }
            };

            A.CallTo(() => _entitiesInSimulationRetriever.ParametersFrom(_simulation)).Returns(parameterCache);
            A.CallTo(() => _favoriteRepository.All()).Returns(new[] { _parameterPath1, _parameterPath2, });
            A.CallTo(() => _entityPathResolver.PathFor(_parameter1)).Returns(_parameterPath1);
            A.CallTo(() => _entityPathResolver.PathFor(_parameter2)).Returns(_parameterPath2);
            A.CallTo(() => _parameterAnalysableParameterSelector.CanUseParameter(_parameter1)).Returns(true);
            A.CallTo(() => _parameterAnalysableParameterSelector.CanUseParameter(_parameter2)).Returns(false);

            _parameter1IdentificationParameter = new IdentificationParameter();
            A.CallTo(() => _identificationParameterFactory.CreateFor(A <ParameterSelection> .That.Matches(x => x.Path == _parameterPath1), A <ParameterIdentification> ._)).Returns(_parameter1IdentificationParameter);
        }
Ejemplo n.º 5
0
        protected override void Context()
        {
            _parameterTask           = A.Fake <ISetParameterTask>();
            _dialogCreator           = A.Fake <IDialogCreator>();
            _parameterIdentification = new ParameterIdentification();
            _runResult = new ParameterIdentificationRunResult();

            _runResult.BestResult.AddValue(new OptimizedParameterValue("P1", 10, 20));
            _runResult.BestResult.AddValue(new OptimizedParameterValue("P2", 4, 5));

            _identificationParameter1 = new IdentificationParameter {
                Name = "P1"
            };
            _identificationParameter2 = new IdentificationParameter {
                Name = "P2", UseAsFactor = true
            };
            _identificationParameter3 = new IdentificationParameter {
                Name = "P3", IsFixed = true,
            };
            _identificationParameter3.Add(DomainHelperForSpecs.ConstantParameterWithValue(25).WithName(Constants.Parameters.START_VALUE));

            _linkedParameter1 = A.Fake <ParameterSelection>();
            A.CallTo(() => _linkedParameter1.Parameter).Returns(DomainHelperForSpecs.ConstantParameterWithValue(2));

            _linkedParameter2 = A.Fake <ParameterSelection>();
            A.CallTo(() => _linkedParameter2.Parameter).Returns(DomainHelperForSpecs.ConstantParameterWithValue(3));
            A.CallTo(() => _linkedParameter2.Dimension).Returns(Constants.Dimension.NO_DIMENSION);

            _linkedParameter3 = A.Fake <ParameterSelection>();
            A.CallTo(() => _linkedParameter3.Parameter).Returns(DomainHelperForSpecs.ConstantParameterWithValue(4));
            A.CallTo(() => _linkedParameter3.Dimension).Returns(Constants.Dimension.NO_DIMENSION);

            _linkedParameter4 = A.Fake <ParameterSelection>();
            A.CallTo(() => _linkedParameter4.Parameter).Returns(DomainHelperForSpecs.ConstantParameterWithValue(5));
            A.CallTo(() => _linkedParameter4.Dimension).Returns(Constants.Dimension.NO_DIMENSION);


            _identificationParameter1.AddLinkedParameter(_linkedParameter1);
            _identificationParameter2.AddLinkedParameter(_linkedParameter2);
            _identificationParameter2.AddLinkedParameter(_linkedParameter3);
            _identificationParameter3.AddLinkedParameter(_linkedParameter4);

            _parameterIdentification.AddIdentificationParameter(_identificationParameter1);
            _parameterIdentification.AddIdentificationParameter(_identificationParameter2);
            _parameterIdentification.AddIdentificationParameter(_identificationParameter3);

            _context = A.Fake <IOSPSuiteExecutionContext>();
            sut      = new TestTransferOptimizedParametersToSimulationsTask(_parameterTask, _dialogCreator, _context);

            _allValueOriginCommands = new List <ICommand>();

            A.CallTo(() => _parameterTask.SetParameterValue(A <IParameter> ._, A <double> ._, A <ISimulation> ._)).ReturnsLazily(x => A.Fake <IOSPSuiteCommmand <IOSPSuiteExecutionContext> >());

            A.CallTo(() => _parameterTask.UpdateParameterValueOrigin(A <IParameter> ._, A <ValueOrigin> ._, A <ISimulation> ._)).ReturnsLazily(x =>
            {
                var command = A.Fake <IOSPSuiteCommmand <IOSPSuiteExecutionContext> >();
                _allValueOriginCommands.Add(command);
                return(command);
            });
        }
        public void AddParameterRangeBasedOn(IdentificationParameter identificationParameter, IParameter parameter)
        {
            identificationParameter.Add(createParameter(Constants.Parameters.START_VALUE));
            identificationParameter.Add(createParameter(Constants.Parameters.MIN_VALUE));
            identificationParameter.Add(createParameter(Constants.Parameters.MAX_VALUE));

            updateParameterRange(identificationParameter, parameter);
        }
        private void findMissingLinkedParameterPaths(IdentificationParameter identificationParameter, ParameterIdentification parameterIdentification, ISimulation oldSimulation, ISimulation newSimulation)
        {
            var linkedParametersNotInSimulation = identificationParameter.LinkedParametersFor(oldSimulation).Where(linkedParameter => !_simulationQuantitySelectionFinder.SimulationHasSelection(linkedParameter, newSimulation));

            linkedParametersNotInSimulation.ToList().Each(parameter =>
                                                          ActionForLinkedParameterIsNotInSimulation(parameterIdentification, newSimulation, parameter, identificationParameter)
                                                          );
        }
        protected override void Context()
        {
            base.Context();
            var identificationParameter = new IdentificationParameter();

            identificationParameter.AddLinkedParameter(_simulationParameterSelection[0]);
            _parameterIdentification.AddIdentificationParameter(identificationParameter);
        }
Ejemplo n.º 9
0
        protected override void Context()
        {
            base.Context();

            _identificationParameter = new IdentificationParameter {
                DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(Constants.Parameters.START_VALUE)
            };
        }
Ejemplo n.º 10
0
        private IEnumerable <LinkedParameterDTO> allExistingLinkedParametersFrom(IdentificationParameter identificationParameter)
        {
            if (identificationParameter == null)
            {
                return(Enumerable.Empty <LinkedParameterDTO>());
            }

            return(_identificationParameter.AllLinkedParameters.MapAllUsing(_linkedParameterDTOMapper));
        }
        private void updateParameter(IdentificationParameter identificationParameter, string parameterName, double value, IDimension dimension, Unit displayUnit)
        {
            var parameter = identificationParameter.Parameter(parameterName);

            parameter.Dimension         = dimension;
            parameter.DisplayUnit       = displayUnit;
            parameter.Formula.Dimension = dimension;
            parameter.Formula.DowncastTo <ConstantFormula>().Value = value;
        }
Ejemplo n.º 12
0
 protected override void Context()
 {
     base.Context();
     _cloneManager = A.Fake <ICloneManager>();
     _sourceParameterIdentification = new IdentificationParameter {
         Name = "TOTO", IsFixed = true, UseAsFactor = false
     };
     _sourceParameterIdentification.AddLinkedParameter(_parameterSelection);
 }
Ejemplo n.º 13
0
        public IdentificationParameterDTO MapFrom(IdentificationParameter identificationParameter)
        {
            var identificationParameterDTO = new IdentificationParameterDTO(identificationParameter);

            identificationParameterDTO.StartValueParameter = _parameterMapper.MapFrom(identificationParameter.StartValueParameter, identificationParameterDTO, x => x.StartValue, x => x.StartValueParameter);
            identificationParameterDTO.MinValueParameter   = _parameterMapper.MapFrom(identificationParameter.MinValueParameter, identificationParameterDTO, x => x.MinValue, x => x.MinValueParameter);
            identificationParameterDTO.MaxValueParameter   = _parameterMapper.MapFrom(identificationParameter.MaxValueParameter, identificationParameterDTO, x => x.MaxValue, x => x.MaxValueParameter);
            return(identificationParameterDTO);
        }
Ejemplo n.º 14
0
 protected override void Context()
 {
     base.Context();
     _identificationParameter2    = new IdentificationParameter();
     _identificationParameterDTO2 = new IdentificationParameterDTO(_identificationParameter2);
     _parameterIdentification.AddIdentificationParameter(_identificationParameter2);
     A.CallTo(() => _identificationParameterDTOMapper.MapFrom(_identificationParameter2)).Returns(_identificationParameterDTO2);
     sut.EditParameterIdentification(_parameterIdentification);
 }
Ejemplo n.º 15
0
        private IEnumerable <ICommand> updateParameterValue(IdentificationParameter identificationParameter, double optimalValue, ParameterSelection linkedParameter)
        {
            var value     = identificationParameter.OptimizedParameterValueFor(optimalValue, linkedParameter);
            var parameter = linkedParameter.Parameter;

            var setValueCommand = _parameterTask.SetParameterValue(parameter, value, linkedParameter.Simulation);

            return(new[] { setValueCommand, updateValueOriginCommand(identificationParameter, parameter, linkedParameter.Simulation).AsHidden() });
        }
 private OptimizedParameterDTO mapFrom(IdentificationParameter identificationParameter, OptimizedParameterValue optimizedParameter)
 {
     return(mapFrom(identificationParameter,
                    optimizedParameter.StartValue,
                    optimizedParameter.Value,
                    optimizedParameter.Min,
                    optimizedParameter.Max,
                    optimizedParameter.Scaling));
 }
Ejemplo n.º 17
0
 protected override void Context()
 {
     base.Context();
     _parameters = new List <ParameterSelection>();
     _newIdentificationParameter    = new IdentificationParameter();
     _newIdentificationParameterDTO = new IdentificationParameterDTO(_newIdentificationParameter);
     A.CallTo(() => _identificationParameterFactory.CreateFor(_parameters, _parameterIdentification)).Returns(_newIdentificationParameter);
     A.CallTo(() => _identificationParameterDTOMapper.MapFrom(_newIdentificationParameter)).Returns(_newIdentificationParameterDTO);
     sut.EditParameterIdentification(_parameterIdentification);
 }
Ejemplo n.º 18
0
 protected override void Context()
 {
     base.Context();
     _identificationParameter = new IdentificationParameter {
         UseAsFactor = false
     };
     _parameter           = A.Fake <IParameter>();
     _parameter.Value     = -1;
     _parameter.Dimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
 }
Ejemplo n.º 19
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_identificationParameter);

            var newIdentificationParameter = new IdentificationParameter();

            A.CallTo(() => _identificationParameterFactory.CreateFor(A <IEnumerable <ParameterSelection> > ._, _parameterIdentificationContext.ParameterIdentification)).Returns(newIdentificationParameter);
        }
 protected override void Context()
 {
     base.Context();
     _newSimulation = A.Fake <ISimulation>();
     sut.AddSimulation(_simulation);
     sut.AddOutputMapping(_outputMapping);
     _identificationParameter = new IdentificationParameter();
     _identificationParameter.AddLinkedParameter(new ParameterSelection(_simulation, A.Fake <QuantitySelection>()));
     sut.AddIdentificationParameter(_identificationParameter);
 }
Ejemplo n.º 21
0
        private void addParameterValue(IdentificationParameter identificationParameter, double value)
        {
            foreach (var linkedParameter in identificationParameter.AllLinkedParameters)
            {
                var simModelBatch = _allSimModelBatches[linkedParameter.Simulation];
                var valueToUse    = identificationParameter.UseAsFactor ? linkedParameter.Parameter.Value * value : value;
                simModelBatch.UpdateParameterValue(linkedParameter.Path, valueToUse);
            }

            _parametersHistory[identificationParameter.Name].AddValue(value);
        }
        protected override void PerformExtraInitializationSteps()
        {
            _parameter3           = A.Fake <IParameter>();
            _parameter3.Dimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            _parameter3.Value     = 100;
            _parameterSelection3  = ParameterSelectionFor(_parameter3, "ParameterPath3");

            _fixedIdentificationParameter = DomainHelperForSpecs.IdentificationParameter("Fixed IdParam", min: 0, max: 200, startValue: 60, isFixed: true);
            _fixedIdentificationParameter.AddLinkedParameter(_parameterSelection3);
            _parameterIdentification.AddIdentificationParameter(_fixedIdentificationParameter);
        }
Ejemplo n.º 23
0
        public static IdentificationParameter IdentificationParameter(string name = "IdentificationParameter", double min = 0, double max = 10, double startValue = 5, bool isFixed = false)
        {
            var identificationParameter = new IdentificationParameter
            {
                ConstantParameterWithValue(min).WithName(Constants.Parameters.MIN_VALUE),
                ConstantParameterWithValue(startValue).WithName(Constants.Parameters.START_VALUE),
                ConstantParameterWithValue(max).WithName(Constants.Parameters.MAX_VALUE)
            }.WithName(name);

            identificationParameter.IsFixed = isFixed;
            return(identificationParameter);
        }
Ejemplo n.º 24
0
        private ICommand updateValueOriginCommand(IdentificationParameter identificationParameter, IParameter parameter, ISimulation simulation)
        {
            var isoDate     = SystemTime.Now().ToIsoFormat();
            var valueOrigin = new ValueOrigin
            {
                Description = Captions.ParameterIdentification.ValueUpdatedFrom(identificationParameter.ParameterIdentification.Name, isoDate),
                Source      = ValueOriginSources.ParameterIdentification,
                Method      = ValueOriginDeterminationMethods.ParameterIdentification
            };

            return(_parameterTask.UpdateParameterValueOrigin(parameter, valueOrigin, simulation));
        }
        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);
        }
Ejemplo n.º 26
0
 protected override void Context()
 {
     base.Context();
     _simulation = A.Fake <ISimulation>();
     _parameterIdentification = new ParameterIdentification();
     _parameter = A.Fake <IParameter>();
     _parameter.Origin.SimulationId = "Sim";
     A.CallTo(() => _withIdRepository.Get <ISimulation>("Sim")).Returns(_simulation);
     A.CallTo(() => _entityPathResolver.PathFor(_parameter)).Returns("Path");
     _identificationParameter = new IdentificationParameter();
     A.CallTo(_identificationParameterFactory).WithReturnType <IdentificationParameter>().Returns(_identificationParameter);
     A.CallTo(() => _parameterAnalysableParameterSelector.CanUseParameter(_parameter)).Returns(true);
 }
Ejemplo n.º 27
0
 private void selectIdentificationParameter(IdentificationParameter identificationParameter)
 {
     if (identificationParameter == null)
     {
         clearSelection();
     }
     else
     {
         var selectedDTO = dtoFrom(identificationParameter);
         View.SelectedIdentificationParameter = selectedDTO;
         SelectIdentificationParameter(selectedDTO);
     }
 }
        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());
        }
Ejemplo n.º 29
0
        protected override void Context()
        {
            base.Context();

            _identificationParameter = new IdentificationParameter {
                DomainHelperForSpecs.ConstantParameterWithValue(10).WithName(Constants.Parameters.START_VALUE)
            };

            var parameterSelection = A.Fake <ParameterSelection>();

            A.CallTo(() => parameterSelection.Parameter).Returns(null);

            _identificationParameter.AddLinkedParameter(parameterSelection);
        }
Ejemplo n.º 30
0
        private OptimizedParameterDTO mapFrom(IdentificationParameter identificationParameter, double optimalValue, double startValue)
        {
            var dto = new OptimizedParameterDTO
            {
                Name         = identificationParameter.Name,
                OptimalValue = mapFrom(optimalValue, identificationParameter.StartValueParameter),
                StartValue   = mapFrom(startValue, identificationParameter.StartValueParameter),
                MinValue     = mapFrom(identificationParameter.MinValue, identificationParameter.MinValueParameter),
                MaxValue     = mapFrom(identificationParameter.MaxValue, identificationParameter.MaxValueParameter),
                Scaling      = identificationParameter.Scaling
            };

            dto.RangeImage = _optimizedParameterRangeImageCreator.CreateFor(dto);
            return(dto);
        }