Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/13/21 17:49:34 (2 years ago)
Author:
gkronber
Message:

#3140: made several more changes for the constant -> number branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs

    r18114 r18115  
    129129
    130130    // state for recursive transformation of trees
    131     private readonly
    132     List<double> initialParamValues;
     131    private readonly List<double> initialParamValues;
    133132    private readonly Dictionary<DataForVariable, AutoDiff.Variable> parameters;
    134133    private readonly List<AutoDiff.Variable> variables;
     
    151150        return var;
    152151      }
    153 
    154152      if (node.Symbol is Constant) {
    155         initialParamValues.Add(((ConstantTreeNode)node).Value);
    156         var var = new AutoDiff.Variable();
    157         variables.Add(var);
    158         return var;
     153        // constants are fixed in autodiff
     154        return (node as ConstantTreeNode).Value;
    159155      }
    160156      if (node.Symbol is Variable || node.Symbol is BinaryFactorVariable) {
     
    267263      }
    268264      if (node.Symbol is Power) {
    269         var powerNode = node.GetSubtree(1) as NumberTreeNode;
     265        var powerNode = node.GetSubtree(1) as INumericTreeNode;
    270266        if (powerNode == null)
    271           throw new NotSupportedException("Only integer powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol.");
     267          throw new NotSupportedException("Only numeric powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol.");
    272268        var intPower = Math.Truncate(powerNode.Value);
    273269        if (intPower != powerNode.Value)
     
    320316      var data = new DataForVariable(varName, varValue, lag);
    321317
    322       AutoDiff.Variable par = null;
    323       if (!parameters.TryGetValue(data, out par)) {
     318      if (!parameters.TryGetValue(data, out AutoDiff.Variable par)) {
    324319        // not found -> create new parameter and entries in names and values lists
    325320        par = new AutoDiff.Variable();
Note: See TracChangeset for help on using the changeset viewer.