Changeset 15480
- Timestamp:
- 11/20/17 20:36:29 (7 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
r15448 r15480 214 214 c = new double[initialConstants.Length + 2]; 215 215 { 216 c[0] = 0.0;217 c[ 1] = 1.0;218 Array.Copy(initialConstants, 0, c, 2, initialConstants.Length);216 Array.Copy(initialConstants, 0, c, 0, initialConstants.Length); 217 c[c.Length - 2] = 0.0; 218 c[c.Length - 1] = 1.0; 219 219 } 220 220 } else { … … 273 273 //retVal == -7 => constant optimization failed due to wrong gradient 274 274 if (retVal != -7) { 275 if (applyLinearScaling) UpdateConstants(tree, c .Skip(2).ToArray(), updateVariableWeights);276 else UpdateConstants(tree, c .ToArray(), updateVariableWeights);275 if (applyLinearScaling) UpdateConstants(tree, c, updateVariableWeights); 276 else UpdateConstants(tree, c, updateVariableWeights); 277 277 } 278 278 var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling); 279 279 280 if (!updateConstantsInTree) UpdateConstants(tree, initialConstants .ToArray(), updateVariableWeights);280 if (!updateConstantsInTree) UpdateConstants(tree, initialConstants, updateVariableWeights); 281 281 282 282 if (originalQuality - quality > 0.001 || double.IsNaN(quality)) { 283 UpdateConstants(tree, initialConstants .ToArray(), updateVariableWeights);283 UpdateConstants(tree, initialConstants, updateVariableWeights); 284 284 return originalQuality; 285 285 } … … 314 314 private static alglib.ndimensional_pgrad CreatePGrad(TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad) { 315 315 return (double[] c, double[] x, ref double fx, double[] grad, object o) => { 316 var tup el= func_grad(c, x);317 fx = tup el.Item2;318 Array.Copy(tup el.Item1, grad, grad.Length);316 var tuple = func_grad(c, x); 317 fx = tuple.Item2; 318 Array.Copy(tuple.Item1, grad, grad.Length); 319 319 var counter = (EvaluationsCounter)o; 320 320 counter.GradientEvaluations++; -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r15447 r15480 251 251 if (node.Symbol is StartSymbol) { 252 252 if (addLinearScalingTerms) { 253 var t = ConvertToAutoDiff(node.GetSubtree(0)); 254 // scaling variables α, β are given at the end of the parameter vector 253 255 var alpha = new AutoDiff.Variable(); 254 256 var beta = new AutoDiff.Variable(); 255 257 variables.Add(beta); 256 258 variables.Add(alpha); 257 return ConvertToAutoDiff(node.GetSubtree(0))* alpha + beta;259 return t * alpha + beta; 258 260 } else return ConvertToAutoDiff(node.GetSubtree(0)); 259 261 }
Note: See TracChangeset
for help on using the changeset viewer.