Changeset 5277 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Manipulators
- Timestamp:
- 01/11/11 16:00:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Manipulators/ParameterConfigurationManipulator.cs
r5112 r5277 49 49 50 50 public sealed override IOperation Apply() { 51 Apply(RandomParameter.ActualValue, ParameterConfigurationTreeParameter.ActualValue, this);51 Apply(RandomParameter.ActualValue, ParameterConfigurationTreeParameter.ActualValue, IntValueManipulatorParameter.ActualValue, DoubleValueManipulatorParameter.ActualValue); 52 52 return base.Apply(); 53 53 } 54 54 55 public static void Apply(IRandom random, IValueConfiguration configuration, ParameterConfigurationManipulator pcmanip) {56 configuration.Mutate(random, Mutate, pcmanip);55 public static void Apply(IRandom random, IValueConfiguration configuration, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { 56 configuration.Mutate(random, Mutate, intValueManipulator, doubleValueManipulator); 57 57 } 58 58 59 private static void Mutate(IRandom random, IOptimizable configuration, ParameterConfigurationManipulator pcmanip) { 60 if (configuration is IValueConfiguration) { 61 var vc = configuration as IValueConfiguration; 59 private static void Mutate(IRandom random, IOptimizable configuration, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { 60 var vc = configuration as IValueConfiguration; 61 var pc = configuration as IParameterConfiguration; 62 63 if (vc != null) { 62 64 var value = vc.ActualValue.Value; 63 65 var range = vc.RangeConstraint; 64 66 if (value is IntValue) { 65 pcmanip.IntValueManipulatorParameter.ActualValue.Apply(random, (IntValue)value, (IntValueRange)range);67 intValueManipulator.Apply(random, (IntValue)value, (IntValueRange)range); 66 68 } else if (value is PercentValue) { 67 pcmanip.DoubleValueManipulatorParameter.ActualValue.Apply(random, (PercentValue)value, ((PercentValueRange)range).AsDoubleValueRange());69 doubleValueManipulator.Apply(random, (PercentValue)value, ((PercentValueRange)range).AsDoubleValueRange()); 68 70 } else if (value is DoubleValue) { 69 pcmanip.DoubleValueManipulatorParameter.ActualValue.Apply(random, (DoubleValue)value, (DoubleValueRange)range);71 doubleValueManipulator.Apply(random, (DoubleValue)value, (DoubleValueRange)range); 70 72 } 71 } else if (configuration is IParameterConfiguration) { 72 var pc = configuration as IParameterConfiguration; 73 pc.ActualValueConfigurationIndex = random.Next(pc.ValueConfigurations.CheckedItems.Count()); 74 pc.ActualValue = pc.ValueConfigurations.CheckedItems.ElementAt(pc.ActualValueConfigurationIndex).ActualValue; 73 } else if (pc != null) { 74 do { 75 pc.ActualValueConfigurationIndex = random.Next(pc.ValueConfigurations.Count()); 76 } while (!pc.ValueConfigurations.ItemChecked(pc.ValueConfigurations[pc.ActualValueConfigurationIndex])); 77 pc.ActualValue = pc.ValueConfigurations[pc.ActualValueConfigurationIndex].ActualValue; 75 78 } 76 79 }
Note: See TracChangeset
for help on using the changeset viewer.