protected override void Context() { base.Context(); _individualValues = new IndividualValues(); _individualValues.AddParameterValue(new ParameterValue("PATH1", 5, 0.5)); _individualValues.AddParameterValue(new ParameterValue("PATH2", 10, 0.8)); }
protected override void Context() { var pathParameterIndividual = "individual"; _pathParameterAdvanced = "advanced"; var anotherPath = "another"; sut = new RandomPopulation(); sut.SetAdvancedParameters(new AdvancedParameterCollection()); _baseIndividual = A.Fake <Individual>(); sut.Settings = new RandomPopulationSettings { BaseIndividual = _baseIndividual }; _entityPathResolver = A.Fake <IEntityPathResolver>(); _individualValues = new IndividualValues(); _individualValues.AddParameterValue(new ParameterValue(pathParameterIndividual, 10, 0.1)); _individualValues.AddParameterValue(new ParameterValue(_pathParameterAdvanced, 20, 0.2)); _oneAdvancedParameter = A.Fake <IParameter>().WithName("Advanced"); A.CallTo(() => _oneAdvancedParameter.IsChangedByCreateIndividual).Returns(false); _oneAdvancedParameter.Visible = true; _individualParameter = A.Fake <IParameter>().WithName("Individual"); A.CallTo(() => _individualParameter.IsChangedByCreateIndividual).Returns(true); _individualParameter.Visible = true; _anotherParameter = A.Fake <IParameter>().WithName("Another"); A.CallTo(() => _anotherParameter.IsChangedByCreateIndividual).Returns(true); _anotherParameter.Visible = true; A.CallTo(() => _entityPathResolver.PathFor(_oneAdvancedParameter)).Returns(_pathParameterAdvanced); A.CallTo(() => _entityPathResolver.PathFor(_individualParameter)).Returns(pathParameterIndividual); A.CallTo(() => _entityPathResolver.PathFor(_anotherParameter)).Returns(anotherPath); A.CallTo(() => _baseIndividual.GetAllChildren <IParameter>()).Returns(new[] { _individualParameter, _oneAdvancedParameter, _anotherParameter }); sut.AddIndividualValues(_individualValues); }
public IndividualValues MapFrom(Individual individual, PathCache <IParameter> updatedParameters) { var individualValues = new IndividualValues(); individualValues.AddCovariate(Constants.Population.GENDER, individual.OriginData.Gender.Name); individualValues.AddCovariate(Constants.Population.POPULATION, individual.OriginData.SpeciesPopulation.Name); updatedParameters.KeyValues.Each(paraKey => individualValues.AddParameterValue(parameterValueFrom(paraKey))); return(individualValues); }