Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 16:46:35 (12 years ago)
Author:
gkronber
Message:

#1847: merged r8084:8205 from trunk into GP move operators branch

Location:
branches/GP-MoveOperators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ReplaceBranchMoveEvaluator.cs

    r7832 r8206  
    8080      var move = (ReplaceBranchMove)MoveParameter.ActualValue.Clone();
    8181
     82      // calculate linear scaling
     83      OnlineCalculatorError errorState;
     84      double alpha, beta;
     85      OnlineLinearScalingParameterCalculator.Calculate(move.NewOutput, move.OriginalOutput, out alpha, out beta, out errorState);
     86
     87      move.Alpha = alpha;
     88      move.Beta = beta;
     89
    8290      move.Parent.RemoveSubtree(move.SubtreeIndex);
    83       move.Parent.InsertSubtree(move.SubtreeIndex, move.NewBranch);
     91      move.Parent.InsertSubtree(move.SubtreeIndex, Scale(move.NewBranch, alpha, beta));
    8492
    8593      var problemData = ProblemDataParameter.ActualValue;
     
    94102    }
    95103
     104    private Addition add = new Addition();
     105    private Multiplication mul = new Multiplication();
     106    private Constant constant = new Constant();
     107
     108    private ISymbolicExpressionTreeNode Scale(ISymbolicExpressionTreeNode node, double alpha, double beta) {
     109      var constAlpha = (ConstantTreeNode)constant.CreateTreeNode();
     110      var constBeta = (ConstantTreeNode)constant.CreateTreeNode();
     111      constAlpha.Value = alpha;
     112      constBeta.Value = beta;
     113      var sum = add.CreateTreeNode();
     114      var prod = mul.CreateTreeNode();
     115      prod.AddSubtree(node); prod.AddSubtree(constBeta);
     116      sum.AddSubtree(prod); sum.AddSubtree(constAlpha);
     117      return sum;
     118    }
     119
    96120    public override IDeepCloneable Clone(Cloner cloner) {
    97121      return new ReplaceBranchMoveEvaluator(this, cloner);
Note: See TracChangeset for help on using the changeset viewer.