Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/20/11 11:12:10 (13 years ago)
Author:
mkommend
Message:

#1479: Merged grammar editor branch into trunk.

Location:
trunk/sources
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources

  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

    • Property svn:ignore set to
      bin
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Argument.cs

    r6233 r6803  
    3232    public const string ArgumentName = "Argument";
    3333    public const string ArgumentDescription = "Symbol that represents a function argument.";
     34    private const int minimumArity = 0;
     35    private const int maximumArity = 0;
     36
     37    public override int MinimumArity {
     38      get { return minimumArity; }
     39    }
     40    public override int MaximumArity {
     41      get { return maximumArity; }
     42    }
     43
    3444    [Storable]
    3545    private int argumentIndex;
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Defun.cs

    r5809 r6803  
    3232    public const string DefunName = "Defun";
    3333    public const string DefunDescription = "Symbol that represents a function defining node.";
     34    private const int minimumArity = 1;
     35    private const int maximumArity = 1;
     36
     37    public override int MinimumArity {
     38      get { return minimumArity; }
     39    }
     40    public override int MaximumArity {
     41      get { return maximumArity; }
     42    }
    3443
    3544    [StorableConstructor]
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/InvokeFunction.cs

    r6233 r6803  
    3232    public const string InvokeFunctionName = "InvokeFunction";
    3333    public const string InvokeFunctionDescription = "Symbol that the invocation of another function.";
     34    private const int minimumArity = 0;
     35    private const int maximumArity = byte.MaxValue;
     36
     37    public override int MinimumArity {
     38      get { return minimumArity; }
     39    }
     40    public override int MaximumArity {
     41      get { return maximumArity; }
     42    }
    3443
    3544    [Storable]
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/ProgramRootSymbol.cs

    r5809 r6803  
    2929    public const string ProgramRootSymbolName = "ProgramRootSymbol";
    3030    public const string ProgramRootSymbolDescription = "Special symbol that represents the program root node of a symbolic expression tree.";
     31    private const int minimumArity = 1;
     32    private const int maximumArity = byte.MaxValue;
     33
     34    public override int MinimumArity {
     35      get { return minimumArity; }
     36    }
     37    public override int MaximumArity {
     38      get { return maximumArity; }
     39    }
    3140
    3241    [StorableConstructor]
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/StartSymbol.cs

    r5809 r6803  
    2929    public const string StartSymbolName = "StartSymbol";
    3030    public const string StartSymbolDescription = "Special symbol that represents the starting node of the result producing branch of a symbolic expression tree.";
     31    private const int minimumArity = 1;
     32    private const int maximumArity = 1;
     33
     34    public override int MinimumArity {
     35      get { return minimumArity; }
     36    }
     37    public override int MaximumArity {
     38      get { return maximumArity; }
     39    }
    3140
    3241    [StorableConstructor]
    33     private StartSymbol(bool deserializing) : base(deserializing) { }
     42    private StartSymbol(bool deserializing)
     43      : base(deserializing) {
     44    }
    3445    private StartSymbol(StartSymbol original, Cloner cloner) : base(original, cloner) { }
    3546    public StartSymbol() : base(StartSymbol.StartSymbolName, StartSymbol.StartSymbolDescription) { }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Symbols/Symbol.cs

    r6233 r6803  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    4243      }
    4344    }
     45
     46    [Storable(DefaultValue = true)]
     47    private bool enabled;
     48    public virtual bool Enabled {
     49      get { return enabled; }
     50      set {
     51        if (value != enabled) {
     52          enabled = value;
     53          OnChanged(EventArgs.Empty);
     54        }
     55      }
     56    }
     57
     58    [Storable(DefaultValue = false)]
     59    private bool @fixed;
     60    public bool Fixed {
     61      get { return @fixed; }
     62      set {
     63        if (value != @fixed) {
     64          @fixed = value;
     65          OnChanged(EventArgs.Empty);
     66        }
     67      }
     68    }
     69
    4470    public override bool CanChangeName {
    4571      get { return !(this is IReadOnlySymbol); }
     
    4874      get { return false; }
    4975    }
     76
     77    public abstract int MinimumArity { get; }
     78    public abstract int MaximumArity { get; }
    5079    #endregion
    5180
     
    5584      : base(original, cloner) {
    5685      initialFrequency = original.initialFrequency;
     86      enabled = original.enabled;
     87      @fixed = original.@fixed;
    5788    }
    5889
     
    6091      : base(name, description) {
    6192      initialFrequency = 1.0;
     93      enabled = true;
     94      @fixed = false;
     95    }
     96
     97    [StorableHook(HookType.AfterDeserialization)]
     98    private void AfterDeserialization() {
     99      // BackwardsCompatibility3.3
     100      #region Backwards compatible code, remove with 3.4
     101      if (initialFrequency.IsAlmost(0.0) && !(this is GroupSymbol)) enabled = false;
     102      #endregion
     103
    62104    }
    63105
     
    66108    }
    67109
    68     #region events
     110    public virtual IEnumerable<ISymbol> Flatten() {
     111      yield return this;
     112    }
     113
    69114    public event EventHandler Changed;
    70     protected void OnChanged(EventArgs e) {
     115    protected virtual void OnChanged(EventArgs e) {
    71116      EventHandler handlers = Changed;
    72117      if (handlers != null)
    73118        handlers(this, e);
    74119    }
    75     #endregion
    76120  }
    77121}
Note: See TracChangeset for help on using the changeset viewer.