Ignore:
Timestamp:
01/21/09 15:46:27 (12 years ago)
Author:
abeham
Message:

implemented changes to crossover described in ticket #470

  • added ChildrenInitializer operator
  • modified CrossoverBase and MultiCrossoverBase
  • removed unnecessary operators in HeuristicLab.RealVector
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Evolutionary/CrossoverBase.cs

    r881 r1159  
    5050      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
    5151
    52       if ((scope.SubScopes.Count % 2) != 0)
    53         throw new InvalidOperationException("Size of mating pool is not even");
     52      if (scope.SubScopes.Count != 2)
     53        throw new InvalidOperationException("ERROR: Number of parents is != 2");
    5454
    55       int children = scope.SubScopes.Count / 2;
    56       for (int i = 0; i < children; i++) {
    57         IScope parent1 = scope.SubScopes[0];
    58         IScope parent2 = scope.SubScopes[1];
    59         IScope child = new Scope(i.ToString());
    60         scope.AddSubScope(child);
    61         Cross(scope, random, parent1, parent2, child);
    62         scope.RemoveSubScope(parent1);
    63         scope.RemoveSubScope(parent2);
    64       }
     55      IScope parent1 = scope.SubScopes[0];
     56      IScope parent2 = scope.SubScopes[1];
     57      IScope child = scope;
     58      Cross(scope, random, parent1, parent2, child);
    6559
    6660      return null;
Note: See TracChangeset for help on using the changeset viewer.