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 | using HeuristicLab.PluginInfrastructure;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
|
---|
32 | [Item("Symbolic Regression Problem (multi objective)", "Represents a multi objective symbolic regression problem.")]
|
---|
33 | [StorableClass]
|
---|
34 | [NonDiscoverableType]
|
---|
35 | public class MultiObjectiveSymbolicRegressionProblem : SymbolicRegressionProblemBase, IMultiObjectiveHeuristicOptimizationProblem {
|
---|
36 |
|
---|
37 | #region Parameter Properties
|
---|
38 | public ValueParameter<BoolArray> MaximizationParameter {
|
---|
39 | get { return (ValueParameter<BoolArray>)Parameters["Maximization"]; }
|
---|
40 | }
|
---|
41 | IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter {
|
---|
42 | get { return MaximizationParameter; }
|
---|
43 | }
|
---|
44 | public new ValueParameter<IMultiObjectiveSymbolicRegressionEvaluator> EvaluatorParameter {
|
---|
45 | get { return (ValueParameter<IMultiObjectiveSymbolicRegressionEvaluator>)Parameters["Evaluator"]; }
|
---|
46 | }
|
---|
47 | IParameter IHeuristicOptimizationProblem.EvaluatorParameter {
|
---|
48 | get { return EvaluatorParameter; }
|
---|
49 | }
|
---|
50 | #endregion
|
---|
51 |
|
---|
52 | #region Properties
|
---|
53 | public new IMultiObjectiveSymbolicRegressionEvaluator Evaluator {
|
---|
54 | get { return EvaluatorParameter.Value; }
|
---|
55 | set { EvaluatorParameter.Value = value; }
|
---|
56 | }
|
---|
57 | IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator {
|
---|
58 | get { return EvaluatorParameter.Value; }
|
---|
59 | }
|
---|
60 | IEvaluator IHeuristicOptimizationProblem.Evaluator {
|
---|
61 | get { return EvaluatorParameter.Value; }
|
---|
62 | }
|
---|
63 | #endregion
|
---|
64 |
|
---|
65 | [StorableConstructor]
|
---|
66 | protected MultiObjectiveSymbolicRegressionProblem(bool deserializing) : base(deserializing) { }
|
---|
67 | protected MultiObjectiveSymbolicRegressionProblem(MultiObjectiveSymbolicRegressionProblem original, Cloner cloner)
|
---|
68 | : base(original, cloner) {
|
---|
69 | RegisterParameterEvents();
|
---|
70 | RegisterParameterValueEvents();
|
---|
71 | }
|
---|
72 | public MultiObjectiveSymbolicRegressionProblem()
|
---|
73 | : base() {
|
---|
74 | var evaluator = new MultiObjectiveSymbolicRegressionPearsonsRSquaredEvaluator();
|
---|
75 | 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 })));
|
---|
76 | Parameters.Add(new ValueParameter<IMultiObjectiveSymbolicRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator));
|
---|
77 |
|
---|
78 | evaluator.QualitiesParameter.ActualName = "TrainingRSquared/Size";
|
---|
79 |
|
---|
80 | ParameterizeEvaluator();
|
---|
81 |
|
---|
82 | RegisterParameterEvents();
|
---|
83 | RegisterParameterValueEvents();
|
---|
84 | }
|
---|
85 |
|
---|
86 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
87 | return new MultiObjectiveSymbolicRegressionProblem(this, cloner);
|
---|
88 | }
|
---|
89 |
|
---|
90 | private void RegisterParameterValueEvents() {
|
---|
91 | EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
|
---|
92 | }
|
---|
93 |
|
---|
94 | private void RegisterParameterEvents() {
|
---|
95 | }
|
---|
96 |
|
---|
97 | #region event handling
|
---|
98 | protected override void OnDataAnalysisProblemChanged(EventArgs e) {
|
---|
99 | base.OnDataAnalysisProblemChanged(e);
|
---|
100 | // paritions could be changed
|
---|
101 | ParameterizeEvaluator();
|
---|
102 | }
|
---|
103 | protected override void OnSolutionParameterNameChanged(EventArgs e) {
|
---|
104 | ParameterizeEvaluator();
|
---|
105 | }
|
---|
106 |
|
---|
107 | protected override void OnEvaluatorChanged(EventArgs e) {
|
---|
108 | base.OnEvaluatorChanged(e);
|
---|
109 | ParameterizeEvaluator();
|
---|
110 | RaiseEvaluatorChanged(e);
|
---|
111 | }
|
---|
112 | #endregion
|
---|
113 |
|
---|
114 | #region event handlers
|
---|
115 | private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
|
---|
116 | OnEvaluatorChanged(e);
|
---|
117 | }
|
---|
118 | #endregion
|
---|
119 |
|
---|
120 | #region Helpers
|
---|
121 | [StorableHook(HookType.AfterDeserialization)]
|
---|
122 | private void AfterDeserializationHook() {
|
---|
123 | RegisterParameterEvents();
|
---|
124 | RegisterParameterValueEvents();
|
---|
125 | }
|
---|
126 |
|
---|
127 | private void ParameterizeEvaluator() {
|
---|
128 | Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
|
---|
129 | Evaluator.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
|
---|
130 | Evaluator.SamplesStartParameter.Value = TrainingSamplesStart;
|
---|
131 | Evaluator.SamplesEndParameter.Value = TrainingSamplesEnd;
|
---|
132 | }
|
---|
133 | #endregion
|
---|
134 | }
|
---|
135 | }
|
---|