Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2993_UserDefinedEvaluators/HeuristicLab.Problems.DataAnalysis.Symbolic.UserDefinedEval/SymbolicRegressionMultiObjectiveUserDefinedEvaluator.cs @ 17915

Last change on this file since 17915 was 16687, checked in by bburlacu, 6 years ago

#2993: Initial implementation of user-defined evaluators as separate plugin.

File size: 2.9 KB
Line 
1using HEAL.Attic;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Data;
5using HeuristicLab.Parameters;
6
7namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
8  [Item("Symbolic regression multi-objective user-defined evaluator", "Encapsulates a collection of single-objective evaluators and returns an array of qualities.")]
9  [StorableType("9F77E2DA-B358-47FA-9DFF-EF04C9A7769A")]
10  public class SymbolicRegressionMultiObjectiveUserDefinedEvaluator : SymbolicDataAnalysisMultiObjectiveUserDefinedEvaluator<IRegressionProblemData>, ISymbolicRegressionMultiObjectiveEvaluator {
11    private const string OptimizeConstantsParameterName = "OptimizeConstants";
12    private const string ConstantOptimizationIterationsParameterName = "ConstantOptimizationIterations";
13
14    public IFixedValueParameter<BoolValue> OptimizeConstantsParameter {
15      get { return (IFixedValueParameter<BoolValue>)Parameters[OptimizeConstantsParameterName]; }
16    }
17
18    public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {
19      get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; }
20    }
21
22    public bool OptimizeConstants => OptimizeConstantsParameter.Value.Value;
23
24    public int ConstantOptimizationIterations => ConstantOptimizationIterationsParameter.Value.Value;
25
26    public SymbolicRegressionMultiObjectiveUserDefinedEvaluator() {
27      Parameters.Add(new FixedValueParameter<BoolValue>(OptimizeConstantsParameterName, new BoolValue(false)));
28      Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, new IntValue(10)));
29    }
30
31    protected SymbolicRegressionMultiObjectiveUserDefinedEvaluator(SymbolicRegressionMultiObjectiveUserDefinedEvaluator original, Cloner cloner) : base(original, cloner) { }
32
33    public override IDeepCloneable Clone(Cloner cloner) {
34      return new SymbolicRegressionMultiObjectiveUserDefinedEvaluator(this, cloner);
35    }
36
37    [StorableConstructor]
38    protected SymbolicRegressionMultiObjectiveUserDefinedEvaluator(StorableConstructorFlag _) : base(_) { }
39
40    public override IOperation InstrumentedApply() {
41      var tree = SymbolicExpressionTreeParameter.ActualValue;
42      var problemData = ProblemDataParameter.ActualValue;
43
44      if (OptimizeConstants) {
45        var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
46        var estimationLimits = EstimationLimitsParameter.ActualValue;
47        var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
48        var iterations = ConstantOptimizationIterations;
49        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, problemData.TrainingIndices, applyLinearScaling, iterations, true, estimationLimits.Lower, estimationLimits.Upper, true);
50      }
51
52      return base.InstrumentedApply();
53    }
54  }
55}
Note: See TracBrowser for help on using the repository browser.