1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
9 | using HeuristicLab.Random;
|
---|
10 |
|
---|
11 | namespace 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 |
|
---|