Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/22/08 18:05:14 (16 years ago)
Author:
gkronber
Message:

merged FunctionsAndStructIdRefactoring-branch (r142, r143, r144, r145, r146, r147, r148, r149, r152, r153) back into the trunk (ticket #112)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/Manipulation/FullTreeShaker.cs

    r88 r155  
    2929using HeuristicLab.Data;
    3030using HeuristicLab.Selection;
     31using HeuristicLab.Functions;
    3132
    3233namespace HeuristicLab.StructureIdentification {
     
    3839    public FullTreeShaker()
    3940      : base() {
     41      AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In));
    4042      AddVariableInfo(new VariableInfo("OperatorLibrary", "Operator library that defines operator mutations", typeof(GPOperatorLibrary), VariableKind.In));
    41       AddVariableInfo(new VariableInfo("OperatorTree", "The operator tree that should be mutated", typeof(IOperator), VariableKind.In));
    42       AddVariableInfo(new VariableInfo("Random", "A random generator (uniform)", typeof(MersenneTwister), VariableKind.In));
    43       AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shakeing operation", typeof(DoubleData), VariableKind.In));
     43      AddVariableInfo(new VariableInfo("ShakingFactor", "Variable that determines the force of the shaking operation", typeof(DoubleData), VariableKind.In));
     44      AddVariableInfo(new VariableInfo("FunctionTree", "The function tree that should be mutated", typeof(IFunctionTree), VariableKind.In | VariableKind.Out));
    4445    }
    4546
    4647    public override IOperation Apply(IScope scope) {
    4748      GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true);
    48       IOperator op = GetVariableValue<IOperator>("OperatorTree", scope, false);
     49      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, false);
    4950      MersenneTwister mt = GetVariableValue<MersenneTwister>("Random", scope, true);
    5051
     
    5657
    5758      TreeGardener gardener = new TreeGardener(mt, library);
    58       var parametricNodes = gardener.GetAllOperators(op).Where(o => o.GetVariable(GPOperatorLibrary.MANIPULATION) != null);
    59       foreach(IOperator subOperator in parametricNodes) {
    60         IOperator mutation =(IOperator)subOperator.GetVariable(GPOperatorLibrary.MANIPULATION).Value;
     59      var parametricBranches = gardener.GetAllSubTrees(tree).Where(branch => branch.Function.GetVariable(GPOperatorLibrary.MANIPULATION) != null);
     60      foreach(IFunctionTree subTree in parametricBranches) {
     61        IOperator mutation =(IOperator)subTree.Function.GetVariable(GPOperatorLibrary.MANIPULATION).Value;
    6162
    6263        // store all local variables into a temporary scope
    6364        Scope mutationScope = new Scope();
    64         foreach(IVariableInfo info in subOperator.VariableInfos) {
    65           if(info.Local) {
    66             mutationScope.AddVariable(subOperator.GetVariable(info.FormalName));
    67           }
     65        foreach(IVariable variable in subTree.LocalVariables) {
     66          mutationScope.AddVariable(variable);
    6867        }
    6968
Note: See TracChangeset for help on using the changeset viewer.