- Timestamp:
- 04/20/12 17:00:09 (13 years ago)
- Location:
- branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack
- Files:
-
- 2 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack/NBinaryVectorCrossover.cs
r7740 r7744 71 71 72 72 public sealed override IOperation Apply() { 73 //ChildrenParameter.ActualValue = Cross(RandomParameter.ActualValue, ParentsParameter.ActualValue);74 73 var offspringSolutions = Cross(RandomParameter.ActualValue, ParentsParameter.ActualValue); 75 74 for (int i = 0; i < offspringSolutions.Length; i++) { -
branches/ScatterSearch/HeuristicLab.Algorithms.ScatterSearch/3.3/Knapsack/NChildCrossover.cs
r7740 r7744 35 35 [StorableClass] 36 36 public sealed class NChildCrossover : NBinaryVectorCrossover { 37 #region Parameter properties 37 38 public IValueLookupParameter<IntValue> NParameter { 38 39 get { return (IValueLookupParameter<IntValue>)Parameters["N"]; } 39 40 } 41 #endregion 40 42 41 43 [StorableConstructor] … … 44 46 public NChildCrossover() 45 47 : base() { 48 #region Create parameters 46 49 Parameters.Add(new ValueLookupParameter<IntValue>("N", "Number of children.", new IntValue(2))); 50 #endregion 47 51 } 48 52 … … 53 57 public static ItemArray<BinaryVector> Apply(IRandom random, BinaryVector parent1, BinaryVector parent2, IntValue n) { 54 58 if (parent1.Length != parent2.Length) 55 throw new ArgumentException("N PointCrossover: The parents are of different length.");59 throw new ArgumentException("NChildCrossover: The parents are of different length."); 56 60 57 61 if (n.Value > Math.Pow(2, parent1.Length) - 2) 58 throw new ArgumentException("N PointCrossover: There cannot be more breakpoints than the size of the parents.");62 throw new ArgumentException("NChildCrossover: There cannot be more children than 2^size of parents - 2."); 59 63 60 64 if (n.Value < 1) 61 throw new ArgumentException("N PointCrossover: N cannot be < 1.");65 throw new ArgumentException("NChildCrossover: N cannot be < 1."); 62 66 63 67 var solutions = new BinaryVector[n.Value];
Note: See TracChangeset
for help on using the changeset viewer.