- Timestamp:
- 01/11/11 16:00:17 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
- Files:
-
- 2 added
- 14 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 } -
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 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterCombinationsEnumerator.cs
r5184 r5277 82 82 83 83 foreach (var valueConfiguration in pc.ValueConfigurations.CheckedItems) { 84 if (valueConfiguration. Optimize) {85 var enumerator = new ParameterCombinationsEnumerator(valueConfiguration );84 if (valueConfiguration.Value.Optimize) { 85 var enumerator = new ParameterCombinationsEnumerator(valueConfiguration.Value); 86 86 enumerator.Reset(); 87 87 valueEnumerator.AddEnumerator(enumerator); 88 88 } else { 89 valueEnumerator.AddEnumerator(new List<IItem> { valueConfiguration }.GetEnumerator());89 valueEnumerator.AddEnumerator(new List<IItem> { valueConfiguration.Value }.GetEnumerator()); 90 90 } 91 91 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5267 r5277 12 12 using System.Reflection; 13 13 using HeuristicLab.Optimization; 14 using HeuristicLab.Collections; 14 15 15 16 namespace HeuristicLab.Problems.MetaOptimization { … … 78 79 79 80 [Storable] 80 protected ICheckedValueConfiguration CollectionvalueConfigurations;81 public ICheckedValueConfiguration CollectionValueConfigurations {81 protected ICheckedValueConfigurationList valueConfigurations; 82 public ICheckedValueConfigurationList ValueConfigurations { 82 83 get { return this.valueConfigurations; } 83 84 protected set { … … 135 136 validTypes = new List<Type>(validTypes) { typeof(NullValue) }.ToArray(); 136 137 } 137 this.ValueConfigurations = new CheckedValueConfiguration Collection();138 this.ValueConfigurations = new CheckedValueConfigurationList(); 138 139 this.ActualValue = new ConstrainedValue( 139 140 valueParameter.Value != null ? (IItem)valueParameter.Value.Clone() : null, … … 173 174 174 175 private void RegisterValueConfigurationEvents() { 175 this.ValueConfigurations.CheckedItemsChanged += new Collection s.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_CheckedItemsChanged);176 this.ValueConfigurations.ItemsAdded += new Collection s.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsAdded);177 this.ValueConfigurations.ItemsRemoved += new Collection s.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsRemoved);176 this.ValueConfigurations.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_CheckedItemsChanged); 177 this.ValueConfigurations.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsAdded); 178 this.ValueConfigurations.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsRemoved); 178 179 } 179 180 180 181 private void DeregisterValueConfigurationEvents() { 181 this.ValueConfigurations.CheckedItemsChanged -= new Collection s.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_CheckedItemsChanged);182 this.ValueConfigurations.ItemsAdded -= new Collection s.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsAdded);183 this.ValueConfigurations.ItemsRemoved -= new Collection s.CollectionItemsChangedEventHandler<IValueConfiguration>(ValueConfigurations_ItemsRemoved);182 this.ValueConfigurations.CheckedItemsChanged -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_CheckedItemsChanged); 183 this.ValueConfigurations.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsAdded); 184 this.ValueConfigurations.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(ValueConfigurations_ItemsRemoved); 184 185 } 185 186 … … 268 269 } 269 270 270 void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<I ValueConfiguration> e) {271 void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 271 272 OnToStringChanged(); 272 273 } 273 void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<I ValueConfiguration> e) {274 void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 274 275 OnToStringChanged(); 275 276 } 276 void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<I ValueConfiguration> e) {277 void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 277 278 OnToStringChanged(); 278 279 } … … 360 361 361 362 if (this.ActualValue.Value is IParameterizedItem) { 362 string subParams = this.ValueConfigurations .CheckedItems.ElementAt(actualValueConfigurationIndex).ParameterInfoString;363 string subParams = this.ValueConfigurations[actualValueConfigurationIndex].ParameterInfoString; 363 364 if (!string.IsNullOrEmpty(subParams)) { 364 365 sb.Append(" ("); … … 383 384 if (Optimize) { 384 385 if (this.ActualValue.Value is IParameterizedItem) { 385 this.ValueConfigurations .CheckedItems.ElementAt(actualValueConfigurationIndex).Parameterize((IParameterizedItem)this.ActualValue.Value);386 this.ValueConfigurations[actualValueConfigurationIndex].Parameterize((IParameterizedItem)this.ActualValue.Value); 386 387 } 387 388 } … … 410 411 public void Randomize(IRandom random) { 411 412 if (Optimize) { 412 foreach (var vc in this.ValueConfigurations.CheckedItems) { 413 vc.Randomize(random); 414 } 415 actualValueConfigurationIndex = random.Next(ValueConfigurations.CheckedItems.Count()); 416 this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue; 417 } 418 } 419 420 public void Mutate(IRandom random, MutateDelegate mutate, ParameterConfigurationManipulator pcmanip) { 421 if (Optimize) { 422 foreach (IValueConfiguration vc in this.ValueConfigurations.CheckedItems) { 423 vc.Mutate(random, mutate, pcmanip); 424 } 425 mutate(random, this, pcmanip); 426 } 427 } 428 429 public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, ParameterConfigurationCrossover pccross) { 413 foreach (var vc in this.ValueConfigurations) { 414 if (this.ValueConfigurations.ItemChecked(vc)) { 415 vc.Randomize(random); 416 } 417 } 418 do { 419 actualValueConfigurationIndex = random.Next(ValueConfigurations.Count()); 420 } while (!this.ValueConfigurations.ItemChecked(this.ValueConfigurations[actualValueConfigurationIndex])); 421 this.ActualValue = this.ValueConfigurations[actualValueConfigurationIndex].ActualValue; 422 } 423 } 424 425 public void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { 426 if (Optimize) { 427 foreach (var vc in this.ValueConfigurations) { 428 if (this.ValueConfigurations.ItemChecked(vc)) { 429 vc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator); 430 } 431 } 432 mutate(random, this, intValueManipulator, doubleValueManipulator); 433 } 434 } 435 436 public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { 430 437 if (Optimize) { 431 438 IParameterConfiguration otherPc = (IParameterConfiguration)other; 432 439 for (int i = 0; i < this.ValueConfigurations.Count; i++) { 433 cross(random, other, pccross); 434 //this.ValueConfigurations.ElementAt(i).Cross(otherPc.ValueConfigurations.ElementAt(i), random); 435 } 436 //if (random.NextDouble() > 0.5) { 437 // actualValueConfigurationIndex = ((ParameterConfiguration)other).actualValueConfigurationIndex; 438 //} 439 //this.ActualValue = this.ValueConfigurations.CheckedItems.ElementAt(actualValueConfigurationIndex).ActualValue; 440 if (this.ValueConfigurations.ItemChecked(this.ValueConfigurations[i])) { 441 this.ValueConfigurations[i].Cross(random, otherPc.ValueConfigurations[i], cross, intValueCrossover, doubleValueCrossover); 442 } 443 } 444 cross(random, this, other, intValueCrossover, doubleValueCrossover); 440 445 } 441 446 } 442 447 443 448 public void UpdateActualValueIndexToItem(IValueConfiguration vc) { 444 for (int i = 0; i < this.ValueConfigurations.C heckedItems.Count(); i++) {445 if (this.ValueConfigurations. CheckedItems.ElementAt(i) == vc) {449 for (int i = 0; i < this.ValueConfigurations.Count(); i++) { 450 if (this.ValueConfigurations.ElementAt(i) == vc) { 446 451 this.actualValueConfigurationIndex = i; 447 452 return; -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs
r5231 r5277 6 6 using HeuristicLab.Common; 7 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 using HeuristicLab.Collections; 8 9 9 10 namespace HeuristicLab.Problems.MetaOptimization { … … 11 12 // todo: control creatable item types 12 13 [StorableClass] 13 public class CheckedValueConfiguration Collection : CheckedItemCollection<IValueConfiguration>, ICheckedValueConfigurationCollection{14 public class CheckedValueConfigurationList : CheckedItemList<IValueConfiguration>, ICheckedValueConfigurationList { 14 15 [Storable] 15 16 private int minItemCount = 1; … … 24 25 } 25 26 26 public CheckedValueConfiguration Collection(ItemSet<IItem> validValues) {27 public CheckedValueConfigurationList(ItemSet<IItem> validValues) { 27 28 this.validValues = validValues; 28 29 RegisterEvents(); 29 30 } 30 public CheckedValueConfiguration Collection() {31 public CheckedValueConfigurationList() { 31 32 RegisterEvents(); 32 33 } 33 34 [StorableConstructor] 34 protected CheckedValueConfiguration Collection(bool deserializing) : base(deserializing) {35 protected CheckedValueConfigurationList(bool deserializing) : base(deserializing) { 35 36 RegisterEvents(); 36 37 } 37 protected CheckedValueConfiguration Collection(CheckedValueConfigurationCollectionoriginal, Cloner cloner) : base(original, cloner) {38 protected CheckedValueConfigurationList(CheckedValueConfigurationList original, Cloner cloner) : base(original, cloner) { 38 39 this.minItemCount = original.MinItemCount; 39 40 this.validValues = original.validValues; … … 41 42 } 42 43 public override IDeepCloneable Clone(Cloner cloner) { 43 return new CheckedValueConfiguration Collection(this, cloner);44 return new CheckedValueConfigurationList(this, cloner); 44 45 } 45 46 [StorableHook(HookType.AfterDeserialization)] … … 49 50 50 51 private void RegisterEvents() { 51 this.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved); 52 } 53 private void DeregisterEvents() { 54 this.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved); 52 this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved); 55 53 } 56 54 57 private void CheckedValueConfigurationCollection_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) { 55 private void DeregisterEvents() { 56 this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved); 57 } 58 59 private void CheckedValueConfigurationList_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 58 60 // auch collectionreset gehört berücksichtigt 59 61 // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt … … 66 68 //} 67 69 } 70 68 71 } 69 72 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5231 r5277 245 245 } 246 246 247 public void Mutate(IRandom random, MutateDelegate mutate, ParameterConfigurationManipulator pcmanip) {247 public void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator) { 248 248 if (Optimize) { 249 249 if (rangeConstraint != null) { 250 mutate(random, this, pcmanip);250 mutate(random, this, intValueManipulator, doubleValueManipulator); 251 251 } else { 252 252 foreach (IParameterConfiguration pc in this.ParameterConfigurations) { 253 pc.Mutate(random, mutate, pcmanip);254 } 255 } 256 } 257 } 258 259 public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, ParameterConfigurationCrossover pccross) {253 pc.Mutate(random, mutate, intValueManipulator, doubleValueManipulator); 254 } 255 } 256 } 257 } 258 259 public void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover) { 260 260 if (Optimize) { 261 IValueConfiguration otherVc = (IValueConfiguration)other;262 261 if (rangeConstraint != null) { 263 cross(random, this, pccross); 264 265 //if (this.actualValue.ValueDataType == typeof(IntValue)) { 266 // //this.actualValue.Value = new IntValue((((IntValue)this.actualValue.Value).Value + ((IntValue)other.ActualValue.Value).Value) / 2); 267 268 // IntegerVector[] parents = new IntegerVector[2]; 269 // parents[0] = new IntegerVector(new int[] { ((IntValue)this.actualValue.Value).Value }); 270 // parents[1] = new IntegerVector(new int[] { ((IntValue)other.ActualValue.Value).Value }); 271 272 // this.actualValue.Value = new IntValue(HeuristicLab.Encodings.IntegerVectorEncoding.DiscreteCrossover.Apply(random, parents[0], parents[1]).First()); 273 274 //} else if (this.actualValue.ValueDataType == typeof(DoubleValue)) { 275 // //this.actualValue.Value = new DoubleValue((((DoubleValue)this.actualValue.Value).Value + ((DoubleValue)other.ActualValue.Value).Value) / 2); 276 // RealVector[] parents = new RealVector[2]; 277 // parents[0] = new RealVector(new double[] { ((DoubleValue)this.actualValue.Value).Value }); 278 // parents[1] = new RealVector(new double[] { ((DoubleValue)other.ActualValue.Value).Value }); 279 280 // if (random.NextDouble() < 0.5) { 281 // this.actualValue.Value = new DoubleValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First()); 282 // } else { 283 // this.actualValue.Value = new DoubleValue(HeuristicLab.Encodings.RealVectorEncoding.DiscreteCrossover.Apply(random, new ItemArray<RealVector>(parents)).First()); 284 // } 285 // //this.actualValue.Value = new DoubleValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First()); 286 287 //} else if (this.actualValue.ValueDataType == typeof(PercentValue)) { 288 // //this.actualValue.Value = new PercentValue((((PercentValue)this.actualValue.Value).Value + ((PercentValue)other.ActualValue.Value).Value) / 2); 289 290 // RealVector[] parents = new RealVector[2]; 291 // parents[0] = new RealVector(new double[] { ((PercentValue)this.actualValue.Value).Value }); 292 // parents[1] = new RealVector(new double[] { ((PercentValue)other.ActualValue.Value).Value }); 293 294 // if (random.NextDouble() < 0.5) { 295 // this.actualValue.Value = new PercentValue(AverageCrossover.Apply(random, new ItemArray<RealVector>(parents)).First()); 296 // } else { 297 // this.actualValue.Value = new PercentValue(HeuristicLab.Encodings.RealVectorEncoding.DiscreteCrossover.Apply(random, new ItemArray<RealVector>(parents)).First()); 298 // } 299 300 //} else if (this.actualValue.ValueDataType == typeof(BoolValue)) { 301 // if (random.NextDouble() > 0.5) 302 // this.actualValue.Value = this.actualValue.Value; 303 // else 304 // this.actualValue.Value = other.ActualValue.Value; 305 //} else { 306 // throw new NotImplementedException(); 307 //} 308 } else { 262 cross(random, this, other, intValueCrossover, doubleValueCrossover); 263 } else { 264 IValueConfiguration otherVc = (IValueConfiguration)other; 309 265 for (int i = 0; i < this.ParameterConfigurations.Count; i++) { 310 this.ParameterConfigurations.ElementAt(i).Cross(random, otherVc.ParameterConfigurations.ElementAt(i), cross, pccross);266 this.ParameterConfigurations.ElementAt(i).Cross(random, otherVc.ParameterConfigurations.ElementAt(i), cross, intValueCrossover, doubleValueCrossover); 311 267 } 312 268 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/HeuristicLab.Problems.MetaOptimization-3.3.csproj
r5184 r5277 149 149 <Compile Include="Interfaces\IParameterConfigurationCrossover.cs" /> 150 150 <Compile Include="Interfaces\ICheckedValueConfigurationCollection.cs" /> 151 <Compile Include="Operators\Crossovers\AverageDoubleValueCrossover.cs" /> 152 <Compile Include="Operators\Crossovers\DiscreteDoubleValueCrossover.cs" /> 151 153 <Compile Include="Operators\Crossovers\DiscreteIntValueCrossover.cs" /> 152 154 <Compile Include="Operators\Interfaces\IDoubleValueCrossover.cs" /> -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/ICheckedValueConfigurationCollection.cs
r5110 r5277 6 6 7 7 namespace HeuristicLab.Problems.MetaOptimization { 8 public interface ICheckedValueConfiguration Collection : ICheckedItemCollection<IValueConfiguration> {8 public interface ICheckedValueConfigurationList : ICheckedItemList<IValueConfiguration> { 9 9 int MinItemCount { get; } 10 10 IItemSet<IItem> ValidValues { get; } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IOptimizable.cs
r5184 r5277 7 7 8 8 namespace HeuristicLab.Problems.MetaOptimization { 9 public delegate void MutateDelegate(IRandom random, IOptimizable configuartion, ParameterConfigurationManipulator pcmanip);10 public delegate void CrossDelegate(IRandom random, IOptimizable configuartion, ParameterConfigurationCrossover pccross);9 public delegate void MutateDelegate(IRandom random, IOptimizable configuartion, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator); 10 public delegate void CrossDelegate(IRandom random, IOptimizable configuartion, IOptimizable other, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover); 11 11 12 12 public interface IOptimizable : IItem { … … 16 16 17 17 void Randomize(IRandom random); 18 void Mutate(IRandom random, MutateDelegate mutate, ParameterConfigurationManipulator pcmanip);19 void Cross(IRandom random, IOptimizable other, CrossDelegate cross, ParameterConfigurationCrossover pccross);18 void Mutate(IRandom random, MutateDelegate mutate, IIntValueManipulator intValueManipulator, IDoubleValueManipulator doubleValueManipulator); 19 void Cross(IRandom random, IOptimizable other, CrossDelegate cross, IIntValueCrossover intValueCrossover, IDoubleValueCrossover doubleValueCrossover); 20 20 string ParameterInfoString { get; } 21 21 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Interfaces/IParameterConfiguration.cs
r5207 r5277 9 9 string ParameterName { get; set; } 10 10 Type ParameterDataType { get; } 11 ICheckedValueConfiguration CollectionValueConfigurations { get; }11 ICheckedValueConfigurationList ValueConfigurations { get; } 12 12 Type[] ValidTypes { get; } 13 13 int ActualValueConfigurationIndex { get; set; } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/MetaOptimizationProblem.cs
r5212 r5277 109 109 var validIntManipulators = new ItemSet<IIntValueManipulator>( ApplicationManager.Manager.GetInstances<IIntValueManipulator>()); 110 110 var validDoubleManipulators = new ItemSet<IDoubleValueManipulator>(ApplicationManager.Manager.GetInstances<IDoubleValueManipulator>()); 111 var validIntCrossovers = new ItemSet<IIntValueCrossover>(ApplicationManager.Manager.GetInstances<IIntValueCrossover>()); 112 var validDoubleCrossovers = new ItemSet<IDoubleValueCrossover>(ApplicationManager.Manager.GetInstances<IDoubleValueCrossover>()); 111 113 Parameters.Add(new ConstrainedValueParameter<IIntValueManipulator>(IntValueManipulatorParameterName, "", validIntManipulators, validIntManipulators.First())); 112 114 Parameters.Add(new ConstrainedValueParameter<IDoubleValueManipulator>(DoubleValueManipulatorParameterName, "", validDoubleManipulators, validDoubleManipulators.First())); 115 Parameters.Add(new ConstrainedValueParameter<IIntValueCrossover>(IntValueCrossoverParameterName, "", validIntCrossovers, validIntCrossovers.First())); 116 Parameters.Add(new ConstrainedValueParameter<IDoubleValueCrossover>(DoubleValueCrossoverParameterName, "", validDoubleCrossovers, validDoubleCrossovers.Where(x => x.GetType() == typeof(AverageDoubleValueCrossover)).SingleOrDefault())); 113 117 114 118 Maximization = new BoolValue(false); -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Crossovers/DiscreteIntValueCrossover.cs
r5111 r5277 28 28 } 29 29 30 public void Apply(IRandom random, IntValue value, IntValue Range range) {31 Apply (random, value, range);30 public void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range) { 31 ApplyStatic(random, value, other, range); 32 32 } 33 33 34 public static void ApplyStatic(IRandom random, IntValue value, IntValueRange range) { 35 34 public static void ApplyStatic(IRandom random, IntValue value, IntValue other, IntValueRange range) { 35 if (random.NextDouble() > 0.5) { 36 value.Value = other.Value; 37 } 36 38 } 37 39 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Interfaces/IDoubleValueCrossover.cs
r5111 r5277 9 9 namespace HeuristicLab.Problems.MetaOptimization { 10 10 public interface IDoubleValueCrossover : ICrossover { 11 void Apply(IRandom random, DoubleValue value, DoubleValue Range range);11 void Apply(IRandom random, DoubleValue value, DoubleValue other, DoubleValueRange range); 12 12 } 13 13 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Operators/Interfaces/IIntValueCrossover.cs
r5111 r5277 9 9 namespace HeuristicLab.Problems.MetaOptimization { 10 10 public interface IIntValueCrossover : ICrossover { 11 void Apply(IRandom random, IntValue value, IntValue Range range);11 void Apply(IRandom random, IntValue value, IntValue other, IntValueRange range); 12 12 } 13 13 }
Note: See TracChangeset
for help on using the changeset viewer.