Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/22 20:33:45 (12 months ago)
Author:
gkronber
Message:

#3136: reintegrated structure-template GP branch into trunk

Location:
trunk
Files:
22 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

    r18210 r18220  
    4747    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    4848    <Prefer32Bit>false</Prefer32Bit>
     49    <LangVersion>default</LangVersion>
    4950  </PropertyGroup>
    5051  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     
    5758    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    5859    <Prefer32Bit>false</Prefer32Bit>
     60    <LangVersion>default</LangVersion>
    5961  </PropertyGroup>
    6062  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
     
    6769    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    6870    <Prefer32Bit>false</Prefer32Bit>
     71    <LangVersion>default</LangVersion>
    6972  </PropertyGroup>
    7073  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
     
    7780    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    7881    <Prefer32Bit>false</Prefer32Bit>
     82    <LangVersion>default</LangVersion>
    7983  </PropertyGroup>
    8084  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     
    8791    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    8892    <Prefer32Bit>false</Prefer32Bit>
     93    <LangVersion>default</LangVersion>
    8994  </PropertyGroup>
    9095  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
     
    97102    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    98103    <Prefer32Bit>false</Prefer32Bit>
     104    <LangVersion>default</LangVersion>
    99105  </PropertyGroup>
    100106  <ItemGroup>
     
    127133    <Compile Include="MultiObjective\ShapeConstrainedRegressionMultiObjectiveProblem.cs" />
    128134    <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer.cs" />
     135    <Compile Include="ParameterOptimization.cs" />
    129136    <Compile Include="Plugin.cs" />
    130137    <Compile Include="ShapeConstraintsAnalyzer.cs" />
     
    135142    <Compile Include="SingleObjective\SolutionQualityAnalyzer.cs" />
    136143    <Compile Include="SingleObjective\SolutionRSquaredAnalyzer.cs" />
     144    <Compile Include="SingleObjective\StructureTemplateSymbolicRegressionProblem.cs" />
    137145    <Compile Include="SymbolicRegressionPhenotypicDiversityAnalyzer.cs" />
    138146    <Compile Include="SymbolicRegressionPruningAnalyzer.cs" />
     
    212220      <Private>False</Private>
    213221    </ProjectReference>
     222    <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
     223      <Project>{BB6D334A-4BB6-4674-9883-31A6EBB32CAB}</Project>
     224      <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name>
     225    </ProjectReference>
    214226    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
    215227      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
     
    257269      <Private>False</Private>
    258270    </ProjectReference>
     271    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances.DataAnalysis\3.3\HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj">
     272      <Project>{94C7714E-29D4-4D6D-B213-2C18D627AB75}</Project>
     273      <Name>HeuristicLab.Problems.Instances.DataAnalysis-3.3</Name>
     274    </ProjectReference>
    259275    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
    260276      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
    261277      <Name>HeuristicLab.Problems.Instances-3.3</Name>
    262278      <Private>False</Private>
     279    </ProjectReference>
     280    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     281      <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>
     282      <Name>HeuristicLab.Random-3.3</Name>
    263283    </ProjectReference>
    264284  </ItemGroup>
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSingleObjectiveEvaluator.cs

    r17180 r18220  
    1 using HEAL.Attic;
     1using System.Collections.Generic;
     2using System.Linq;
     3using HEAL.Attic;
     4using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    25#region License Information
    36/* HeuristicLab
     
    2427  [StorableType("5dd2601a-b884-48c0-85bc-bc1f437187a3")]
    2528  public interface ISymbolicRegressionSingleObjectiveEvaluator : ISymbolicRegressionEvaluator, ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData> {
     29    double Evaluate(
     30      ISymbolicExpressionTree tree,
     31      IRegressionProblemData problemData,
     32      IEnumerable<int> rows,
     33      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     34      bool applyLinearScaling = true,
     35      double lowerEstimationLimit = double.MinValue,
     36      double upperEstimationLimit = double.MaxValue);
    2637  }
    2738}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs

    r18132 r18220  
    7070    public override IOperation InstrumentedApply() {
    7171      IEnumerable<int> rows = GenerateRowsToEvaluate();
    72       var solution = SymbolicExpressionTreeParameter.ActualValue;
     72      var tree = SymbolicExpressionTreeParameter.ActualValue;
    7373      var problemData = ProblemDataParameter.ActualValue;
    7474      var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
     
    7777
    7878      if (UseParameterOptimization) {
    79         SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     79        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    8080      }
    8181
    82       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, applyLinearScaling);
     82      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     83        tree, problemData, rows, interpreter, applyLinearScaling,
     84        estimationLimits.Lower, estimationLimits.Upper);
    8385
    8486      if (DecimalPlaces >= 0)
     
    107109      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    108110
    109       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, applyLinearScaling);
     111      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     112        tree, problemData, rows,
     113        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     114        applyLinearScaling,
     115        estimationLimits.Lower, estimationLimits.Upper);
    110116
    111117      lock (locker) {
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs

    r18132 r18220  
    6363    }
    6464
    65     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    66       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     65    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     66      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     67         tree, problemData, rows,
     68         interpreter, applyLinearScaling,
     69         lowerEstimationLimit, upperEstimationLimit);
    6770      if (decimalPlaces >= 0)
    6871        r2 = Math.Round(r2, decimalPlaces);
    69       return new double[2] { r2, solution.IterateNodesPostfix().Sum(n => n.GetLength()) }; // sum of the length of the whole sub-tree for each node
     72      return new double[2] { r2, tree.IterateNodesPostfix().Sum(n => n.GetLength()) }; // sum of the length of the whole sub-tree for each node
    7073    }
    7174
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs

    r18132 r18220  
    6262    }
    6363
    64     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    65       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     64    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     65      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     66        tree, problemData, rows, interpreter, applyLinearScaling,
     67        lowerEstimationLimit, upperEstimationLimit);
    6668      if (decimalPlaces >= 0)
    6769        r2 = Math.Round(r2, decimalPlaces);
    68       return new double[2] { r2, solution.IterateNodesPostfix().OfType<IVariableTreeNode>().Count() }; // count the number of variables
     70      return new double[2] { r2, tree.IterateNodesPostfix().OfType<IVariableTreeNode>().Count() }; // count the number of variables
    6971    }
    7072
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs

    r18132 r18220  
    6161    }
    6262
    63     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    64       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     63    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     64      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     65         tree, problemData, rows,
     66         interpreter, applyLinearScaling,
     67         lowerEstimationLimit, upperEstimationLimit);
    6568      if (decimalPlaces >= 0)
    6669        r2 = Math.Round(r2, decimalPlaces);
    67       return new double[2] { r2, SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity(solution) };
     70      return new double[2] { r2, SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity(tree) };
    6871    }
    6972
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs

    r18132 r18220  
    2222using System;
    2323using System.Collections.Generic;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Data;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
     
    4747    public override IOperation InstrumentedApply() {
    4848      IEnumerable<int> rows = GenerateRowsToEvaluate();
    49       var solution = SymbolicExpressionTreeParameter.ActualValue;
     49      var tree = SymbolicExpressionTreeParameter.ActualValue;
    5050      var problemData = ProblemDataParameter.ActualValue;
    5151      var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
     
    5454
    5555      if (UseParameterOptimization) {
    56         SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
     56        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
    5757      }
    5858
    59       double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
     59      double[] qualities = Calculate(
     60        tree, ProblemDataParameter.ActualValue,
     61        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     62        ApplyLinearScalingParameter.ActualValue.Value,
     63        EstimationLimitsParameter.ActualValue.Lower,
     64        EstimationLimitsParameter.ActualValue.Upper,
     65        DecimalPlaces);
    6066      QualitiesParameter.ActualValue = new DoubleArray(qualities);
    6167      return base.InstrumentedApply();
    6268    }
    6369
    64     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    65       var mse = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(interpreter, solution, lowerEstimationLimit,
    66         upperEstimationLimit, problemData, rows, applyLinearScaling);
     70    public static double[] Calculate(
     71      ISymbolicExpressionTree tree,
     72      IRegressionProblemData problemData,
     73      IEnumerable<int> rows,
     74      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     75      bool applyLinearScaling,
     76      double lowerEstimationLimit, double upperEstimationLimit,
     77      int decimalPlaces) {
     78      var mse = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(
     79        tree, problemData, rows,
     80        interpreter, applyLinearScaling,
     81        lowerEstimationLimit,
     82        upperEstimationLimit);
    6783
    6884      if (decimalPlaces >= 0)
    6985        mse = Math.Round(mse, decimalPlaces);
    7086
    71       return new double[2] { mse, solution.Length };
     87      return new double[2] { mse, tree.Length };
    7288    }
    7389
     
    7793      ApplyLinearScalingParameter.ExecutionContext = context;
    7894
    79       double[] quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
     95      double[] quality = Calculate(
     96        tree, problemData, rows,
     97        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     98        ApplyLinearScalingParameter.ActualValue.Value,
     99        EstimationLimitsParameter.ActualValue.Lower,
     100        EstimationLimitsParameter.ActualValue.Upper, DecimalPlaces);
    80101
    81102      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs

    r18132 r18220  
    6161    }
    6262
    63     public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
    64       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     63    public static double[] Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree tree, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling, int decimalPlaces) {
     64      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     65        tree, problemData, rows, interpreter, applyLinearScaling,
     66        lowerEstimationLimit, upperEstimationLimit);
    6567      if (decimalPlaces >= 0)
    6668        r2 = Math.Round(r2, decimalPlaces);
    67       return new double[2] { r2, solution.Length };
     69      return new double[2] { r2, tree.Length };
    6870    }
    6971
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Plugin.cs.frame

    r17931 r18220  
    3434  [PluginDependency("HeuristicLab.Core", "3.3")]
    3535  [PluginDependency("HeuristicLab.Data", "3.3")]
    36   [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")]
     36  [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
     37  [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] 
    3738  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3839  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     
    4142  [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")]
    4243  [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")]
     44  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
     45  [PluginDependency("HeuristicLab.Problems.Instances.DataAnalysis", "3.3")]
    4346  public class HeuristicLabProblemsDataAnalysisSymbolicRegressionPlugin : PluginBase {
    4447  }
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs

    r18132 r18220  
    125125      var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    126126
    127       if (OptimizeParameters) {
    128         SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows,
    129           false, ParameterOptimizationIterations, true,
    130           estimationLimits.Lower, estimationLimits.Upper);
    131       } else {
    132         if (applyLinearScaling) {
    133           var rootNode = new ProgramRootSymbol().CreateTreeNode();
    134           var startNode = new StartSymbol().CreateTreeNode();
    135           var offset = tree.Root.GetSubtree(0) //Start
    136                                 .GetSubtree(0); //Offset
    137           var scaling = offset.GetSubtree(0);
    138 
    139           //Check if tree contains offset and scaling nodes
    140           if (!(offset.Symbol is Addition) || !(scaling.Symbol is Multiplication))
    141             throw new ArgumentException($"{ItemName} can only be used with LinearScalingGrammar.");
    142 
    143           var t = (ISymbolicExpressionTreeNode)scaling.GetSubtree(0).Clone();
    144           rootNode.AddSubtree(startNode);
    145           startNode.AddSubtree(t);
    146           var newTree = new SymbolicExpressionTree(rootNode);
    147 
    148           //calculate alpha and beta for scaling
    149           var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(newTree, problemData.Dataset, rows);
    150 
    151           var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    152           OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out var alpha, out var beta,
    153             out var errorState);
    154 
    155           if (errorState == OnlineCalculatorError.None) {
    156             //Set alpha and beta to the scaling nodes from ia grammar
    157             var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
    158             offsetParameter.Value = alpha;
    159             var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
    160             scalingParameter.Value = beta;
    161           }
    162         } // else: alpha and beta are evolved
    163       }
    164 
    165       var quality = Calculate(interpreter, tree, estimationLimits.Lower, estimationLimits.Upper, problemData, rows,
    166         BoundsEstimator, UseSoftConstraints, PenalityFactor);
     127      var quality = Evaluate(tree, problemData, rows, interpreter, applyLinearScaling, estimationLimits.Lower, estimationLimits.Upper);
    167128      QualityParameter.ActualValue = new DoubleValue(quality);
    168129
     
    170131    }
    171132
     133    private static void CalcLinearScalingTerms(
     134      ISymbolicExpressionTree tree,
     135      IRegressionProblemData problemData,
     136      IEnumerable<int> rows,
     137      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter) {
     138      var rootNode = new ProgramRootSymbol().CreateTreeNode();
     139      var startNode = new StartSymbol().CreateTreeNode();
     140      var offset = tree.Root.GetSubtree(0) //Start
     141                            .GetSubtree(0); //Offset
     142      var scaling = offset.GetSubtree(0);
     143
     144      //Check if tree contains offset and scaling nodes
     145      if (!(offset.Symbol is Addition) || !(scaling.Symbol is Multiplication))
     146        throw new ArgumentException($"Scaling can only be used with LinearScalingGrammar.");
     147
     148      var t = (ISymbolicExpressionTreeNode)scaling.GetSubtree(0).Clone();
     149      rootNode.AddSubtree(startNode);
     150      startNode.AddSubtree(t);
     151      var newTree = new SymbolicExpressionTree(rootNode);
     152
     153      //calculate alpha and beta for scaling
     154      var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(newTree, problemData.Dataset, rows);
     155
     156      var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
     157      OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out var alpha, out var beta,
     158        out var errorState);
     159
     160      if (errorState == OnlineCalculatorError.None) {
     161        //Set alpha and beta to the scaling nodes from grammar
     162        var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
     163        offsetParameter.Value = alpha;
     164        var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
     165        scalingParameter.Value = beta;
     166      }
     167    }
     168
    172169    public static double Calculate(
     170      ISymbolicExpressionTree tree,
     171      IRegressionProblemData problemData, IEnumerable<int> rows,
    173172      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
    174       ISymbolicExpressionTree tree,
    175173      double lowerEstimationLimit, double upperEstimationLimit,
    176       IRegressionProblemData problemData, IEnumerable<int> rows,
    177174      IBoundsEstimator estimator,
    178175      bool useSoftConstraints = false, double penaltyFactor = 1.0) {
    179176
     177      var constraints = Enumerable.Empty<ShapeConstraint>();
     178      if (problemData is ShapeConstrainedRegressionProblemData scProbData)
     179        constraints = scProbData.ShapeConstraints.EnabledConstraints;
     180
    180181      var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
     182      var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    181183      var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    182       var constraints = Enumerable.Empty<ShapeConstraint>();
    183       if (problemData is ShapeConstrainedRegressionProblemData scProbData) {
    184         constraints = scProbData.ShapeConstraints.EnabledConstraints;
    185       }
     184      var nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out var errorState);
     185      if (errorState != OnlineCalculatorError.None)
     186        return 1.0;
     187
     188      if (!constraints.Any())
     189        return nmse;
     190
    186191      var intervalCollection = problemData.VariableRanges;
    187 
    188       var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
    189       var nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues,
    190         out var errorState);
    191 
    192       if (errorState != OnlineCalculatorError.None) {
     192      var constraintViolations = IntervalUtil.GetConstraintViolations(constraints, estimator, intervalCollection, tree);
     193
     194      // infinite/NaN constraints
     195      if (constraintViolations.Any(x => double.IsNaN(x) || double.IsInfinity(x)))
    193196        return 1.0;
    194       }
    195 
    196       var constraintViolations = IntervalUtil.GetConstraintViolations(constraints, estimator, intervalCollection, tree);
    197 
    198       if (constraintViolations.Any(x => double.IsNaN(x) || double.IsInfinity(x))) {
    199         return 1.0;
    200       }
    201 
    202       if (useSoftConstraints) {
    203         if (penaltyFactor < 0.0)
    204           throw new ArgumentException("The parameter has to be >= 0.0.", nameof(penaltyFactor));
    205 
    206         var weightedViolationsAvg = constraints
    207           .Zip(constraintViolations, (c, v) => c.Weight * v)
    208           .Average();
    209 
    210         return Math.Min(nmse, 1.0) + penaltyFactor * weightedViolationsAvg;
    211       } else if (constraintViolations.Any(x => x > 0.0)) {
    212         return 1.0;
    213       }
    214 
    215       return nmse;
     197
     198      // hard constraints
     199      if (!useSoftConstraints) {
     200        if (constraintViolations.Any(x => x > 0.0))
     201          return 1.0;
     202        return nmse;
     203      }
     204
     205      // soft constraints
     206      if (penaltyFactor < 0.0)
     207        throw new ArgumentException("The parameter has to be >= 0.0.", nameof(penaltyFactor));
     208
     209      var weightedViolationsAvg = constraints
     210        .Zip(constraintViolations, (c, v) => c.Weight * v)
     211        .Average();
     212
     213      return Math.Min(nmse, 1.0) + penaltyFactor * weightedViolationsAvg;
    216214    }
    217215
     
    223221      ApplyLinearScalingParameter.ExecutionContext = context;
    224222
    225       var nmse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree,
    226         EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper,
    227         problemData, rows, BoundsEstimator, UseSoftConstraints, PenalityFactor);
     223      var nmse = Calculate(
     224        tree, problemData, rows,
     225        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     226        EstimationLimitsParameter.ActualValue.Lower,
     227        EstimationLimitsParameter.ActualValue.Upper,
     228        BoundsEstimator,
     229        UseSoftConstraints,
     230        PenalityFactor);
    228231
    229232      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    233236      return nmse;
    234237    }
     238
     239    public override double Evaluate(
     240      ISymbolicExpressionTree tree,
     241      IRegressionProblemData problemData,
     242      IEnumerable<int> rows,
     243      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     244      bool applyLinearScaling = true,
     245      double lowerEstimationLimit = double.MinValue,
     246      double upperEstimationLimit = double.MaxValue) {
     247
     248      if (OptimizeParameters)
     249        Optimize(
     250          interpreter, tree,
     251          problemData, rows,
     252          ParameterOptimizationIterations,
     253          updateVariableWeights: true,
     254          lowerEstimationLimit,
     255          upperEstimationLimit);
     256      else if (applyLinearScaling) // extra scaling terms, which are included in tree
     257        CalcLinearScalingTerms(tree, problemData, rows, interpreter);
     258
     259      return Calculate(
     260        tree, problemData,
     261        rows, interpreter,
     262        lowerEstimationLimit,
     263        upperEstimationLimit,
     264        BoundsEstimator,
     265        UseSoftConstraints,
     266        PenalityFactor);
     267    }
     268
     269    public static double Optimize(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     270          ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows,
     271          int maxIterations, bool updateVariableWeights = true,
     272          double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue,
     273          bool updateParametersInTree = true, Action<double[], double, object> iterationCallback = null, EvaluationsCounter counter = null) {
     274
     275      // Numeric parameters in the tree become variables for parameter optimization.
     276      // Variables in the tree become parameters (fixed values) for parameter optimization.
     277      // For each parameter (variable in the original tree) we store the
     278      // variable name, variable value (for factor vars) and lag as a DataForVariable object.
     279      // A dictionary is used to find parameters
     280      double[] initialParameters;
     281      var parameters = new List<TreeToAutoDiffTermConverter.DataForVariable>();
     282
     283      TreeToAutoDiffTermConverter.ParametricFunction func;
     284      TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad;
     285      if (!TreeToAutoDiffTermConverter.TryConvertToAutoDiff(tree, updateVariableWeights, addLinearScalingTerms: false, out parameters, out initialParameters, out func, out func_grad))
     286        throw new NotSupportedException("Could not optimize parameters of symbolic expression tree due to not supported symbols used in the tree.");
     287      var parameterEntries = parameters.ToArray(); // order of entries must be the same for x
     288
     289      // extract initial parameters
     290      double[] c = (double[])initialParameters.Clone();
     291
     292      double originalQuality = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(
     293        tree, problemData, rows,
     294        interpreter, applyLinearScaling: false,
     295        lowerEstimationLimit,
     296        upperEstimationLimit);
     297
     298      if (counter == null) counter = new EvaluationsCounter();
     299      var rowEvaluationsCounter = new EvaluationsCounter();
     300
     301      alglib.minlmreport rep;
     302
     303      IDataset ds = problemData.Dataset;
     304      int n = rows.Count();
     305      int k = parameters.Count;
     306
     307      double[,] x = new double[n, k];
     308      int row = 0;
     309      foreach (var r in rows) {
     310        int col = 0;
     311        foreach (var info in parameterEntries) {
     312          if (ds.VariableHasType<double>(info.variableName)) {
     313            x[row, col] = ds.GetDoubleValue(info.variableName, r + info.lag);
     314          } else if (ds.VariableHasType<string>(info.variableName)) {
     315            x[row, col] = ds.GetStringValue(info.variableName, r) == info.variableValue ? 1 : 0;
     316          } else throw new InvalidProgramException("found a variable of unknown type");
     317          col++;
     318        }
     319        row++;
     320      }
     321      double[] y = ds.GetDoubleValues(problemData.TargetVariable, rows).ToArray();
     322
     323
     324      alglib.ndimensional_rep xrep = (p, f, obj) => iterationCallback(p, f, obj);
     325
     326      try {
     327        alglib.minlmcreatevj(y.Length, c, out var lmstate);
     328        alglib.minlmsetcond(lmstate, 0.0, maxIterations);
     329        alglib.minlmsetxrep(lmstate, iterationCallback != null);
     330        // alglib.minlmoptguardgradient(lmstate, 1e-5); // for debugging gradient calculation
     331        alglib.minlmoptimize(lmstate, CreateFunc(func, x, y), CreateJac(func_grad, x, y), xrep, rowEvaluationsCounter);
     332        alglib.minlmresults(lmstate, out c, out rep);
     333        // alglib.minlmoptguardresults(lmstate, out var optGuardReport);
     334      } catch (ArithmeticException) {
     335        return originalQuality;
     336      } catch (alglib.alglibexception) {
     337        return originalQuality;
     338      }
     339
     340      counter.FunctionEvaluations += rowEvaluationsCounter.FunctionEvaluations / n;
     341      counter.GradientEvaluations += rowEvaluationsCounter.GradientEvaluations / n;
     342
     343      // * TerminationType, completion code:
     344      //     * -8    optimizer detected NAN/INF values either in the function itself,
     345      //             or in its Jacobian
     346      //     * -5    inappropriate solver was used:
     347      //             * solver created with minlmcreatefgh() used  on  problem  with
     348      //               general linear constraints (set with minlmsetlc() call).
     349      //     * -3    constraints are inconsistent
     350      //     *  2    relative step is no more than EpsX.
     351      //     *  5    MaxIts steps was taken
     352      //     *  7    stopping conditions are too stringent,
     353      //             further improvement is impossible
     354      //     *  8    terminated   by  user  who  called  MinLMRequestTermination().
     355      //             X contains point which was "current accepted" when termination
     356      //             request was submitted.
     357      if (rep.terminationtype > 0) {
     358        UpdateParameters(tree, c, updateVariableWeights);
     359      }
     360      var quality = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(
     361        tree, problemData, rows,
     362        interpreter, applyLinearScaling: false,
     363        lowerEstimationLimit, upperEstimationLimit);
     364
     365      if (!updateParametersInTree) UpdateParameters(tree, initialParameters, updateVariableWeights);
     366
     367      if (originalQuality < quality || double.IsNaN(quality)) {
     368        UpdateParameters(tree, initialParameters, updateVariableWeights);
     369        return originalQuality;
     370      }
     371      return quality;
     372    }
     373
     374    private static void UpdateParameters(ISymbolicExpressionTree tree, double[] parameters, bool updateVariableWeights) {
     375      int i = 0;
     376      foreach (var node in tree.Root.IterateNodesPrefix().OfType<SymbolicExpressionTreeTerminalNode>()) {
     377        NumberTreeNode numberTreeNode = node as NumberTreeNode;
     378        VariableTreeNodeBase variableTreeNodeBase = node as VariableTreeNodeBase;
     379        FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode;
     380        if (numberTreeNode != null) {
     381          if (numberTreeNode.Parent.Symbol is Power
     382              && numberTreeNode.Parent.GetSubtree(1) == numberTreeNode) continue; // exponents in powers are not optimized (see TreeToAutoDiffTermConverter)
     383          numberTreeNode.Value = parameters[i++];
     384        } else if (updateVariableWeights && variableTreeNodeBase != null)
     385          variableTreeNodeBase.Weight = parameters[i++];
     386        else if (factorVarTreeNode != null) {
     387          for (int j = 0; j < factorVarTreeNode.Weights.Length; j++)
     388            factorVarTreeNode.Weights[j] = parameters[i++];
     389        }
     390      }
     391    }
     392
     393    private static alglib.ndimensional_fvec CreateFunc(TreeToAutoDiffTermConverter.ParametricFunction func, double[,] x, double[] y) {
     394      int d = x.GetLength(1);
     395      // row buffer
     396      var xi = new double[d];
     397      // function must return residuals, alglib optimizes resid²
     398      return (double[] c, double[] resid, object o) => {
     399        for (int i = 0; i < y.Length; i++) {
     400          Buffer.BlockCopy(x, i * d * sizeof(double), xi, 0, d * sizeof(double)); // copy row. We are using BlockCopy instead of Array.Copy because x has rank 2
     401          resid[i] = func(c, xi) - y[i];
     402        }
     403        var counter = (EvaluationsCounter)o;
     404        counter.FunctionEvaluations += y.Length;
     405      };
     406    }
     407
     408    private static alglib.ndimensional_jac CreateJac(TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad, double[,] x, double[] y) {
     409      int numParams = x.GetLength(1);
     410      // row buffer
     411      var xi = new double[numParams];
     412      return (double[] c, double[] resid, double[,] jac, object o) => {
     413        int numVars = c.Length;
     414        for (int i = 0; i < y.Length; i++) {
     415          Buffer.BlockCopy(x, i * numParams * sizeof(double), xi, 0, numParams * sizeof(double)); // copy row
     416          var tuple = func_grad(c, xi);
     417          resid[i] = tuple.Item2 - y[i];
     418          Buffer.BlockCopy(tuple.Item1, 0, jac, i * numVars * sizeof(double), numVars * sizeof(double)); // copy the gradient to jac. BlockCopy because jac has rank 2.
     419        }
     420        var counter = (EvaluationsCounter)o;
     421        counter.FunctionEvaluations += y.Length;
     422        counter.GradientEvaluations += y.Length;
     423      };
     424    }
     425
     426    public class EvaluationsCounter {
     427      public int FunctionEvaluations = 0;
     428      public int GradientEvaluations = 0;
     429    }
    235430  }
    236431}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionLogResidualEvaluator.cs

    r17180 r18220  
    5454
    5555    public override IOperation InstrumentedApply() {
    56       var solution = SymbolicExpressionTreeParameter.ActualValue;
     56      var tree = SymbolicExpressionTreeParameter.ActualValue;
    5757      IEnumerable<int> rows = GenerateRowsToEvaluate();
    5858
    59       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
     59      double quality = Calculate(
     60        tree, ProblemDataParameter.ActualValue,
     61        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     62        EstimationLimitsParameter.ActualValue.Lower,
     63        EstimationLimitsParameter.ActualValue.Upper);
    6064      QualityParameter.ActualValue = new DoubleValue(quality);
    6165
     
    6367    }
    6468
    65     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) {
    66       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     69    public static double Calculate(
     70      ISymbolicExpressionTree tree,
     71      IRegressionProblemData problemData,
     72      IEnumerable<int> rows,
     73      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     74      double lowerEstimationLimit,
     75      double upperEstimationLimit) {
     76      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    6777      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    6878      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
     
    8393      EstimationLimitsParameter.ExecutionContext = context;
    8494
    85       double mlr = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
     95      double mlr = Calculate(
     96        tree, problemData, rows,
     97        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     98        EstimationLimitsParameter.ActualValue.Lower,
     99        EstimationLimitsParameter.ActualValue.Upper);
    86100
    87101      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    90104      return mlr;
    91105    }
     106
     107    public override double Evaluate(
     108      ISymbolicExpressionTree tree,
     109      IRegressionProblemData problemData,
     110      IEnumerable<int> rows,
     111      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     112      bool applyLinearScaling = true,
     113      double lowerEstimationLimit = double.MinValue,
     114      double upperEstimationLimit = double.MaxValue) {
     115      return Calculate(tree, problemData, rows, interpreter, lowerEstimationLimit, upperEstimationLimit);
     116    }
    92117  }
    93118}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionMeanRelativeErrorEvaluator.cs

    r17180 r18220  
    4747
    4848    public override IOperation InstrumentedApply() {
    49       var solution = SymbolicExpressionTreeParameter.ActualValue;
     49      var tree = SymbolicExpressionTreeParameter.ActualValue;
    5050      IEnumerable<int> rows = GenerateRowsToEvaluate();
    5151
    52       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows);
     52      double quality = Calculate(
     53        tree, ProblemDataParameter.ActualValue, rows,
     54        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     55        EstimationLimitsParameter.ActualValue.Lower,
     56        EstimationLimitsParameter.ActualValue.Upper);
    5357      QualityParameter.ActualValue = new DoubleValue(quality);
    5458
     
    5660    }
    5761
    58     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows) {
    59       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     62    public static double Calculate(
     63      ISymbolicExpressionTree tree,
     64      IRegressionProblemData problemData,
     65      IEnumerable<int> rows,
     66      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     67      double lowerEstimationLimit, double upperEstimationLimit) {
     68      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    6069      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    6170      IEnumerable<double> boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
     
    7685      EstimationLimitsParameter.ExecutionContext = context;
    7786
    78       double mre = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows);
     87      double mre = Calculate(
     88        tree, problemData, rows,
     89        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     90        EstimationLimitsParameter.ActualValue.Lower,
     91        EstimationLimitsParameter.ActualValue.Upper);
    7992
    8093      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    8396      return mre;
    8497    }
     98
     99    public override double Evaluate(
     100      ISymbolicExpressionTree tree,
     101      IRegressionProblemData problemData,
     102      IEnumerable<int> rows,
     103      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     104      bool applyLinearScaling = true,
     105      double lowerEstimationLimit = double.MinValue,
     106      double upperEstimationLimit = double.MaxValue) {
     107      return Calculate(tree, problemData, rows, interpreter, lowerEstimationLimit, upperEstimationLimit);
     108    }
    85109  }
    86110}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionParameterOptimizationEvaluator.cs

    r18132 r18220  
    197197          Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationRowsPercentageParameterName, "Determines the percentage of the rows which should be used for parameter optimization", new PercentValue(1)));
    198198        }
    199        
     199
    200200      }
    201201    }
     
    203203    private static readonly object locker = new object();
    204204    public override IOperation InstrumentedApply() {
    205       var solution = SymbolicExpressionTreeParameter.ActualValue;
     205      var tree = SymbolicExpressionTreeParameter.ActualValue;
    206206      double quality;
    207207      if (RandomParameter.ActualValue.NextDouble() < ParameterOptimizationProbability.Value) {
    208208        IEnumerable<int> parameterOptimizationRows = GenerateRowsToEvaluate(ParameterOptimizationRowsPercentage.Value);
    209209        var counter = new EvaluationsCounter();
    210         quality = OptimizeParameters(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, ProblemDataParameter.ActualValue,
     210        quality = OptimizeParameters(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, ProblemDataParameter.ActualValue,
    211211           parameterOptimizationRows, ApplyLinearScalingParameter.ActualValue.Value, ParameterOptimizationIterations.Value, updateVariableWeights: UpdateVariableWeights, lowerEstimationLimit: EstimationLimitsParameter.ActualValue.Lower, upperEstimationLimit: EstimationLimitsParameter.ActualValue.Upper, updateParametersInTree: UpdateParametersInTree, counter: counter);
    212212
    213213        if (ParameterOptimizationRowsPercentage.Value != RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value) {
    214214          var evaluationRows = GenerateRowsToEvaluate();
    215           quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, evaluationRows, ApplyLinearScalingParameter.ActualValue.Value);
     215          quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     216            tree, ProblemDataParameter.ActualValue,
     217            evaluationRows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     218            ApplyLinearScalingParameter.ActualValue.Value,
     219            EstimationLimitsParameter.ActualValue.Lower,
     220            EstimationLimitsParameter.ActualValue.Upper);
    216221        }
    217222
     
    225230      } else {
    226231        var evaluationRows = GenerateRowsToEvaluate();
    227         quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, evaluationRows, ApplyLinearScalingParameter.ActualValue.Value);
     232        quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     233          tree, ProblemDataParameter.ActualValue,
     234          evaluationRows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     235          ApplyLinearScalingParameter.ActualValue.Value,
     236          EstimationLimitsParameter.ActualValue.Lower,
     237          EstimationLimitsParameter.ActualValue.Upper);
    228238      }
    229239      QualityParameter.ActualValue = new DoubleValue(quality);
    230240
    231241      return base.InstrumentedApply();
     242    }
     243
     244    public override double Evaluate(
     245      ISymbolicExpressionTree tree,
     246      IRegressionProblemData problemData,
     247      IEnumerable<int> rows,
     248      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     249      bool applyLinearScaling = true,
     250      double lowerEstimationLimit = double.MinValue,
     251      double upperEstimationLimit = double.MaxValue) {
     252
     253      var random = RandomParameter.ActualValue;
     254      double quality = double.NaN;
     255
     256      var propability = random.NextDouble();
     257      if (propability < ParameterOptimizationProbability.Value) {
     258        quality = OptimizeParameters(
     259          interpreter, tree,
     260          problemData, rows,
     261          applyLinearScaling,
     262          ParameterOptimizationIterations.Value,
     263          updateVariableWeights: UpdateVariableWeights,
     264          lowerEstimationLimit: lowerEstimationLimit,
     265          upperEstimationLimit: upperEstimationLimit,
     266          updateParametersInTree: UpdateParametersInTree);
     267      }
     268      if (double.IsNaN(quality) || ParameterOptimizationRowsPercentage.Value != RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value) {
     269        quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     270          tree, problemData,
     271          rows, interpreter,
     272          applyLinearScaling,
     273          lowerEstimationLimit,
     274          upperEstimationLimit);
     275      }
     276      return quality;
    232277    }
    233278
     
    242287      // because Evaluate() is used to get the quality of evolved models on
    243288      // different partitions of the dataset (e.g., best validation model)
    244       double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     289      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     290        tree, problemData, rows,
     291        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     292        ApplyLinearScalingParameter.ActualValue.Value,
     293        EstimationLimitsParameter.ActualValue.Lower,
     294        EstimationLimitsParameter.ActualValue.Upper);
    245295
    246296      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    290340      }
    291341
    292       double originalQuality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     342      double originalQuality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     343        tree, problemData, rows,
     344        interpreter, applyLinearScaling,
     345        lowerEstimationLimit,
     346        upperEstimationLimit);
    293347
    294348      if (counter == null) counter = new EvaluationsCounter();
     
    348402        } else UpdateParameters(tree, c, updateVariableWeights);
    349403      }
    350       var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
     404      var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
     405        tree, problemData, rows,
     406        interpreter, applyLinearScaling,
     407        lowerEstimationLimit, upperEstimationLimit);
    351408
    352409      if (!updateParametersInTree) UpdateParameters(tree, initialParameters, updateVariableWeights);
     
    366423        FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode;
    367424        if (numberTreeNode != null) {
    368           if (numberTreeNode.Parent.Symbol is Power 
     425          if (numberTreeNode.Parent.Symbol is Power
    369426              && numberTreeNode.Parent.GetSubtree(1) == numberTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter)
    370427          numberTreeNode.Value = parameters[i++];
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs

    r17180 r18220  
    2222using HeuristicLab.Common;
    2323using HEAL.Attic;
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     25using System.Collections.Generic;
     26
    2427namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
    2528  [StorableType("7EB90F03-4385-474F-BDE7-3B133E8FEAAB")]
     
    2831    protected SymbolicRegressionSingleObjectiveEvaluator(StorableConstructorFlag _) : base(_) { }
    2932    protected SymbolicRegressionSingleObjectiveEvaluator(SymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { }
    30     protected SymbolicRegressionSingleObjectiveEvaluator(): base() {}   
     33    protected SymbolicRegressionSingleObjectiveEvaluator(): base() {}
     34    public abstract double Evaluate(
     35      ISymbolicExpressionTree tree,
     36      IRegressionProblemData problemData,
     37      IEnumerable<int> rows,
     38      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     39      bool applyLinearScaling = true,
     40      double lowerEstimationLimit = double.MinValue,
     41      double upperEstimationLimit = double.MaxValue);
    3142  }
    3243}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs

    r17180 r18220  
    4343
    4444    public override IOperation InstrumentedApply() {
    45       var solution = SymbolicExpressionTreeParameter.ActualValue;
     45      var tree = SymbolicExpressionTreeParameter.ActualValue;
    4646      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4747
    48       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     48      double quality = Calculate(
     49        tree, ProblemDataParameter.ActualValue,
     50        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     51        ApplyLinearScalingParameter.ActualValue.Value,
     52        EstimationLimitsParameter.ActualValue.Lower,
     53        EstimationLimitsParameter.ActualValue.Upper);
    4954      QualityParameter.ActualValue = new DoubleValue(quality);
    5055
     
    5257    }
    5358
    54     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
    55       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     59    public static double Calculate(
     60      ISymbolicExpressionTree tree,
     61      IRegressionProblemData problemData,
     62      IEnumerable<int> rows,
     63      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     64      bool applyLinearScaling,
     65      double lowerEstimationLimit,
     66      double upperEstimationLimit) {
     67      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    5668      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    5769      OnlineCalculatorError errorState;
     
    7688      ApplyLinearScalingParameter.ExecutionContext = context;
    7789
    78       double mse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     90      double mse = Calculate(
     91        tree, problemData, rows,
     92        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     93        ApplyLinearScalingParameter.ActualValue.Value,
     94        EstimationLimitsParameter.ActualValue.Lower,
     95        EstimationLimitsParameter.ActualValue.Upper);
    7996
    8097      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    84101      return mse;
    85102    }
     103
     104    public override double Evaluate(
     105      ISymbolicExpressionTree tree,
     106      IRegressionProblemData problemData,
     107      IEnumerable<int> rows,
     108      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     109      bool applyLinearScaling = true,
     110      double lowerEstimationLimit = double.MinValue,
     111      double upperEstimationLimit = double.MaxValue) {
     112      return Calculate(tree, problemData, rows, interpreter, applyLinearScaling, lowerEstimationLimit, upperEstimationLimit);
     113    }
    86114  }
    87115}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs

    r17180 r18220  
    4343
    4444    public override IOperation InstrumentedApply() {
    45       var solution = SymbolicExpressionTreeParameter.ActualValue;
     45      var tree = SymbolicExpressionTreeParameter.ActualValue;
    4646      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4747
    48       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     48      double quality = Calculate(tree,
     49        ProblemDataParameter.ActualValue, rows,
     50        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     51        ApplyLinearScalingParameter.ActualValue.Value,
     52        EstimationLimitsParameter.ActualValue.Lower,
     53        EstimationLimitsParameter.ActualValue.Upper);
    4954      QualityParameter.ActualValue = new DoubleValue(quality);
    5055
     
    5257    }
    5358
    54     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
    55       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     59    public static double Calculate(
     60      ISymbolicExpressionTree tree,
     61      IRegressionProblemData problemData,
     62      IEnumerable<int> rows,
     63      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     64      bool applyLinearScaling,
     65      double lowerEstimationLimit,
     66      double upperEstimationLimit) {
     67      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    5668      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    5769      OnlineCalculatorError errorState;
     
    7688      ApplyLinearScalingParameter.ExecutionContext = context;
    7789
    78       double mse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     90      double mse = Calculate(
     91        tree, problemData, rows,
     92        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     93        ApplyLinearScalingParameter.ActualValue.Value,
     94        EstimationLimitsParameter.ActualValue.Lower,
     95        EstimationLimitsParameter.ActualValue.Upper);
    7996
    8097      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    84101      return mse;
    85102    }
     103
     104    public override double Evaluate(
     105      ISymbolicExpressionTree tree,
     106      IRegressionProblemData problemData,
     107      IEnumerable<int> rows,
     108      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     109      bool applyLinearScaling = true,
     110      double lowerEstimationLimit = double.MinValue,
     111      double upperEstimationLimit = double.MaxValue) {
     112      return Calculate(tree, problemData, rows, interpreter, applyLinearScaling, lowerEstimationLimit, upperEstimationLimit);
     113    }
    86114  }
    87115}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs

    r17180 r18220  
    4343
    4444    public override IOperation InstrumentedApply() {
    45       var solution = SymbolicExpressionTreeParameter.ActualValue;
     45      var tree = SymbolicExpressionTreeParameter.ActualValue;
    4646      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4747
    48       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     48      double quality = Calculate(
     49        tree, ProblemDataParameter.ActualValue,
     50        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     51        ApplyLinearScalingParameter.ActualValue.Value,         
     52        EstimationLimitsParameter.ActualValue.Lower,
     53        EstimationLimitsParameter.ActualValue.Upper);
    4954      QualityParameter.ActualValue = new DoubleValue(quality);
    5055
     
    5257    }
    5358
    54     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
    55       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     59    public static double Calculate(
     60      ISymbolicExpressionTree tree,
     61      IRegressionProblemData problemData,
     62      IEnumerable<int> rows,
     63      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     64      bool applyLinearScaling,
     65      double lowerEstimationLimit, double upperEstimationLimit) {
     66      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    5667      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    5768      OnlineCalculatorError errorState;
     
    7687      ApplyLinearScalingParameter.ExecutionContext = context;
    7788
    78       double mse = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     89      double mse = Calculate(       
     90        tree, problemData, rows,
     91        SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     92        ApplyLinearScalingParameter.ActualValue.Value,
     93        EstimationLimitsParameter.ActualValue.Lower,
     94        EstimationLimitsParameter.ActualValue.Upper);
    7995
    8096      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    84100      return mse;
    85101    }
     102
     103    public override double Evaluate(
     104      ISymbolicExpressionTree tree,
     105      IRegressionProblemData problemData,
     106      IEnumerable<int> rows,
     107      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     108      bool applyLinearScaling = true,
     109      double lowerEstimationLimit = double.MinValue,
     110      double upperEstimationLimit = double.MaxValue) {
     111      return Calculate(tree, problemData, rows, interpreter, applyLinearScaling, lowerEstimationLimit, upperEstimationLimit);
     112    }
    86113  }
    87114}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs

    r17180 r18220  
    4848      IEnumerable<int> rows = GenerateRowsToEvaluate();
    4949
    50       double quality = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value);
     50      double quality = Calculate(
     51        solution, ProblemDataParameter.ActualValue,
     52        rows, SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     53        ApplyLinearScalingParameter.ActualValue.Value,
     54        EstimationLimitsParameter.ActualValue.Lower,
     55        EstimationLimitsParameter.ActualValue.Upper);
    5156      QualityParameter.ActualValue = new DoubleValue(quality);
    5257
     
    5459    }
    5560
    56     public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, double lowerEstimationLimit, double upperEstimationLimit, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling) {
    57       IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
     61    public static double Calculate(
     62      ISymbolicExpressionTree tree,
     63      IRegressionProblemData problemData,
     64      IEnumerable<int> rows,
     65      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     66      bool applyLinearScaling,
     67      double lowerEstimationLimit,
     68      double upperEstimationLimit) {
     69      IEnumerable<double> estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, rows);
    5870      IEnumerable<double> targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
    5971      OnlineCalculatorError errorState;
     
    7890      ApplyLinearScalingParameter.ExecutionContext = context;
    7991
    80       double r2 = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
     92      double r2 = Calculate(
     93         tree, problemData, rows,
     94         SymbolicDataAnalysisTreeInterpreterParameter.ActualValue,
     95         ApplyLinearScalingParameter.ActualValue.Value,
     96         EstimationLimitsParameter.ActualValue.Lower,
     97         EstimationLimitsParameter.ActualValue.Upper);
    8198
    8299      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
     
    86103      return r2;
    87104    }
     105
     106    public override double Evaluate(
     107      ISymbolicExpressionTree tree,
     108      IRegressionProblemData problemData,
     109      IEnumerable<int> rows,
     110      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     111      bool applyLinearScaling = true,
     112      double lowerEstimationLimit = double.MinValue,
     113      double upperEstimationLimit = double.MaxValue) {
     114      return Calculate(
     115        tree, problemData, rows,
     116        interpreter, applyLinearScaling,
     117        lowerEstimationLimit, upperEstimationLimit);
     118    }
    88119  }
    89120}
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs

    r18107 r18220  
    5555
    5656    public override void Load(IRegressionProblemData data) {
    57       if (data is ShapeConstrainedRegressionProblemData scProblemData) {
    58       } else {
     57      var scProblemData = data as ShapeConstrainedRegressionProblemData;
     58      if (scProblemData == null) {
    5959        scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
    6060                                                                  data.TrainingPartition, data.TestPartition) {
Note: See TracChangeset for help on using the changeset viewer.