Ejemplo n.º 1
0
		public virtual void Update(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))
							{
								if (propertyInfo.PropertyType == typeof(int))
									propertyInfo.SetValue((object)component, (object)(int)paramSet.GetParam(NParam), (object[])null);
								if (propertyInfo.PropertyType == typeof(double))
									propertyInfo.SetValue((object)component, (object)paramSet.GetParam(NParam), (object[])null);
								++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))
									{
										if (propertyInfo.PropertyType == typeof(int))
											propertyInfo.SetValue((object)component, (object)(int)paramSet.GetParam(NParam), (object[])null);
										if (propertyInfo.PropertyType == typeof(double))
											propertyInfo.SetValue((object)component, (object)paramSet.GetParam(NParam), (object[])null);
										++NParam;
									}
								}
							}
						}
					}
				}
			}
		}
Ejemplo n.º 2
0
		public void Update(ParamSet paramSet)
		{
			foreach (StrategyRunner strategyRunner in this.solutionRunner.Runners.Values)
			{
				if (strategyRunner.Enabled)
				{
					Strategy strategy = strategyRunner.Strategy;
					Dictionary<string, OptimizationParameter> dictionary = this.parameters[strategyRunner.StrategyName];
					foreach (FieldInfo fieldInfo in strategy.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
					{
						if (dictionary.ContainsKey(fieldInfo.Name) && dictionary[fieldInfo.Name].Enabled)
						{
							int number = dictionary[fieldInfo.Name].Number;
							if (fieldInfo.FieldType == typeof(int))
								fieldInfo.SetValue((object)strategy, (object)(int)paramSet.GetParam(number));
							if (fieldInfo.FieldType == typeof(double))
								fieldInfo.SetValue((object)strategy, (object)paramSet.GetParam(number));
						}
					}
				}
			}
		}
Ejemplo n.º 3
0
		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;
									}
								}
							}
						}
					}
				}
			}
		}
Ejemplo n.º 4
0
		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;
					}
				}
			}
		}