Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3801 for trunk


Ignore:
Timestamp:
05/13/10 20:28:11 (15 years ago)
Author:
gkronber
Message:

Fixed linear scaler to work also when no scaling parameters are given. #938

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/SymbolicRegressionSolutionLinearScaler.cs

    r3710 r3801  
    7272      DoubleValue alpha = AlphaParameter.ActualValue;
    7373      DoubleValue beta = BetaParameter.ActualValue;
    74       var mainBranch = tree.Root.SubTrees[0].SubTrees[0];
    75       var scaledMainBranch = MakeSum(MakeProduct(beta.Value, mainBranch), alpha.Value);
     74      if (alpha != null && beta != null) {
     75        var mainBranch = tree.Root.SubTrees[0].SubTrees[0];
     76        var scaledMainBranch = MakeSum(MakeProduct(beta.Value, mainBranch), alpha.Value);
    7677
    77       // remove the main branch before cloning to prevent cloning of sub-trees
    78       tree.Root.SubTrees[0].RemoveSubTree(0);
    79       var scaledTree = (SymbolicExpressionTree)tree.Clone();
    80       // insert main branch into the original tree again
    81       tree.Root.SubTrees[0].InsertSubTree(0, mainBranch);
    82       // insert the scaled main branch into the cloned tree
    83       scaledTree.Root.SubTrees[0].InsertSubTree(0, scaledMainBranch);
    84       ScaledSymbolicExpressionTreeParameter.ActualValue = scaledTree;
     78        // remove the main branch before cloning to prevent cloning of sub-trees
     79        tree.Root.SubTrees[0].RemoveSubTree(0);
     80        var scaledTree = (SymbolicExpressionTree)tree.Clone();
     81        // insert main branch into the original tree again
     82        tree.Root.SubTrees[0].InsertSubTree(0, mainBranch);
     83        // insert the scaled main branch into the cloned tree
     84        scaledTree.Root.SubTrees[0].InsertSubTree(0, scaledMainBranch);
     85        ScaledSymbolicExpressionTreeParameter.ActualValue = scaledTree;
     86      } else {
     87        // alpha or beta parameter not available => do not scale tree
     88        ScaledSymbolicExpressionTreeParameter.ActualValue = tree;
     89      }
     90     
    8591      return base.Apply();
    8692    }
Note: See TracChangeset for help on using the changeset viewer.