- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/AverageCrossover.cs
r3376 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 25 … … 58 56 result[i] = avg / (double)parentsCount; 59 57 } 60 } catch (IndexOutOfRangeException) { 58 } 59 catch (IndexOutOfRangeException) { 61 60 throw new ArgumentException("AverageCrossover: The parents' vectors are of different length.", "parents"); 62 61 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/BlendAlphaBetaCrossover.cs
r3907 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; … … 138 137 if (QualityParameter.ActualValue == null || QualityParameter.ActualValue.Length != parents.Length) throw new InvalidOperationException("BlendAlphaBetaCrossover: Parameter " + QualityParameter.ActualName + " could not be found, or not in the same quantity as there are parents."); 139 138 if (AlphaParameter.ActualValue == null || BetaParameter.ActualValue == null) throw new InvalidOperationException("BlendAlphaBetaCrossover: Parameter " + AlphaParameter.ActualName + " or paramter " + BetaParameter.ActualName + " could not be found."); 140 139 141 140 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 142 141 bool maximization = MaximizationParameter.ActualValue.Value; -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/BlendAlphaCrossover.cs
r3909 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/DiscreteCrossover.cs
r3376 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 using HeuristicLab.Parameters;27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 25 … … 48 45 public static RealVector Apply(IRandom random, ItemArray<RealVector> parents) { 49 46 int length = parents[0].Length; 50 51 for (int i = 0; i < parents.Length; i++) { 52 if (parents[i].Length != length)47 48 for (int i = 0; i < parents.Length; i++) { 49 if (parents[i].Length != length) 53 50 throw new ArgumentException("DiscreteCrossover: The parents' vectors are of different length.", "parents"); 54 51 } 55 52 56 53 RealVector result = new RealVector(length); 57 54 for (int i = 0; i < length; i++) { 58 55 result[i] = parents[random.Next(parents.Length)][i]; 59 } 60 56 } 57 61 58 return result; 62 59 } -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/HeuristicCrossover.cs
r3659 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; … … 72 71 if (betterParent.Length != worseParent.Length) 73 72 throw new ArgumentException("HeuristicCrossover: the two parents are not of the same length"); 74 73 75 74 int length = betterParent.Length; 76 75 double[] result = new double[length]; -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/LocalCrossover.cs
r3376 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 25 … … 47 45 if (parent1.Length != parent2.Length) 48 46 throw new ArgumentException("LocalCrossover: the two parents are not of the same length"); 49 47 50 48 double factor; 51 49 int length = parent1.Length; -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/RandomConvexCrossover.cs
r3376 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 25 … … 47 45 if (parent1.Length != parent2.Length) 48 46 throw new ArgumentException("ERROR in RandomConvexCrossover: the two parents are not of the same length"); 49 47 50 48 int length = parent1.Length; 51 49 double[] result = new double[length]; -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/SimulatedBinaryCrossover.cs
r3376 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/SinglePointCrossover.cs
r3675 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 25 -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/UniformAllPositionsArithmeticCrossover.cs
r3909 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; … … 82 81 /// <returns>The vector resulting from the crossover.</returns> 83 82 protected override RealVector Cross(IRandom random, ItemArray<RealVector> parents) { 84 83 if (parents.Length != 2) throw new ArgumentException("UniformAllPositionsArithmeticCrossover: There must be exactly two parents.", "parents"); 85 84 if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("UniformAllPositionsArithmeticCrossover: Parameter " + AlphaParameter.ActualName + " could not be found."); 86 85 return Apply(random, parents[0], parents[1], AlphaParameter.ActualValue); -
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/UniformSomePositionsArithmeticCrossover.cs
r3909 r4068 21 21 22 22 using System; 23 using HeuristicLab.Common;24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; … … 74 73 if (alpha.Value < 0 || alpha.Value > 1) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: Parameter alpha must be in the range [0;1]", "alpha"); 75 74 if (probability.Value < 0 || probability.Value > 1) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: Parameter probability must be in the range [0;1]", "probability"); 76 75 77 76 RealVector result = new RealVector(length); 78 77 for (int i = 0; i < length; i++) { … … 92 91 /// <param name="parents">The collection of parents (must be of size 2).</param> 93 92 /// <returns>The vector resulting from the crossover.</returns> 94 protected override RealVector 93 protected override RealVector Cross(IRandom random, ItemArray<RealVector> parents) { 95 94 if (parents.Length != 2) throw new ArgumentException("UniformSomePositionsArithmeticCrossover: There must be exactly two parents.", "parents"); 96 95 if (AlphaParameter.ActualValue == null) throw new InvalidOperationException("UniformSomePositionsArithmeticCrossover: Parameter " + AlphaParameter.ActualName + " could not be found.");
Note: See TracChangeset
for help on using the changeset viewer.