source: branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs @ 18063

Last change on this file since 18063 was 18063, checked in by dpiringe, 9 months ago

#3136

  • added view components and classes for sub functions
File size: 2.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7using HEAL.Attic;
8using HeuristicLab.Common;
9using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
10using HeuristicLab.Parameters;
11using HeuristicLab.Data;
12
13namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
14  [StorableType("598B5DCB-95AC-465A-920B-E1E6DACFFA4B")]
15  public class SubFunction : ParameterizedNamedItem {
16    #region Constants
17    private const string GrammarParameterName = "Grammar";
18    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
19    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
20    #endregion
21
22    #region Parameters
23    public IValueParameter<ISymbolicDataAnalysisGrammar> GrammarParameter => (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[GrammarParameterName];
24    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter => (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName];
25    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter => (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName];
26    #endregion
27
28    #region Properties
29    public ISymbolicDataAnalysisGrammar Grammar {
30      get => GrammarParameter.Value;
31      set => GrammarParameter.Value = value;
32    }
33
34    public int MaximumSymbolicExpressionTreeDepth {
35      get => MaximumSymbolicExpressionTreeDepthParameter.Value.Value;
36      set => MaximumSymbolicExpressionTreeDepthParameter.Value.Value = value;
37    }
38
39    public int MaximumSymbolicExpressionTreeLength {
40      get => MaximumSymbolicExpressionTreeLengthParameter.Value.Value;
41      set => MaximumSymbolicExpressionTreeLengthParameter.Value.Value = value;
42    }
43    #endregion
44
45    #region Constructors
46    public SubFunction() {
47      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(GrammarParameterName, new LinearScalingGrammar()));
48      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(10)));
49      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(30)));
50    }
51
52    protected SubFunction(SubFunction original, Cloner cloner) { }
53
54    [StorableConstructor]
55    protected SubFunction(StorableConstructorFlag _) : base(_) {}
56    #endregion
57
58    #region Cloning
59    public override IDeepCloneable Clone(Cloner cloner) =>
60      new SubFunction(this, cloner);
61    #endregion
62  }
63}
Note: See TracBrowser for help on using the repository browser.