Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11680


Ignore:
Timestamp:
12/12/14 14:50:27 (10 years ago)
Author:
mkommend
Message:

#2287: Extended constants optimization evaluator to be able to handle the square root symbol and changed optimization of square.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs

    r11171 r11680  
    155155      eval: Math.Tan,
    156156      diff: x => 1 + Math.Tan(x) * Math.Tan(x));
    157     private static readonly Func<Term, UnaryFunc> square = UnaryFunc.Factory(
    158        eval: x => x * x,
    159        diff: x => 2 * x);
    160157    private static readonly Func<Term, UnaryFunc> erf = UnaryFunc.Factory(
    161158      eval: alglib.errorfunction,
     
    378375          return true;
    379376        }
     377      }
     378      if (node.Symbol is Square) {
     379        AutoDiff.Term t;
     380        if (!TryTransformToAutoDiff(node.GetSubtree(0), variables, parameters, variableNames, out t)) {
     381          term = null;
     382          return false;
     383        } else {
     384          term = AutoDiff.TermBuilder.Power(t, 2.0);
     385          return true;
     386        }
     387      } if (node.Symbol is SquareRoot) {
     388        AutoDiff.Term t;
     389        if (!TryTransformToAutoDiff(node.GetSubtree(0), variables, parameters, variableNames, out t)) {
     390          term = null;
     391          return false;
     392        } else {
     393          term = AutoDiff.TermBuilder.Power(t, 0.5);
     394          return true;
     395        }
    380396      } if (node.Symbol is Sine) {
    381397        AutoDiff.Term t;
     
    403419        } else {
    404420          term = tan(t);
    405           return true;
    406         }
    407       }
    408       if (node.Symbol is Square) {
    409         AutoDiff.Term t;
    410         if (!TryTransformToAutoDiff(node.GetSubtree(0), variables, parameters, variableNames, out t)) {
    411           term = null;
    412           return false;
    413         } else {
    414           term = square(t);
    415421          return true;
    416422        }
     
    464470         !(n.Symbol is Logarithm) &&
    465471         !(n.Symbol is Exponential) &&
     472         !(n.Symbol is SquareRoot) &&
     473         !(n.Symbol is Square) &&
    466474         !(n.Symbol is Sine) &&
    467475         !(n.Symbol is Cosine) &&
    468476         !(n.Symbol is Tangent) &&
    469          !(n.Symbol is Square) &&
    470477         !(n.Symbol is Erf) &&
    471478         !(n.Symbol is Norm) &&
Note: See TracChangeset for help on using the changeset viewer.