Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/20/21 18:13:55 (3 years ago)
Author:
dpiringe
Message:

#3026

  • merged trunk into branch
Location:
branches/3026_IntegrationIntoSymSpace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithBoundsEstimator.cs

    r17928 r18027  
    223223            break;
    224224          }
     225        case OpCodes.Power: {
     226          var a = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     227          var b = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     228          // support only integer powers
     229          if (b.LowerBound == b.UpperBound && Math.Truncate(b.LowerBound) == b.LowerBound) {
     230            result = Interval.Power(a, (int)b.LowerBound);
     231          } else {
     232            throw new NotSupportedException("Interval is only supported for integer powers");
     233          }
     234          break;
     235        }
    225236        case OpCodes.Absolute: {
    226237            var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     
    329340          !(n.Symbol is Cube) &&
    330341          !(n.Symbol is CubeRoot) &&
     342          !(n.Symbol is Power) &&
    331343          !(n.Symbol is Absolute) &&
    332344          !(n.Symbol is AnalyticQuotient)
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs

    r17928 r18027  
    283283            break;
    284284          }
     285        case OpCodes.Power: {
     286            var a = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     287            var b = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     288            // support only integer powers
     289            if (b.LowerBound == b.UpperBound && Math.Truncate(b.LowerBound) == b.LowerBound) {
     290              result = Interval.Power(a, (int)b.LowerBound);
     291            } else {
     292              throw new NotSupportedException("Interval is only supported for integer powers");
     293            }
     294            break;
     295          }
     296
    285297        case OpCodes.Absolute: {
    286298            var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     
    309321
    310322    public static bool IsCompatible(ISymbolicExpressionTree tree) {
    311       var containsUnknownSymbols = (
    312         from n in tree.Root.GetSubtree(0).IterateNodesPrefix()
    313         where
     323      foreach (var n in tree.Root.GetSubtree(0).IterateNodesPrefix()) {
     324        if (
    314325          !(n.Symbol is Variable) &&
    315326          !(n.Symbol is Constant) &&
     
    329340          !(n.Symbol is Cube) &&
    330341          !(n.Symbol is CubeRoot) &&
     342          !(n.Symbol is Power) &&
    331343          !(n.Symbol is Absolute) &&
    332           !(n.Symbol is AnalyticQuotient)
    333         select n).Any();
    334       return !containsUnknownSymbols;
     344          !(n.Symbol is AnalyticQuotient)) return false;
     345
     346        else if (n.Symbol is Power) {
     347          // only integer exponents are supported
     348          var exp = n.GetSubtree(1) as ConstantTreeNode;
     349          if (exp == null || exp.Value != Math.Truncate(exp.Value)) return false;
     350        }
     351      }
     352      return true;
    335353    }
    336354  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/OpCodes.cs

    r17180 r18027  
    144144      { typeof(Cosine), OpCodes.Cos },
    145145      { typeof(Tangent), OpCodes.Tan },
    146       { typeof (HyperbolicTangent), OpCodes.Tanh},
     146      { typeof(HyperbolicTangent), OpCodes.Tanh},
    147147      { typeof(Logarithm), OpCodes.Log },
    148148      { typeof(Exponential), OpCodes.Exp },
Note: See TracChangeset for help on using the changeset viewer.