Changeset 5277 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/Crossovers/ParameterConfigurationCrossover.cs
- 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/Crossovers/ParameterConfigurationCrossover.cs
r5207 r5277 58 58 ParameterConfigurationTree child2 = (ParameterConfigurationTree)ParentsParameter.ActualValue[1]; 59 59 60 child1.Cross(RandomParameter.ActualValue, child2, Cross, this);60 child1.Cross(RandomParameter.ActualValue, child2, Cross, IntValueCrossoverParameter.ActualValue, DoubleValueCrossoverParameter.ActualValue); 61 61 this.ChildParameter.ActualValue = child1; 62 62 … … 64 64 } 65 65 66 private static void Cross(IRandom random, IOptimizable configuartion, ParameterConfigurationCrossover pccross) { 67 if (configuartion is IValueConfiguration) { 68 var vc = configuartion as IValueConfiguration; 66 public static void Apply(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { 67 configuartion.Cross(random, other, Cross, intValueCrossover, doubleValueCrossover); 68 } 69 70 private static void Cross(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { 71 var vc = configuartion as IValueConfiguration; 72 var pc = configuartion as IParameterConfiguration; 73 if (vc != null) { 69 74 var value = vc.ActualValue.Value; 70 75 var range = vc.RangeConstraint; 71 76 72 77 if (value is IntValue) { 73 pccross.IntValueCrossoverParameter.ActualValue.Apply(random, (IntValue)value, (IntValueRange)range);78 intValueCrossover.Apply(random, (IntValue)value, (IntValue)((IValueConfiguration)other).ActualValue.Value, (IntValueRange)range); 74 79 } else if (value is PercentValue) { 75 pccross.DoubleValueCrossoverParameter.ActualValue.Apply(random, (PercentValue)value, ((PercentValueRange)range).AsDoubleValueRange());80 doubleValueCrossover.Apply(random, (PercentValue)value, (DoubleValue)((IValueConfiguration)other).ActualValue.Value, ((PercentValueRange)range).AsDoubleValueRange()); 76 81 } else if (value is DoubleValue) { 77 pccross.DoubleValueCrossoverParameter.ActualValue.Apply(random, (DoubleValue)value, (DoubleValueRange)range);82 doubleValueCrossover.Apply(random, (DoubleValue)value, (DoubleValue)((IValueConfiguration)other).ActualValue.Value, (DoubleValueRange)range); 78 83 } 79 } else if (configuartion is IParameterConfiguration) { 80 84 } else if (pc != null) { 85 if (random.NextDouble() > 0.5) { 86 pc.ActualValueConfigurationIndex = ((ParameterConfiguration)other).ActualValueConfigurationIndex; 87 } 88 pc.ActualValue = pc.ValueConfigurations[pc.ActualValueConfigurationIndex].ActualValue; 81 89 } 82 90 }
Note: See TracChangeset
for help on using the changeset viewer.