Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/MultiObjectiveSymbolicVectorRegressionProblem.cs @ 9674

Last change on this file since 9674 was 5275, checked in by gkronber, 14 years ago

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File size: 5.5 KB
Line 
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
22using System;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Data;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30using HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Evaluators;
31using HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic.Interfaces;
32
33namespace HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression.Symbolic {
34  [Item("Symbolic Vector Regression Problem (multi objective)", "Represents a multi objective symbolic vector regression problem.")]
35  [Creatable("Problems")]
36  [StorableClass]
37  public class MultiObjectiveSymbolicVectorRegressionProblem : SymbolicVectorRegressionProblem, IMultiObjectiveProblem {
38
39    #region Parameter Properties
40    public ValueParameter<BoolArray> MultiObjectiveMaximizationParameter {
41      get { return (ValueParameter<BoolArray>)Parameters["MultiObjectiveMaximization"]; }
42    }
43    IParameter IMultiObjectiveProblem.MaximizationParameter {
44      get { return MultiObjectiveMaximizationParameter; }
45    }
46
47    public new ValueParameter<IMultiObjectiveSymbolicVectorRegressionEvaluator> EvaluatorParameter {
48      get { return (ValueParameter<IMultiObjectiveSymbolicVectorRegressionEvaluator>)Parameters["Evaluator"]; }
49    }
50    IParameter IProblem.EvaluatorParameter {
51      get { return EvaluatorParameter; }
52    }
53    #endregion
54
55    #region Properties
56    public new IMultiObjectiveSymbolicVectorRegressionEvaluator Evaluator {
57      get { return EvaluatorParameter.Value; }
58      set { EvaluatorParameter.Value = value; }
59    }
60    IMultiObjectiveEvaluator IMultiObjectiveProblem.Evaluator {
61      get { return EvaluatorParameter.Value; }
62    }
63    IEvaluator IProblem.Evaluator {
64      get { return EvaluatorParameter.Value; }
65    }
66    #endregion
67
68    [StorableConstructor]
69    protected MultiObjectiveSymbolicVectorRegressionProblem(bool deserializing) : base(deserializing) { }
70    protected MultiObjectiveSymbolicVectorRegressionProblem(MultiObjectiveSymbolicVectorRegressionProblem original, Cloner cloner)
71      : base(original, cloner) {
72        Initialize();
73    }
74    public MultiObjectiveSymbolicVectorRegressionProblem()
75      : base() {
76      var evaluator = new SymbolicVectorRegressionScaledMseEvaluator();
77      Parameters.Add(new ValueParameter<BoolArray>("MultiObjectiveMaximization", "Set to false as the error of the regression model should be minimized.", new BoolArray(MultiVariateDataAnalysisProblemData.TargetVariables.CheckedItems.Count())));
78      Parameters.Add(new ValueParameter<IMultiObjectiveSymbolicVectorRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator));
79
80      ParameterizeEvaluator();
81      Initialize();
82    }
83   
84    [StorableHook(HookType.AfterDeserialization)]
85    private void AfterDeserializationHook() {
86      Initialize();
87    }
88
89    public override IDeepCloneable Clone(Cloner cloner) {
90      return new MultiObjectiveSymbolicVectorRegressionProblem(this, cloner);
91    }
92
93    private void RegisterParameterValueEvents() {
94      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
95    }
96
97    #region event handling
98    protected override void OnMultiVariateDataAnalysisProblemChanged(EventArgs e) {
99      base.OnMultiVariateDataAnalysisProblemChanged(e);
100      MultiObjectiveMaximizationParameter.Value = new BoolArray(MultiVariateDataAnalysisProblemData.TargetVariables.CheckedItems.Count());
101      // paritions could be changed
102      ParameterizeEvaluator();
103    }
104
105    protected override void OnSolutionParameterNameChanged(EventArgs e) {
106      base.OnSolutionParameterNameChanged(e);
107      ParameterizeEvaluator();
108    }
109
110    protected virtual void OnEvaluatorChanged(EventArgs e) {
111      ParameterizeEvaluator();
112      RaiseEvaluatorChanged(e);
113    }
114    #endregion
115
116    #region event handlers
117    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
118      OnEvaluatorChanged(e);
119    }
120    #endregion
121
122    #region Helpers
123    private void Initialize() {
124      RegisterParameterValueEvents();
125    }
126
127
128    private void ParameterizeEvaluator() {
129      Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
130      Evaluator.MultiVariateDataAnalysisProblemDataParameter.ActualName = MultiVariateDataAnalysisProblemDataParameter.Name;
131      Evaluator.SamplesStartParameter.Value = TrainingSamplesStart;
132      Evaluator.SamplesEndParameter.Value = TrainingSamplesEnd;
133    }
134    #endregion
135  }
136}
Note: See TracBrowser for help on using the repository browser.