Changeset 15515 for stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Timestamp:
- 12/12/17 16:16:12 (7 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15447-15448,15480-15481,15483
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 15447,15480-15481
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r15145 r15515 87 87 #endregion 88 88 89 public static bool TryConvertToAutoDiff(ISymbolicExpressionTree tree, bool makeVariableWeightsVariable, 89 public static bool TryConvertToAutoDiff(ISymbolicExpressionTree tree, bool makeVariableWeightsVariable, bool addLinearScalingTerms, 90 90 out List<DataForVariable> parameters, out double[] initialConstants, 91 91 out ParametricFunction func, … … 93 93 94 94 // use a transformator object which holds the state (variable list, parameter list, ...) for recursive transformation of the tree 95 var transformator = new TreeToAutoDiffTermConverter(makeVariableWeightsVariable );95 var transformator = new TreeToAutoDiffTermConverter(makeVariableWeightsVariable, addLinearScalingTerms); 96 96 AutoDiff.Term term; 97 97 try { … … 120 120 private readonly List<AutoDiff.Variable> variables; 121 121 private readonly bool makeVariableWeightsVariable; 122 123 private TreeToAutoDiffTermConverter(bool makeVariableWeightsVariable) { 122 private readonly bool addLinearScalingTerms; 123 124 private TreeToAutoDiffTermConverter(bool makeVariableWeightsVariable, bool addLinearScalingTerms) { 124 125 this.makeVariableWeightsVariable = makeVariableWeightsVariable; 126 this.addLinearScalingTerms = addLinearScalingTerms; 125 127 this.initialConstants = new List<double>(); 126 128 this.parameters = new Dictionary<DataForVariable, AutoDiff.Variable>(); … … 248 250 } 249 251 if (node.Symbol is StartSymbol) { 250 var alpha = new AutoDiff.Variable(); 251 var beta = new AutoDiff.Variable(); 252 variables.Add(beta); 253 variables.Add(alpha); 254 return ConvertToAutoDiff(node.GetSubtree(0)) * alpha + beta; 252 if (addLinearScalingTerms) { 253 // scaling variables α, β are given at the beginning of the parameter vector 254 var alpha = new AutoDiff.Variable(); 255 var beta = new AutoDiff.Variable(); 256 variables.Add(beta); 257 variables.Add(alpha); 258 var t = ConvertToAutoDiff(node.GetSubtree(0)); 259 return t * alpha + beta; 260 } else return ConvertToAutoDiff(node.GetSubtree(0)); 255 261 } 256 262 throw new ConversionException();
Note: See TracChangeset
for help on using the changeset viewer.