Changeset 7506 for trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDeterministicBestCrossover.cs
- Timestamp:
- 02/23/12 16:05:57 (12 years ago)
- 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 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 31 32 31 [Item("DeterministicBestCrossover", "An operator which performs subtree swapping by choosing the best subtree to be swapped in a certain position:\n" + 33 32 "- Take two parent individuals P0 and P1\n" + … … 85 84 // create symbols in order to improvize an ad-hoc tree so that the child can be evaluated 86 85 ISymbolicExpressionTreeNode selectedBranch = null; 87 88 86 var nodeQualities = new List<Tuple<ISymbolicExpressionTreeNode, double>>(); 89 90 87 var originalChild = crossoverPoint0.Child; 91 88 … … 93 90 var parent = node.Parent; 94 91 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); 96 94 Swap(crossoverPoint0, originalChild); // swap the child back (so that the next swap will not affect the currently swapped node from parent1) 97 95 nodeQualities.Add(new Tuple<ISymbolicExpressionTreeNode, double>(node, quality)); … … 99 97 } 100 98 101 nodeQualities.Sort((a, b) => a.Item2.CompareTo(b.Item2)); // assuming this sorts the list in ascending order99 nodeQualities.Sort((a, b) => a.Item2.CompareTo(b.Item2)); 102 100 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 111 101 112 102 // swap the node that would create the best offspring
Note: See TracChangeset
for help on using the changeset viewer.