Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/21/08 20:57:45 (17 years ago)
Author:
gkronber
Message:

more fixes after major refactoring step (ticket #112)

Location:
branches/FunctionsAndStructIdRefactoring/HeuristicLab.StructureIdentification
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/FunctionsAndStructIdRefactoring/HeuristicLab.StructureIdentification/RandomTreeCreator.cs

    r143 r145  
    4141      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In));
    43       AddVariableInfo(new VariableInfo("OperatorTree", "The tree to mutate", typeof(IFunctionTree), VariableKind.In));
    44       AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
    45       AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.In));
     43      AddVariableInfo(new VariableInfo("FunctionTree", "The created tree", typeof(IFunctionTree), VariableKind.New | VariableKind.Out));
     44      AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
     45      AddVariableInfo(new VariableInfo("TreeHeight", "The height of the tree", typeof(IntData), VariableKind.New | VariableKind.Out));
    4646    }
    4747
     
    6767      int actualTreeHeight = gardener.GetTreeHeight(root);
    6868
    69       scope.AddVariable(new HeuristicLab.Core.Variable("OperatorTree", root));
    70       scope.AddVariable(new HeuristicLab.Core.Variable("TreeSize", new IntData(actualTreeSize)));
    71       scope.AddVariable(new HeuristicLab.Core.Variable("TreeHeight", new IntData(actualTreeHeight)));
     69      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("FunctionTree"), root));
     70      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeSize"), new IntData(actualTreeSize)));
     71      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeHeight"), new IntData(actualTreeHeight)));
    7272
    7373      if(!gardener.IsValidTree(root)) { throw new InvalidProgramException(); }
  • branches/FunctionsAndStructIdRefactoring/HeuristicLab.StructureIdentification/TreeGardener.cs

    r143 r145  
    325325
    326326    internal bool IsValidTree(IFunctionTree tree) {
    327       if (!tree.Function.IsValid())
    328         return false;
    329       foreach (IFunctionTree subTree in tree.SubTrees) {
    330         if (!subTree.Function.IsValid())
    331           return false;
    332       }
    333 
     327      foreach(IConstraint constraint in tree.Function.Constraints) {
     328        if(constraint is NumberOfSubOperatorsConstraint) {
     329          int max = ((NumberOfSubOperatorsConstraint)constraint).MaxOperators.Data;
     330          int min = ((NumberOfSubOperatorsConstraint)constraint).MinOperators.Data;
     331          if(tree.SubTrees.Count < min || tree.SubTrees.Count > max) return false;
     332        }
     333      }
     334      foreach(IFunctionTree subTree in tree.SubTrees) {
     335        if(!IsValidTree(subTree)) return false;
     336      }
    334337      return true;
    335338    }
Note: See TracChangeset for help on using the changeset viewer.