Changeset 18072


Ignore:
Timestamp:
10/28/21 14:31:33 (8 months ago)
Author:
chaider
Message:

#3136

  • Added info text in StructureTemplateView
  • Fixed cloning constructors
  • Added check if linear scaling nodes are set
Location:
branches/3136_Structural_GP
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs

    r18071 r18072  
    2323    private const string StructureDefinitionParameterName = "Structure Definition";
    2424    private const string StructureTemplateParameterName = "Structure Template";
    25     #endregion
    26 
    27     #region Parameter
     25
     26    private const string StructureTemplateDescriptionText =
     27      "Enter your expression as string in infix format into the empty input field.\n" +
     28      "By checking the \"Apply Linear Scaling\" checkbox you can add the relevant scaling terms to your expression.\n" +
     29      "After entering the expression click parse to build the tree.\n" +
     30      "To edit the defined sub-functions, click on the coressponding colored node in the tree view.";
     31    #endregion
     32
     33    #region Parameters
    2834    public IValueParameter<IRegressionProblemData> ProblemDataParameter => (IValueParameter<IRegressionProblemData>)Parameters[ProblemDataParameterName];
    2935    public IFixedValueParameter<StringValue> StructureDefinitionParameter => (IFixedValueParameter<StringValue>)Parameters[StructureDefinitionParameterName];
     
    6975
    7076      Parameters.Add(new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, problemData));
    71       Parameters.Add(new FixedValueParameter<StructureTemplate>(StructureTemplateParameterName, structureTemplate));
    72 
    73     }
    74 
    75     public StructuredSymbolicRegressionSingleObjectiveProblem(StructuredSymbolicRegressionSingleObjectiveProblem original, Cloner cloner) { }
     77      Parameters.Add(new FixedValueParameter<StructureTemplate>(StructureTemplateParameterName,
     78        StructureTemplateDescriptionText, structureTemplate));
     79
     80
     81    }
     82
     83    public StructuredSymbolicRegressionSingleObjectiveProblem(StructuredSymbolicRegressionSingleObjectiveProblem original,
     84      Cloner cloner) : base(original, cloner){ }
    7685
    7786    [StorableConstructor]
     
    114123      if (results.TryGetValue("Best Tree", out IResult result)) {
    115124        var tree = BuildTree(individuals[bestIdx]);
    116         AdjustLinearScalingParams(tree, Interpreter);
     125        if (StructureTemplate.ApplyLinearScaling)
     126          AdjustLinearScalingParams(tree, Interpreter);
    117127        result.Value = tree;
    118128      }
    119129      else {
    120130        var tree = BuildTree(individuals[bestIdx]);
    121         AdjustLinearScalingParams(tree, Interpreter);
     131        if (StructureTemplate.ApplyLinearScaling)
     132          AdjustLinearScalingParams(tree, Interpreter);
    122133        results.Add(new Result("Best Tree", tree));
    123134      }
     
    128139      var tree = BuildTree(individual);
    129140
    130       AdjustLinearScalingParams(tree, Interpreter);
     141      if (StructureTemplate.ApplyLinearScaling)
     142        AdjustLinearScalingParams(tree, Interpreter);
    131143      var estimationInterval = ProblemData.VariableRanges.GetInterval(ProblemData.TargetVariable);
    132144      var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs

    r18071 r18072  
    3838
    3939    [Storable]
    40     public IReadOnlyDictionary<string, SubFunction> SubFunctions { get; private set; }
     40    public IReadOnlyDictionary<string, SubFunction> SubFunctions { get; private set; } = new Dictionary<string, SubFunction>();
    4141
    4242    [Storable]
     
    6666    protected StructureTemplate(StorableConstructorFlag _) : base(_) { }
    6767
    68     protected StructureTemplate(StructureTemplate original, Cloner cloner) { }
     68    protected StructureTemplate(StructureTemplate original, Cloner cloner) : base(original, cloner) { }
    6969    #endregion
    7070
     
    7373      new StructureTemplate(this, cloner);
    7474    #endregion
     75
     76   
    7577
    7678    private Dictionary<string, SubFunction> GetSubFunctions() {
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs

    r18071 r18072  
    6363    private void OnParameterValueChanged(object sender, EventArgs e) => Changed?.Invoke(this, EventArgs.Empty);
    6464
    65     protected SubFunction(SubFunction original, Cloner cloner) {
     65    protected SubFunction(SubFunction original, Cloner cloner) : base(original, cloner) {
    6666      Arguments = original.Arguments;
    6767    }
Note: See TracChangeset for help on using the changeset viewer.