1 | using HEAL.Attic;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Data;
|
---|
5 | using HeuristicLab.Parameters;
|
---|
6 | using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
9 | [Item("Symbolic regression single-objective user-defined evaluator", "Encapsulates a collection of single-objective evaluators and aggregates their output.")]
|
---|
10 | [StorableType("BCA2D407-576B-4529-8586-A4DFCE117F4C")]
|
---|
11 | public class SymbolicRegressionSingleObjectiveUserDefinedEvaluator : SymbolicDataAnalysisSingleObjectiveUserDefinedEvaluator<IRegressionProblemData>, ISymbolicRegressionSingleObjectiveEvaluator {
|
---|
12 | private const string OptimizeConstantsParameterName = "OptimizeConstants";
|
---|
13 | private const string ConstantOptimizationIterationsParameterName = "ConstantOptimizationIterations";
|
---|
14 |
|
---|
15 | public IFixedValueParameter<BoolValue> OptimizeConstantsParameter {
|
---|
16 | get { return (IFixedValueParameter<BoolValue>)Parameters[OptimizeConstantsParameterName]; }
|
---|
17 | }
|
---|
18 |
|
---|
19 | public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {
|
---|
20 | get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; }
|
---|
21 | }
|
---|
22 |
|
---|
23 | public bool OptimizeConstants => OptimizeConstantsParameter.Value.Value;
|
---|
24 |
|
---|
25 | public int ConstantOptimizationIterations => ConstantOptimizationIterationsParameter.Value.Value;
|
---|
26 |
|
---|
27 | public ILookupParameter<DoubleArray> QualitiesParameter => throw new System.NotImplementedException();
|
---|
28 |
|
---|
29 | public SymbolicRegressionSingleObjectiveUserDefinedEvaluator() {
|
---|
30 | Parameters.Add(new FixedValueParameter<BoolValue>(OptimizeConstantsParameterName, new BoolValue(false)));
|
---|
31 | Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, new IntValue(10)));
|
---|
32 | }
|
---|
33 |
|
---|
34 | protected SymbolicRegressionSingleObjectiveUserDefinedEvaluator(SymbolicRegressionSingleObjectiveUserDefinedEvaluator original, Cloner cloner) : base(original, cloner) { }
|
---|
35 |
|
---|
36 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
37 | return new SymbolicRegressionSingleObjectiveUserDefinedEvaluator(this, cloner);
|
---|
38 | }
|
---|
39 |
|
---|
40 | [StorableConstructor]
|
---|
41 | protected SymbolicRegressionSingleObjectiveUserDefinedEvaluator(StorableConstructorFlag _) : base(_) { }
|
---|
42 |
|
---|
43 | public override IOperation InstrumentedApply() {
|
---|
44 | var tree = SymbolicExpressionTreeParameter.ActualValue;
|
---|
45 | var problemData = ProblemDataParameter.ActualValue;
|
---|
46 |
|
---|
47 | if (OptimizeConstants) {
|
---|
48 | var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.ActualValue;
|
---|
49 | var estimationLimits = EstimationLimitsParameter.ActualValue;
|
---|
50 | var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
|
---|
51 | var iterations = ConstantOptimizationIterations;
|
---|
52 | SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, problemData.TrainingIndices, applyLinearScaling, iterations, true, estimationLimits.Lower, estimationLimits.Upper, true);
|
---|
53 | }
|
---|
54 |
|
---|
55 | return base.InstrumentedApply();
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|