Changeset 6618 for branches/GP.Grammar.Editor/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs
- Timestamp:
- 08/01/11 17:48:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs
r5445 r6618 48 48 49 49 protected override AlbaEncoding Crossover(IRandom random, AlbaEncoding parent1, AlbaEncoding parent2) { 50 //note - the inner crossover is called here and the resultis converted to an alba representation50 //note - the inner crossover is called here and the solution is converted to an alba representation 51 51 //some refactoring should be done here in the future - the crossover operation should be called directly 52 52 53 InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName; 54 IAtomicOperation op = this.ExecutionContext.CreateOperation( 55 InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope); 56 op.Operator.Execute((IExecutionContext)op, CancellationToken); 53 if (parent1.Length == parent2.Length) { 54 InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName; 55 IAtomicOperation op = this.ExecutionContext.CreateOperation( 56 InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope); 57 op.Operator.Execute((IExecutionContext)op, CancellationToken); 57 58 58 string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;59 if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {60 Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;61 ExecutionContext.Scope.Variables.Remove(childName);59 string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName; 60 if (ExecutionContext.Scope.Variables.ContainsKey(childName)) { 61 Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation; 62 ExecutionContext.Scope.Variables.Remove(childName); 62 63 63 return new AlbaEncoding(permutation, Cities); 64 } else 65 return null; 64 return new AlbaEncoding(permutation, Cities); 65 } else 66 return null; 67 } else { 68 return parent1.Clone() as AlbaEncoding; 69 } 66 70 } 67 71 }
Note: See TracChangeset
for help on using the changeset viewer.