Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/17/11 22:51:11 (13 years ago)
Author:
abeham
Message:

#1541

  • updated to latest trunk version
Location:
branches/QAPAlgorithms
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/QAPAlgorithms

  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs.frame

    r6099 r6569  
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.3.4.$WCREV$")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.3.5.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Properties/AssemblyInfo.frame

    r6099 r6569  
    4545
    4646[assembly: AssemblyVersion("3.3.0.0")]
    47 [assembly: AssemblyFileVersion("3.3.4.$WCREV$")]
     47[assembly: AssemblyFileVersion("3.3.5.$WCREV$")]
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Tests/Properties/AssemblyInfo.cs

    r5446 r6569  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.3.0")]
     55[assembly: AssemblyFileVersion("3.3.5.0")]
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs.frame

    r6099 r6569  
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.0.$WCREV$")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.1.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/FullTreeShaker.cs

    r5809 r6569  
    3232    private const string ShakingFactorParameterName = "ShakingFactor";
    3333    #region parameter properties
    34     public IValueLookupParameter<DoubleValue> ShakingFactorParameter {
    35       get { return (IValueLookupParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; }
     34    public IValueParameter<DoubleValue> ShakingFactorParameter {
     35      get { return (IValueParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; }
    3636    }
    3737    #endregion
    3838    #region properties
    39     public DoubleValue ShakingFactor {
    40       get { return ShakingFactorParameter.ActualValue; }
     39    public double ShakingFactor {
     40      get { return ShakingFactorParameter.Value.Value; }
     41      set { ShakingFactorParameter.Value.Value = value; }
    4142    }
    4243    #endregion
    43 
    4444    [StorableConstructor]
    4545    private FullTreeShaker(bool deserializing) : base(deserializing) { }
     
    4747    public FullTreeShaker()
    4848      : base() {
    49       Parameters.Add(new ValueLookupParameter<DoubleValue>(ShakingFactorParameterName, "The shaking factor that should be used for the manipulation of constants (default=1.0).", new DoubleValue(1.0)));
     49      Parameters.Add(new FixedValueParameter<DoubleValue>(ShakingFactorParameterName, "The shaking factor that should be used for the manipulation of constants (default=1.0).", new DoubleValue(1.0)));
    5050    }
    5151
     
    5757      tree.Root.ForEachNodePostfix(node => {
    5858        if (node.HasLocalParameters) {
    59           node.ShakeLocalParameters(random, ShakingFactor.Value);
     59          node.ShakeLocalParameters(random, ShakingFactor);
    6060        }
    6161      });
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs

    r5809 r6569  
    3434    private const string ShakingFactorParameterName = "ShakingFactor";
    3535    #region parameter properties
    36     public IValueLookupParameter<DoubleValue> ShakingFactorParameter {
    37       get { return (IValueLookupParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; }
     36    public IValueParameter<DoubleValue> ShakingFactorParameter {
     37      get { return (IValueParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; }
    3838    }
    3939    #endregion
    4040    #region properties
    41     public DoubleValue ShakingFactor {
    42       get { return ShakingFactorParameter.ActualValue; }
     41    public double ShakingFactor {
     42      get { return ShakingFactorParameter.Value.Value; }
     43      set { ShakingFactorParameter.Value.Value = value; }
    4344    }
    4445    #endregion
     
    4849    public OnePointShaker()
    4950      : base() {
    50       Parameters.Add(new ValueLookupParameter<DoubleValue>(ShakingFactorParameterName, "The shaking factor that should be used for the manipulation of constants (default=1.0).", new DoubleValue(1.0)));
     51      Parameters.Add(new FixedValueParameter<DoubleValue>(ShakingFactorParameterName, "The shaking factor that should be used for the manipulation of constants (default=1.0).", new DoubleValue(1.0)));
    5152    }
    5253
     
    6263      if (parametricNodes.Count > 0) {
    6364        var selectedPoint = parametricNodes.SelectRandom(random);
    64         selectedPoint.ShakeLocalParameters(random, ShakingFactor.Value);
     65        selectedPoint.ShakeLocalParameters(random, ShakingFactor);
    6566      }
    6667    }
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.frame

    r5869 r6569  
    4545
    4646[assembly: AssemblyVersion("3.4.0.0")]
    47 [assembly: AssemblyFileVersion("3.4.0.$WCREV$")]
     47[assembly: AssemblyFileVersion("3.4.1.$WCREV$")]
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammar.cs

    r6233 r6569  
    2121
    2222using System;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using System.Collections.Generic;
    2628
    2729namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    7274    }
    7375
    74     [Storable]
    7576    private ProgramRootSymbol programRootSymbol;
    7677    public ProgramRootSymbol ProgramRootSymbol {
     
    99100    }
    100101
    101     [Storable]
    102102    private Defun defunSymbol;
    103103    protected Defun DefunSymbol {
     
    111111    #endregion
    112112
     113    [StorableHook(HookType.AfterDeserialization)]
     114    private void AfterDeserialization() {
     115      foreach (ISymbol symbol in symbols.Values)
     116        RegisterSymbolEvents(symbol);
     117    }
    113118    [StorableConstructor]
    114119    protected SymbolicExpressionGrammar(bool deserializing) : base(deserializing) { }
    115120    protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner)
    116121      : base(original, cloner) {
     122      foreach (ISymbol symbol in Symbols)
     123        RegisterSymbolEvents(symbol);
     124
    117125      programRootSymbol = cloner.Clone(original.programRootSymbol);
    118126      startSymbol = cloner.Clone(original.StartSymbol);
     
    153161    }
    154162
     163    protected override void AddSymbol(ISymbol symbol) {
     164      base.AddSymbol(symbol);
     165      RegisterSymbolEvents(symbol);
     166    }
     167    protected override void RemoveSymbol(ISymbol symbol) {
     168      DeregisterSymbolEvents(symbol);
     169      base.RemoveSymbol(symbol);
     170    }
     171
    155172    public event EventHandler ReadOnlyChanged;
    156173    protected virtual void OnReadOnlyChanged() {
     
    166183    }
    167184    #endregion
     185
     186    #region symbol events
     187    protected virtual void RegisterSymbolEvents(ISymbol symbol) {
     188      symbol.NameChanging += new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
     189      symbol.NameChanged += new EventHandler(Symbol_NameChanged);
     190    }
     191    protected virtual void DeregisterSymbolEvents(ISymbol symbol) {
     192      symbol.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
     193      symbol.NameChanged -= new EventHandler(Symbol_NameChanged);
     194    }
     195
     196    private void Symbol_NameChanging(object sender, CancelEventArgs<string> e) {
     197      if (symbols.ContainsKey(e.Value)) e.Cancel = true;
     198    }
     199    private void Symbol_NameChanged(object sender, EventArgs e) {
     200      ISymbol symbol = (ISymbol)sender;
     201      string oldName = symbols.Where(x => x.Value == symbol).First().Key;
     202      string newName = symbol.Name;
     203
     204      symbols.Remove(oldName);
     205      symbols.Add(newName, symbol);
     206
     207      var subtreeCount = symbolSubtreeCount[oldName];
     208      symbolSubtreeCount.Remove(oldName);
     209      symbolSubtreeCount.Add(newName, subtreeCount);
     210
     211      List<string> allowedChilds;
     212      if (allowedChildSymbols.TryGetValue(oldName, out allowedChilds)) {
     213        allowedChildSymbols.Remove(oldName);
     214        allowedChildSymbols.Add(newName, allowedChilds);
     215      }
     216
     217      for (int i = 0; i < GetMaximumSubtreeCount(symbol); i++) {
     218        if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(oldName, i), out allowedChilds)) {
     219          allowedChildSymbolsPerIndex.Remove(Tuple.Create(oldName, i));
     220          allowedChildSymbolsPerIndex.Add(Tuple.Create(newName, i), allowedChilds);
     221        }
     222      }
     223
     224      foreach (var parent in Symbols) {
     225        if (allowedChildSymbols.TryGetValue(parent.Name, out allowedChilds))
     226          if (allowedChilds.Remove(oldName))
     227            allowedChilds.Add(newName);
     228
     229        for (int i = 0; i < GetMaximumSubtreeCount(parent); i++) {
     230          if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, i), out allowedChilds))
     231            if (allowedChilds.Remove(oldName)) allowedChilds.Add(newName);
     232        }
     233      }
     234
     235      ClearCaches();
     236    }
     237    #endregion
    168238  }
    169239}
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs

    r6233 r6569  
    8181      cachedMinExpressionDepth = new Dictionary<string, int>();
    8282    }
    83     [StorableHook(HookType.AfterDeserialization)]
    84     private void AfterDeserialization() {
    85       foreach (ISymbol symbol in symbols.Values)
    86         RegisterSymbolEvents(symbol);
    87     }
    8883
    8984    protected SymbolicExpressionGrammarBase(SymbolicExpressionGrammarBase original, Cloner cloner)
     
    9388      cachedMinExpressionDepth = new Dictionary<string, int>();
    9489
    95 
    9690      symbols = original.symbols.ToDictionary(x => x.Key, y => (ISymbol)cloner.Clone(y.Value));
    9791      symbolSubtreeCount = new Dictionary<string, Tuple<int, int>>(original.symbolSubtreeCount);
     
    10498      foreach (var element in original.allowedChildSymbolsPerIndex)
    10599        allowedChildSymbolsPerIndex.Add(element.Key, new List<string>(element.Value));
    106 
    107       foreach (ISymbol symbol in symbols.Values)
    108         RegisterSymbolEvents(symbol);
    109100    }
    110101
     
    122113
    123114    #region protected grammar manipulation methods
    124     protected void AddSymbol(ISymbol symbol) {
     115    protected virtual void AddSymbol(ISymbol symbol) {
    125116      if (ContainsSymbol(symbol)) throw new ArgumentException("Symbol " + symbol + " is already defined.");
    126       RegisterSymbolEvents(symbol);
    127117      symbols.Add(symbol.Name, symbol);
    128118      symbolSubtreeCount.Add(symbol.Name, Tuple.Create(0, 0));
     
    130120    }
    131121
    132     private void RegisterSymbolEvents(ISymbol symbol) {
    133       symbol.NameChanging += new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
    134       symbol.NameChanged += new EventHandler(Symbol_NameChanged);
    135     }
    136     private void DeregisterSymbolEvents(ISymbol symbol) {
    137       symbol.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
    138       symbol.NameChanged -= new EventHandler(Symbol_NameChanged);
    139     }
    140 
    141     private void Symbol_NameChanging(object sender, CancelEventArgs<string> e) {
    142       if (symbols.ContainsKey(e.Value)) e.Cancel = true;
    143     }
    144     private void Symbol_NameChanged(object sender, EventArgs e) {
    145       ISymbol symbol = (ISymbol)sender;
    146       string oldName = symbols.Where(x => x.Value == symbol).First().Key;
    147       string newName = symbol.Name;
    148 
    149       symbols.Remove(oldName);
    150       symbols.Add(newName, symbol);
    151 
    152       var subtreeCount = symbolSubtreeCount[oldName];
    153       symbolSubtreeCount.Remove(oldName);
    154       symbolSubtreeCount.Add(newName, subtreeCount);
    155 
    156       List<string> allowedChilds;
    157       if (allowedChildSymbols.TryGetValue(oldName, out allowedChilds)) {
    158         allowedChildSymbols.Remove(oldName);
    159         allowedChildSymbols.Add(newName, allowedChilds);
    160       }
    161 
    162       for (int i = 0; i < GetMaximumSubtreeCount(symbol); i++) {
    163         if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(oldName, i), out allowedChilds)) {
    164           allowedChildSymbolsPerIndex.Remove(Tuple.Create(oldName, i));
    165           allowedChildSymbolsPerIndex.Add(Tuple.Create(newName, i), allowedChilds);
    166         }
    167       }
    168 
    169       foreach (var parent in Symbols) {
    170         if (allowedChildSymbols.TryGetValue(parent.Name, out allowedChilds))
    171           if (allowedChilds.Remove(oldName))
    172             allowedChilds.Add(newName);
    173 
    174         for (int i = 0; i < GetMaximumSubtreeCount(parent); i++) {
    175           if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, i), out allowedChilds))
    176             if (allowedChilds.Remove(oldName)) allowedChilds.Add(newName);
    177         }
    178       }
    179 
    180       ClearCaches();
    181     }
    182 
    183     protected void RemoveSymbol(ISymbol symbol) {
     122    protected virtual void RemoveSymbol(ISymbol symbol) {
    184123      symbols.Remove(symbol.Name);
    185124      allowedChildSymbols.Remove(symbol.Name);
     
    198137        }
    199138      }
    200       DeregisterSymbolEvents(symbol);
    201139      ClearCaches();
    202140    }
     
    315253
    316254
    317     private void ClearCaches() {
     255    protected void ClearCaches() {
    318256      cachedMinExpressionLength.Clear();
    319257      cachedMaxExpressionLength.Clear();
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs

    r6237 r6569  
    4242    }
    4343
     44    [Storable]
    4445    private ISymbolicExpressionGrammar grammar;
    4546    public SymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar)
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r5809 r6569  
    186186
    187187    public override string ToString() {
    188       return Symbol.Name;
     188      if (Symbol != null) return Symbol.Name;
     189      return "SymbolicExpressionTreeNode";
    189190    }
    190191
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs

    r5809 r6569  
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
    2828  public static class Grammars {
     29
     30    [StorableClass]
    2931    private class Addition : Symbol {
     32      [StorableConstructor]
     33      protected Addition(bool deserializing) : base(deserializing) { }
    3034      protected Addition(Addition original, Cloner cloner) : base(original, cloner) { }
    3135      public Addition() : base("Addition", "") { }
     
    3438      }
    3539    }
     40
     41    [StorableClass]
    3642    private class Subtraction : Symbol {
     43      [StorableConstructor]
     44      protected Subtraction(bool deserializing) : base(deserializing) { }
    3745      protected Subtraction(Subtraction original, Cloner cloner) : base(original, cloner) { }
    3846      public Subtraction() : base("Subtraction", "") { }
     
    4149      }
    4250    }
     51
     52    [StorableClass]
    4353    private class Multiplication : Symbol {
     54      [StorableConstructor]
     55      protected Multiplication(bool deserializing) : base(deserializing) { }
    4456      protected Multiplication(Multiplication original, Cloner cloner) : base(original, cloner) { }
    4557      public Multiplication() : base("Multiplication", "") { }
     
    4860      }
    4961    }
     62
     63    [StorableClass]
    5064    private class Division : Symbol {
     65      [StorableConstructor]
     66      protected Division(bool deserializing) : base(deserializing) { }
    5167      protected Division(Division original, Cloner cloner) : base(original, cloner) { }
    5268      public Division() : base("Division", "") { }
     
    5571      }
    5672    }
     73
     74    [StorableClass]
    5775    private class Terminal : Symbol {
     76      [StorableConstructor]
     77      protected Terminal(bool deserializing) : base(deserializing) { }
    5878      protected Terminal(Terminal original, Cloner cloner) : base(original, cloner) { }
    5979      public Terminal() : base("Terminal", "") { }
     
    6787    }
    6888
     89    [StorableClass]
    6990    private class TerminalNode : SymbolicExpressionTreeTerminalNode {
    7091      public override bool HasLocalParameters { get { return true; } }
     
    94115    }
    95116
     117    [StorableClass]
    96118    private class SimpleArithmeticGrammar : SymbolicExpressionGrammar {
     119      [StorableConstructor]
     120      protected SimpleArithmeticGrammar(bool deserializing) : base(deserializing) { }
    97121      protected SimpleArithmeticGrammar(SimpleArithmeticGrammar original, Cloner cloner) : base(original, cloner) { }
    98122      public SimpleArithmeticGrammar()
  • branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Properties/AssemblyInfo.cs

    r5809 r6569  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.4.0.0")]
    55 [assembly: AssemblyFileVersion("3.4.0.0")]
     55[assembly: AssemblyFileVersion("3.4.1.0")]
Note: See TracChangeset for help on using the changeset viewer.