private IDistributedParameter create(ParameterDistributionMetaData distributionMetaData, Func <IDistributedParameter, IDistributionFormula> createFormula) { var param = _objectBaseFactory.CreateDistributedParameter(); setParameterProperties(param, distributionMetaData); addParametersToDistributedParameter(param, distributionMetaData); param.Formula = createFormula(param); updateDefaultValueFor(param); return(param); }
public AdvancedParameter Create(IParameter parameter, DistributionType distributionType) { var advancedParameter = _objectBaseFactory.Create <AdvancedParameter>(); //we don't care about the name, it should only be unique in the hiearchy advancedParameter.Name = _entityPathResolver.PathFor(parameter); advancedParameter.ParameterPath = advancedParameter.Name; var distributionMetaData = new ParameterDistributionMetaData { DistributionType = distributionType.Id, BuildingBlockType = buildingBlockTypeFrom(parameter), Mean = defaultMeanValueBasedOn(parameter.Value, distributionType), Deviation = defaultStdValueBasedOn(distributionType), Dimension = parameter.Dimension.Name, DefaultUnit = parameter.DisplayUnit.Name, ParameterName = "distribution" }; if (distributionType == DistributionTypes.Uniform) { distributionMetaData.MinValue = parameter.MinValue ?? parameter.Value / _defaultUniformFactor; //+ _defaultUniformFactor in case the default value is 0 distributionMetaData.MaxValue = parameter.MaxValue ?? (parameter.Value * _defaultUniformFactor + _defaultUniformFactor); } else { distributionMetaData.MinValue = parameter.MinValue; distributionMetaData.MinIsAllowed = parameter.MinIsAllowed; distributionMetaData.MaxValue = parameter.MaxValue; distributionMetaData.MaxIsAllowed = parameter.MaxIsAllowed; } advancedParameter.DistributedParameter = _parameterFactory.CreateFor(distributionMetaData); //should set the distribution parameter as visible since they will need to be edited advancedParameter.DistributedParameter.AllParameters().Each(x => { x.Visible = true; x.IsDefault = false; x.CanBeVaried = true; x.CanBeVariedInPopulation = false; }); return(advancedParameter); }
private void addParametersToDistributedParameter(IDistributedParameter param, ParameterDistributionMetaData distributionMetaData) { var percentile = createHiddenParameterBasedOn(Constants.Distribution.PERCENTILE, distributionMetaData) .WithDimension(_dimensionRepository.NoDimension); percentile.Value = CoreConstants.DEFAULT_PERCENTILE; param.Add(percentile); if (distributionMetaData.Distribution == DistributionTypes.Normal) { param.Add(createHiddenParameterBasedOn(Constants.Distribution.MEAN, distributionMetaData)); param.Add(createHiddenParameterBasedOn(Constants.Distribution.DEVIATION, distributionMetaData)); } else if (distributionMetaData.Distribution == DistributionTypes.LogNormal) { //log normal=> we need to reset dimension param.Add(createHiddenParameterBasedOn(Constants.Distribution.MEAN, distributionMetaData)); var gsd = createHiddenParameterBasedOn(Constants.Distribution.GEOMETRIC_DEVIATION, distributionMetaData) .WithDimension(_dimensionRepository.NoDimension); gsd.Info.MinIsAllowed = true; gsd.Info.MinValue = 1; gsd.DisplayUnit = _dimensionRepository.NoDimension.DefaultUnit; param.Add(gsd); } else if (distributionMetaData.Distribution == DistributionTypes.Uniform) { param.Add(createHiddenParameterBasedOn(Constants.Distribution.MINIMUM, distributionMetaData)); param.Add(createHiddenParameterBasedOn(Constants.Distribution.MAXIMUM, distributionMetaData)); } else if (distributionMetaData.Distribution == DistributionTypes.Discrete) { param.Add(createHiddenParameterBasedOn(Constants.Distribution.MEAN, distributionMetaData)); } else if (distributionMetaData.Distribution == DistributionTypes.Unknown) { /*nothing to do*/ } else { throw new DistributionNotFoundException(distributionMetaData); } updateRangeValueForMean(param); }
public IDistributedParameter CreateFor(ParameterDistributionMetaData distributionMetaData) { return(create(distributionMetaData, p => _formulaFactory.DistributionFor(distributionMetaData, p))); }
public IDistributionFormula DistributionFor(ParameterDistributionMetaData distributionMetaData, IDistributedParameter parameterWithDistribution) { return(_distributionFactory.CreateFor(distributionMetaData, parameterWithDistribution)); }
public static ParameterDistributionMetaData From(ParameterDistributionMetaData source) { return(source.MemberwiseClone().DowncastTo <ParameterDistributionMetaData>()); }