Free cookie consent management tool by TermsFeed Policy Generator

source: branches/sluengo/HeuristicLab.Problems.TradeRules/Symbols/BoolConstantTreeNode.cs @ 17189

Last change on this file since 17189 was 9262, checked in by sluengo, 12 years ago
File size: 1.6 KB
RevLine 
[9262]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Common;
6using HeuristicLab.Core;
7using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
8using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
9using HeuristicLab.Random;
10
11namespace HeuristicLab.Problems.TradeRules
12{
13    [StorableClass]
14    public sealed class BoolConstantTreeNode : SymbolicExpressionTreeTerminalNode
15    {
16
17      public new BoolConstant Symbol {
18      get { return (BoolConstant)base.Symbol; }
19    }
20
21    private double BoolConstantValue;
22    [Storable]
23    public double Value {
24      get { return BoolConstantValue; }
25      set { BoolConstantValue = value; }
26    }
27
28    [StorableConstructor]
29    private BoolConstantTreeNode(bool deserializing) : base(deserializing) { }
30
31    private BoolConstantTreeNode(BoolConstantTreeNode original, Cloner cloner)
32      : base(original, cloner) {
33      BoolConstantValue = original.BoolConstantValue;
34    }
35
36    private BoolConstantTreeNode() : base() { }
37    public BoolConstantTreeNode(BoolConstant BoolConstantSymbol) : base(BoolConstantSymbol) { }
38
39    public override bool HasLocalParameters {
40      get {
41        return true;
42      }
43    }
44    public override void ResetLocalParameters(IRandom random) {
45      base.ResetLocalParameters(random);
46      if (random.Next(1) == 0) Value = -1;
47      else Value = 1;
48    }
49
50    public override IDeepCloneable Clone(Cloner cloner) {
51      return new BoolConstantTreeNode(this, cloner);
52    }
53
54    public override string ToString() {
55      return BoolConstantValue.ToString("E5");
56    }
57  }
58}
59
Note: See TracBrowser for help on using the repository browser.