Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12453


Ignore:
Timestamp:
06/16/15 12:23:18 (9 years ago)
Author:
mkommend
Message:

#2276: Changes to reduce the memory consumption of GP.

Location:
branches/HeuristicLab.DatasetRefactor/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r12438 r12453  
    135135      parent0.Root.ForEachNodePostfix((n) => {
    136136        if (n.SubtreeCount > 0 && n != parent0.Root) {
    137           foreach (var child in n.Subtrees) {
     137          //avoid linq to reduce memory pressure
     138          for (int i = 0; i < n.SubtreeCount; i++) {
     139            var child = n.GetSubtree(i);
    138140            if (child.GetLength() <= maxBranchLength &&
    139141                child.GetDepth() <= maxBranchDepth) {
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Grammars/SymbolicExpressionGrammarBase.cs

    r12438 r12453  
    338338        List<string> temp;
    339339        if (allowedChildSymbols.TryGetValue(parent.Name, out temp)) {
    340           if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) {
    341             cachedIsAllowedChildSymbol.Add(key, true);
    342             return true;
     340          for (int i = 0; i < temp.Count; i++) {
     341            var symbol = GetSymbol(temp[i]);
     342            foreach (var s in symbol.Flatten())
     343              if (s.Name == child.Name) {
     344                cachedIsAllowedChildSymbol.Add(key, true);
     345                return true;
     346              }
    343347          }
    344348        }
     
    365369        List<string> temp;
    366370        if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, argumentIndex), out temp)) {
    367           if (temp.SelectMany(s => GetSymbol(s).Flatten()).Any(s => s.Name == child.Name)) {
    368             cachedIsAllowedChildSymbolIndex.Add(key, true);
    369             return true;
     371          for (int i = 0; i < temp.Count; i++) {
     372            var symbol = GetSymbol(temp[i]);
     373            foreach (var s in symbol.Flatten())
     374              if (s.Name == child.Name) {
     375                cachedIsAllowedChildSymbolIndex.Add(key, true);
     376                return true;
     377              }
    370378          }
    371379        }
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs

    r12031 r12453  
    175175
    176176    public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() {
    177       var list = new List<ISymbolicExpressionTreeNode>() { this };
     177      var list = new List<ISymbolicExpressionTreeNode>(GetLength()) { this };
    178178      int i = 0;
    179179      while (i != list.Count) {
     
    193193    public void ForEachNodePrefix(Action<ISymbolicExpressionTreeNode> a) {
    194194      a(this);
    195       if (Subtrees != null) {
    196         foreach (var subtree in Subtrees) {
    197           subtree.ForEachNodePrefix(a);
     195      if (subtrees != null) {
     196        //avoid linq to reduce memory pressure
     197        for (int i = 0; i < subtrees.Count; i++) {
     198          subtrees[i].ForEachNodePrefix(a);
    198199        }
    199200      }
     
    207208
    208209    public void ForEachNodePostfix(Action<ISymbolicExpressionTreeNode> a) {
    209       if (Subtrees != null) {
    210         foreach (var subtree in Subtrees) {
    211           subtree.ForEachNodePostfix(a);
     210      if (subtrees != null) {
     211        //avoid linq to reduce memory pressure
     212        for (int i = 0; i < subtrees.Count; i++) {
     213          subtrees[i].ForEachNodePostfix(a);
    212214        }
    213215      }
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeTopLevelNode.cs

    r12031 r12453  
    3939    protected SymbolicExpressionTreeTopLevelNode(SymbolicExpressionTreeTopLevelNode original, Cloner cloner)
    4040      : base(original, cloner) {
    41       //      grammar = cloner.Clone(original.Grammar);
    42       grammar = original.Grammar;
     41      grammar = cloner.Clone(original.Grammar);
    4342    }
    4443    public SymbolicExpressionTreeTopLevelNode() : base() { }
  • branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs

    r12031 r12453  
    6060
    6161    public override IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) {
    62       var rowsToEvaluate = rows.Except(evaluationCache.Keys);
     62      var rowsToEvaluate = rows.Where(row => !evaluationCache.ContainsKey(row));
    6363      var rowsEnumerator = rowsToEvaluate.GetEnumerator();
    6464      var valuesEnumerator = Model.GetEstimatedValues(ProblemData.Dataset, rowsToEvaluate).GetEnumerator();
Note: See TracChangeset for help on using the changeset viewer.