Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18068 for branches


Ignore:
Timestamp:
10/15/21 17:00:28 (3 years ago)
Author:
dpiringe
Message:

#3136

  • modified the StructureTemplateView to enable colorful tree nodes of type SubFunctionTreeNode
  • refactored SubFunctionTreeNode, SubFunction and StructureTemplate
Location:
branches/3136_Structural_GP
Files:
7 edited

Legend:

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

    r18067 r18068  
    2222    private const string ProblemDataParameterName = "ProblemData";
    2323    private const string StructureDefinitionParameterName = "Structure Definition";
    24     private const string GrammarParameterName = "Grammar";
    2524    private const string StructureTemplateParameterName = "Structure Template";
    2625    #endregion
     
    3029    public IFixedValueParameter<StringValue> StructureDefinitionParameter => (IFixedValueParameter<StringValue>)Parameters[StructureDefinitionParameterName];
    3130    public IFixedValueParameter<StructureTemplate> StructureTemplateParameter => (IFixedValueParameter<StructureTemplate>)Parameters[StructureTemplateParameterName];
    32     public IValueParameter<ISymbolicDataAnalysisGrammar> GrammarParameter => (IValueParameter<ISymbolicDataAnalysisGrammar>)Parameters[GrammarParameterName];
    3331    #endregion
    3432
     
    5149    }
    5250
    53     public ISymbolicDataAnalysisGrammar Grammar {
    54       get => GrammarParameter.Value;
    55       set => GrammarParameter.Value = value;
    56     }
    57 
    5851    IParameter IDataAnalysisProblem.ProblemDataParameter => ProblemDataParameter;
    5952    IDataAnalysisProblemData IDataAnalysisProblem.ProblemData => ProblemData;
     
    6962    public StructuredSymbolicRegressionSingleObjectiveProblem() {
    7063      var problemData = new ShapeConstrainedRegressionProblemData();
    71       var grammar = new LinearScalingGrammar();
    72       var varSym = (Variable)grammar.GetSymbol("Variable");
    73       varSym.AllVariableNames = problemData.InputVariables.Select(x => x.Value);
    74       varSym.VariableNames = problemData.InputVariables.Select(x => x.Value);
    75       varSym.Enabled = true;
    7664
    7765      var structureTemplate = new StructureTemplate();
     
    8068      Parameters.Add(new ValueParameter<IRegressionProblemData>(ProblemDataParameterName, problemData));
    8169      Parameters.Add(new FixedValueParameter<StructureTemplate>(StructureTemplateParameterName, structureTemplate));
    82       Parameters.Add(new ValueParameter<ISymbolicDataAnalysisGrammar>(GrammarParameterName, grammar));
    8370
    84       //structureTemplate.Template = "f(x)*f(y)+5";
    8571    }
    8672
     
    9783
    9884    private void OnTemplateChanged(object sender, EventArgs args) {
     85      SetupStructureTemplate();
     86    }
     87
     88    private void SetupStructureTemplate() {
    9989      foreach (var e in Encoding.Encodings.ToArray())
    10090        Encoding.Remove(e);
    10191
    102       foreach (var sf in StructureTemplate.SubFunctions.Values) {
    103         Encoding.Add(new SymbolicExpressionTreeEncoding(sf.Name, sf.Grammar, sf.MaximumSymbolicExpressionTreeLength, sf.MaximumSymbolicExpressionTreeDepth));
     92      foreach (var f in StructureTemplate.SubFunctions.Values) {
     93        SetupVariables(f);
     94        if(!Encoding.Encodings.Any(x => x.Name == f.Name)) // to prevent the same encoding twice
     95          Encoding.Add(new SymbolicExpressionTreeEncoding(f.Name, f.Grammar, f.MaximumSymbolicExpressionTreeLength, f.MaximumSymbolicExpressionTreeDepth));
    10496      }
    10597    }
     
    122114      else
    123115        results.Add(new Result("Best Tree", BuildTree(individuals[bestIdx])));
    124 
    125       /*
    126       if (results.TryGetValue("Tree", out IResult result)) {
    127         var list = result.Value as ItemList<ISymbolicExpressionTree>;
    128         list.Clear();
    129         list.AddRange(individuals.Select(x => (BuildTree(x))));
    130       } else
    131         results.Add(new Result("Tree", new ItemList<ISymbolicExpressionTree>(individuals.Select(x => (BuildTree(x))))));
    132       */
    133116    }
    134117
     
    152135        if (n.Symbol is SubFunctionSymbol) {
    153136          var subFunctionTreeNode = n as SubFunctionTreeNode;
    154           var subFunctionTree = individual.SymbolicExpressionTree(subFunctionTreeNode.SubFunction.Name);
     137          var subFunctionTree = individual.SymbolicExpressionTree(subFunctionTreeNode.Name);
    155138          var parent = n.Parent;
    156139
     
    167150    }
    168151
     152    private void SetupVariables(SubFunction subFunction) {
     153      var varSym = (Variable)subFunction.Grammar.GetSymbol("Variable");
     154      if (varSym == null) {
     155        varSym = new Variable();
     156        subFunction.Grammar.AddSymbol(varSym);
     157      }
     158
     159      var allVariables = ProblemData.InputVariables.Select(x => x.Value);
     160      var allInputs = allVariables.Where(x => x != ProblemData.TargetVariable);
     161
     162      // set all variables
     163      varSym.AllVariableNames = allVariables;
     164
     165      // set all allowed variables
     166      if (subFunction.Arguments.Contains("_")) {
     167        varSym.VariableNames = allInputs;
     168      } else {
     169        var vars = new List<string>();
     170        var exceptions = new List<Exception>();
     171        foreach (var arg in subFunction.Arguments) {
     172          if (allInputs.Contains(arg))
     173            vars.Add(arg);
     174          else
     175            exceptions.Add(new ArgumentException($"The argument '{arg}' for sub-function '{subFunction.Name}' is not a valid variable."));
     176        }
     177        if (exceptions.Any())
     178          throw new AggregateException(exceptions);
     179        varSym.VariableNames = vars;
     180      }
     181
     182      varSym.Enabled = true;
     183    }
     184
    169185    public void Load(RegressionProblemData data) {
    170186      ProblemData = data;
     187      SetupStructureTemplate();
    171188    }
    172189  }
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.Designer.cs

    r18067 r18068  
    3030      this.expressionInput = new System.Windows.Forms.TextBox();
    3131      this.parseButton = new System.Windows.Forms.Button();
    32       this.errorLabel = new System.Windows.Forms.Label();
    33       this.symRegTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView();
     32      this.infoLabel = new System.Windows.Forms.Label();
    3433      this.templateStructureGroupBox = new System.Windows.Forms.GroupBox();
    3534      this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    3635      this.splitContainer = new System.Windows.Forms.SplitContainer();
     36      this.detailsGroupBox = new System.Windows.Forms.GroupBox();
    3737      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    3838      this.templateStructureGroupBox.SuspendLayout();
     
    4141      this.splitContainer.Panel2.SuspendLayout();
    4242      this.splitContainer.SuspendLayout();
     43      this.detailsGroupBox.SuspendLayout();
    4344      this.SuspendLayout();
    4445      //
     
    5152      this.expressionInput.Size = new System.Drawing.Size(288, 20);
    5253      this.expressionInput.TabIndex = 1;
    53       this.expressionInput.TextChanged += new System.EventHandler(this.expressionInput_TextChanged);
     54      this.expressionInput.TextChanged += new System.EventHandler(this.ExpressionInputTextChanged);
    5455      //
    5556      // parseButton
     
    6162      this.parseButton.Text = "Parse";
    6263      this.parseButton.UseVisualStyleBackColor = true;
    63       this.parseButton.Click += new System.EventHandler(this.parseButton_Click);
     64      this.parseButton.Click += new System.EventHandler(this.ParseButtonClick);
    6465      //
    6566      // errorLabel
    6667      //
    67       this.errorLabel.AutoSize = true;
    68       this.errorLabel.Location = new System.Drawing.Point(155, 50);
    69       this.errorLabel.Name = "errorLabel";
    70       this.errorLabel.Size = new System.Drawing.Size(54, 13);
    71       this.errorLabel.TabIndex = 4;
    72       this.errorLabel.Text = "errorLabel";
    73       //
    74       // symRegTreeChart
    75       //
    76       this.symRegTreeChart.AllowDrop = true;
    77       this.symRegTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    78             | System.Windows.Forms.AnchorStyles.Right)));
    79       this.symRegTreeChart.Caption = "Graphical SymbolicExpressionTree View";
    80       this.symRegTreeChart.Content = null;
    81       this.symRegTreeChart.Location = new System.Drawing.Point(6, 74);
    82       this.symRegTreeChart.Name = "symRegTreeChart";
    83       this.symRegTreeChart.ReadOnly = false;
    84       this.symRegTreeChart.Size = new System.Drawing.Size(288, 153);
    85       this.symRegTreeChart.TabIndex = 6;
     68      this.infoLabel.AutoSize = true;
     69      this.infoLabel.Location = new System.Drawing.Point(155, 50);
     70      this.infoLabel.Name = "errorLabel";
     71      this.infoLabel.Size = new System.Drawing.Size(54, 13);
     72      this.infoLabel.TabIndex = 4;
     73      this.infoLabel.Text = "errorLabel";
    8674      //
    8775      // templateStructureGroupBox
    8876      //
    8977      this.templateStructureGroupBox.Controls.Add(this.treeChart);
    90       this.templateStructureGroupBox.Controls.Add(this.symRegTreeChart);
    9178      this.templateStructureGroupBox.Controls.Add(this.parseButton);
    92       this.templateStructureGroupBox.Controls.Add(this.errorLabel);
     79      this.templateStructureGroupBox.Controls.Add(this.infoLabel);
    9380      this.templateStructureGroupBox.Controls.Add(this.expressionInput);
    9481      this.templateStructureGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     
    10289      // treeChart
    10390      //
    104       this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     91      this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     92            | System.Windows.Forms.AnchorStyles.Left)
    10593            | System.Windows.Forms.AnchorStyles.Right)));
    10694      this.treeChart.BackgroundColor = System.Drawing.Color.White;
    10795      this.treeChart.LineColor = System.Drawing.Color.Black;
    108       this.treeChart.Location = new System.Drawing.Point(6, 233);
     96      this.treeChart.Location = new System.Drawing.Point(6, 74);
    10997      this.treeChart.MinimumHorizontalDistance = 30;
    11098      this.treeChart.MinimumHorizontalPadding = 20;
     
    114102      this.treeChart.PreferredNodeHeight = 46;
    115103      this.treeChart.PreferredNodeWidth = 70;
    116       this.treeChart.Size = new System.Drawing.Size(288, 150);
     104      this.treeChart.Size = new System.Drawing.Size(288, 320);
    117105      this.treeChart.SuspendRepaint = false;
    118106      this.treeChart.TabIndex = 7;
     
    134122      // splitContainer.Panel2
    135123      //
    136       this.splitContainer.Panel2.Controls.Add(this.viewHost);
     124      this.splitContainer.Panel2.Controls.Add(this.detailsGroupBox);
    137125      this.splitContainer.Panel2MinSize = 5;
    138126      this.splitContainer.Size = new System.Drawing.Size(600, 400);
    139127      this.splitContainer.SplitterDistance = 300;
    140128      this.splitContainer.TabIndex = 10;
     129      //
     130      // detailsGroupBox
     131      //
     132      this.detailsGroupBox.Controls.Add(this.viewHost);
     133      this.detailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
     134      this.detailsGroupBox.Location = new System.Drawing.Point(0, 0);
     135      this.detailsGroupBox.Name = "detailsGroupBox";
     136      this.detailsGroupBox.Size = new System.Drawing.Size(296, 400);
     137      this.detailsGroupBox.TabIndex = 9;
     138      this.detailsGroupBox.TabStop = false;
     139      this.detailsGroupBox.Text = "Details";
    141140      //
    142141      // viewHost
     
    146145      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    147146      this.viewHost.Enabled = false;
    148       this.viewHost.Location = new System.Drawing.Point(0, 0);
     147      this.viewHost.Location = new System.Drawing.Point(3, 16);
    149148      this.viewHost.Name = "viewHost";
    150149      this.viewHost.ReadOnly = false;
    151       this.viewHost.Size = new System.Drawing.Size(296, 400);
     150      this.viewHost.Size = new System.Drawing.Size(290, 381);
    152151      this.viewHost.TabIndex = 8;
    153152      this.viewHost.ViewsLabelVisible = true;
     
    167166      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    168167      this.splitContainer.ResumeLayout(false);
     168      this.detailsGroupBox.ResumeLayout(false);
    169169      this.ResumeLayout(false);
    170170
     
    174174    private System.Windows.Forms.TextBox expressionInput;
    175175    private System.Windows.Forms.Button parseButton;
    176     private System.Windows.Forms.Label errorLabel;
    177     private Encodings.SymbolicExpressionTreeEncoding.Views.GraphicalSymbolicExpressionTreeView symRegTreeChart;
     176    private System.Windows.Forms.Label infoLabel;
    178177    private System.Windows.Forms.GroupBox templateStructureGroupBox;
    179178    private System.Windows.Forms.SplitContainer splitContainer;
    180179    private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart;
    181180    private MainForm.WindowsForms.ViewHost viewHost;
     181    private System.Windows.Forms.GroupBox detailsGroupBox;
    182182  }
    183183}
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs

    r18067 r18068  
    2424    public StructureTemplateView() {
    2525      InitializeComponent();
    26       errorLabel.Text = "";
    27       treeChart.SymbolicExpressionTreeNodeClicked += TreeChart_SymbolicExpressionTreeNodeClicked;
     26      infoLabel.Text = "";
     27      treeChart.SymbolicExpressionTreeNodeClicked += SymbolicExpressionTreeNodeClicked;
     28     
    2829    }
    2930
    30     private void TreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
     31    private void SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    3132      var visualTreeNode = sender as VisualTreeNode<ISymbolicExpressionTreeNode>;
    3233      if(visualTreeNode != null) {
    3334        var subFunctionTreeNode = visualTreeNode.Content as SubFunctionTreeNode;
    34         viewHost.Content = subFunctionTreeNode?.SubFunction;
     35        if(Content.SubFunctions.TryGetValue(subFunctionTreeNode.Name, out SubFunction subFunction))
     36          viewHost.Content = subFunction;
    3537      }
    3638    }
     
    3941      base.OnContentChanged();
    4042      if (Content == null) return;
    41 
    4243      expressionInput.Text = Content.Template;
    43       symRegTreeChart.Content = Content.Tree;
    44 
    45       treeChart.Tree = Content.Tree;
    46 
    47       errorLabel.Text = "";
    48      
     44      PaintTree();
     45      infoLabel.Text = "";
    4946    }
    5047
    51     private void parseButton_Click(object sender, EventArgs e) {
     48    private void ParseButtonClick(object sender, EventArgs e) {
    5249      if(!string.IsNullOrEmpty(expressionInput.Text)) {
    5350        try {
    5451          Content.Template = expressionInput.Text;
    55           symRegTreeChart.Content = Content.Tree;
    56           treeChart.Tree = Content.Tree;
    57 
    58           errorLabel.Text = "Template structure successfully parsed.";
    59           errorLabel.ForeColor = Color.DarkGreen;
     52          PaintTree();
     53          infoLabel.Text = "Template structure successfully parsed.";
     54          infoLabel.ForeColor = Color.DarkGreen;
    6055        } catch (Exception ex) {
    61           errorLabel.Text = ex.Message;
    62           errorLabel.ForeColor = Color.DarkRed;
     56          infoLabel.Text = ex.Message;
     57          infoLabel.ForeColor = Color.DarkRed;
    6358        }
    6459      }
    6560    }
    6661
    67     private void expressionInput_TextChanged(object sender, EventArgs e) {
    68       errorLabel.Text = "Unparsed changes! Press parse button to save changes.";
    69       errorLabel.ForeColor = Color.DarkOrange;
     62    private void ExpressionInputTextChanged(object sender, EventArgs e) {
     63      infoLabel.Text = "Unparsed changes! Press parse button to save changes.";
     64      infoLabel.ForeColor = Color.DarkOrange;
    7065    }
    7166
     67
     68    private void PaintTree() {
     69      if(Content != null && Content.Tree != null) {
     70        treeChart.Tree = Content.Tree;
     71        foreach (var n in Content.Tree.IterateNodesPrefix()) {
     72          if (n.Symbol is SubFunctionSymbol) {
     73            var visualNode = treeChart.GetVisualSymbolicExpressionTreeNode(n);
     74            visualNode.FillColor = Color.LightCyan;
     75            visualNode.LineColor = Color.SlateGray;
     76          }
     77        }
     78        treeChart.RepaintNodes();
     79      }
     80    }
    7281  }
    7382}
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs

    r18067 r18068  
    11using System;
     2using System.Linq;
    23using System.Collections.Generic;
    34using HeuristicLab.Core;
     
    1718      get => template;
    1819      set {
    19         if(template != value) {
    20           template = value;
    21           tree = Parser.Parse(template);
    22           GetSubFunctions(Tree);
    23           OnChanged();
    24         }
     20        template = value;
     21        tree = Parser.Parse(template);
     22        GetSubFunctions(Tree);
     23        OnChanged();
    2524      }
    2625    }
     
    3130
    3231    [Storable]
    33     public IDictionary<SubFunctionTreeNode, SubFunction> SubFunctions { get; private set; } = new Dictionary<SubFunctionTreeNode, SubFunction>();
     32    public IReadOnlyDictionary<string, SubFunction> SubFunctions { get; private set; } = new Dictionary<string, SubFunction>();
    3433
    3534    protected InfixExpressionParser Parser { get; set; } = new InfixExpressionParser();
     35
    3636    #endregion
    3737
     
    5757
    5858    private void GetSubFunctions(ISymbolicExpressionTree tree) {
    59       int count = 1;
    60       SubFunctions.Clear();
     59      var subFunctions = new Dictionary<string, SubFunction>();
    6160      foreach (var node in tree.IterateNodesPrefix())
    62         if (node is SubFunctionTreeNode subFunctionTreeNode) {
    63           var subFunction = new SubFunction() {
    64             Name = $"f{count++}({string.Join(",", subFunctionTreeNode.Arguments)})",
    65             FunctionArguments = subFunctionTreeNode.Arguments
    66           };
    67           subFunctionTreeNode.SubFunction = subFunction;
    68           SubFunctions.Add(subFunctionTreeNode, subFunction);
     61        if (node is SubFunctionTreeNode subFunctionTreeNode) {
     62          if (!subFunctionTreeNode.Arguments.Any())
     63            throw new ArgumentException($"The sub-function '{subFunctionTreeNode}' requires inputs (e.g. {subFunctionTreeNode.Name}(var1, var2)).");
     64
     65          if (subFunctions.TryGetValue(subFunctionTreeNode.Name, out SubFunction v)) {
     66            if(!v.Arguments.SequenceEqual(subFunctionTreeNode.Arguments))
     67              throw new ArgumentException(
     68                $"The sub-function '{v.Name}' has (at least two) different signatures " +
     69                $"({v.Name}({string.Join(",", v.Arguments)}) <> {subFunctionTreeNode.Name}({string.Join(",", subFunctionTreeNode.Arguments)})).");
     70          } else {
     71            var subFunction = new SubFunction() {
     72              Name = subFunctionTreeNode.Name,
     73              Arguments = subFunctionTreeNode.Arguments
     74            };
     75            subFunction.Changed += OnSubFunctionChanged;
     76            subFunctions.Add(subFunction.Name, subFunction);
     77          }
    6978        }
     79      SubFunctions = subFunctions;
    7080    }
     81
     82    private void OnSubFunctionChanged(object sender, EventArgs e) => OnChanged();
    7183  }
    7284}
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs

    r18067 r18068  
    1818    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
    1919    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    20     private const string FunctionArgumentsParameterName = "Function Arguments";
    2120    #endregion
    2221
     
    2524    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeDepthParameter => (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeDepthParameterName];
    2625    public IFixedValueParameter<IntValue> MaximumSymbolicExpressionTreeLengthParameter => (IFixedValueParameter<IntValue>)Parameters[MaximumSymbolicExpressionTreeLengthParameterName];
    27     public IValueParameter<ReadOnlyItemList<StringValue>> FunctionArgumentsParameter => (IValueParameter<ReadOnlyItemList<StringValue>>)Parameters[FunctionArgumentsParameterName];
    2826    #endregion
    2927
     
    4442    }
    4543
    46     public IEnumerable<string> FunctionArguments { // TODO: gehört weg
    47       get => FunctionArgumentsParameter.Value.Select(x => x.Value);
    48       set {
    49         var varSym = (Variable)Grammar.GetSymbol("Variable");
    50         if (varSym == null)
    51           throw new ArgumentException($"No variable symbol existent.");
     44    public IEnumerable<string> Arguments { get; set; }
     45    #endregion
    5246
    53         FunctionArgumentsParameter.Value = new ItemList<StringValue>(value.Select(x => new StringValue(x))).AsReadOnly();
    54 
    55         varSym.AllVariableNames = FunctionArguments;
    56         varSym.VariableNames = FunctionArguments;
    57         varSym.Enabled = true;
    58       }
    59     }
     47    #region Events
     48    public event EventHandler Changed;
    6049    #endregion
    6150
     
    6554      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, new IntValue(10)));
    6655      Parameters.Add(new FixedValueParameter<IntValue>(MaximumSymbolicExpressionTreeLengthParameterName, new IntValue(30)));
    67       Parameters.Add(new ValueParameter<ReadOnlyItemList<StringValue>>(FunctionArgumentsParameterName, new ReadOnlyItemList<StringValue>()));
     56
     57      // TODO: separate events for each parameter
     58      GrammarParameter.ValueChanged += OnParameterValueChanged;
     59      MaximumSymbolicExpressionTreeDepthParameter.Value.ValueChanged += OnParameterValueChanged;
     60      MaximumSymbolicExpressionTreeLengthParameter.Value.ValueChanged += OnParameterValueChanged;
    6861    }
     62
     63    private void OnParameterValueChanged(object sender, EventArgs e) => Changed?.Invoke(this, EventArgs.Empty);
    6964
    7065    protected SubFunction(SubFunction original, Cloner cloner) { }
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/SubFunctionSymbol.cs

    r18065 r18068  
    99  [Item("SubFunctionSymbol", "Symbol that represents a sub function.")]
    1010  public class SubFunctionSymbol : Symbol {
    11     public override int MinimumArity => 1;
    12     public override int MaximumArity => byte.MaxValue;
     11    public override int MinimumArity => 0;
     12    public override int MaximumArity => 1;
    1313
    1414    public SubFunctionSymbol() : base("SubFunctionSymbol", "Symbol that represents a sub function.") { }
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/SubFunctionTreeNode.cs

    r18067 r18068  
    1010namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    1111  [StorableType("05130B5F-0125-4367-A4E9-C42D1085024E")]
    12   public class SubFunctionTreeNode : SymbolicExpressionTreeNode { //TODO: as TerminalNode? -> but has children in a fully builded tree
     12  public class SubFunctionTreeNode : SymbolicExpressionTreeNode {
    1313
    1414    #region Properties
     
    1717    public IEnumerable<string> Arguments { get; set; } = Enumerable.Empty<string>();
    1818   
    19     public SubFunction SubFunction { get; set; }
    20 
    2119    public string Name { get; set; }
    2220    #endregion
     
    2826    protected SubFunctionTreeNode(StorableConstructorFlag _) : base(_) { }
    2927
    30     protected SubFunctionTreeNode(SubFunctionTreeNode original, Cloner cloner) : base(original, cloner) {
    31       this.SubFunction = original.SubFunction;
    32     }
     28    protected SubFunctionTreeNode(SubFunctionTreeNode original, Cloner cloner) : base(original, cloner) { }
    3329    #endregion
    3430
     
    4036      if (string.IsNullOrEmpty(Name))
    4137        return base.ToString();
    42       return Name;
     38      return $"{Name}({string.Join(",", Arguments)})";
    4339    }
    4440   
Note: See TracChangeset for help on using the changeset viewer.