- Timestamp:
- 07/17/11 22:51:11 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs.frame
r6099 r6569 26 26 27 27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.3. 4.$WCREV$")]28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.3.5.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Properties/AssemblyInfo.frame
r6099 r6569 45 45 46 46 [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 53 53 // by using the '*' as shown below: 54 54 [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 26 26 27 27 namespace 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$")] 29 29 [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/FullTreeShaker.cs
r5809 r6569 32 32 private const string ShakingFactorParameterName = "ShakingFactor"; 33 33 #region parameter properties 34 public IValue LookupParameter<DoubleValue> ShakingFactorParameter {35 get { return (IValue LookupParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; }34 public IValueParameter<DoubleValue> ShakingFactorParameter { 35 get { return (IValueParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; } 36 36 } 37 37 #endregion 38 38 #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; } 41 42 } 42 43 #endregion 43 44 44 [StorableConstructor] 45 45 private FullTreeShaker(bool deserializing) : base(deserializing) { } … … 47 47 public FullTreeShaker() 48 48 : 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))); 50 50 } 51 51 … … 57 57 tree.Root.ForEachNodePostfix(node => { 58 58 if (node.HasLocalParameters) { 59 node.ShakeLocalParameters(random, ShakingFactor .Value);59 node.ShakeLocalParameters(random, ShakingFactor); 60 60 } 61 61 }); -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs
r5809 r6569 34 34 private const string ShakingFactorParameterName = "ShakingFactor"; 35 35 #region parameter properties 36 public IValue LookupParameter<DoubleValue> ShakingFactorParameter {37 get { return (IValue LookupParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; }36 public IValueParameter<DoubleValue> ShakingFactorParameter { 37 get { return (IValueParameter<DoubleValue>)Parameters[ShakingFactorParameterName]; } 38 38 } 39 39 #endregion 40 40 #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; } 43 44 } 44 45 #endregion … … 48 49 public OnePointShaker() 49 50 : 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))); 51 52 } 52 53 … … 62 63 if (parametricNodes.Count > 0) { 63 64 var selectedPoint = parametricNodes.SelectRandom(random); 64 selectedPoint.ShakeLocalParameters(random, ShakingFactor .Value);65 selectedPoint.ShakeLocalParameters(random, ShakingFactor); 65 66 } 66 67 } -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Properties/AssemblyInfo.frame
r5869 r6569 45 45 46 46 [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 21 21 22 22 using System; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Collections.Generic; 26 28 27 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 72 74 } 73 75 74 [Storable]75 76 private ProgramRootSymbol programRootSymbol; 76 77 public ProgramRootSymbol ProgramRootSymbol { … … 99 100 } 100 101 101 [Storable]102 102 private Defun defunSymbol; 103 103 protected Defun DefunSymbol { … … 111 111 #endregion 112 112 113 [StorableHook(HookType.AfterDeserialization)] 114 private void AfterDeserialization() { 115 foreach (ISymbol symbol in symbols.Values) 116 RegisterSymbolEvents(symbol); 117 } 113 118 [StorableConstructor] 114 119 protected SymbolicExpressionGrammar(bool deserializing) : base(deserializing) { } 115 120 protected SymbolicExpressionGrammar(SymbolicExpressionGrammar original, Cloner cloner) 116 121 : base(original, cloner) { 122 foreach (ISymbol symbol in Symbols) 123 RegisterSymbolEvents(symbol); 124 117 125 programRootSymbol = cloner.Clone(original.programRootSymbol); 118 126 startSymbol = cloner.Clone(original.StartSymbol); … … 153 161 } 154 162 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 155 172 public event EventHandler ReadOnlyChanged; 156 173 protected virtual void OnReadOnlyChanged() { … … 166 183 } 167 184 #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 168 238 } 169 239 } -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r6233 r6569 81 81 cachedMinExpressionDepth = new Dictionary<string, int>(); 82 82 } 83 [StorableHook(HookType.AfterDeserialization)]84 private void AfterDeserialization() {85 foreach (ISymbol symbol in symbols.Values)86 RegisterSymbolEvents(symbol);87 }88 83 89 84 protected SymbolicExpressionGrammarBase(SymbolicExpressionGrammarBase original, Cloner cloner) … … 93 88 cachedMinExpressionDepth = new Dictionary<string, int>(); 94 89 95 96 90 symbols = original.symbols.ToDictionary(x => x.Key, y => (ISymbol)cloner.Clone(y.Value)); 97 91 symbolSubtreeCount = new Dictionary<string, Tuple<int, int>>(original.symbolSubtreeCount); … … 104 98 foreach (var element in original.allowedChildSymbolsPerIndex) 105 99 allowedChildSymbolsPerIndex.Add(element.Key, new List<string>(element.Value)); 106 107 foreach (ISymbol symbol in symbols.Values)108 RegisterSymbolEvents(symbol);109 100 } 110 101 … … 122 113 123 114 #region protected grammar manipulation methods 124 protected v oid AddSymbol(ISymbol symbol) {115 protected virtual void AddSymbol(ISymbol symbol) { 125 116 if (ContainsSymbol(symbol)) throw new ArgumentException("Symbol " + symbol + " is already defined."); 126 RegisterSymbolEvents(symbol);127 117 symbols.Add(symbol.Name, symbol); 128 118 symbolSubtreeCount.Add(symbol.Name, Tuple.Create(0, 0)); … … 130 120 } 131 121 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) { 184 123 symbols.Remove(symbol.Name); 185 124 allowedChildSymbols.Remove(symbol.Name); … … 198 137 } 199 138 } 200 DeregisterSymbolEvents(symbol);201 139 ClearCaches(); 202 140 } … … 315 253 316 254 317 pr ivatevoid ClearCaches() {255 protected void ClearCaches() { 318 256 cachedMinExpressionLength.Clear(); 319 257 cachedMaxExpressionLength.Clear(); -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeGrammar.cs
r6237 r6569 42 42 } 43 43 44 [Storable] 44 45 private ISymbolicExpressionGrammar grammar; 45 46 public SymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar) -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
r5809 r6569 186 186 187 187 public override string ToString() { 188 return Symbol.Name; 188 if (Symbol != null) return Symbol.Name; 189 return "SymbolicExpressionTreeNode"; 189 190 } 190 191 -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs
r5809 r6569 27 27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests { 28 28 public static class Grammars { 29 30 [StorableClass] 29 31 private class Addition : Symbol { 32 [StorableConstructor] 33 protected Addition(bool deserializing) : base(deserializing) { } 30 34 protected Addition(Addition original, Cloner cloner) : base(original, cloner) { } 31 35 public Addition() : base("Addition", "") { } … … 34 38 } 35 39 } 40 41 [StorableClass] 36 42 private class Subtraction : Symbol { 43 [StorableConstructor] 44 protected Subtraction(bool deserializing) : base(deserializing) { } 37 45 protected Subtraction(Subtraction original, Cloner cloner) : base(original, cloner) { } 38 46 public Subtraction() : base("Subtraction", "") { } … … 41 49 } 42 50 } 51 52 [StorableClass] 43 53 private class Multiplication : Symbol { 54 [StorableConstructor] 55 protected Multiplication(bool deserializing) : base(deserializing) { } 44 56 protected Multiplication(Multiplication original, Cloner cloner) : base(original, cloner) { } 45 57 public Multiplication() : base("Multiplication", "") { } … … 48 60 } 49 61 } 62 63 [StorableClass] 50 64 private class Division : Symbol { 65 [StorableConstructor] 66 protected Division(bool deserializing) : base(deserializing) { } 51 67 protected Division(Division original, Cloner cloner) : base(original, cloner) { } 52 68 public Division() : base("Division", "") { } … … 55 71 } 56 72 } 73 74 [StorableClass] 57 75 private class Terminal : Symbol { 76 [StorableConstructor] 77 protected Terminal(bool deserializing) : base(deserializing) { } 58 78 protected Terminal(Terminal original, Cloner cloner) : base(original, cloner) { } 59 79 public Terminal() : base("Terminal", "") { } … … 67 87 } 68 88 89 [StorableClass] 69 90 private class TerminalNode : SymbolicExpressionTreeTerminalNode { 70 91 public override bool HasLocalParameters { get { return true; } } … … 94 115 } 95 116 117 [StorableClass] 96 118 private class SimpleArithmeticGrammar : SymbolicExpressionGrammar { 119 [StorableConstructor] 120 protected SimpleArithmeticGrammar(bool deserializing) : base(deserializing) { } 97 121 protected SimpleArithmeticGrammar(SimpleArithmeticGrammar original, Cloner cloner) : base(original, cloner) { } 98 122 public SimpleArithmeticGrammar() -
branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Properties/AssemblyInfo.cs
r5809 r6569 53 53 // by using the '*' as shown below: 54 54 [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.