protected override void Context() { _distributedParameter = DomainHelperForSpecs.NormalDistributedParameter(); sut = new AdvancedParameter { DistributedParameter = _distributedParameter }; }
protected override void Context() { base.Context(); _molecule1RefConcDistribution = DomainHelperForSpecs.NormalDistributedParameter(defaultMean: 4, defaultDeviation: 2).WithId("Molecule1RefConf"); _molecule2HalfLifeIntestineDistribution = DomainHelperForSpecs.NormalDistributedParameter(defaultMean: 6, defaultDeviation: 3).WithId("Molecule2HalfLifeIntestine"); A.CallTo(() => _moleculeParameterFactory.ParameterFor(_molecule1.Name, _molecule1.ReferenceConcentration.Name)).Returns(_molecule1RefConcDistribution); A.CallTo(() => _moleculeParameterFactory.ParameterFor(_molecule1.Name, _molecule1.HalfLifeLiver.Name)).Returns(null); A.CallTo(() => _moleculeParameterFactory.ParameterFor(_molecule1.Name, _molecule1.HalfLifeIntestine.Name)).Returns(null); A.CallTo(() => _moleculeParameterFactory.ParameterFor(_molecule2.Name, _molecule2.ReferenceConcentration.Name)).Returns(null); A.CallTo(() => _moleculeParameterFactory.ParameterFor(_molecule2.Name, _molecule2.HalfLifeLiver.Name)).Returns(null); A.CallTo(() => _moleculeParameterFactory.ParameterFor(_molecule2.Name, _molecule2.HalfLifeIntestine.Name)).Returns(_molecule2HalfLifeIntestineDistribution); _advancedParameterMolecule1RefConc = A.Fake <IAdvancedParameter>().WithName("Molecule1RefConf"); _advancedParameterMolecule1RefConc.ParameterPath = "Path1"; _advancedParameterMolecule2HalfLifeIntestine = A.Fake <IAdvancedParameter>().WithName("Molecule2HalfLifeIntestine"); _advancedParameterMolecule2HalfLifeIntestine.ParameterPath = "Path2"; A.CallTo(() => _advancedParmeterFactory.Create(_molecule1.ReferenceConcentration, DistributionTypes.Normal)).Returns(_advancedParameterMolecule1RefConc); A.CallTo(() => _advancedParmeterFactory.Create(_molecule2.HalfLifeIntestine, DistributionTypes.Normal)).Returns(_advancedParameterMolecule2HalfLifeIntestine); }
protected override void Context() { base.Context(); _organism = new Organism(); _anotherTopContainer = new Container().WithName("Another container"); _spatialStructure = new PKSimSpatialStructure(); _spatialStructure.AddTopContainer(_organism); _spatialStructure.AddTopContainer(_anotherTopContainer); _ga = DomainHelperForSpecs.ConstantParameterWithValue().WithName(Constants.Parameters.GESTATIONAL_AGE); _age = DomainHelperForSpecs.ConstantParameterWithValue().WithName(CoreConstants.Parameters.AGE); _height = DomainHelperForSpecs.ConstantParameterWithValue().WithName(CoreConstants.Parameters.HEIGHT); _distributedParameter = DomainHelperForSpecs.NormalDistributedParameter(isDefault: false, distributionParameterIsDefault: false).WithName("Distributed"); _p1 = DomainHelperForSpecs.ConstantParameterWithValue().WithName("P1"); _p2 = DomainHelperForSpecs.ConstantParameterWithValue().WithName("P2"); _organism.Add(_ga); _organism.Add(_age); _organism.Add(_height); _organism.Add(_p1); _anotherTopContainer.Add(_p2); _organism.Add(_distributedParameter); _mean = _distributedParameter.Parameter(Constants.Distribution.MEAN); _deviation = _distributedParameter.Parameter(Constants.Distribution.DEVIATION); }
protected override void Context() { base.Context(); _normalDistribution1 = new ParameterDistributionMetaData { Age = 20, Mean = 5, Deviation = 10 }; _normalDistribution2 = new ParameterDistributionMetaData { Age = 10, Mean = 15, Deviation = 30 }; _normalDistributions = new List <ParameterDistributionMetaData> { _normalDistribution1, _normalDistribution2 }; _parameter = A.Fake <IDistributedParameter>(); IParameter meanParameter = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("Mean"); IParameter deviationParameter = DomainHelperForSpecs.ConstantParameterWithValue(2).WithName("Deviation"); A.CallTo(() => _parameter.MeanParameter).Returns(meanParameter); A.CallTo(() => _parameter.DeviationParameter).Returns(deviationParameter); A.CallTo(() => _distrFormulaFactory.CreateNormalDistributionFormulaFor(_parameter, meanParameter, deviationParameter)).Returns(new NormalDistributionFormula()); _originData = new OriginData { Age = 12 }; }
protected override void Context() { base.Context(); _executionContext = A.Fake <IExecutionContext>(); var container = new Container(); var objectPathFactory = new ObjectPathFactoryForSpecs(); _paraWithValueUnchanged1 = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName("para1").WithDimension(A.Fake <IDimension>()); _paraWithValueUnchanged1.IsFixedValue = false; _paraWithValueChanged2 = DomainHelperForSpecs.ConstantParameterWithValue(2).WithName("para2").WithDimension(A.Fake <IDimension>()); _paraWithValueChanged2.Id = "tralala"; _paraWithValueChanged2.Formula = new ExplicitFormula("15"); _paraWithValueChanged2.Formula.AddObjectPath(objectPathFactory.CreateRelativeFormulaUsablePath(_paraWithValueChanged2, _paraWithValueUnchanged1)); _paraWithValueChanged2.Value = 20; _paraWithValueUnchanged3 = DomainHelperForSpecs.ConstantParameterWithValue(3).WithName("para3"); _distributedParameter = DomainHelperForSpecs.NormalDistributedParameter().WithName("para4"); _distributedParameter.Value = 1.2; _distributedParameter.IsFixedValue = false; _paraWithValueUnchanged3.IsFixedValue = false; container.Add(_paraWithValueChanged2); container.Add(_paraWithValueUnchanged1); container.Add(_paraWithValueUnchanged3); container.Add(_distributedParameter); _parameterToReset.Add(_paraWithValueUnchanged1); _parameterToReset.Add(_paraWithValueChanged2); _parameterToReset.Add(_paraWithValueUnchanged3); _parameterToReset.Add(_distributedParameter); A.CallTo(() => _executionContext.BuildingBlockContaining(_paraWithValueChanged2)).Returns(A.Fake <IPKSimBuildingBlock>()); }
protected override void Context() { base.Context(); _valueOrigin1 = new ValueOrigin { Method = ValueOriginDeterminationMethods.Assumption }; _valueOrigin2 = new ValueOrigin { Method = ValueOriginDeterminationMethods.Other }; _distributionFormula = A.Fake <IDistributionFormula>(); _parameter = A.Fake <IDistributedParameter>(); _subParameter = A.Fake <IParameter>(); _originData = new OriginData { Age = new OriginDataParameter(40) }; _distributions.Add(new ParameterDistributionMetaData { DistributionType = CoreConstants.Distribution.Normal, Age = 20, ValueOrigin = _valueOrigin1 }); _distributions.Add(new ParameterDistributionMetaData { DistributionType = CoreConstants.Distribution.Normal, Age = 50, ValueOrigin = _valueOrigin2 }); A.CallTo(() => _formulaFactory.DistributionFor(A <IEnumerable <ParameterDistributionMetaData> > ._, _parameter, _originData)).Returns(_distributionFormula); A.CallTo(() => _objectBaseFactory.CreateDistributedParameter()).Returns(_parameter); A.CallTo(() => _objectBaseFactory.CreateParameter()).Returns(_subParameter); A.CallTo(() => _objectBaseFactory.Create <ExplicitFormula>()).Returns(new ExplicitFormula()); A.CallTo(() => _dimensionRepository.DimensionByName(A <string> .Ignored)).Returns(_dimension); }
protected override void Context() { base.Context(); _percentileToSet = 0.8; _distributedParameter = DomainHelperForSpecs.NormalDistributedParameter(); A.CallTo(() => _executionContext.BuildingBlockContaining(_distributedParameter)).Returns(A.Fake <IPKSimBuildingBlock>()); }
public ICommand UpdateDistributedTableFormula(IParameter tableParameter, IDistributedParameter distributedParameter) { var distributedTableFormula = tableParameter.Formula as DistributedTableFormula; if (distributedTableFormula == null) { return(new PKSimEmptyCommand()); } if (distributedParameter.Formula.DistributionType() == DistributionTypes.Discrete) { if (ValueComparer.AreValuesEqual(distributedParameter.Value, tableParameter.Value, CoreConstants.DOUBLE_RELATIVE_EPSILON)) { return(new PKSimEmptyCommand()); } return(executeAndUpdatedDefaultStateAndValue(new UpdateDistributedTableFormulaRatioCommand(tableParameter, distributedParameter.Value / tableParameter.Value), tableParameter)); } if (ValueComparer.ArePercentilesEqual(distributedTableFormula.Percentile, distributedParameter.Percentile)) { return(new PKSimEmptyCommand()); } return(executeAndUpdatedDefaultStateAndValue(new UpdateDistributedTableFormulaPercentileCommand(tableParameter, distributedParameter.Percentile), tableParameter)); }
private void createSpatialStructureTableParameter( IParameter structureParameter, IDistributedParameter baseIndividualParameter, IReadOnlyList <ParameterDistributionMetaData> distributionsForMale, IReadOnlyList <ParameterDistributionMetaData> distributionsForFemale, IBuildConfiguration buildConfiguration) { var allDistributionsForParameter = allDistributionsWithAgeStrictBiggerThanOriginData(distributionsForMale, distributionsForFemale, _baseIndividual.OriginData); if (!allDistributionsForParameter.Any()) { return; } //remove the parameter from the parent container and add a new one that will contain the table formula //retrieve the table formula corresponding to the individual values var newParameter = _parameterFactory.CreateFor(structureParameter.Name, structureParameter.BuildingBlockType); newParameter.UpdatePropertiesFrom(structureParameter, _cloneManager); var parentContainer = structureParameter.ParentContainer; parentContainer.RemoveChild(structureParameter); parentContainer.Add(newParameter); newParameter.Editable = false; var formula = createTableFormulaFrom(baseIndividualParameter, allDistributionsForParameter); updateConstantParameterToFormula(newParameter, formula, buildConfiguration); }
public void UpdateDistributedParameterTo3_1_3(IDistributedParameter distributedParameter) { var geoSDParameter = distributedParameter.GetSingleChildByName <IParameter>(Constants.Distribution.GEOMETRIC_DEVIATION); var constantFormula = ((ConstantFormula)geoSDParameter.Formula); constantFormula.Value = Math.Exp(constantFormula.Value); }
protected override void ClearReferences() { _advancedParameter = null; _advancedParameterContainer = null; _parameter = null; _oldDistributedParameter = null; _newDistributedParameter = null; }
public DiscreteDistributionFormula CreateDiscreteDistributionFormulaFor(IDistributedParameter distributedParameter, IParameter meanParameter) { var distribution = createDistribution <DiscreteDistributionFormula>(); distribution.Dimension = meanParameter.Dimension; addObjectPathToDistributionFormula(distribution, distributedParameter, meanParameter, Constants.Distribution.MEAN); return(distribution); }
public IMoBiCommand UpdateDistributedFormula(IDistributedParameter distributedParameter, IDistributionFormula newDistributedFormula, string formulaType, IBuildingBlock buildingBlock) { _context.Register(newDistributedFormula); _context.Register(distributedParameter.Formula); var command = new UpdateDistributedFormulaCommand(distributedParameter, newDistributedFormula, formulaType, buildingBlock).Run(_context); return(withUpdatedDefaultStateAndValueOrigin(command, newDistributedFormula, buildingBlock)); }
protected override void Context() { base.Context(); _parent = new Container().WithName("bla"); _distributedParameter = new DistributedParameter().WithName("Dis").WithParentContainer(_parent); _spatialStructure = new MoBiSpatialStructure().WithTopContainer(_parent); sut.Edit(_spatialStructure); }
public UniformDistributionFormula CreateUniformDistributionFormulaFor(IDistributedParameter distributedParameter, IParameter minParameter, IParameter maxParameter) { var distribution = createDistribution <UniformDistributionFormula>(); distribution.Dimension = minParameter.Dimension; addObjectPathToDistributionFormula(distribution, distributedParameter, minParameter, Constants.Distribution.MINIMUM); addObjectPathToDistributionFormula(distribution, distributedParameter, maxParameter, Constants.Distribution.MAXIMUM); return(distribution); }
protected override void Context() { base.Context(); A.CallTo(() => _formulaTypeMapper.MapFrom(_targetParameter)).Returns(FormulaType.Distribution); _targetDistributedParameter = DomainHelperForSpecs.NormalDistributedParameter(); _targetParameter = _targetDistributedParameter; _sourceParameter.Value = 1.2; _targetParameter.Value = 1.2; }
protected override void Context() { base.Context(); _distributedParameter = new DistributedParameter().WithName("DP").WithFormula(new LogNormalDistributionFormula()); _distributedParameter.Add( new Parameter().WithName(Constants.Distribution.MEAN).WithFormula(new ConstantFormula().WithValue(2))); _geoSDParameter = new Parameter().WithName(Constants.Distribution.GEOMETRIC_DEVIATION).WithFormula(new ConstantFormula().WithValue(_geometricDeviation)); _distributedParameter.Add(_geoSDParameter); }
protected override void Context() { base.Context(); _unit = A.Fake <Unit>(); _distributedParameter = A.Fake <IDistributedParameter>(); _meanParameter = A.Fake <IParameter>(); _distributedParmaeterDTO = new DistributionParameterDTO(_meanParameter); sut.Edit(_distributedParameter); }
public LogNormalDistributionFormula CreateLogNormalDistributionFormulaFor(IDistributedParameter distributedParameter, IParameter meanParameter, IParameter deviationParameter) { var distribution = createDistribution <LogNormalDistributionFormula>(); distribution.Dimension = meanParameter.Dimension; addObjectPathToDistributionFormula(distribution, distributedParameter, meanParameter, Constants.Distribution.MEAN); addObjectPathToDistributionFormula(distribution, distributedParameter, deviationParameter, Constants.Distribution.GEOMETRIC_DEVIATION); return(distribution); }
public UpdateDistributedFormulaCommand(IDistributedParameter parameter, IDistributionFormula newFormula, string formulaType, IBuildingBlock buildingBlock) : base(buildingBlock) { _parameter = parameter; _parameterId = parameter.Id; _newFormula = newFormula; _oldFormula = _parameter.Formula; Description = AppConstants.Commands.UpdateDistributedFormulaCommandDescription(parameter.EntityPath(), formulaType); ObjectType = ObjectTypes.DistributedParameter; CommandType = Command.CommandTypeEdit; }
protected override void Context() { _buildingBlock = A.Fake <IBuildingBlock>(); _parameter = new DistributedParameter(); _parameter.Formula = new DiscreteDistributionFormula(); _newFormula = new LogNormalDistributionFormula(); _formulaType = "XX"; sut = new UpdateDistributedFormulaCommand(_parameter, _newFormula, _formulaType, _buildingBlock); _context = A.Fake <IMoBiContext>(); }
protected override void Context() { _entityPathResolver = A.Fake <IEntityPathResolver>(); _parameterFactory = A.Fake <IParameterFactory>(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); _distributedParameter = A.Fake <IDistributedParameter>(); A.CallTo(() => _parameterFactory.CreateFor(A <ParameterDistributionMetaData> ._)) .Invokes(x => _distributionMetaData = x.GetArgument <ParameterDistributionMetaData>(0)).Returns(_distributedParameter); sut = new AdvancedParameterFactory(_entityPathResolver, _parameterFactory, _objectBaseFactory); }
protected override void Context() { base.Context(); A.CallTo(() => _formulaTypeMapper.MapFrom(_targetParameter)).Returns(FormulaType.Distribution); A.CallTo(() => _formulaTypeMapper.MapFrom(_sourceParameter)).Returns(FormulaType.Table); _targetDistributedParameter = DomainHelperForSpecs.NormalDistributedParameter(); _targetParameter = _targetDistributedParameter; _sourceParameter.Formula = new DistributedTableFormula { Percentile = 0.2 }; }
public IDistributionFormula CreateFor(IDistributionMetaData distribution, IDistributedParameter parameter) { foreach (var factory in _allDistributionFactory) { if (factory.IsSatisfiedBy(distribution)) { return(factory.CreateFor(distribution, parameter)); } } throw new DistributionNotFoundException(distribution); }
public override void UpdateInternalFrom(IBuildingBlockChangeCommand originalCommand) { base.UpdateInternalFrom(originalCommand); var switchDistributionTypeCommand = originalCommand as SwitchAdvancedParameterDistributionTypeCommand; if (switchDistributionTypeCommand == null) { return; } _newDistributedParameter = switchDistributionTypeCommand._oldDistributedParameter; _oldDistributedParameter = switchDistributionTypeCommand._newDistributedParameter; }
protected override void Context() { _topContainer = new Container().WithName("top"); _organ = new Container().WithName("organ").WithParentContainer(_topContainer); _comp = new Container().WithName("comp").WithParentContainer(_organ); _parameter = new DistributedParameter().WithName("P1").WithParentContainer(_comp); new Parameter().WithName("LALA").WithParentContainer(_parameter); _reak = A.Fake <IUsingFormula>(); A.CallTo(() => _reak.ParentContainer).Returns(_topContainer); A.CallTo(() => _reak.RootContainer).Returns(_topContainer); sut = new ObjectPathFactory(new AliasCreator()); }
public override void RestoreExecutionData(IExecutionContext context) { base.RestoreExecutionData(context); _advancedParameterContainer = context.Get <RandomPopulation>(BuildingBlockId); _parameter = context.Get <IParameter>(ParameterId); var entityPathResolver = context.Resolve <IEntityPathResolver>(); _advancedParameter = _advancedParameterContainer.AdvancedParameterFor(entityPathResolver, _parameter); _oldDistributedParameter = context.Deserialize <IDistributedParameter>(_serializationStream); _newDistributedParameter = _advancedParameter.DistributedParameter; _newDistributionType = _advancedParameter.DistributionType; }
private void addObjectPathToDistributionFormula(IDistributionFormula distribution, IDistributedParameter distributedParameter, IParameter usedParameter, string alias) { var usedParameterPath = _objectPathFactory.CreateRelativeFormulaUsablePath(distributedParameter, usedParameter); usedParameterPath.Alias = alias; usedParameterPath.Dimension = usedParameter.Dimension; distribution.AddObjectPath(usedParameterPath); }
protected override void Context() { base.Context(); _buildingBlock = A.Fake <IBuildingBlock>(); _parentContainer = A.Fake <IContainer>(); var modalPresenter = A.Fake <IModalPresenter>(); _distributedParameter = A.Fake <IDistributedParameter>(); A.CallTo(_context.ApplicationController).WithReturnType <IModalPresenter>().Returns(modalPresenter); A.CallTo(() => modalPresenter.Show()).Returns(true); A.CallTo(() => _context.Context.Create <IDistributedParameter>()).Returns(_distributedParameter); }
private TableFormula createTableFormulaFrom(IDistributedParameter individualParameter, IReadOnlyList <ParameterDistributionMetaData> allDistributionsWithAgeStrictBiggerThanOriginData) { var parameter = new TableFormulaParameter <IDistributedParameter> { OriginData = _baseOriginData, Parameter = individualParameter, Value = individualParameter.Value, Percentile = individualParameter.Percentile }; return(createTableFormulaFrom(parameter, allDistributionsWithAgeStrictBiggerThanOriginData)); }