Changeset 18063 for branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Timestamp:
- 10/05/21 17:16:22 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs
r18062 r18063 13 13 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 14 14 15 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression .SingleObjective{15 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 16 16 [StorableType("7464E84B-65CC-440A-91F0-9FA920D730F9")] 17 [Item(Name = "StructuredSymbolicRegressionSingleObjectiveProblem", Description = "A problem with a structural definition and unfixed subfunctions.")] 17 [Item(Name = "Structured Symbolic Regression Single Objective Problem (single-objective)", Description = "A problem with a structural definition and unfixed subfunctions.")] 18 [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 150)] 18 19 public class StructuredSymbolicRegressionSingleObjectiveProblem : SingleObjectiveBasicProblem<MultiEncoding>, IRegressionProblem, IProblemInstanceConsumer<RegressionProblemData> { 19 20 … … 22 23 private const string StructureDefinitionParameterName = "Structure Definition"; 23 24 private const string GrammarParameterName = "Grammar"; 25 private const string StructureTemplateParameterName = "Structure Template"; 24 26 25 27 #endregion … … 28 30 public IValueParameter<IRegressionProblemData> ProblemDataParameter => (IValueParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName]; 29 31 public IFixedValueParameter<StringValue> StructureDefinitionParameter => (IFixedValueParameter<StringValue>)Parameters[StructureDefinitionParameterName]; 32 public IFixedValueParameter<StructureTemplate> StructureTemplateParameter => (IFixedValueParameter<StructureTemplate>)Parameters[StructureTemplateParameterName]; 30 33 public IValueParameter<ISymbolicDataAnalysisGrammar> GrammarParameter => (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[GrammarParameterName]; // könnte auch weg? 31 34 #endregion … … 43 46 get => StructureDefinitionParameter.Value.Value; 44 47 set => StructureDefinitionParameter.Value.Value = value; 48 } 49 50 public StructureTemplate StructureTemplate { 51 get => StructureTemplateParameter.Value; 45 52 } 46 53 … … 71 78 Parameters.Add(new ValueParameter<RegressionProblemData>(ProblemDataParameterName, problemData)); 72 79 Parameters.Add(new FixedValueParameter<StringValue>(StructureDefinitionParameterName, new StringValue("e^f(x)/F(y)"))); 80 Parameters.Add(new FixedValueParameter<StructureTemplate>(StructureTemplateParameterName, new StructureTemplate())); 73 81 Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(GrammarParameterName, grammar)); 74 82 var parser = new InfixExpressionParser(); … … 78 86 } 79 87 80 public StructuredSymbolicRegressionSingleObjectiveProblem(StructuredSymbolicRegressionSingleObjectiveProblem original, Cloner cloner) { 81 } 88 public StructuredSymbolicRegressionSingleObjectiveProblem(StructuredSymbolicRegressionSingleObjectiveProblem original, Cloner cloner) { } 82 89 83 90 [StorableConstructor] 84 protected StructuredSymbolicRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { 85 } 91 protected StructuredSymbolicRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { } 86 92 87 93 public override IDeepCloneable Clone(Cloner cloner) => … … 97 103 98 104 public override double Evaluate(Individual individual, IRandom random) { 99 foreach(var kvp in individual.Values) { 105 Console.WriteLine(StructureTemplate.Template); 106 foreach (var kvp in individual.Values) { 100 107 if(kvp.Value is SymbolicExpressionTree tree) { 101 108 foreach(var n in tree.IterateNodesPrefix()) {
Note: See TracChangeset
for help on using the changeset viewer.