Changeset 77 for trunk/sources/HeuristicLab.RealVector
- Timestamp:
- 03/18/08 16:00:00 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.RealVector
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.RealVector/HeuristicCrossover.cs
r73 r77 35 35 protected sealed override void Cross(IScope scope, IRandom random, IScope parent1, IScope parent2, IScope child) { 36 36 bool maximization = GetVariableValue<BoolData>("Maximization", scope, true).Data; 37 IVariableInfo realVectorInfo = GetVariableInfo("RealVector"); 38 IVariableInfo qualityInfo = GetVariableInfo("Quality"); 39 DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false); 40 DoubleData quality1 = parent1.GetVariableValue<DoubleData>(qualityInfo.ActualName, false); 41 DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false); 42 DoubleData quality2 = parent2.GetVariableValue<DoubleData>(qualityInfo.ActualName, false); 37 DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>("RealVector", false); 38 DoubleData quality1 = parent1.GetVariableValue<DoubleData>("Quality", false); 39 DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>("RealVector", false); 40 DoubleData quality2 = parent2.GetVariableValue<DoubleData>("Quality", false); 43 41 44 42 if (vector1.Data.Length != vector2.Data.Length) throw new InvalidOperationException("Cannot apply crossover to real vectors of different length."); 45 43 46 44 double[] result = Apply(random, maximization, vector1.Data, quality1.Data, vector2.Data, quality2.Data); 47 child.AddVariable(new Variable( realVectorInfo.ActualName, new DoubleArrayData(result)));45 child.AddVariable(new Variable(child.TranslateName("RealVector"), new DoubleArrayData(result))); 48 46 } 49 47 } -
trunk/sources/HeuristicLab.RealVector/RealVectorCrossoverBase.cs
r2 r77 35 35 36 36 protected sealed override void Cross(IScope scope, IRandom random, IScope parent1, IScope parent2, IScope child) { 37 IVariableInfo realVectorInfo = GetVariableInfo("RealVector"); 38 DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false); 39 DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false); 37 DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>("RealVector", false); 38 DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>("RealVector", false); 40 39 41 40 if (vector1.Data.Length != vector2.Data.Length) throw new InvalidOperationException("Cannot apply crossover to real vectors of different length."); 42 41 43 42 double[] result = Cross(scope, random, vector1.Data, vector2.Data); 44 child.AddVariable(new Variable( realVectorInfo.ActualName, new DoubleArrayData(result)));43 child.AddVariable(new Variable(child.TranslateName("RealVector"), new DoubleArrayData(result))); 45 44 } 46 45 -
trunk/sources/HeuristicLab.RealVector/UniformRandomRealVectorGenerator.cs
r2 r77 54 54 55 55 double[] vector = Apply(random, length, min, max); 56 scope.AddVariable(new Variable( GetVariableInfo("RealVector").ActualName, new DoubleArrayData(vector)));56 scope.AddVariable(new Variable(scope.TranslateName("RealVector"), new DoubleArrayData(vector))); 57 57 58 58 return null;
Note: See TracChangeset
for help on using the changeset viewer.