source: branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs @ 18061

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

#3136

  • added a new type of problem called StructuredSymbolicRegressionSingleObjectiveProblem, represents a first construct for future implementations
File size: 3.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7using HeuristicLab.Optimization;
8using HEAL.Attic;
9using HeuristicLab.Common;
10using HeuristicLab.Problems.Instances;
11using HeuristicLab.Parameters;
12using HeuristicLab.Data;
13
14namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.SingleObjective {
15  [StorableType("7464E84B-65CC-440A-91F0-9FA920D730F9")]
16  [Item(Name = "StructuredSymbolicRegressionSingleObjectiveProblem", Description = "A problem with a structural definition and unfixed subfunctions.")]
17  public class StructuredSymbolicRegressionSingleObjectiveProblem : SingleObjectiveBasicProblem<MultiEncoding>, IRegressionProblem, IProblemInstanceConsumer<RegressionProblemData> {
18
19    #region Constants
20    private const string ProblemDataParameterName = "ProblemData";
21    private const string StructureDefinitionParameterName = "Structure Definition";
22    private const string GrammarParameterName = "Grammar";
23
24    #endregion
25
26    #region Parameter
27    public IValueParameter<IRegressionProblemData> ProblemDataParameter => (IValueParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName];
28    public IFixedValueParameter<StringValue> StructureDefinitionParameter => (IFixedValueParameter<StringValue>)Parameters[StructureDefinitionParameterName];
29    public IValueParameter<ISymbolicDataAnalysisGrammar> GrammarParameter => (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[GrammarParameterName];
30    #endregion
31
32    #region Properties
33    public IRegressionProblemData ProblemData {
34      get => ProblemDataParameter.Value;
35      set {
36        ProblemDataParameter.Value = value;
37        ProblemDataChanged?.Invoke(this, EventArgs.Empty);
38      }
39    }
40
41    public string StructureDefinition {
42      get => StructureDefinitionParameter.Value.Value;
43      set => StructureDefinitionParameter.Value.Value = value;
44    }
45
46    public ISymbolicDataAnalysisGrammar Grammar {
47      get => GrammarParameter.Value;
48      set => GrammarParameter.Value = value;
49    }
50
51    IParameter IDataAnalysisProblem.ProblemDataParameter => ProblemDataParameter;
52    IDataAnalysisProblemData IDataAnalysisProblem.ProblemData => ProblemData;
53
54    public override bool Maximization => false;
55    #endregion
56
57    #region EventHandlers
58    public event EventHandler ProblemDataChanged;
59    #endregion
60
61    #region Constructors & Cloning
62    public StructuredSymbolicRegressionSingleObjectiveProblem() {
63      Parameters.Add(new ValueParameter<RegressionProblemData>(ProblemDataParameterName, new RegressionProblemData()));
64      Parameters.Add(new FixedValueParameter<StringValue>(StructureDefinitionParameterName, new StringValue("")));
65      Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(GrammarParameterName, new LinearScalingGrammar()));
66    }
67
68    public StructuredSymbolicRegressionSingleObjectiveProblem(StructuredSymbolicRegressionSingleObjectiveProblem original, Cloner cloner) {
69    }
70
71    [StorableConstructor]
72    protected StructuredSymbolicRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) {
73    }
74
75    public override IDeepCloneable Clone(Cloner cloner) =>
76      new StructuredSymbolicRegressionSingleObjectiveProblem(this, cloner);
77    #endregion
78
79    public override double Evaluate(Individual individual, IRandom random) {
80      return 0.0;
81    }
82
83    public void Load(RegressionProblemData data) {
84      ProblemData = data;
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.