Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/20/10 16:35:42 (15 years ago)
Author:
abeham
Message:

Updated StochasticMultiOperator and Multicrossover/Multimutation #976

Location:
trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Crossovers/MultiPermutationCrossover.cs

    r3425 r3445  
    3131  [Item("MultiPermutationCrossover", "Randomly selects and applies one of its crossovers every time it is called.")]
    3232  [StorableClass]
    33   public class MultiPermutationCrossover : StochasticMultiOperator<IPermutationCrossover>, IPermutationCrossover {
     33  public class MultiPermutationCrossover : StochasticMultiOperator<IPermutationCrossover>, IPermutationCrossover, IStochasticOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
    3636    }
    3737    protected override bool CreateChildOperation {
    38       get { return true; }
    39     }
    40     public override bool AutomaticTypeDiscovery {
    4138      get { return true; }
    4239    }
     
    5855      Parameters.Add(new LookupParameter<Permutation>("Child", "The child permutation resulting from the crossover."));
    5956      ChildParameter.ActualName = "Permutation";
     57    }
    6058
    61       Initialize();
     59    protected override void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationCrossover>> e) {
     60      base.Operators_ItemsReplaced(sender, e);
    6261      ParameterizeCrossovers();
    6362    }
    6463
    65     [StorableHook(HookType.AfterDeserialization)]
    66     private void Initialize() {
    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();
    73     }
    74 
    75     private void Operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationCrossover>> e) {
     64    protected override void Operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationCrossover>> e) {
     65      base.Operators_ItemsAdded(sender, e);
    7666      ParameterizeCrossovers();
    7767    }
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Manipulators/MultiPermutationManipulator.cs

    r3425 r3445  
    3131  [Item("MultiPermutationManipulator", "Randomly selects and applies one of its manipulators every time it is called.")]
    3232  [StorableClass]
    33   public class MultiPermutationManipulator : StochasticMultiOperator<IPermutationManipulator>, IPermutationManipulator {
     33  public class MultiPermutationManipulator : StochasticMultiOperator<IPermutationManipulator>, IPermutationManipulator, IStochasticOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
    3636    }
    3737    protected override bool CreateChildOperation {
    38       get { return true; }
    39     }
    40     public override bool AutomaticTypeDiscovery {
    4138      get { return true; }
    4239    }
     
    5148      : base() {
    5249      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that is being manipulating."));
     50    }
    5351
    54       Initialize();
     52    protected override void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationManipulator>> e) {
     53      base.Operators_ItemsReplaced(sender, e);
    5554      ParameterizeManipulators();
    5655    }
    5756
    58     [StorableHook(HookType.AfterDeserialization)]
    59     private void Initialize() {
    60       Operators.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IPermutationManipulator>>(Operators_ItemsAdded);
    61       Operators.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IPermutationManipulator>>(Operators_ItemsReplaced);
    62     }
    63 
    64     private void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationManipulator>> e) {
    65       ParameterizeManipulators();
    66     }
    67 
    68     private void Operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationManipulator>> e) {
     57    protected override void Operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IPermutationManipulator>> e) {
     58      base.Operators_ItemsAdded(sender, e);
    6959      ParameterizeManipulators();
    7060    }
Note: See TracChangeset for help on using the changeset viewer.