Changeset 15142 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators
- Timestamp:
- 07/06/17 11:12:18 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
r15141 r15142 164 164 // A dictionary is used to find parameters 165 165 double[] initialConstants; 166 var parameters = new List<TreeToAutoDiffTerm Transformator.DataForVariable>();167 168 TreeToAutoDiffTerm Transformator.ParametricFunction func;169 TreeToAutoDiffTerm Transformator.ParametricFunctionGradient func_grad;170 if (!TreeToAutoDiffTerm Transformator.TryTransformToAutoDiff(tree, updateVariableWeights, out parameters, out initialConstants, out func, out func_grad))166 var parameters = new List<TreeToAutoDiffTermConverter.DataForVariable>(); 167 168 TreeToAutoDiffTermConverter.ParametricFunction func; 169 TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad; 170 if (!TreeToAutoDiffTermConverter.TryConvertToAutoDiff(tree, updateVariableWeights, out parameters, out initialConstants, out func, out func_grad)) 171 171 throw new NotSupportedException("Could not optimize constants of symbolic expression tree due to not supported symbols used in the tree."); 172 172 if (parameters.Count == 0) return 0.0; // gkronber: constant expressions always have a R² of 0.0 … … 175 175 176 176 //extract inital constants 177 double[] c = new double[initialConstants.Length ];177 double[] c = new double[initialConstants.Length + 2]; 178 178 { 179 179 c[0] = 0.0; … … 254 254 } 255 255 256 private static alglib.ndimensional_pfunc CreatePFunc(TreeToAutoDiffTerm Transformator.ParametricFunction func) {256 private static alglib.ndimensional_pfunc CreatePFunc(TreeToAutoDiffTermConverter.ParametricFunction func) { 257 257 return (double[] c, double[] x, ref double fx, object o) => { 258 258 fx = func(c, x); … … 260 260 } 261 261 262 private static alglib.ndimensional_pgrad CreatePGrad(TreeToAutoDiffTerm Transformator.ParametricFunctionGradient func_grad) {262 private static alglib.ndimensional_pgrad CreatePGrad(TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad) { 263 263 return (double[] c, double[] x, ref double fx, double[] grad, object o) => { 264 264 var tupel = func_grad(c, x); … … 268 268 } 269 269 public static bool CanOptimizeConstants(ISymbolicExpressionTree tree) { 270 return TreeToAutoDiffTerm Transformator.IsCompatible(tree);270 return TreeToAutoDiffTermConverter.IsCompatible(tree); 271 271 } 272 272 }
Note: See TracChangeset
for help on using the changeset viewer.