Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/01/11 17:48:53 (13 years ago)
Author:
mkommend
Message:

#1479: Integrated trunk changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs

    r5445 r6618  
    4848
    4949    protected override AlbaEncoding Crossover(IRandom random, AlbaEncoding parent1, AlbaEncoding parent2) {
    50       //note - the inner crossover is called here and the result is converted to an alba representation
     50      //note - the inner crossover is called here and the solution is converted to an alba representation
    5151      //some refactoring should be done here in the future - the crossover operation should be called directly
    5252
    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);
    5758
    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);
    6263
    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      }
    6670    }
    6771  }
Note: See TracChangeset for help on using the changeset viewer.