using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using System.Text; using System.Threading.Tasks; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Algorithms.IteratedSymbolicExpressionConstruction { // the state represents the combination of parent symbol and it's child index [StorableClass] [Item("ParentChildStateFunction", "")] public class ParentChildStateFunction : Item, IStateFunction { public ParentChildStateFunction() : base() { } public object CreateState(ISymbolicExpressionTreeNode root, List actions, ISymbolicExpressionTreeNode parentNode, int childIdx) { if (parentNode == null) return string.Empty; else return parentNode.Symbol.Name + "." + string.Join(".", parentNode.Subtrees.Select(t => t.Symbol.Name)); } #region item [StorableConstructor] protected ParentChildStateFunction(bool deserializing) : base(deserializing) { } protected ParentChildStateFunction(ParentChildStateFunction original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new ParentChildStateFunction(this, cloner); } #endregion } }