Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1418: Added IHeuristicOptimizationProblem and adapted all according classes.

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