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