Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3535 for trunk


Ignore:
Timestamp:
04/26/10 16:16:49 (15 years ago)
Author:
gkronber
Message:

Fixed bugs in manipulation operators. #937 (Data types and operators for symbolic expression tree encoding)

Location:
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/ArchitectureAlteringOperators/SubroutineDeleter.cs

    r3534 r3535  
    102102        int maxHeight = Math.Max(minPossibleHeight, invocationCutPoint.ReplacedChild.GetHeight());
    103103        replacementTree = selectedSymbol.CreateTreeNode();
     104        if (replacementTree.HasLocalParameters)
     105          replacementTree.ResetLocalParameters(random);
    104106        invocationCutPoint.Parent.RemoveSubTree(invocationCutPoint.ReplacedChildIndex);
    105107        invocationCutPoint.Parent.InsertSubTree(invocationCutPoint.ReplacedChildIndex, replacementTree);
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/OnePointShaker.cs

    r3512 r3535  
    3737
    3838    protected override void Manipulate(IRandom random, SymbolicExpressionTree symbolicExpressionTree, ISymbolicExpressionGrammar grammar, IntValue maxTreeSize, IntValue maxTreeHeight, out bool success) {
     39      var parametricNodes = from node in symbolicExpressionTree.IterateNodesPrefix()
     40                            where node.HasLocalParameters
     41                            select node;
     42      if (parametricNodes.Count() > 0) {
     43        SymbolicExpressionTreeNode selectedPoint = parametricNodes.SelectRandom(random);
    3944
    40       SymbolicExpressionTreeNode selectedPoint = (from node in symbolicExpressionTree.IterateNodesPrefix()
    41                                                   where node.HasLocalParameters
    42                                                   select node).SelectRandom(random);
    43 
    44       selectedPoint.ShakeLocalParameters(random, 1.0);
    45       success = true;
     45        selectedPoint.ShakeLocalParameters(random, 1.0);
     46        success = true;
     47      } else {
     48        success = false;
     49      }
    4650    }
    4751  }
Note: See TracChangeset for help on using the changeset viewer.