Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/18 13:52:40 (6 years ago)
Author:
pfleck
Message:

#2845 reverted the last merge (r16307) because some revisions were missing

Location:
branches/2845_EnhancedProgress
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2845_EnhancedProgress

  • branches/2845_EnhancedProgress/HeuristicLab.Algorithms.DataAnalysis

  • branches/2845_EnhancedProgress/HeuristicLab.Algorithms.DataAnalysis/3.4

    • Property svn:mergeinfo deleted
  • branches/2845_EnhancedProgress/HeuristicLab.Algorithms.DataAnalysis/3.4/NonlinearRegression/NonlinearRegression.cs

    r16307 r16308  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    5151    private const string SeedParameterName = "Seed";
    5252    private const string InitParamsRandomlyParameterName = "InitializeParametersRandomly";
    53     private const string ApplyLinearScalingParameterName = "Apply linear scaling";
    5453
    5554    public IFixedValueParameter<StringValue> ModelStructureParameter {
     
    7473    public IFixedValueParameter<BoolValue> InitParametersRandomlyParameter {
    7574      get { return (IFixedValueParameter<BoolValue>)Parameters[InitParamsRandomlyParameterName]; }
    76     }
    77 
    78     public IFixedValueParameter<BoolValue> ApplyLinearScalingParameter {
    79       get { return (IFixedValueParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
    8075    }
    8176
     
    108103      get { return InitParametersRandomlyParameter.Value.Value; }
    109104      set { InitParametersRandomlyParameter.Value.Value = value; }
    110     }
    111 
    112     public bool ApplyLinearScaling {
    113       get { return ApplyLinearScalingParameter.Value.Value; }
    114       set { ApplyLinearScalingParameter.Value.Value = value; }
    115105    }
    116106
     
    129119      Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyParameterName, "Switch to determine if the random number seed should be initialized randomly.", new BoolValue(true)));
    130120      Parameters.Add(new FixedValueParameter<BoolValue>(InitParamsRandomlyParameterName, "Switch to determine if the real-valued model parameters should be initialized randomly in each restart.", new BoolValue(false)));
    131       Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Switch to determine if linear scaling terms should be added to the model", new BoolValue(true)));
    132121
    133122      SetParameterHiddenState();
     
    157146      if (!Parameters.ContainsKey(InitParamsRandomlyParameterName))
    158147        Parameters.Add(new FixedValueParameter<BoolValue>(InitParamsRandomlyParameterName, "Switch to determine if the numeric parameters of the model should be initialized randomly.", new BoolValue(false)));
    159       if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
    160         Parameters.Add(new FixedValueParameter<BoolValue>(ApplyLinearScalingParameterName, "Switch to determine if linear scaling terms should be added to the model", new BoolValue(true)));
    161 
    162148
    163149      SetParameterHiddenState();
     
    188174        if (SetSeedRandomly) Seed = (new System.Random()).Next();
    189175        var rand = new MersenneTwister((uint)Seed);
    190         bestSolution = CreateRegressionSolution(Problem.ProblemData, ModelStructure, Iterations, ApplyLinearScaling, rand);
     176        bestSolution = CreateRegressionSolution(Problem.ProblemData, ModelStructure, Iterations, rand);
    191177        trainRMSERow.Values.Add(bestSolution.TrainingRootMeanSquaredError);
    192178        testRMSERow.Values.Add(bestSolution.TestRootMeanSquaredError);
    193179        for (int r = 0; r < Restarts; r++) {
    194           var solution = CreateRegressionSolution(Problem.ProblemData, ModelStructure, Iterations, ApplyLinearScaling, rand);
     180          var solution = CreateRegressionSolution(Problem.ProblemData, ModelStructure, Iterations, rand);
    195181          trainRMSERow.Values.Add(solution.TrainingRootMeanSquaredError);
    196182          testRMSERow.Values.Add(solution.TestRootMeanSquaredError);
     
    200186        }
    201187      } else {
    202         bestSolution = CreateRegressionSolution(Problem.ProblemData, ModelStructure, Iterations, ApplyLinearScaling);
     188        bestSolution = CreateRegressionSolution(Problem.ProblemData, ModelStructure, Iterations);
    203189      }
    204190
     
    220206    /// <param name="random">Optional random number generator for random initialization of numeric constants.</param>
    221207    /// <returns></returns>
    222     public static ISymbolicRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData, string modelStructure, int maxIterations, bool applyLinearScaling, IRandom rand = null) {
     208    public static ISymbolicRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData, string modelStructure, int maxIterations, IRandom rand = null) {
    223209      var parser = new InfixExpressionParser();
    224210      var tree = parser.Parse(modelStructure);
     
    276262
    277263      SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, problemData.TrainingIndices,
    278         applyLinearScaling: applyLinearScaling, maxIterations: maxIterations,
     264        applyLinearScaling: false, maxIterations: maxIterations,
    279265        updateVariableWeights: false, updateConstantsInTree: true);
    280266
    281       var model = new SymbolicRegressionModel(problemData.TargetVariable, tree, (ISymbolicDataAnalysisExpressionTreeInterpreter)interpreter.Clone());
    282       if (applyLinearScaling)
    283         model.Scale(problemData);
    284 
    285       SymbolicRegressionSolution solution = new SymbolicRegressionSolution(model, (IRegressionProblemData)problemData.Clone());
     267      var scaledModel = new SymbolicRegressionModel(problemData.TargetVariable, tree, (ISymbolicDataAnalysisExpressionTreeInterpreter)interpreter.Clone());
     268      scaledModel.Scale(problemData);
     269      SymbolicRegressionSolution solution = new SymbolicRegressionSolution(scaledModel, (IRegressionProblemData)problemData.Clone());
    286270      solution.Model.Name = "Regression Model";
    287271      solution.Name = "Regression Solution";
Note: See TracChangeset for help on using the changeset viewer.