public virtual void Init(ParamSet paramSet) { int NParam = 0; foreach (ComponentType type in this.componentTypeList) { IComponentBase component = this.GetComponent(type); string str = (string)(object)type; foreach (PropertyInfo propertyInfo in component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty)) { if (this.optimizationParemeters.Contains((object)(str + propertyInfo.Name))) { foreach (Attribute attribute in propertyInfo.GetCustomAttributes(false)) { if (attribute.GetType() == typeof(OptimizationParameterAttribute)) { OptimizationParameterAttribute parameterAttribute = attribute as OptimizationParameterAttribute; paramSet.SetParamName(NParam, str + propertyInfo.Name); paramSet.SetParam(NParam, parameterAttribute.LowerBound + (parameterAttribute.UpperBound - parameterAttribute.LowerBound) / 2.0); paramSet.SetLowerBound(NParam, parameterAttribute.LowerBound); paramSet.SetUpperBound(NParam, parameterAttribute.UpperBound); paramSet.SetSteps(NParam, parameterAttribute.Step); if (propertyInfo.PropertyType == typeof(int)) paramSet.SetParamType(NParam, EParamType.Int); else paramSet.SetParamType(NParam, EParamType.Float); ++NParam; } } } } } foreach (StrategyBase strategyBase in this.strategies) { if (strategyBase.IsEnabled) { foreach (ComponentType type in strategyBase.ComponentTypeList) { IComponentBase component = strategyBase.GetComponent(type); string str = (string)(object)type; foreach (PropertyInfo propertyInfo in component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty)) { if (this.optimizationParemeters.Contains((object)(str + propertyInfo.Name))) { foreach (Attribute attribute in propertyInfo.GetCustomAttributes(false)) { if (attribute.GetType() == typeof(OptimizationParameterAttribute)) { OptimizationParameterAttribute parameterAttribute = attribute as OptimizationParameterAttribute; paramSet.SetParamName(NParam, str + propertyInfo.Name); paramSet.SetParam(NParam, parameterAttribute.LowerBound + (parameterAttribute.UpperBound - parameterAttribute.LowerBound) / 2.0); paramSet.SetLowerBound(NParam, parameterAttribute.LowerBound); paramSet.SetUpperBound(NParam, parameterAttribute.UpperBound); paramSet.SetSteps(NParam, parameterAttribute.Step); if (propertyInfo.PropertyType == typeof(int)) paramSet.SetParamType(NParam, EParamType.Int); else paramSet.SetParamType(NParam, EParamType.Float); ++NParam; } } } } } } } }
public void Init(ParamSet paramSet) { int num = 0; foreach (Dictionary<string, OptimizationParameter> dictionary in this.parameters.Values) { foreach (OptimizationParameter optimizationParameter in dictionary.Values) { if (optimizationParameter.Enabled) { paramSet.SetParamName(num, optimizationParameter.Name); paramSet.SetParam(num, optimizationParameter.Start + (optimizationParameter.Stop - optimizationParameter.Start) / 2.0); paramSet.SetLowerBound(num, optimizationParameter.Start); paramSet.SetUpperBound(num, optimizationParameter.Stop); paramSet.SetSteps(num, optimizationParameter.Step); paramSet.SetParamType(num, optimizationParameter.Type); optimizationParameter.Number = num; ++num; } } } }