Changeset 8828
- Timestamp:
- 10/22/12 16:01:16 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
r8823 r8828 134 134 } 135 135 QualityParameter.ActualValue = new DoubleValue(quality); 136 EvaluatedTreesParameter.ActualValue.Value += 1; 137 EvaluatedTreeNodesParameter.ActualValue.Value += solution.Length; 136 lock (locker) { 137 EvaluatedTreesParameter.ActualValue.Value += 1; 138 EvaluatedTreeNodesParameter.ActualValue.Value += solution.Length; 139 } 138 140 139 141 if (Successor != null) … … 143 145 } 144 146 147 private object locker = new object(); 145 148 private void AddResults() { 146 if (EvaluatedTreesParameter.ActualValue == null) { 147 var scope = ExecutionContext.Scope; 148 while (scope.Parent != null) 149 scope = scope.Parent; 150 scope.Variables.Add(new Core.Variable(EvaluatedTreesResultName, new IntValue())); 151 } 152 if (EvaluatedTreeNodesParameter.ActualValue == null) { 153 var scope = ExecutionContext.Scope; 154 while (scope.Parent != null) 155 scope = scope.Parent; 156 scope.Variables.Add(new Core.Variable(EvaluatedTreeNodesResultName, new IntValue())); 149 lock (locker) { 150 if (EvaluatedTreesParameter.ActualValue == null) { 151 var scope = ExecutionContext.Scope; 152 while (scope.Parent != null) 153 scope = scope.Parent; 154 scope.Variables.Add(new Core.Variable(EvaluatedTreesResultName, new IntValue())); 155 } 156 if (EvaluatedTreeNodesParameter.ActualValue == null) { 157 var scope = ExecutionContext.Scope; 158 while (scope.Parent != null) 159 scope = scope.Parent; 160 scope.Variables.Add(new Core.Variable(EvaluatedTreeNodesResultName, new IntValue())); 161 } 157 162 } 158 163 } … … 206 211 207 212 AutoDiff.Term func; 208 if (!TryTransformToAutoDiff(tree.Root.GetSubtree(0), variables, parameters, variableNames, out func)) return 0.0; 213 if (!TryTransformToAutoDiff(tree.Root.GetSubtree(0), variables, parameters, variableNames, out func)) 214 throw new NotSupportedException("Could not optimize constants of symbolic expression tree due to not supported symbols used in the tree."); 209 215 if (variableNames.Count == 0) return 0.0; 210 216 … … 224 230 if (constantTreeNode != null) 225 231 c[i++] = constantTreeNode.Value; 226 else if (variableTreeNode != null && !variableTreeNode.Weight.IsAlmost(1.0))232 else if (variableTreeNode != null) 227 233 c[i++] = variableTreeNode.Weight; 228 234 } … … 274 280 if (constantTreeNode != null) 275 281 constantTreeNode.Value = c[i++]; 276 else if (variableTreeNode != null && !variableTreeNode.Weight.IsAlmost(1.0))282 else if (variableTreeNode != null) 277 283 variableTreeNode.Weight = c[i++]; 278 284 } … … 304 310 } 305 311 if (node.Symbol is Variable) { 306 // don't tune weights with a value of 1.0 because it was probably set by the simplifier307 312 var varNode = node as VariableTreeNode; 308 313 var par = new AutoDiff.Variable(); 309 314 parameters.Add(par); 310 315 variableNames.Add(varNode.VariableName); 311 if (!varNode.Weight.IsAlmost(1.0)) { 312 var w = new AutoDiff.Variable(); 313 variables.Add(w); 314 term = AutoDiff.TermBuilder.Product(w, par); 315 } else { 316 term = par; 317 } 316 var w = new AutoDiff.Variable(); 317 variables.Add(w); 318 term = AutoDiff.TermBuilder.Product(w, par); 318 319 return true; 319 320 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs
r8793 r8828 76 76 : base(original, cloner) { 77 77 } 78 public SymbolicDataAnalysisSingleObjectiveValidationAnalyzer() 79 78 79 protected SymbolicDataAnalysisSingleObjectiveValidationAnalyzer(): base() { 80 80 Parameters.Add(new LookupParameter<IRandom>(RandomParameterName, "The random generator.")); 81 81 Parameters.Add(new LookupParameter<U>(ProblemDataParameterName, "The problem data of the symbolic data analysis problem."));
Note: See TracChangeset
for help on using the changeset viewer.