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));
						}
					}
				}
			}
		}