Changeset 17434 for branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars
- Timestamp:
- 02/11/20 13:36:02 (5 years ago)
- Location:
- branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/EmptySymbolicExpressionTreeGrammar.cs
r16130 r17434 2 2 3 3 /* HeuristicLab 4 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. … … 27 27 using HeuristicLab.Common; 28 28 using HeuristicLab.Core; 29 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;29 using HEAL.Attic; 30 30 31 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 32 32 33 [Storable Class]33 [StorableType("59B5B5B9-0F49-4994-B221-856AA43C28B4")] 34 34 internal sealed class EmptySymbolicExpressionTreeGrammar : NamedItem, ISymbolicExpressionTreeGrammar { 35 35 [Storable] … … 37 37 38 38 [StorableConstructor] 39 private EmptySymbolicExpressionTreeGrammar( bool deserializing) : base(deserializing) { }39 private EmptySymbolicExpressionTreeGrammar(StorableConstructorFlag _) : base(_) { } 40 40 internal EmptySymbolicExpressionTreeGrammar(ISymbolicExpressionGrammar grammar) 41 41 : base() { -
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/GrammarUtils.cs
r16130 r17434 2 2 3 3 /* HeuristicLab 4 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. -
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SimpleSymbolicExpressionGrammar.cs
r16130 r17434 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System.Collections.Generic; 23 23 using HeuristicLab.Common; 24 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;24 using HEAL.Attic; 25 25 26 26 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 27 [Storable Class]27 [StorableType("70D190B2-22F4-41E5-9938-EFD1B14ECF43")] 28 28 public sealed class SimpleSymbolicExpressionGrammar : SymbolicExpressionGrammar { 29 29 [StorableConstructor] 30 private SimpleSymbolicExpressionGrammar( bool deserializing) : base(deserializing) { }30 private SimpleSymbolicExpressionGrammar(StorableConstructorFlag _) : base(_) { } 31 31 private SimpleSymbolicExpressionGrammar(SimpleSymbolicExpressionGrammar original, Cloner cloner) : base(original, cloner) { } 32 32 public override IDeepCloneable Clone(Cloner cloner) { -
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammar.cs
r16130 r17434 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HEAL.Attic; 29 29 30 30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 31 [Storable Class]31 [StorableType("925BDEE9-0D46-48DB-BA1B-DCE82C0480B3")] 32 32 public abstract class SymbolicExpressionGrammar : SymbolicExpressionGrammarBase, ISymbolicExpressionGrammar { 33 33 #region fields & properties … … 121 121 122 122 [StorableConstructor] 123 protected SymbolicExpressionGrammar(bool deserializing) 124 : base(deserializing) { 123 protected SymbolicExpressionGrammar(StorableConstructorFlag _) : base(_) { 125 124 emptyGrammar = new EmptySymbolicExpressionTreeGrammar(this); 126 125 } -
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs
r16130 r17434 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 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 HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 28 29 29 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 34 34 /// in the sub-trees of a symbol (can be specified for each sub-tree index separately). 35 35 /// </summary> 36 [Storable Class]36 [StorableType("E76C087C-4E10-488A-86D0-295A4265DA53")] 37 37 public abstract class SymbolicExpressionGrammarBase : NamedItem, ISymbolicExpressionGrammarBase { 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 … … 80 81 81 82 [StorableConstructor] 82 protected SymbolicExpressionGrammarBase(bool deserializing) 83 : base(deserializing) { 83 protected SymbolicExpressionGrammarBase(StorableConstructorFlag _) : base(_) { 84 84 85 85 symbols = new Dictionary<string, ISymbol>(); … … 89 89 90 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; 91 105 } 92 106 -
branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionTreeGrammar.cs
r16130 r17434 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.Common; 25 using H euristicLab.Persistence.Default.CompositeSerializers.Storable;25 using HEAL.Attic; 26 26 27 27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 28 [Storable Class]28 [StorableType("ADB1DF1C-BE39-49F7-BADD-978F495EEA4D")] 29 29 internal sealed class SymbolicExpressionTreeGrammar : SymbolicExpressionGrammarBase, ISymbolicExpressionTreeGrammar { 30 30 [StorableConstructor] 31 private SymbolicExpressionTreeGrammar( bool deserializing) : base(deserializing) { }31 private SymbolicExpressionTreeGrammar(StorableConstructorFlag _) : base(_) { } 32 32 private SymbolicExpressionTreeGrammar(SymbolicExpressionTreeGrammar original, Cloner cloner) 33 33 : base(original, cloner) {
Note: See TracChangeset
for help on using the changeset viewer.