1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Optimization;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
|
---|
31 | [Item("Symbolic Regression Problem (multi objective)", "Represents a multi objective symbolic regression problem.")]
|
---|
32 | [StorableClass]
|
---|
33 | public class MultiObjectiveSymbolicRegressionProblem : SymbolicRegressionProblemBase, IMultiObjectiveHeuristicOptimizationProblem {
|
---|
34 |
|
---|
35 | #region Parameter Properties
|
---|
36 | public ValueParameter<BoolArray> MaximizationParameter {
|
---|
37 | get { return (ValueParameter<BoolArray>)Parameters["Maximization"]; }
|
---|
38 | }
|
---|
39 | IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter {
|
---|
40 | get { return MaximizationParameter; }
|
---|
41 | }
|
---|
42 | public new ValueParameter<IMultiObjectiveSymbolicRegressionEvaluator> EvaluatorParameter {
|
---|
43 | get { return (ValueParameter<IMultiObjectiveSymbolicRegressionEvaluator>)Parameters["Evaluator"]; }
|
---|
44 | }
|
---|
45 | IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
|
---|
46 | get { return EvaluatorParameter; }
|
---|
47 | }
|
---|
48 | #endregion
|
---|
49 |
|
---|
50 | #region Properties
|
---|
51 | public new IMultiObjectiveSymbolicRegressionEvaluator Evaluator {
|
---|
52 | get { return EvaluatorParameter.Value; }
|
---|
53 | set { EvaluatorParameter.Value = value; }
|
---|
54 | }
|
---|
55 | IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator {
|
---|
56 | get { return EvaluatorParameter.Value; }
|
---|
57 | }
|
---|
58 | IEvaluator IHeuristicOptimizationProblem.Evaluator {
|
---|
59 | get { return EvaluatorParameter.Value; }
|
---|
60 | }
|
---|
61 | #endregion
|
---|
62 |
|
---|
63 | [StorableConstructor]
|
---|
64 | protected MultiObjectiveSymbolicRegressionProblem(bool deserializing) : base(deserializing) { }
|
---|
65 | protected MultiObjectiveSymbolicRegressionProblem(MultiObjectiveSymbolicRegressionProblem original, Cloner cloner)
|
---|
66 | : base(original, cloner) {
|
---|
67 | RegisterParameterEvents();
|
---|
68 | RegisterParameterValueEvents();
|
---|
69 | }
|
---|
70 | public MultiObjectiveSymbolicRegressionProblem()
|
---|
71 | : base() {
|
---|
72 | var evaluator = new MultiObjectiveSymbolicRegressionPearsonsRSquaredEvaluator();
|
---|
73 | Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false as the error of the regression model should be minimized.", new BoolArray(new bool[] { true, false })));
|
---|
74 | Parameters.Add(new ValueParameter<IMultiObjectiveSymbolicRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator));
|
---|
75 |
|
---|
76 | evaluator.QualitiesParameter.ActualName = "TrainingRSquared/Size";
|
---|
77 |
|
---|
78 | ParameterizeEvaluator();
|
---|
79 |
|
---|
80 | RegisterParameterEvents();
|
---|
81 | RegisterParameterValueEvents();
|
---|
82 | }
|
---|
83 |
|
---|
84 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
85 | return new MultiObjectiveSymbolicRegressionProblem(this, cloner);
|
---|
86 | }
|
---|
87 |
|
---|
88 | private void RegisterParameterValueEvents() {
|
---|
89 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
90 | }
|
---|
91 |
|
---|
92 | private void RegisterParameterEvents() {
|
---|
93 | }
|
---|
94 |
|
---|
95 | #region event handling
|
---|
96 | protected override void OnDataAnalysisProblemChanged(EventArgs e) {
|
---|
97 | base.OnDataAnalysisProblemChanged(e);
|
---|
98 | // paritions could be changed
|
---|
99 | ParameterizeEvaluator();
|
---|
100 | }
|
---|
101 | protected override void OnSolutionParameterNameChanged(EventArgs e) {
|
---|
102 | ParameterizeEvaluator();
|
---|
103 | }
|
---|
104 |
|
---|
105 | protected override void OnEvaluatorChanged(EventArgs e) {
|
---|
106 | base.OnEvaluatorChanged(e);
|
---|
107 | ParameterizeEvaluator();
|
---|
108 | RaiseEvaluatorChanged(e);
|
---|
109 | }
|
---|
110 | #endregion
|
---|
111 |
|
---|
112 | #region event handlers
|
---|
113 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
114 | OnEvaluatorChanged(e);
|
---|
115 | }
|
---|
116 | #endregion
|
---|
117 |
|
---|
118 | #region Helpers
|
---|
119 | [StorableHook(HookType.AfterDeserialization)]
|
---|
120 | private void AfterDeserializationHook() {
|
---|
121 | RegisterParameterEvents();
|
---|
122 | RegisterParameterValueEvents();
|
---|
123 | }
|
---|
124 |
|
---|
125 | private void ParameterizeEvaluator() {
|
---|
126 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
127 | Evaluator.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
128 | Evaluator.SamplesStartParameter.Value = TrainingSamplesStart;
|
---|
129 | Evaluator.SamplesEndParameter.Value = TrainingSamplesEnd;
|
---|
130 | }
|
---|
131 | #endregion
|
---|
132 | }
|
---|
133 | }
|
---|