Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/09 19:24:23 (15 years ago)
Author:
gkronber
Message:

Created a branch for #713

Location:
branches/GP-Refactoring-713
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/ChangeNodeTypeManipulation.cs

    r656 r2202  
    4545      : base() {
    4646      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
    47       AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(GPOperatorLibrary), VariableKind.In));
     47      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
    4848      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    4949      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
     
    5757      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
    5858      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
    59       GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     59      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
    6060      IntData treeSize = GetVariableValue<IntData>("TreeSize", scope, false);
    6161      IntData treeHeight = GetVariableValue<IntData>("TreeHeight", scope, false);
     
    148148      // first let's choose the function we want to use instead of the old child. For this we have to determine the
    149149      // pool of allowed functions based on constraints of the parent if there is one.
    150       IList<IFunction> allowedFunctions = gardener.GetAllowedSubFunctions(parent!=null?parent.Function:null, childIndex);
     150      List<IFunction> allowedFunctions = new List<IFunction>(gardener.GetAllowedSubFunctions(parent != null ? parent.Function : null, childIndex));
    151151      // try to make a tree with the same arity as the old child.
    152152      int actualArity = child.SubTrees.Count;
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/CutOutNodeManipulation.cs

    r656 r2202  
    5050      : base() {
    5151      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
    52       AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(GPOperatorLibrary), VariableKind.In));
     52      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
    5353      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    5454      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
     
    6262      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
    6363      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
    64       GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     64      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
    6565      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
    6666      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/DeleteSubTreeManipulation.cs

    r656 r2202  
    4040      : base() {
    4141      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
    42       AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(GPOperatorLibrary), VariableKind.In));
     42      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
    4343      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    4444      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
     
    5252      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
    5353      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
    54       GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     54      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
    5555      TreeGardener gardener = new TreeGardener(random, library);
    5656      IFunctionTree parent = gardener.GetRandomParentNode(root);
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/FullTreeShaker.cs

    r706 r2202  
    3333  public class FullTreeShaker : DelegatingOperator {
    3434    public override string Description {
    35       get { return "Manipulates all tree nodes for which a '" + FunctionBase.MANIPULATION + "' variable is defined."; }
     35      get { return "Manipulates all tree nodes for which a manipulator is defined."; }
    3636    }
    3737
     
    3939      : base() {
    4040      AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In));
    41       AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof(GPOperatorLibrary), VariableKind.In));
     41      AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof(FunctionLibrary), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In));
    4343      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
     
    4545
    4646    public override IOperation Apply(IScope scope) {
    47       GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     47      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
    4848      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
    4949      MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true);
     
    5656
    5757      TreeGardener gardener = new TreeGardener(mt, library);
    58       var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable(FunctionBase.MANIPULATION) != null);
     58      var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Manipulator!= null);
    5959      foreach(IFunctionTree subTree in parametricBranches) {
    60         IOperator mutation = (IOperator)subTree.Function.GetVariable(FunctionBase.MANIPULATION).Value;
     60        IOperator mutation = subTree.Manipulator;
    6161
    6262        // store all local variables into a temporary scope
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/OnePointShaker.cs

    r1039 r2202  
    3333  public class OnePointShaker : DelegatingOperator {
    3434    public override string Description {
    35       get { return "Selects a random node of all tree-nodes that have a '"+FunctionBase.MANIPULATION+"' variable defined and manipulates the selected node."; }
     35      get { return "Selects a random node of all tree-nodes that have a manipulator defined and manipulates the selected node."; }
    3636    }
    3737
    3838    public OnePointShaker()
    3939      : base() {
    40       AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines mutation operations for operators", typeof(GPOperatorLibrary), VariableKind.In));
     40      AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines mutation operations for operators", typeof(FunctionLibrary), VariableKind.In));
    4141      AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("ShakingFactor", "Factor that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In));
     
    4545
    4646    public override IOperation Apply(IScope scope) {
    47       GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     47      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
    4848      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
    4949      MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true);
     
    5151
    5252      // get all nodes for which a manipulation is defined
    53       var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable(FunctionBase.MANIPULATION) != null);
     53      var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Manipulator != null);
    5454
    5555      if(parametricBranches.Count() == 0) return null; // don't manipulate anything if there are no nodes with a manipulation operator
    5656
    5757      IFunctionTree selectedBranch = parametricBranches.ElementAt(mt.Next(parametricBranches.Count()));
    58       IOperator mutation = (IOperator)selectedBranch.Function.GetVariable(FunctionBase.MANIPULATION).Value;
     58      IOperator mutation = selectedBranch.Manipulator;
    5959      CompositeOperation next = new CompositeOperation();
    6060
  • branches/GP-Refactoring-713/sources/HeuristicLab.GP/3.3/Manipulation/SubstituteSubTreeManipulation.cs

    r656 r2202  
    3939      : base() {
    4040      AddVariableInfo(new VariableInfo("Random", "Uniform random number generator", typeof(MersenneTwister), VariableKind.In));
    41       AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(GPOperatorLibrary), VariableKind.In));
     41      AddVariableInfo(new VariableInfo("OperatorLibrary", "The operator library containing all available operators", typeof(FunctionLibrary), VariableKind.In));
    4242      AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In));
    4343      AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In));
     
    5050      IFunctionTree root = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
    5151      MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true);
    52       GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
     52      FunctionLibrary library = GetVariableValue<FunctionLibrary>("OperatorLibrary", scope, true);
    5353      int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data;
    5454      int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data;
Note: See TracChangeset for help on using the changeset viewer.