Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/05/21 11:16:48 (4 years ago)
Author:
gkronber
Message:

#3095: added support for integer powers to parameter optimization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs

    r17180 r17817  
    258258      if (node.Symbol is CubeRoot) {
    259259        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);
    260269      }
    261270      if (node.Symbol is Sine) {
     
    340349          !(n.Symbol is AnalyticQuotient) &&
    341350          !(n.Symbol is Cube) &&
    342           !(n.Symbol is CubeRoot)
     351          !(n.Symbol is CubeRoot) &&
     352          !(n.Symbol is Power)
    343353        select n).Any();
    344354      return !containsUnknownSymbol;
Note: See TracChangeset for help on using the changeset viewer.