Changeset 17035 for branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 06/26/19 08:13:50 (6 years ago)
- Location:
- branches/2925_AutoDiffForDynamicalModels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2925_AutoDiffForDynamicalModels
- Property svn:mergeinfo changed
/trunk merged: 17007-17009,17014-17016,17019-17024,17028,17030,17032-17033
- Property svn:mergeinfo changed
-
branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged: 17020
- Property svn:mergeinfo changed
-
branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r16953 r17035 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 List<Action> afterDeserializationActions = new List<Action>();40 private IEnumerable<ISymbol> storableSymbols; 41 41 [Storable(Name = "Symbols")] 42 42 private IEnumerable<ISymbol> StorableSymbols { 43 43 get { return symbols.Values.ToArray(); } 44 set { afterDeserializationActions.Add(() => { foreach (var s in value) symbols.Add(s.Name, s); }); } 45 } 46 44 set { storableSymbols = value; } 45 } 46 47 private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> storableSymbolSubtreeCount; 47 48 [Storable(Name = "SymbolSubtreeCount")] 48 49 private IEnumerable<KeyValuePair<ISymbol, Tuple<int, int>>> StorableSymbolSubtreeCount { 49 50 get { return symbolSubtreeCount.Select(x => new KeyValuePair<ISymbol, Tuple<int, int>>(GetSymbol(x.Key), x.Value)).ToArray(); } 50 set { afterDeserializationActions.Add(() => { foreach (var pair in value) symbolSubtreeCount.Add(pair.Key.Name, pair.Value); }); } 51 } 52 51 set { storableSymbolSubtreeCount = value; } 52 } 53 54 private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> storableAllowedChildSymbols; 53 55 [Storable(Name = "AllowedChildSymbols")] 54 56 private IEnumerable<KeyValuePair<ISymbol, IEnumerable<ISymbol>>> StorableAllowedChildSymbols { 55 57 get { return allowedChildSymbols.Select(x => new KeyValuePair<ISymbol, IEnumerable<ISymbol>>(GetSymbol(x.Key), x.Value.Select(GetSymbol).ToArray())).ToArray(); } 56 set { afterDeserializationActions.Add(() => { foreach (var pair in value) allowedChildSymbols.Add(pair.Key.Name, pair.Value.Select(y => y.Name).ToList()); }); } 57 } 58 58 set { storableAllowedChildSymbols = value; } 59 } 60 61 private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> storableAllowedChildSymbolsPerIndex; 59 62 [Storable(Name = "AllowedChildSymbolsPerIndex")] 60 63 private IEnumerable<KeyValuePair<Tuple<ISymbol, int>, IEnumerable<ISymbol>>> StorableAllowedChildSymbolsPerIndex { 61 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(); } 62 set { 63 afterDeserializationActions.Add(() => { 64 foreach (var pair in value) 65 allowedChildSymbolsPerIndex.Add(Tuple.Create(pair.Key.Item1.Name, pair.Key.Item2), pair.Value.Select(y => y.Name).ToList()); 66 }); 67 } 65 set { storableAllowedChildSymbolsPerIndex = value; } 68 66 } 69 67 #endregion … … 91 89 92 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; 93 105 } 94 106
Note: See TracChangeset
for help on using the changeset viewer.