Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12420


Ignore:
Timestamp:
06/10/15 10:49:31 (9 years ago)
Author:
mkommend
Message:

#2320: Marked SymbolicExpressionTreeEncoding.EnumberableExtensions as obsolete and called the methods in Random.RandomEnumerable whereever possible.

Location:
branches/SymbolicExpressionTreeEncoding
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentCreater.cs

    r12012 r12420  
    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/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDeleter.cs

    r12012 r12420  
    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/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/ArgumentDuplicater.cs

    r12012 r12420  
    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/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineCreater.cs

    r12012 r12420  
    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/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs

    r12012 r12420  
    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/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs

    r12012 r12420  
    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();
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r12346 r12420  
    102102          .ToList();
    103103        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
     104
     105#pragma warning disable 612, 618
    104106        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
     107#pragma warning restore 612, 618
     108
    105109        var tree = selectedSymbol.CreateTreeNode();
    106110        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
     
    134138          throw new InvalidOperationException("No symbols are available for the tree.");
    135139        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
     140
     141#pragma warning disable 612, 618
    136142        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
     143#pragma warning restore 612, 618
     144       
    137145        var tree = selectedSymbol.CreateTreeNode();
    138146        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r12347 r12420  
    9494        var possibleSymbols = allowedSymbols.Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)).ToList();
    9595        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
     96
     97#pragma warning disable 612, 618
    9698        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
     99#pragma warning restore 612, 618
     100
    97101        var tree = selectedSymbol.CreateTreeNode();
    98102        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
     
    122126
    123127        var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList();
     128#pragma warning disable 612, 618
    124129        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
     130#pragma warning restore 612, 618
     131
    125132        var tree = selectedSymbol.CreateTreeNode();
    126133        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r12313 r12420  
    166166          if (allowedSymbols.Count == 0) return false;
    167167          var weights = allowedSymbols.Select(x => x.InitialFrequency).ToList();
     168
     169#pragma warning disable 612, 618
    168170          var selectedSymbol = allowedSymbols.SelectRandom(weights, random);
     171#pragma warning restore 612, 618
     172
    169173          ISymbolicExpressionTreeNode newTree = selectedSymbol.CreateTreeNode();
    170174          if (newTree.HasLocalParameters) newTree.ResetLocalParameters(random);
     
    212216                             select g).First().ToList();
    213217      var weights = possibleSymbols.Select(x => x.InitialFrequency).ToList();
     218
     219#pragma warning disable 612, 618
    214220      var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
     221#pragma warning restore 612, 618
     222
    215223      var tree = selectedSymbol.CreateTreeNode();
    216224      if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r12012 r12420  
    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      }
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/EnumerableExtensions.cs

    r12341 r12420  
    2929  //This class should not be used anymore. Use HeuristicLab.Random.RandomEnumberable instead
    3030  //This could not be fixed right now, because the algorithm behavior would be modified => version increment
     31  [Obsolete("This class will be removed in the future, because the functionality is provided in HeuristicLab.Random.RandomEnumerable.")]
    3132  public static class EnumerableExtensions {
     33    [Obsolete("This method should not be used anymore. Use the extensions provided by HeuristicLab.Random.RandomEnumberable instead.")]
    3234    public static T SelectRandom<T>(this IEnumerable<T> xs, IRandom random) {
    3335      var list = xs as IList<T>;
     
    3941      }
    4042    }
     43    [Obsolete("This method should not be used anymore. Use the extensions provided by HeuristicLab.Random.RandomEnumberable instead.")]
    4144    public static T SelectRandom<T>(this IEnumerable<T> xs, IEnumerable<double> weights, IRandom random) {
    4245      var list = xs as IList<T>;
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs

    r12012 r12420  
    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
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs

    r12012 r12420  
    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      }
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs

    r12012 r12420  
    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);
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs

    r12012 r12420  
    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();
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionContextAwareCrossover.cs

    r12012 r12420  
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Random;
    2930
    3031namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    6869          possibleChildren.Add(n);
    6970      });
    70       var selectedChild = possibleChildren.SelectRandom(random);
     71
     72      var selectedChild = possibleChildren.SampleRandom(random);
    7173      var crossoverPoints = new List<CutPoint>();
    7274      var qualities = new List<Tuple<CutPoint, double>>();
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDepthConstrainedCrossover.cs

    r12012 r12420  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Random;
    3132
    3233namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    115116        throw new Exception("No crossover points available in the first parent");
    116117
    117       var crossoverPoint0 = crossoverPoints0.SelectRandom(random);
    118 
     118      var crossoverPoint0 = crossoverPoints0.SampleRandom(random);
    119119      int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child);
    120120      int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength();
     
    126126                             select s).ToList();
    127127      if (allowedBranches.Count == 0) return parent0;
    128       var selectedBranch = allowedBranches.SelectRandom(random);
     128
     129      var selectedBranch = allowedBranches.SampleRandom(random);
    129130      Swap(crossoverPoint0, selectedBranch);
    130131      return parent0;
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDeterministicBestCrossover.cs

    r12012 r12420  
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Random;
    2930
    3031namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    6768          crossoverPoints0.Add(new CutPoint(n.Parent, n));
    6869      });
    69       CutPoint crossoverPoint0 = crossoverPoints0.SelectRandom(random);
     70
     71      CutPoint crossoverPoint0 = crossoverPoints0.SampleRandom(random);
    7072      int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child);
    7173      int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength();
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs

    r12012 r12420  
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Random;
    2930
    3031namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    6970        }
    7071      });
    71       var crossoverPoint0 = crossoverPoints0.SelectRandom(random);
     72
     73      var crossoverPoint0 = crossoverPoints0.SampleRandom(random);
    7274      int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child);
    7375      int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength();
     
    137139          weights[i] /= sum;
    138140
     141#pragma warning disable 612, 618
    139142        selectedBranch = allowedBranches.SelectRandom(weights, random);
     143#pragma warning restore 612, 618
    140144      }
    141145      Swap(crossoverPoint0, selectedBranch);
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs

    r12012 r12420  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Random;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    8182          crossoverPoints0.Add(new CutPoint(n.Parent, n));
    8283      });
    83       var crossoverPoint0 = crossoverPoints0.SelectRandom(random);
     84
     85      var crossoverPoint0 = crossoverPoints0.SampleRandom(random);
    8486      int level = parent0.Root.GetBranchLevel(crossoverPoint0.Child);
    8587      int length = parent0.Root.GetLength() - crossoverPoint0.Child.GetLength();
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableConditionTreeNode.cs

    r12012 r12420  
    7474      base.ResetLocalParameters(random);
    7575      threshold = NormalDistributedRandom.NextDouble(random, Symbol.ThresholdInitializerMu, Symbol.ThresholdInitializerSigma);
     76
     77#pragma warning disable 612, 618
    7678      variableName = Symbol.VariableNames.SelectRandom(random);
     79#pragma warning restore 612, 618
     80
    7781      slope = NormalDistributedRandom.NextDouble(random, Symbol.SlopeInitializerMu, Symbol.SlopeInitializerSigma);
    7882    }
     
    8286      double x = NormalDistributedRandom.NextDouble(random, Symbol.ThresholdManipulatorMu, Symbol.ThresholdManipulatorSigma);
    8387      threshold = threshold + x * shakingFactor;
     88
     89#pragma warning disable 612, 618
    8490      variableName = Symbol.VariableNames.SelectRandom(random);
     91#pragma warning restore 612, 618
     92
    8593      x = NormalDistributedRandom.NextDouble(random, Symbol.SlopeManipulatorMu, Symbol.SlopeManipulatorSigma);
    8694      slope = slope + x * shakingFactor;
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableTreeNode.cs

    r12012 r12420  
    6161      base.ResetLocalParameters(random);
    6262      weight = NormalDistributedRandom.NextDouble(random, Symbol.WeightMu, Symbol.WeightSigma);
     63
     64#pragma warning disable 612, 618
    6365      variableName = Symbol.VariableNames.SelectRandom(random);
     66#pragma warning restore 612, 618
    6467    }
    6568
     
    7073        double x = NormalDistributedRandom.NextDouble(random, Symbol.WeightManipulatorMu, Symbol.WeightManipulatorSigma);
    7174        weight = weight + x * shakingFactor;
    72       } else {       
     75      } else {
    7376        double x = NormalDistributedRandom.NextDouble(random, 1.0, Symbol.MultiplicativeWeightManipulatorSigma);
    7477        weight = weight * x;
    7578      }
     79#pragma warning disable 612, 618
    7680      variableName = Symbol.VariableNames.SelectRandom(random);
     81#pragma warning restore 612, 618
    7782    }
    7883
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.GrammaticalEvolution/3.3/Mappers/GenotypeToPhenotypeMapper.cs

    r12012 r12420  
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3232using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
     33using HeuristicLab.Random;
    3334
    3435namespace HeuristicLab.Problems.GrammaticalEvolution {
     
    6869      if (!possibleSymbolsList.Any()) return null;
    6970
    70       var newNode = possibleSymbolsList.SelectRandom(random).CreateTreeNode();
     71      var newNode = possibleSymbolsList.SampleRandom(random).CreateTreeNode();
    7172      if (newNode.HasLocalParameters) newNode.ResetLocalParameters(random);
    7273      return newNode;
  • branches/SymbolicExpressionTreeEncoding/HeuristicLab.Problems.GrammaticalEvolution/3.3/Mappers/RandomMapper.cs

    r12012 r12420  
    2929using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Random;
    3132
    3233namespace HeuristicLab.Problems.GrammaticalEvolution {
     
    102103        } else {
    103104          // similar to PIGEMapper, but here the current node is determined randomly ...
    104           ISymbolicExpressionTreeNode current = nonTerminals.SelectRandom(random);
     105          ISymbolicExpressionTreeNode current = nonTerminals.SampleRandom(random);
    105106          nonTerminals.Remove(current);
    106107
Note: See TracChangeset for help on using the changeset viewer.