Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs @ 5593

Last change on this file since 5593 was 5580, checked in by mkommend, 14 years ago

#1418: Added single and multi-objective SymbolicDataAnalysisProblem classes and adapted generic type parameter.

File size: 9.0 KB
Line 
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
22using System;
23using System.Drawing;
24using HeuristicLab.Common;
25using HeuristicLab.Common.Resources;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Optimization;
29using HeuristicLab.Parameters;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31
32namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
33  [StorableClass]
34  public abstract class SymbolicDataAnalysisProblem<T, U, V> : HeuristicOptimizationProblem<U, V>, ISymbolicDataAnalysisProblem, IStorableContent
35    where T : class,IDataAnalysisProblemData
36    where U : class, ISymbolicDataAnalysisEvaluator<T>
37    where V : class, ISymbolicDataAnalysisSolutionCreator {
38    #region parameter names & descriptions
39    private const string ProblemDataParameterName = "ProblemData";
40    private const string SymbolicExpressionTreeGrammarParameterName = "SymbolicExpressionTreeGrammar";
41    private const string SymbolicExpressionTreeInterpreterParameterName = "SymbolicExpressionTreeInterpreter";
42    private const string LowerEstimationLimitParameterName = "LowerEstimationLimit";
43    private const string UpperEstimationLimitParameterName = "UpperEstimationLimit";
44    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
45    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
46    private const string MaximumFunctionDefinitionsParameterName = "MaximumFunctionDefinitions";
47    private const string MaximumFunctionArgumentsParameterName = "MaximumFunctionArguments";
48
49    private const string ProblemDataParameterDescription = "";
50    private const string SymbolicExpressionTreeGrammarParameterDescription = "The grammar that should be used for symbolic expression tree.";
51    private const string SymoblicExpressionTreeInterpreterParameterDescription = "The interpreter that should be used to evaluate the symbolic expression tree.";
52    private const string LowerEstimationLimitParameterDescription = "The lower limit for the estimated value that can be returned by the symbolic data analysis model.";
53    private const string UpperEstimationLimitParameterDescription = "The upper limit for the estimated value that can be returned by the symbolic data analysis model.";
54    private const string MaximumSymbolicExpressionTreeDepthParameterDescription = "Maximal depth of the symbolic expression. The minimum depth needed for the algorithm is 3 because two levels are reserved for the ProgramRoot and the Start symbol.";
55    private const string MaximumSymbolicExpressionTreeLengthParameterDescription = "Maximal length of the symbolic expression.";
56    private const string MaximumFunctionDefinitionsParameterDescription = "Maximal number of automatically defined functions";
57    private const string MaximumFunctionArgumentsParameterDescription = "Maximal number of arguments of automatically defined functions.";
58    #endregion
59
60    #region parameter properties
61    IParameter IDataAnalysisProblem.ProblemDataParameter {
62      get { return ProblemDataParameter; }
63    }
64    public IValueParameter<T> ProblemDataParameter {
65      get { return (IValueParameter<T>)Parameters[ProblemDataParameterName]; }
66    }
67    public IValueParameter<ISymbolicDataAnalysisGrammar> SymbolicExpressionTreeGrammarParameter {
68      get { return (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[SymbolicExpressionTreeGrammarParameterName]; }
69    }
70    public IValueParameter<ISymbolicDataAnalysisTreeInterpreter> SymbolicExpressionTreeInterpreterParameter {
71      get { return (IValueParameter<ISymbolicDataAnalysisTreeInterpreter>)Parameters[SymbolicExpressionTreeInterpreterParameterName]; }
72    }
73    public IValueParameter<DoubleValue> LowerEstimationLimitParameter {
74      get { return (IValueParameter<DoubleValue>)Parameters[LowerEstimationLimitParameterName]; }
75    }
76    public IValueParameter<DoubleValue> UpperEstimationLimitParameter {
77      get { return (IValueParameter<DoubleValue>)Parameters[UpperEstimationLimitParameterName]; }
78    }
79    public IValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter {
80      get { return (IValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName]; }
81    }
82    public IValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter {
83      get { return (IValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName]; }
84    }
85    public IValueParameter<IntValue> MaximumFunctionDefinitionsParameter {
86      get { return (IValueParameter<IntValue>)Parameters[MaximumFunctionDefinitionsParameterName]; }
87    }
88    public IValueParameter<IntValue> MaximumFunctionArgumentsParameter {
89      get { return (IValueParameter<IntValue>)Parameters[MaximumFunctionArgumentsParameterName]; }
90    }
91    #endregion
92
93    #region properties
94    public string Filename { get; set; }
95    public override Image ItemImage { get { return VSImageLibrary.Type; } }
96
97    IDataAnalysisProblemData IDataAnalysisProblem.ProblemData {
98      get { return ProblemData; }
99    }
100    public T ProblemData {
101      get { return ProblemDataParameter.Value; }
102    }
103
104    public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar {
105      get { return SymbolicExpressionTreeGrammarParameter.Value; }
106      protected set { SymbolicExpressionTreeGrammarParameter.Value = value; }
107    }
108    public ISymbolicDataAnalysisTreeInterpreter SymbolicExpressionTreeInterpreter {
109      get { return SymbolicExpressionTreeInterpreterParameter.Value; }
110      protected set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
111    }
112
113    public DoubleValue LowerEstimationLimit {
114      get { return LowerEstimationLimitParameter.Value; }
115    }
116    public DoubleValue UpperEstimationLimit {
117      get { return UpperEstimationLimitParameter.Value; }
118    }
119
120    public IntValue MaximumSymbolicExpressionTreeDepth {
121      get { return MaximumSymbolicExpressionTreeDepthParameter.Value; }
122    }
123    public IntValue MaximumSymbolicExpressionTreeLength {
124      get { return MaximumSymbolicExpressionTreeLengthParameter.Value; }
125    }
126    public IntValue MaximumFunctionDefinitions {
127      get { return MaximumFunctionDefinitionsParameter.Value; }
128    }
129    public IntValue MaximumFunctionArguments {
130      get { return MaximumFunctionArguments; }
131    }
132    #endregion
133
134    [StorableConstructor]
135    protected SymbolicDataAnalysisProblem(bool deserializing) : base(deserializing) { }
136    protected SymbolicDataAnalysisProblem(SymbolicDataAnalysisProblem<T, U, V> original, Cloner cloner) : base(original, cloner) { }
137
138    protected SymbolicDataAnalysisProblem()
139      : base() {
140      Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription));
141      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(SymbolicExpressionTreeGrammarParameterName, SymbolicExpressionTreeGrammarParameterDescription));
142      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisTreeInterpreter>(SymbolicExpressionTreeInterpreterParameterName, SymoblicExpressionTreeInterpreterParameterDescription));
143      Parameters.Add(new ValueParameter<DoubleValue>(LowerEstimationLimitParameterName, LowerEstimationLimitParameterDescription));
144      Parameters.Add(new ValueParameter<DoubleValue>(UpperEstimationLimitParameterName, UpperEstimationLimitParameterDescription));
145      Parameters.Add(new ValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, MaximumSymbolicExpressionTreeDepthParameterDescription));
146      Parameters.Add(new ValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, MaximumSymbolicExpressionTreeLengthParameterDescription));
147      Parameters.Add(new ValueParameter<IntValue>(MaximumFunctionDefinitionsParameterName, MaximumFunctionDefinitionsParameterDescription));
148      Parameters.Add(new ValueParameter<IntValue>(MaximumFunctionArgumentsParameterName, MaximumFunctionArgumentsParameterDescription));
149    }
150
151    public event EventHandler ProblemDataChanged;
152    protected virtual void OnProblemDataChanged() {
153      var handler = ProblemDataChanged;
154      if (handler != null) handler(this, EventArgs.Empty);
155    }
156  }
157}
Note: See TracBrowser for help on using the repository browser.