- Timestamp:
- 04/19/10 23:34:34 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/MultiPermutationCrossover.cs
r3419 r3425 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Collections; 23 24 using HeuristicLab.Core; … … 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 29 29 namespace HeuristicLab.Encodings.PermutationEncoding .Crossovers{30 namespace HeuristicLab.Encodings.PermutationEncoding { 30 31 [Item("MultiPermutationCrossover", "Randomly selects and applies one of its crossovers every time it is called.")] 31 32 [StorableClass] 32 public class MultiPermutationCrossover : MultiCrossover<IPermutationCrossover>, IPermutationCrossover {33 public class MultiPermutationCrossover : StochasticMultiOperator<IPermutationCrossover>, IPermutationCrossover { 33 34 public override bool CanChangeName { 34 35 get { return false; } 35 36 } 37 protected override bool CreateChildOperation { 38 get { return true; } 39 } 40 public override bool AutomaticTypeDiscovery { 41 get { return true; } 42 } 43 36 44 public ILookupParameter<ItemArray<Permutation>> ParentsParameter { 37 45 get { return (ILookupParameter<ItemArray<Permutation>>)Parameters["Parents"]; } … … 58 66 private void Initialize() { 59 67 Operators.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IPermutationCrossover>>(Operators_ItemsAdded); 68 Operators.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IPermutationCrossover>>(Operators_ItemsReplaced); 69 } 70 71 private void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationCrossover>> e) { 72 ParameterizeCrossovers(); 60 73 } 61 74 … … 65 78 66 79 private void ParameterizeCrossovers() { 67 foreach (IPermutationCrossover crossover in Operators ) {80 foreach (IPermutationCrossover crossover in Operators.OfType<IPermutationCrossover>()) { 68 81 crossover.ChildParameter.ActualName = ChildParameter.Name; 69 82 crossover.ParentsParameter.ActualName = ParentsParameter.Name; 70 83 } 71 foreach (IStochasticOperator crossover in Operators ) {84 foreach (IStochasticOperator crossover in Operators.OfType<IStochasticOperator>()) { 72 85 crossover.RandomParameter.ActualName = RandomParameter.Name; 73 86 }
Note: See TracChangeset
for help on using the changeset viewer.