Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/22/15 14:27:37 (9 years ago)
Author:
bburlacu
Message:

#1772: Merge trunk changes. Remove dead code from the genealogy analyzer.

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs

    r12155 r12891  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Random;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    8485      ISymbolicExpressionTree clonedTree = (ISymbolicExpressionTree)symbolicExpressionTree.Clone();
    8586
    86       var functionDefiningBranches = clonedTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    87       if (functionDefiningBranches.Count() == 0)
     87      var functionDefiningBranches = clonedTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList();
     88      if (!functionDefiningBranches.Any())
    8889        // no function defining branch found => abort
    8990        return false;
    9091
    9192      // select a random function defining branch
    92       var selectedDefunBranch = functionDefiningBranches.SelectRandom(random);
     93      var selectedDefunBranch = functionDefiningBranches.SampleRandom(random);
     94
    9395      var definedArguments = (from symbol in selectedDefunBranch.Grammar.Symbols.OfType<Argument>()
    9496                              select symbol.ArgumentIndex).Distinct();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDeleter.cs

    r12155 r12891  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Random;
    2728
    2829namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5455      int maxFunctionDefinitions, int maxFunctionArguments) {
    5556
    56       var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    57       if (functionDefiningBranches.Count() == 0)
     57      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList();
     58      if (!functionDefiningBranches.Any())
    5859        // no function defining branch => abort
    5960        return false;
    60       var selectedDefunBranch = functionDefiningBranches.SelectRandom(random);
     61
     62      var selectedDefunBranch = functionDefiningBranches.SampleRandom(random);
    6163      if (selectedDefunBranch.NumberOfArguments <= 1)
    6264        // argument deletion by consolidation is not possible => abort
     
    7779
    7880      // delete the dynamic argument symbol that matches the argument to be removed
    79       var matchingSymbol = selectedDefunBranch.Grammar.Symbols.OfType<Argument>().Where(s => s.ArgumentIndex == removedArgument).Single();
     81      var matchingSymbol = selectedDefunBranch.Grammar.Symbols.OfType<Argument>().Single(s => s.ArgumentIndex == removedArgument);
    8082      selectedDefunBranch.Grammar.RemoveSymbol(matchingSymbol);
    8183      selectedDefunBranch.NumberOfArguments--;
    8284      // reduce arity in known functions of all root branches
    8385      foreach (var subtree in symbolicExpressionTree.Root.Subtrees) {
    84         var matchingInvokeSymbol = subtree.Grammar.Symbols.OfType<InvokeFunction>().Where(s => s.FunctionName == selectedDefunBranch.FunctionName).SingleOrDefault();
     86        var matchingInvokeSymbol = subtree.Grammar.Symbols.OfType<InvokeFunction>().SingleOrDefault(s => s.FunctionName == selectedDefunBranch.FunctionName);
    8587        if (matchingInvokeSymbol != null) {
    8688          subtree.Grammar.SetSubtreeCount(matchingInvokeSymbol, selectedDefunBranch.NumberOfArguments, selectedDefunBranch.NumberOfArguments);
     
    99101                     select node;
    100102      foreach (var argNode in argNodes) {
    101         var replacementSymbol = possibleArgumentSymbols.SelectRandom(random);
     103        var replacementSymbol = possibleArgumentSymbols.SampleRandom(random);
    102104        argNode.Symbol = replacementSymbol;
    103105      }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDuplicater.cs

    r12155 r12891  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Random;
    2930
    3031namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5657      ISymbolicExpressionTree symbolicExpressionTree,
    5758      int maxFunctionDefinitions, int maxFunctionArguments) {
    58       var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
     59      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList();
    5960
    6061      var allowedArgumentIndexes = Enumerable.Range(0, maxFunctionArguments);
    61       if (functionDefiningBranches.Count() == 0)
     62      if (!functionDefiningBranches.Any())
    6263        // no function defining branches => abort
    6364        return false;
    6465
    65       var selectedDefunBranch = functionDefiningBranches.SelectRandom(random);
    66       var argumentSymbols = selectedDefunBranch.Grammar.Symbols.OfType<Argument>();
    67       if (argumentSymbols.Count() == 0 || argumentSymbols.Count() >= maxFunctionArguments)
     66      var selectedDefunBranch = functionDefiningBranches.SampleRandom(random);
     67
     68      var argumentSymbols = selectedDefunBranch.Grammar.Symbols.OfType<Argument>().ToList();
     69      if (!argumentSymbols.Any() || argumentSymbols.Count() >= maxFunctionArguments)
    6870        // when no argument or number of arguments is already at max allowed value => abort
    6971        return false;
    70       var selectedArgumentSymbol = argumentSymbols.SelectRandom(random);
     72
     73      var selectedArgumentSymbol = argumentSymbols.SampleRandom(random);
    7174      var takenIndexes = argumentSymbols.Select(s => s.ArgumentIndex);
    7275      var newArgumentIndex = allowedArgumentIndexes.Except(takenIndexes).First();
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs

    r12155 r12891  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Random;
    3132
    3233namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    113114                          from subtree in parent.Subtrees
    114115                          select new CutPoint(parent, subtree)).ToList();
    115       if (allCutPoints.Count() == 0)
     116      if (!allCutPoints.Any())
    116117        // no cut points => abort
    117118        return false;
    118119      string newFunctionName = allowedFunctionNames.Except(functionDefiningBranches.Select(x => x.FunctionName)).First();
    119       var selectedCutPoint = allCutPoints.SelectRandom(random);
     120      var selectedCutPoint = allCutPoints.SampleRandom(random);
     121
    120122      // select random branches as argument cut-off points (replaced by argument terminal nodes in the function)
    121123      List<CutPoint> argumentCutPoints = SelectRandomArgumentBranches(selectedCutPoint.Child, random, ARGUMENT_CUTOFF_PROBABILITY, maxFunctionArguments);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs

    r12155 r12891  
    2626using HeuristicLab.Data;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Random;
    2829
    2930namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5556      ISymbolicExpressionTree symbolicExpressionTree,
    5657      int maxFunctionDefinitions, int maxFunctionArguments) {
    57       var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
     58      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList();
    5859
    59       if (functionDefiningBranches.Count() == 0)
     60      if (!functionDefiningBranches.Any())
    6061        // no ADF to delete => abort
    6162        return false;
    62       var selectedDefunBranch = functionDefiningBranches.SelectRandom(random);
     63
     64      var selectedDefunBranch = functionDefiningBranches.SampleRandom(random);
    6365      // remove the selected defun
    6466      int defunSubtreeIndex = symbolicExpressionTree.Root.IndexOfSubtree(selectedDefunBranch);
     
    9294        var allowedSymbolsList = invocationCutPoint.Parent.Grammar.GetAllowedChildSymbols(invocationCutPoint.Parent.Symbol, invocationCutPoint.ChildIndex).ToList();
    9395        var weights = allowedSymbolsList.Select(s => s.InitialFrequency);
     96
     97#pragma warning disable 612, 618
    9498        var selectedSymbol = allowedSymbolsList.SelectRandom(weights, random);
     99#pragma warning restore 612, 618
     100
    95101
    96102        int minPossibleLength = invocationCutPoint.Parent.Grammar.GetMinimumExpressionLength(selectedSymbol);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs

    r12155 r12891  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Random;
    3031
    3132namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    5960      ISymbolicExpressionTree symbolicExpressionTree,
    6061      int maxFunctionDefinitions, int maxFunctionArguments) {
    61       var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>();
    62       if (functionDefiningBranches.Count() == 0 || functionDefiningBranches.Count() == maxFunctionDefinitions)
     62      var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList();
     63      if (!functionDefiningBranches.Any() || functionDefiningBranches.Count() == maxFunctionDefinitions)
    6364        // no function defining branches to duplicate or already reached the max number of ADFs
    6465        return false;
     
    6768      var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefinitions)
    6869                                 select "ADF" + index.ToString(formatString);
    69       var selectedBranch = functionDefiningBranches.SelectRandom(random);
     70
     71      var selectedBranch = functionDefiningBranches.SampleRandom(random);
    7072      var duplicatedDefunBranch = (DefunTreeNode)selectedBranch.Clone();
    7173      string newFunctionName = allowedFunctionNames.Except(UsedFunctionNames(symbolicExpressionTree)).First();
Note: See TracChangeset for help on using the changeset viewer.