Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

Legend:

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

  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r12012 r12422  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Random;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    181182                                   select branch).ToList();
    182183        if (allowedInternalBranches.Count > 0) {
    183           return allowedInternalBranches.SelectRandom(random);
     184          return allowedInternalBranches.SampleRandom(random);
     185
    184186        } else {
    185187          // no internal nodes allowed => select leaf nodes
     
    187189                                 where branch == null || branch.SubtreeCount == 0
    188190                                 select branch).ToList();
    189           return allowedLeafBranches.SelectRandom(random);
     191          return allowedLeafBranches.SampleRandom(random);
    190192        }
    191193      } else {
     
    195197                               select branch).ToList();
    196198        if (allowedLeafBranches.Count > 0) {
    197           return allowedLeafBranches.SelectRandom(random);
     199          return allowedLeafBranches.SampleRandom(random);
    198200        } else {
    199201          allowedInternalBranches = (from branch in branches
    200202                                     where branch != null && branch.SubtreeCount > 0
    201203                                     select branch).ToList();
    202           return allowedInternalBranches.SelectRandom(random);
     204          return allowedInternalBranches.SampleRandom(random);
     205
    203206        }
    204207      }
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SymbolicExpressionTreeCrossover.cs

    r12012 r12422  
    3434  public abstract class SymbolicExpressionTreeCrossover : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeCrossover {
    3535    private const string ParentsParameterName = "Parents";
    36     private const string ChildParameterName = "Child";
    3736    #region Parameter Properties
    3837    public ILookupParameter<ItemArray<ISymbolicExpressionTree>> ParentsParameter {
    3938      get { return (ScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[ParentsParameterName]; }
    4039    }
    41     public ILookupParameter<ISymbolicExpressionTree> ChildParameter {
    42       get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[ChildParameterName]; }
    43     }
    4440    #endregion
    4541    #region Properties
    46     public ItemArray<ISymbolicExpressionTree> Parents {
     42    private ItemArray<ISymbolicExpressionTree> Parents {
    4743      get { return ParentsParameter.ActualValue; }
    4844    }
    49     public ISymbolicExpressionTree Child {
    50       get { return ChildParameter.ActualValue; }
    51       set { ChildParameter.ActualValue = value; }
     45    private ISymbolicExpressionTree Child {
     46      get { return SymbolicExpressionTreeParameter.ActualValue; }
     47      set { SymbolicExpressionTreeParameter.ActualValue = value; }
    5248    }
    5349    #endregion
     
    5854      : base() {
    5955      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed."));
    60       Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));
    6156      ParentsParameter.ActualName = "SymbolicExpressionTree";
    62       ChildParameter.ActualName = "SymbolicExpressionTree";
    6357    }
    6458
     
    6761        throw new ArgumentException("Number of parents must be exactly two for symbolic expression tree crossover operators.");
    6862
    69       ISymbolicExpressionTree result = Crossover(Random, Parents[0], Parents[1]);
     63      ISymbolicExpressionTree result = Crossover(RandomParameter.ActualValue, Parents[0], Parents[1]);
    7064
    7165      Child = result;
Note: See TracChangeset for help on using the changeset viewer.