Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/23/12 16:05:57 (12 years ago)
Author:
mkommend
Message:

#1682: Integrated new gp crossovers into the trunk and corrected the parameter wiring.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDeterministicBestCrossover.cs

    r7503 r7506  
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    31 
    3231  [Item("DeterministicBestCrossover", "An operator which performs subtree swapping by choosing the best subtree to be swapped in a certain position:\n" +
    3332                                      "- Take two parent individuals P0 and P1\n" +
     
    8584      // create symbols in order to improvize an ad-hoc tree so that the child can be evaluated
    8685      ISymbolicExpressionTreeNode selectedBranch = null;
    87 
    8886      var nodeQualities = new List<Tuple<ISymbolicExpressionTreeNode, double>>();
    89 
    9087      var originalChild = crossoverPoint0.Child;
    9188
     
    9390        var parent = node.Parent;
    9491        Swap(crossoverPoint0, node); // the swap will set the nodes parent to crossoverPoint0.Parent
    95         double quality = evaluator.Evaluate(context, parent0, problemData, rows);
     92        IExecutionContext childContext = new ExecutionContext(context, evaluator, context.Scope);
     93        double quality = evaluator.Evaluate(childContext, parent0, problemData, rows);
    9694        Swap(crossoverPoint0, originalChild); // swap the child back (so that the next swap will not affect the currently swapped node from parent1)
    9795        nodeQualities.Add(new Tuple<ISymbolicExpressionTreeNode, double>(node, quality));
     
    9997      }
    10098
    101       nodeQualities.Sort((a, b) => a.Item2.CompareTo(b.Item2)); // assuming this sorts the list in ascending order
     99      nodeQualities.Sort((a, b) => a.Item2.CompareTo(b.Item2));
    102100      selectedBranch = evaluator.Maximization ? nodeQualities.Last().Item1 : nodeQualities.First().Item1;
    103 
    104 
    105       if (selectedBranch == null)
    106         throw new Exception("Selected branch is null");
    107 
    108       if (selectedBranch.Parent == null)
    109         throw new Exception("Parent is null");
    110 
    111101
    112102      // swap the node that would create the best offspring
Note: See TracChangeset for help on using the changeset viewer.