Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/28/11 17:11:56 (14 years ago)
Author:
gkronber
Message:

#1418 improved ChangeNodeTypeManipulation operator to make unit test succeed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Tests/Grammars.cs

    r5549 r5567  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2526
    2627namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding_3._4.Tests {
     
    5960      public override IDeepCloneable Clone(Cloner cloner) {
    6061        return new Terminal(this, cloner);
     62      }
     63
     64      public override ISymbolicExpressionTreeNode CreateTreeNode() {
     65        return new TerminalNode(this);
     66      }
     67    }
     68
     69    private class TerminalNode : SymbolicExpressionTreeTerminalNode {
     70      public override bool HasLocalParameters { get { return true; } }
     71      private double value;
     72      protected TerminalNode(TerminalNode original, Cloner cloner)
     73        : base(original, cloner) {
     74        this.value = original.value;
     75      }
     76      [StorableConstructor]
     77      protected TerminalNode(bool deserializing) : base(deserializing) { }
     78      public TerminalNode(Terminal symbol) : base(symbol) { }
     79
     80      public override IDeepCloneable Clone(Cloner cloner) {
     81        return new TerminalNode(this, cloner);
     82      }
     83      public override void ResetLocalParameters(Core.IRandom random) {
     84        base.ResetLocalParameters(random);
     85        value = random.NextDouble();
     86      }
     87      public override void ShakeLocalParameters(Core.IRandom random, double shakingFactor) {
     88        base.ShakeLocalParameters(random, shakingFactor);
     89        value = random.NextDouble();
     90      }
     91      public override string ToString() {
     92        return value.ToString("E4");
    6193      }
    6294    }
Note: See TracChangeset for help on using the changeset viewer.