Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/23/16 19:33:03 (8 years ago)
Author:
bburlacu
Message:

#2685: Revert accidental commit.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
Files:
2 edited

Legend:

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

    r14353 r14354  
    7070      }
    7171      if (errorState != OnlineCalculatorError.None) return double.NaN;
    72       return r * r;
     72      return r*r;
    7373    }
    7474
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPhenotypicDiversityAnalyzer.cs

    r14353 r14354  
    4242    private const string ProblemDataParameterName = "ProblemData";
    4343    private const string EstimationLimitsParameterName = "EstimationLimits";
    44     private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
    4544    #endregion
    4645
     
    6160      get { return (IValueLookupParameter<DoubleLimit>)Parameters[EstimationLimitsParameterName]; }
    6261    }
    63     public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
    64       get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
    65     }
    6662    #endregion
    6763
     
    7470      Parameters.Add(new ValueLookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The problem data on which the symbolic data analysis solution should be evaluated."));
    7571      Parameters.Add(new ValueLookupParameter<DoubleLimit>(EstimationLimitsParameterName, "The upper and lower limit that should be used as cut off value for the output values of symbolic data analysis trees."));
    76       Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Whether or not to apply linear scaling to the estimated values"));
    7772      #endregion
    7873
     
    8479    protected SymbolicRegressionPhenotypicDiversityAnalyzer(bool deserializing)
    8580      : base(deserializing) {
    86     }
    87 
    88     [StorableHook(HookType.AfterDeserialization)]
    89     private void AfterDeserialization() {
    90       if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
    91         Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Whether or not to apply linear scaling to the estimated values"));
    9281    }
    9382
     
    10998      }
    11099
    111       if (updateCounter.Value != updateInterval) return base.Apply();
    112 
    113       var scopes = ExecutionContext.Scope.SubScopes;
    114       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
    115 
    116       foreach (var scope in scopes.Where(x => !x.Variables.ContainsKey("EstimatedValues"))) {
    117         var tree = (ISymbolicExpressionTree)scope.Variables["SymbolicExpressionTree"].Value;
     100      if (updateCounter.Value == updateInterval) {
     101        var trees = SymbolicExpressionTreeParameter.ActualValue;
    118102        var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
    119103        var ds = ProblemDataParameter.ActualValue.Dataset;
    120104        var rows = ProblemDataParameter.ActualValue.TrainingIndices;
    121         var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(tree, ds, rows).ToArray();
    122105
    123         var estimationLimits = EstimationLimitsParameter.ActualValue;
    124 
    125         if (applyLinearScaling) {
    126           var linearScalingCalculator = new OnlineLinearScalingParameterCalculator();
    127           var targetValues = ds.GetDoubleValues(ProblemDataParameter.ActualValue.TargetVariable, rows);
    128           int i = 0;
    129           foreach (var target in targetValues) {
    130             var estimated = estimatedValues[i];
    131             if (!double.IsNaN(estimated) && !double.IsInfinity(estimated))
    132               linearScalingCalculator.Add(estimated, target);
    133             i++;
    134           }
    135           if (linearScalingCalculator.ErrorState == OnlineCalculatorError.None) {
    136             var alpha = linearScalingCalculator.Alpha;
    137             var beta = linearScalingCalculator.Beta;
    138             for (i = 0; i < estimatedValues.Length; ++i) {
    139               estimatedValues[i] = estimatedValues[i] * beta + alpha;
    140             }
    141           }
    142         }
    143         // add estimated values to escope
    144         scope.Variables.Add(new Core.Variable("EstimatedValues", new DoubleArray(estimatedValues.LimitToRange(estimationLimits.Lower, estimationLimits.Upper).ToArray())));
     106        var evaluatedValues = new ItemArray<DoubleArray>(trees.Select(t => new DoubleArray(interpreter.GetSymbolicExpressionTreeValues(t, ds, rows).ToArray())));
     107        EvaluatedValuesParameter.ActualValue = evaluatedValues;
    145108      }
    146109      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.