- Timestamp:
- 07/17/21 18:14:43 (3 years ago)
- Location:
- stable
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 17817
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression merged: 17817
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4 merged: 17817
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
r17181 r18015 209 209 bool updateConstantsInTree = true, Action<double[], double, object> iterationCallback = null, EvaluationsCounter counter = null) { 210 210 211 // numeric constants in the tree become variables for constant opt212 // variables in the tree become parameters (fixed values) for constant opt213 // for each parameter (variable in the original tree) we store the211 // Numeric constants in the tree become variables for parameter optimization. 212 // Variables in the tree become parameters (fixed values) for parameter optimization. 213 // For each parameter (variable in the original tree) we store the 214 214 // variable name, variable value (for factor vars) and lag as a DataForVariable object. 215 215 // A dictionary is used to find parameters … … 221 221 if (!TreeToAutoDiffTermConverter.TryConvertToAutoDiff(tree, updateVariableWeights, applyLinearScaling, out parameters, out initialConstants, out func, out func_grad)) 222 222 throw new NotSupportedException("Could not optimize constants of symbolic expression tree due to not supported symbols used in the tree."); 223 if (parameters.Count == 0) return 0.0; // gkronber:constant expressions always have a R² of 0.0223 if (parameters.Count == 0) return 0.0; // constant expressions always have a R² of 0.0 224 224 var parameterEntries = parameters.ToArray(); // order of entries must be the same for x 225 225 226 // extract inital constants226 // extract inital constants 227 227 double[] c; 228 228 if (applyLinearScaling) { … … 309 309 VariableTreeNodeBase variableTreeNodeBase = node as VariableTreeNodeBase; 310 310 FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode; 311 if (constantTreeNode != null) 311 if (constantTreeNode != null) { 312 if (constantTreeNode.Parent.Symbol is Power 313 && constantTreeNode.Parent.GetSubtree(1) == constantTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter) 312 314 constantTreeNode.Value = constants[i++]; 313 else if (updateVariableWeights && variableTreeNodeBase != null)315 } else if (updateVariableWeights && variableTreeNodeBase != null) 314 316 variableTreeNodeBase.Weight = constants[i++]; 315 317 else if (factorVarTreeNode != null) { -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r17181 r18015 258 258 if (node.Symbol is CubeRoot) { 259 259 return cbrt(ConvertToAutoDiff(node.GetSubtree(0))); 260 } 261 if (node.Symbol is Power) { 262 var powerNode = node.GetSubtree(1) as ConstantTreeNode; 263 if (powerNode == null) 264 throw new NotSupportedException("Only integer powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol."); 265 var intPower = Math.Truncate(powerNode.Value); 266 if (intPower != powerNode.Value) 267 throw new NotSupportedException("Only integer powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol."); 268 return AutoDiff.TermBuilder.Power(ConvertToAutoDiff(node.GetSubtree(0)), intPower); 260 269 } 261 270 if (node.Symbol is Sine) { … … 340 349 !(n.Symbol is AnalyticQuotient) && 341 350 !(n.Symbol is Cube) && 342 !(n.Symbol is CubeRoot) 351 !(n.Symbol is CubeRoot) && 352 !(n.Symbol is Power) 343 353 select n).Any(); 344 354 return !containsUnknownSymbol;
Note: See TracChangeset
for help on using the changeset viewer.