Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/21/15 16:30:14 (9 years ago)
Author:
abeham
Message:

#2319: Added SinglePointCrossover

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LinearLinkage/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Manipulators/GraftManipulator.cs

    r12288 r12396  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    27 using HeuristicLab.Parameters;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2927
     
    3331  public sealed class GraftManipulator : LinearLinkageManipulator {
    3432
    35     public IValueLookupParameter<IntValue> MaxGroupsParameter {
    36       get { return (IValueLookupParameter<IntValue>)Parameters["MaxGroups"]; }
    37     }
    38 
    3933    [StorableConstructor]
    4034    private GraftManipulator(bool deserializing) : base(deserializing) { }
    4135    private GraftManipulator(GraftManipulator original, Cloner cloner) : base(original, cloner) { }
    42     public GraftManipulator() {
    43       Parameters.Add(new ValueLookupParameter<IntValue>("MaxGroups", "The maximum number of groups. If a value less or equal than 0 is used the number of groups is not limited.", new IntValue(-1)));
    44     }
    45     public GraftManipulator(int maxGroups)
    46       : this() {
    47       MaxGroupsParameter.Value = new IntValue(maxGroups);
    48     }
     36    public GraftManipulator() { }
    4937
    5038    public override IDeepCloneable Clone(Cloner cloner) {
     
    5240    }
    5341
    54     public static void Apply(IRandom random, LinearLinkage lle, int maxGroups) {
     42    public static void Apply(IRandom random, LinearLinkage lle) {
    5543      int tries = lle.Length;
    5644      var index = random.Next(lle.Length);
     
    5947        tries--;
    6048      }
    61       if (lle[index] != index) Apply(random, lle, maxGroups, index);
     49      if (lle[index] != index) Apply(random, lle, index);
    6250    }
    6351
    64     public static void Apply(IRandom random, LinearLinkage lle, int maxGroups, int index) {
     52    public static void Apply(IRandom random, LinearLinkage lle, int index) {
    6553      var groups = lle.Select((val, idx) => Tuple.Create(idx, val))
    6654                      .Where(x => x.Item1 == x.Item2)
     
    8472
    8573    protected override void Manipulate(IRandom random, LinearLinkage lle) {
    86       var maxGroups = MaxGroupsParameter.ActualValue.Value;
    87       Apply(random, lle, maxGroups <= 0 ? int.MaxValue : maxGroups);
     74      Apply(random, lle);
    8875    }
    8976  }
Note: See TracChangeset for help on using the changeset viewer.