Changeset 1218 for trunk/sources/HeuristicLab.Evolutionary
- Timestamp:
- 02/16/09 01:21:53 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Evolutionary
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Evolutionary/CrossoverBase.cs ¶
r1159 r1218 28 28 namespace HeuristicLab.Evolutionary { 29 29 /// <summary> 30 /// Base class for cross ingover operators.30 /// Base class for crossover operators. 31 31 /// </summary> 32 32 public abstract class CrossoverBase : OperatorBase { … … 40 40 41 41 /// <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)"/>. 44 43 /// </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> 48 45 /// <returns><c>null</c>.</returns> 49 46 public override IOperation Apply(IScope scope) { 50 47 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); 60 49 return null; 61 50 } 62 51 63 52 /// <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"/>. 66 55 /// </summary> 67 /// <param name="scope">The current scope .</param>56 /// <param name="scope">The current scope which represents a new child.</param> 68 57 /// <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); 73 59 } 74 60 } -
TabularUnified trunk/sources/HeuristicLab.Evolutionary/HeuristicLab.Evolutionary.csproj ¶
r1159 r1218 61 61 <ItemGroup> 62 62 <Compile Include="ChildrenInitializer.cs" /> 63 <Compile Include="MultiCrossoverBase.cs" />64 63 <Compile Include="SASEGASAReunificator.cs" /> 65 64 <Compile Include="CrossoverBase.cs" />
Note: See TracChangeset
for help on using the changeset viewer.