Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/15 11:29:34 (10 years ago)
Author:
mkommend
Message:

#2320: Merged the encoding class and all accompanying changes in the trunk.

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs

    r12012 r12422  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using System.Collections.Generic;
    2727
    2828namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5353      int tries = 0;
    5454      do {
     55
     56#pragma warning disable 612, 618
    5557        parent = symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1).Where(n => n.SubtreeCount > 0).SelectRandom(random);
     58#pragma warning restore 612, 618
     59
    5660        childIndex = random.Next(parent.SubtreeCount);
    5761
     
    8185      if (tries < MAX_TRIES) {
    8286        var weights = allowedSymbols.Select(s => s.InitialFrequency).ToList();
     87#pragma warning disable 612, 618
    8388        var newSymbol = allowedSymbols.SelectRandom(weights, random);
     89#pragma warning restore 612, 618
    8490
    8591        // replace the old node with the new node
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs

    r12012 r12422  
    2020#endregion
    2121
    22 using System.Linq;
     22using System.Collections.Generic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Parameters;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using HeuristicLab.Parameters;
    28 using System.Collections.Generic;
     28using HeuristicLab.Random;
    2929
    3030namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    6666      });
    6767      if (parametricNodes.Count > 0) {
    68         var selectedPoint = parametricNodes.SelectRandom(random);
     68        var selectedPoint = parametricNodes.SampleRandom(random);
    6969        selectedPoint.ShakeLocalParameters(random, shakingFactor);
    7070      }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs

    r12012 r12422  
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Random;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    8081      var nodes = symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1).Where(n => n.SubtreeCount > 0).ToList();
    8182      do {
    82         parent = nodes.SelectRandom(random);
     83        parent = nodes.SampleRandom(random);
     84
    8385        childIndex = random.Next(parent.SubtreeCount);
    8486        var child = parent.GetSubtree(childIndex);
     
    111113                             select g).First().ToList();
    112114      var weights = possibleSymbols.Select(x => x.InitialFrequency).ToList();
     115
     116#pragma warning disable 612, 618
    113117      var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
     118#pragma warning restore 612, 618
     119
    114120      var newTreeNode = selectedSymbol.CreateTreeNode();
    115121      if (newTreeNode.HasLocalParameters) newTreeNode.ResetLocalParameters(random);
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs

    r12012 r12422  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using HeuristicLab.Common;
     
    2627using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using System.Collections.Generic;
    2929
    3030namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    7878      int tries = 0;
    7979      do {
     80#pragma warning disable 612, 618
    8081        parent = symbolicExpressionTree.Root.IterateNodesPrefix().Skip(1).Where(n => n.SubtreeCount > 0).SelectRandom(random);
     82#pragma warning restore 612, 618
     83
    8184        childIndex = random.Next(parent.SubtreeCount);
    8285        var child = parent.GetSubtree(childIndex);
     
    99102      if (tries < MAX_TRIES) {
    100103        var weights = allowedSymbols.Select(s => s.InitialFrequency).ToList();
     104#pragma warning disable 612, 618
    101105        var seedSymbol = allowedSymbols.SelectRandom(weights, random);
     106#pragma warning restore 612, 618
     107
    102108        // replace the old node with the new node
    103109        var seedNode = seedSymbol.CreateTreeNode();
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs

    r12012 r12422  
    3232  [StorableClass]
    3333  public abstract class SymbolicExpressionTreeManipulator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeManipulator {
    34     private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    35 
    36     #region Parameter Properties
    37     public ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
    38       get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    39     }
    40     #endregion
    41 
    42     #region Properties
    43     public ISymbolicExpressionTree SymbolicExpressionTree {
    44       get { return SymbolicExpressionTreeParameter.ActualValue; }
    45     }
    46     #endregion
    47 
    4834    [StorableConstructor]
    4935    protected SymbolicExpressionTreeManipulator(bool deserializing) : base(deserializing) { }
     
    5137    public SymbolicExpressionTreeManipulator()
    5238      : base() {
    53       Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
     39     
    5440    }
    5541
Note: See TracChangeset for help on using the changeset viewer.