Beispiel #1
0
 protected override void Context()
 {
     base.Context();
     _advancedParameter = A.Fake <AdvancedParameter>();
     _advancedParameter.ParameterPath = "A NEW PARAMETER PATH";
     sut.AddAdvancedParameter(_advancedParameter, generateRandomValues: false);
 }
 protected override void Context()
 {
     base.Context();
     _parameterPath      = "Liver|P1";
     _originalSimulation = new PopulationSimulation();
     _originalSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("Pop", PKSimBuildingBlockType.Population)
     {
         BuildingBlock = _population
     });
     _originalSimulation.Add(new AdvancedParameterCollection().WithName("AdvancedParameterCollection"));
     _advancedParameter = A.Fake <AdvancedParameter>();
     _advancedParameter.ParameterPath = _parameterPath;
     A.CallTo(() => _advancedParameter.GenerateRandomValues(3)).Returns(new []
     {
         new RandomValue {
             Percentile = 0.5, Value = 1
         },
         new RandomValue {
             Percentile = 0.5, Value = 2
         },
         new RandomValue {
             Percentile = 0.5, Value = 3
         },
     });
     _originalSimulation.AddAdvancedParameter(_advancedParameter, generateRandomValues: true);
 }
 protected override void Context()
 {
     base.Context();
     _anotherPopulation = A.Fake <RandomPopulation>();
     _parameter         = new AdvancedParameter();
     sut.EditPopulation(_population);
 }
 protected override void Context()
 {
     base.Context();
     _advancedParameter = A.Fake <AdvancedParameter>();
     _advancedParameter.ParameterPath = "A NEW PARAMETER PATH";
     sut.AddAdvancedParameter(_advancedParameter);
 }
        protected override void Context()
        {
            base.Context();
            _individualPropertiesCache = A.Fake <IndividualValuesCache>();
            _patchCache = new PathCacheForSpecs <IParameter>();
            var individualParameter = A.Fake <IParameter>();

            A.CallTo(() => individualParameter.IsChangedByCreateIndividual).Returns(true);
            _patchCache.Add("Path1", individualParameter);

            var advancedParameter = A.Fake <IParameter>();

            A.CallTo(() => advancedParameter.IsChangedByCreateIndividual).Returns(false);
            advancedParameter.CanBeVariedInPopulation = true;
            _patchCache.Add("PathAdvanced", advancedParameter);

            A.CallTo(() => _individualPropertiesCache.AllParameterPaths()).Returns(new[] { "Path1", "Path2", "PathAdvanced" });
            A.CallTo(() => _individualPropertiesCache.ParameterValuesFor("Path1")).Returns(_value1);
            A.CallTo(() => _individualPropertiesCache.ParameterValuesFor("Path2")).Returns(_value2);
            A.CallTo(() => _individualPropertiesCache.ParameterValuesFor("PathAdvanced")).Returns(_value3);
            _populationSimulation = A.Fake <PopulationSimulation>();
            _parameterValueCache  = A.Fake <ParameterValuesCache>();
            A.CallTo(() => _populationSimulation.ParameterValuesCache).Returns(_parameterValueCache);
            _mobiPopulation = A.Fake <MoBiPopulation>();
            A.CallTo(_simulationFactory).WithReturnType <PopulationSimulation>().Returns(_populationSimulation);
            A.CallTo(() => _objectBaseFactory.Create <MoBiPopulation>()).Returns(_mobiPopulation);
            A.CallTo(() => _parameterRetriever.ParametersFrom(_populationSimulation)).Returns(_patchCache);
            A.CallTo(() => _individualPropertiesCacheImporter.ImportFrom(_populationFile, _patchCache, A <IImportLogger> ._)).Returns(_individualPropertiesCache);

            _advancedParameterContainer = new AdvancedParameter();
            A.CallTo(() => _advancedParameterFactory.Create(advancedParameter, DistributionTypes.Unknown)).Returns(_advancedParameterContainer);
        }
Beispiel #6
0
 public void Edit(AdvancedParameter advancedParameter)
 {
     _advancedParameter    = advancedParameter;
     _advancedParameterDTO = _advancedParameterDTOMapper.MapFrom(_advancedParameter);
     _distributionParameterPresenter.Edit(_advancedParameterDTO.Parameters);
     _view.BindTo(_advancedParameterDTO);
 }
Beispiel #7
0
 public void RemoveSelectionFor(AdvancedParameter advancedParameter)
 {
     if (Equals(advancedParameter, _advancedParameter))
     {
         RemoveSelection();
     }
 }
Beispiel #8
0
        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 <AdvancedParameter>().WithName("Molecule1RefConf");
            _advancedParameterMolecule1RefConc.ParameterPath = "Path1";

            _advancedParameterMolecule2HalfLifeIntestine = A.Fake <AdvancedParameter>().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();
     _advancedParameter = new AdvancedParameter();
     //in this scenario, _advancedPara1 is being deleted from the advanced parameters
     _advancedParameter.ParameterPath = _pathAdvancedPara1;
     sut.EditPopulation(_population);
 }
 protected override void Context()
 {
     base.Context();
     _advancedParameter = A.Fake <AdvancedParameter>();
     //in this scenario, para1 was selected to become and advanced parameter
     _advancedParameter.ParameterPath = _pathPara1;
     sut.EditPopulation(_population);
 }
 protected override void ClearReferences()
 {
     _advancedParameter          = null;
     _advancedParameterContainer = null;
     _parameter = null;
     _oldDistributedParameter = null;
     _newDistributedParameter = null;
 }
 protected override void Context()
 {
     base.Context();
     _command           = A.Fake <IPKSimCommand>();
     _advancedParameter = new AdvancedParameter();
     _advancedParameter.ParameterPath = _pathAdvancedPara1;
     A.CallTo(() => _advancedParametersTask.SwitchDistributionTypeFor(_advancedPara1, _population, DistributionTypes.Normal)).Returns(_command);
     sut.EditPopulation(_population);
 }
 protected override void Context()
 {
     base.Context();
     _parameter         = A.Fake <IParameter>();
     _node              = A.Fake <ITreeNode>();
     _advancedParameter = new AdvancedParameter();
     sut.EditPopulation(_population);
     A.CallTo(() => _population.AdvancedParameterFor(_entityPathResolver, _parameter)).Returns(_advancedParameter);
 }
 protected override void Context()
 {
     base.Context();
     sut.EditPopulation(_population);
     _advancedParameter = new  AdvancedParameter();
     _parameter         = new PKSimParameter().WithName("tralala");
     _treeNode          = new ObjectWithIdAndNameNode <IParameter>(_parameter);
     A.CallTo(() => _population.AdvancedParameterFor(_entityPathResolver, _parameter)).Returns(_advancedParameter);
 }
 public AdvancedParameterDTO MapFrom(AdvancedParameter advancedParameter)
 {
     return(new AdvancedParameterDTO
     {
         DistributionType = advancedParameter.DistributionType,
         ParameterFullDisplayName = advancedParameter.FullDisplayName,
         Parameters = advancedParameter.AllParameters
     });
 }
Beispiel #16
0
 protected override void Context()
 {
     base.Context();
     _p1 = A.Fake <IParameter>();
     _allParameters.AddRange(new[] { _p1 });
     sut.EditPopulation(_population);
     _advancedParameterThatDoesNotExist = new AdvancedParameter {
         ParameterPath = "DOES NOT EXIT"
     };
 }
        public void RemoveAdvancedParameter(AdvancedParameter advancedParameter)
        {
            var parameter = parameterFor(advancedParameter);

            if (parameter == null)
            {
                return;
            }
            _parametersPresenter.RemoveParameter(parameter);
            refresh();
        }
        public void AddAdvancedParameter(AdvancedParameter advancedParameter)
        {
            var parameter = parameterFor(advancedParameter);

            if (parameter == null)
            {
                return;
            }
            _parametersPresenter.AddParameter(parameter);
            _parametersPresenter.SelectParameter(parameter);
        }
Beispiel #19
0
        protected override async Task Context()
        {
            await base.Context();

            _allImportedParameters.AddRange(new[] { "P1", "P2" });
            _allParameters.Add("P1", new PKSimParameter().WithName("P1"));
            _allParameters.Add("P2", new PKSimParameter().WithName("P2"));
            _allCreateIndividualParameters.Add("P1", _allParameters.FindByName("P1"));
            _advancedParameter = new AdvancedParameter();
            A.CallTo(() => _advancedParameterFactory.Create(_allParameters.FindByName("P2"), DistributionTypes.Unknown)).Returns(_advancedParameter);
            A.CallTo(() => _createdPopulation.IndividualPropertiesCache.AllParameterPaths()).Returns(_allImportedParameters);
        }
        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;
        }
Beispiel #21
0
 protected override void Context()
 {
     base.Context();
     _allImportedParameters.AddRange(new[] { "P1", "P2" });
     _allParameters.Add("P1", new PKSimParameter().WithName("P1"));
     _allParameters.Add("P2", new PKSimParameter().WithName("P2"));
     _allCreateIndividualParameters.Add("P1", _allParameters.FindByName("P1"));
     _advancedParameter = new AdvancedParameter();
     A.CallTo(() => _containerTask.CacheAllChildren <IParameter>(_cloneIndividual)).Returns(_allParameters);
     A.CallTo(() => _containerTask.CacheAllChildrenSatisfying(_cloneIndividual, A <Func <IParameter, bool> > ._)).Returns(_allCreateIndividualParameters);
     A.CallTo(() => _advancedParameterFactory.Create(_allParameters.FindByName("P2"), DistributionTypes.Unknown)).Returns(_advancedParameter);
     A.CallTo(() => _createdPopulation.IndividualPropertiesCache.AllParameterPaths()).Returns(_allImportedParameters);
 }
Beispiel #22
0
 protected override void Context()
 {
     base.Context();
     _parameter         = A.Fake <IParameter>();
     _advancedParameter = A.Fake <AdvancedParameter>().WithId("Id");
     _advancedParameter.ParameterPath = "A NEW PARAMETER PATH";
     A.CallTo(() => _entityPathResolver.PathFor(_parameter)).Returns(_advancedParameter.ParameterPath);
     _randomValues = new List <RandomValue>
     {
         new RandomValue {
             Value = 1, Percentile = 0.5
         },
     };
     A.CallTo(() => _advancedParameter.GenerateRandomValues(sut.NumberOfItems)).Returns(_randomValues);
 }
 protected override void Context()
 {
     base.Context();
     _parameter             = A.Fake <IDistributedParameter>();
     _distributedParameters = new PathCacheForSpecs <IParameter> {
         { "P1", _parameter }
     };
     _populationSimulation = A.Fake <PopulationSimulation>();
     _mobiPopulation       = A.Fake <MoBiPopulation>();
     _advancedParameter    = new AdvancedParameter();
     _parameterValueCache  = A.Fake <ParameterValuesCache>();
     A.CallTo(() => _populationSimulation.ParameterValuesCache).Returns(_parameterValueCache);
     A.CallTo(_simulationFactory).WithReturnType <PopulationSimulation>().Returns(_populationSimulation);
     A.CallTo(() => _objectBaseFactory.Create <MoBiPopulation>()).Returns(_mobiPopulation);
     A.CallTo(() => _objectBaseFactory.Create <AdvancedParameter>()).Returns(_advancedParameter);
     A.CallTo(_parameterRetriever).WithReturnType <PathCache <IParameter> >().Returns(_distributedParameters);
 }
Beispiel #24
0
        protected override void Context()
        {
            base.Context();
            _populationSimulation            = new PopulationSimulation();
            _populationSimulation.Model      = new OSPSuite.Core.Domain.Model();
            _populationSimulation.Model.Root = new Container();
            var randomPopulation = new RandomPopulation();

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("id", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = randomPopulation
            });
            _populationSimulation.SetAdvancedParameters(new AdvancedParameterCollection());
            _populationSimulation.Add(new Parameter().WithName("Param1"));
            _advancedParameter = new AdvancedParameter {
                ParameterPath = "OLD|Param1"
            };
            _populationSimulation.AddAdvancedParameter(_advancedParameter);
            _populationSimulation.Name = "NEW";
        }
        public SwitchAdvancedParameterDistributionTypeCommand(IParameter parameter, IAdvancedParameterContainer advancedParameterContainer, DistributionType newDistributionType, IExecutionContext context)
        {
            _advancedParameterContainer = advancedParameterContainer;
            _newDistributionType        = newDistributionType;
            _parameter      = parameter;
            ParameterId     = parameter.Id;
            BuildingBlockId = _advancedParameterContainer.Id;
            var entityPathResolver       = context.Resolve <IEntityPathResolver>();
            var advancedParameterFactory = context.Resolve <IAdvancedParameterFactory>();

            _advancedParameter       = _advancedParameterContainer.AdvancedParameterFor(entityPathResolver, _parameter);
            _oldDistributedParameter = _advancedParameter.DistributedParameter;
            _oldDistributionType     = _advancedParameter.DistributionType;
            var newParameter = advancedParameterFactory.Create(_parameter, _newDistributionType);

            _newDistributedParameter = newParameter.DistributedParameter;
            ObjectType  = context.TypeFor(_advancedParameter);
            Description = PKSimConstants.Command.SwitchAdvancedParameterDistributionTypeDescription(_advancedParameter.ParameterPath, _oldDistributionType.ToString(), _newDistributionType.ToString());
            context.UpdateBuildingBlockPropertiesInCommand(this, _advancedParameterContainer);
        }
 protected override void Context()
 {
     base.Context();
     _moleculeParameterAsAdvanced = A.Fake <IParameter>();
     _molecule   = new IndividualEnzyme();
     _population = new RandomPopulation {
         Settings = new RandomPopulationSettings {
             BaseIndividual = new Individual()
         }
     };
     _population.Add(new AdvancedParameterCollection());
     _population.AddMolecule(_molecule);
     A.CallTo(() => _entityPathResolver.PathFor(_moleculeParameterAsAdvanced)).Returns("A|B");
     _molecule.Add(_moleculeParameterAsAdvanced);
     _advancedParameter = new AdvancedParameter {
         ParameterPath = "A|B", Name = "A|B"
     };
     _population.AddAdvancedParameter(_advancedParameter);
     _population.AddAdvancedParameter(new AdvancedParameter {
         ParameterPath = "ANOTHER PARAMETER", Name = "ANOTHER PARAMETER"
     });
 }
Beispiel #27
0
        private void addSurfaceAreaVariabilityTo(Population population)
        {
            var individual = population.FirstIndividual;

            if (individual == null)
            {
                return;
            }
            var factor = effectiveSurfaceAreaVariabilityParameterIn(individual) as IDistributedParameter;

            if (factor == null)
            {
                return;
            }
            var parameterPath = _entityPathResolver.PathFor(factor);
            //use a clone as this parameter will be used to create the advanced parameter
            var clone             = _cloner.Clone(factor);
            var advancedParameter = new AdvancedParameter {
                DistributedParameter = clone, Seed = population.Seed
            };
            var randomValues = advancedParameter.GenerateRandomValues(population.NumberOfItems);

            population.IndividualPropertiesCache.Add(randomValues.Select(rv => new ParameterValue(parameterPath, rv.Value, rv.Percentile)).ToList());
        }
 private IParameter parameterFor(AdvancedParameter advancedParameter)
 {
     return(_allParametersCache[advancedParameter.ParameterPath]);
 }
 public void Select(AdvancedParameter advancedParameter)
 {
     _parametersPresenter.SelectParameter(_allParametersCache[advancedParameter.ParameterPath]);
 }
 protected override void Because()
 {
     _advancedParameter = sut.Create(_parameter, DistributionTypes.Uniform);
 }