Changeset 17120 for branches/2994-AutoDiffForIntervals/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
- Timestamp:
- 07/10/19 17:39:38 (5 years ago)
- Location:
- branches/2994-AutoDiffForIntervals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2994-AutoDiffForIntervals
- Property svn:mergeinfo changed
-
branches/2994-AutoDiffForIntervals/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/branches/2435-alglib_3_15/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 17034 /trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 17020,17037
- Property svn:mergeinfo changed
-
branches/2994-AutoDiffForIntervals/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r16565 r17120 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 38 38 39 39 #region properties for separation between implementation and persistence 40 private IEnumerable<ISymbol> storableSymbols; 40 41 [Storable(Name = "Symbols")] 41 42 private IEnumerable<ISymbol> StorableSymbols { 42 43 get { return symbols.Values.ToArray(); } 43 set { foreach (var s in value) symbols.Add(s.Name, s); } 44 } 45 44 set { storableSymbols = value; } 45 } 46 47 private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> storableSymbolSubtreeCount; 46 48 [Storable(Name = "SymbolSubtreeCount")] 47 49 private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> StorableSymbolSubtreeCount { 48 50 get { return symbolSubtreeCount.Select(x => new KeyValuePair<ISymbol, Tuple<int, int>>(GetSymbol(x.Key), x.Value)).ToArray(); } 49 set { foreach (var pair in value) symbolSubtreeCount.Add(pair.Key.Name, pair.Value); } 50 } 51 51 set { storableSymbolSubtreeCount = value; } 52 } 53 54 private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> storableAllowedChildSymbols; 52 55 [Storable(Name = "AllowedChildSymbols")] 53 56 private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> StorableAllowedChildSymbols { 54 57 get { return allowedChildSymbols.Select(x => new KeyValuePair<ISymbol, IEnumerable<ISymbol>>(GetSymbol(x.Key), x.Value.Select(GetSymbol).ToArray())).ToArray(); } 55 set { foreach (var pair in value) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList()); } 56 } 57 58 set { storableAllowedChildSymbols = value; } 59 } 60 61 private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> storableAllowedChildSymbolsPerIndex; 58 62 [Storable(Name = "AllowedChildSymbolsPerIndex")] 59 63 private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> StorableAllowedChildSymbolsPerIndex { 60 64 get { return allowedChildSymbolsPerIndex.Select(x => new KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>(Tuple.Create(GetSymbol(x.Key.Item1), x.Key.Item2), x.Value.Select(GetSymbol).ToArray())).ToArray(); } 61 set { 62 foreach (var pair in value) 63 allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList()); 64 } 65 set { storableAllowedChildSymbolsPerIndex = value; } 65 66 } 66 67 #endregion … … 88 89 89 90 suppressEvents = false; 91 } 92 93 [StorableHook(HookType.AfterDeserialization)] 94 private void AfterDeserialization() { 95 foreach (var s in storableSymbols) symbols.Add(s.Name, s); 96 foreach (var pair in storableSymbolSubtreeCount) symbolSubtreeCount.Add(pair.Key.Name, pair.Value); 97 foreach (var pair in storableAllowedChildSymbols) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList()); 98 foreach (var pair in storableAllowedChildSymbolsPerIndex) 99 allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList()); 100 101 storableSymbols = null; 102 storableSymbolSubtreeCount = null; 103 storableAllowedChildSymbols = null; 104 storableAllowedChildSymbolsPerIndex = null; 90 105 } 91 106
Note: See TracChangeset
for help on using the changeset viewer.