Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/09 01:21:53 (16 years ago)
Author:
swagner
Message:

Refactoring of crossover operators (#470)

Location:
trunk/sources/HeuristicLab.Evolutionary
Files:
1 deleted
2 edited

Legend:

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

    r1159 r1218  
    2828namespace HeuristicLab.Evolutionary {
    2929  /// <summary>
    30   /// Base class for crossing over operators.
     30  /// Base class for crossover operators.
    3131  /// </summary>
    3232  public abstract class CrossoverBase : OperatorBase {
     
    4040
    4141    /// <summary>
    42     /// Replaces the parents (the sub scopes of the current <paramref name="scope"/>) with created children
    43     /// by crossing over of two adjacent sub scopes.
     42    /// Retrieves the random number generator and calls <see cref="Cross(HeuristicLab.Core.IScope, HeuristicLab.Core.IRandom)"/>.
    4443    /// </summary>
    45     /// <exception cref="InvalidOperationException">Thrown when the size of the mating pool
    46     /// is not even.</exception>
    47     /// <param name="scope">The current scope whose sub scopes shall be parents.</param>
     44    /// <param name="scope">The current scope which represents a new child.</param>
    4845    /// <returns><c>null</c>.</returns>
    4946    public override IOperation Apply(IScope scope) {
    5047      IRandom random = GetVariableValue<IRandom>("Random", scope, true);
    51 
    52       if (scope.SubScopes.Count != 2)
    53         throw new InvalidOperationException("ERROR: Number of parents is != 2");
    54 
    55       IScope parent1 = scope.SubScopes[0];
    56       IScope parent2 = scope.SubScopes[1];
    57       IScope child = scope;
    58       Cross(scope, random, parent1, parent2, child);
    59 
     48      Cross(scope, random);
    6049      return null;
    6150    }
    6251
    6352    /// <summary>
    64     /// Performs a cross over of <paramref name="parent1"/> and <paramref name="parent2"/>
    65     /// to create a new <paramref name="child"/>.
     53    /// Performs a crossover of all parents (sub-scopes) of <paramref name="scope"/> to create a new child.
     54    /// Note that all children have to be prepared using the <see cref="HeuristicLab.Evolutionary.ChildrenInitializer"/>.
    6655    /// </summary>
    67     /// <param name="scope">The current scope.</param>
     56    /// <param name="scope">The current scope which represents a new child.</param>
    6857    /// <param name="random">A random number generator.</param>
    69     /// <param name="parent1">The parent scope 1 to cross over.</param>
    70     /// <param name="parent2">The parent scope 2 to cross over.</param>
    71     /// <param name="child">The resulting child of the cross over.</param>
    72     protected abstract void Cross(IScope scope, IRandom random, IScope parent1, IScope parent2, IScope child);
     58    protected abstract void Cross(IScope scope, IRandom random);
    7359  }
    7460}
  • TabularUnified trunk/sources/HeuristicLab.Evolutionary/HeuristicLab.Evolutionary.csproj

    r1159 r1218  
    6161  <ItemGroup>
    6262    <Compile Include="ChildrenInitializer.cs" />
    63     <Compile Include="MultiCrossoverBase.cs" />
    6463    <Compile Include="SASEGASAReunificator.cs" />
    6564    <Compile Include="CrossoverBase.cs" />
Note: See TracChangeset for help on using the changeset viewer.