Changeset 8207
- Timestamp:
- 07/03/12 17:36:20 (12 years ago)
- Location:
- branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ReplaceBranchMoveEvaluator.cs
r8206 r8207 78 78 public override IOperation Apply() { 79 79 var evaluator = EvaluatorParameter.ActualValue; 80 var move = (ReplaceBranchMove)MoveParameter.ActualValue.Clone(); 80 81 var move = MoveParameter.ActualValue; 81 82 82 83 // calculate linear scaling … … 88 89 move.Beta = beta; 89 90 90 move.Parent.RemoveSubtree(move.SubtreeIndex); 91 move.Parent.InsertSubtree(move.SubtreeIndex, Scale(move.NewBranch, alpha, beta)); 91 // clone tree and parent 92 var cloner = new Cloner(); 93 var clonedTree = cloner.Clone(move.Tree); 94 var clonedParent = cloner.Clone(move.Parent); 95 var clonedBranch = cloner.Clone(move.NewBranch); 96 97 clonedParent.RemoveSubtree(move.SubtreeIndex); 98 clonedParent.InsertSubtree(move.SubtreeIndex, Scale(clonedBranch, alpha, beta)); 92 99 93 100 var problemData = ProblemDataParameter.ActualValue; … … 96 103 var fitnessPartition = FitnessCalculationPartitionParameter.ActualValue; 97 104 var rows = Enumerable.Range(fitnessPartition.Start, fitnessPartition.End - fitnessPartition.Start); 98 var quality = evaluator.Evaluate(childContext, move.Tree, problemData, rows);105 var quality = evaluator.Evaluate(childContext, clonedTree, problemData, rows); 99 106 100 107 MoveQualityParameter.ActualValue = new DoubleValue(quality); -
branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ReplaceBranchMoveMaker.cs
r8206 r8207 74 74 75 75 quality.Value = moveQuality.Value; 76 // update solution 77 SymbolicExpressionTreeParameter.ActualValue = move.Tree; 76 78 77 79 return base.Apply(); -
branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ReplaceBranchMultiMoveGenerator.cs
r8206 r8207 112 112 base.ClearState(); 113 113 } 114 public override void InitializeState() { 115 trees = null; 116 treeOutput = null; 117 base.InitializeState(); 118 } 114 119 115 120 public override IOperation Apply() { … … 149 154 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 150 155 var ds = ProblemDataParameter.ActualValue.Dataset; 151 var rows = ProblemDataParameter.ActualValue.TrainingIndi zes;156 var rows = ProblemDataParameter.ActualValue.TrainingIndices; 152 157 153 158 while (count < n) { … … 160 165 161 166 var bestTrees = new SortedList<double, Tuple<ISymbolicExpressionTree, double[]>>(); 162 double bestSimilarity = 0 .0;167 double bestSimilarity = 0; 163 168 // iterate over the whole pool of branches for replacement 164 169 for (int i = 0; i < trees.Count; i++) { … … 175 180 bestTrees.Add(similarity, Tuple.Create(trees[i], treeOutput[i])); 176 181 if (bestTrees.Count > 30) 177 bestTrees.RemoveAt(bestTrees.Count - 1); 182 bestTrees.RemoveAt(0); // remove moves with small R² at the beginning 183 178 184 } 179 185 } … … 206 212 var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; 207 213 var ds = ProblemDataParameter.ActualValue.Dataset; 208 var rows = ProblemDataParameter.ActualValue.TrainingIndi zes;214 var rows = ProblemDataParameter.ActualValue.TrainingIndices; 209 215 // create pool of random branches for replacement (no constants) 210 216 // and evaluate the output
Note: See TracChangeset
for help on using the changeset viewer.