Changeset 3048 for trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/HeuristicCrossover.cs
- Timestamp:
- 03/15/10 23:49:54 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/HeuristicCrossover.cs
r3017 r3048 40 40 /// Whether the problem is a maximization or minimization problem. 41 41 /// </summary> 42 public ValueLookupParameter<Bool Data> MaximizationParameter {43 get { return (ValueLookupParameter<Bool Data>)Parameters["Maximization"]; }42 public ValueLookupParameter<BoolValue> MaximizationParameter { 43 get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; } 44 44 } 45 45 /// <summary> 46 46 /// The quality of the parents. 47 47 /// </summary> 48 public SubScopesLookupParameter<Double Data> QualityParameter {49 get { return (SubScopesLookupParameter<Double Data>)Parameters["Quality"]; }48 public SubScopesLookupParameter<DoubleValue> QualityParameter { 49 get { return (SubScopesLookupParameter<DoubleValue>)Parameters["Quality"]; } 50 50 } 51 51 … … 56 56 public HeuristicCrossover() 57 57 : base() { 58 Parameters.Add(new ValueLookupParameter<Bool Data>("Maximization", "Whether the problem is a maximization problem or not."));59 Parameters.Add(new SubScopesLookupParameter<Double Data>("Quality", "The quality values of the parents."));58 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "Whether the problem is a maximization problem or not.")); 59 Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Quality", "The quality values of the parents.")); 60 60 } 61 61 … … 68 68 /// <param name="worseParent">The second parent for the crossover operation.</param> 69 69 /// <returns>The newly created real vector, resulting from the heuristic crossover.</returns> 70 public static DoubleArray Data Apply(IRandom random, DoubleArrayData betterParent, DoubleArrayDataworseParent) {70 public static DoubleArray Apply(IRandom random, DoubleArray betterParent, DoubleArray worseParent) { 71 71 if (betterParent.Length != worseParent.Length) 72 72 throw new ArgumentException("HeuristicCrossover: the two parents are not of the same length"); … … 79 79 result[i] = betterParent[i] + factor * (betterParent[i] - worseParent[i]); 80 80 } 81 return new DoubleArray Data(result);81 return new DoubleArray(result); 82 82 } 83 83 … … 96 96 /// <param name="parents">An array containing the two real vectors that should be crossed.</param> 97 97 /// <returns>The newly created real vector, resulting from the crossover operation.</returns> 98 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {98 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 99 99 if (parents.Length != 2) throw new ArgumentException("HeuristicCrossover: The number of parents is not equal to 2"); 100 100 … … 102 102 if (QualityParameter.ActualValue == null || QualityParameter.ActualValue.Length != parents.Length) throw new InvalidOperationException("HeuristicCrossover: Parameter " + QualityParameter.ActualName + " could not be found, or not in the same quantity as there are parents."); 103 103 104 ItemArray<Double Data> qualities = QualityParameter.ActualValue;104 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 105 105 bool maximization = MaximizationParameter.ActualValue.Value; 106 106
Note: See TracChangeset
for help on using the changeset viewer.