Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Algorithms.IteratedSentenceConstruction/HeuristicLab.Algorithms.IteratedSymbolicExpressionConstruction/3.3/StateFunctions/ParentChildStateFunction.cs @ 13398

Last change on this file since 13398 was 12924, checked in by gkronber, 9 years ago

#2471

  • implemented a demo for value approximation with gbt and a trivial feature function
File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Runtime.InteropServices.WindowsRuntime;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
10using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
11
12namespace HeuristicLab.Algorithms.IteratedSymbolicExpressionConstruction {
13  // the state represents the combination of parent symbol and it's child index
14  [StorableClass]
15  [Item("ParentChildStateFunction", "")]
16  public class ParentChildStateFunction : Item, IStateFunction {
17    public ParentChildStateFunction()
18      : base() {
19    }
20
21    public object CreateState(ISymbolicExpressionTreeNode root, List<ISymbol> actions, ISymbolicExpressionTreeNode parentNode, int childIdx) {
22      if (parentNode == null) return string.Empty;
23      else return parentNode.Symbol.Name + "." + string.Join(".", parentNode.Subtrees.Select(t => t.Symbol.Name));
24    }
25
26    #region item
27    [StorableConstructor]
28    protected ParentChildStateFunction(bool deserializing) : base(deserializing) { }
29    protected ParentChildStateFunction(ParentChildStateFunction original, Cloner cloner)
30      : base(original, cloner) {
31    }
32    public override IDeepCloneable Clone(Cloner cloner) {
33      return new ParentChildStateFunction(this, cloner);
34    }
35    #endregion
36  }
37}
Note: See TracBrowser for help on using the repository browser.