Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/10 18:12:47 (14 years ago)
Author:
gkronber
Message:

Fixed bugs in the operator for transformation of networks to closed-form function trees. #833 (Genetic Programming based search for equations (modeling with multiple target variables))

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Networks/3.2/NetworkToFunctionTransformer.cs

    r2627 r2630  
    8787        return tree;
    8888      } else if (tree.Function is Flip) {
    89         if (tree.SubTrees[0].Function is OpenParameter) return tree.SubTrees[0];
    90         else return InvertChain(ApplyFlips(tree.SubTrees[0]));
     89        var partiallyAppliedBranch = ApplyFlips(tree.SubTrees[0]);
     90        if (partiallyAppliedBranch.Function is OpenParameter) return partiallyAppliedBranch;
     91        else return InvertChain(partiallyAppliedBranch);
    9192      } else {
    9293        List<IFunctionTree> subTrees = new List<IFunctionTree>(tree.SubTrees);
     
    210211    /// <returns></returns>
    211212    private static IFunctionTree TransformExpression(IFunctionTree tree, string targetVariable, IEnumerable<string> parameters) {
     213      if (tree.Function is Variable || tree.Function is Constant || tree.Function is Differential) return tree;
    212214      if (tree.Function is Addition || tree.Function is Subtraction ||
    213215          tree.Function is Multiplication || tree.Function is Division ||
     
    252254            combinator.AddSubTree(subTrees[i]);
    253255        }
    254         if (subTrees[targetIndex].Function is Variable || subTrees[targetIndex].Function is Constant) return combinator;
     256        if (subTrees[targetIndex].Function is Variable) return combinator;
    255257        else {
    256           IFunctionTree targetChain = InvertF0Chain(subTrees[targetIndex]);
    257           AppendLeft(targetChain, combinator);
     258          IFunctionTree bottomLeft;
     259          IFunctionTree targetChain = InvertF0Chain(subTrees[targetIndex], out bottomLeft);
     260          bottomLeft.InsertSubTree(0, combinator);
    258261          return targetChain;
    259262        }
     
    264267    // precondition: left bottom is a variable (the selected target variable)
    265268    // postcondition: the chain is inverted. the target variable is removed
    266     private static IFunctionTree InvertF0Chain(IFunctionTree tree) {
     269    private static IFunctionTree InvertF0Chain(IFunctionTree tree, out IFunctionTree bottomLeft) {
    267270      List<IFunctionTree> currentChain = IterateChain(tree).ToList();
    268271
     
    286289        }
    287290      }
     291      bottomLeft = invParent;
    288292      return root;
    289293    }
Note: See TracChangeset for help on using the changeset viewer.