Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/10 16:12:26 (14 years ago)
Author:
gkronber
Message:

Implemented a fix in TreeGardener for #836 (Initial population doesn't contain all functions in combination with SimpleFunctionLibraryInjector). Added test cases for SimpleFunctionLibraryInjector. Changed code for calculation of minTreeHeight and minTreeSize in FunctionBase

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs

    r2566 r2675  
    6767
    6868    protected override FunctionLibrary CreateFunctionLibrary() {
     69      return Create(
     70        GetVariableValue<BoolData>(DIFFERENTIALS_ALLOWED, null, false).Data,
     71        minTimeOffset,
     72        maxTimeOffset);
     73    }
     74
     75    public static FunctionLibrary Create(bool differentialAllowed, int minTimeOffset, int maxTimeOffset) {
    6976      FunctionLibrary functionLibrary = new FunctionLibrary();
    7077
     
    8592
    8693      List<IFunction> valueNodes = new List<IFunction>();
    87       ConditionalAddFunction(DIFFERENTIALS_ALLOWED, differential, valueNodes);
     94      if (differentialAllowed) valueNodes.Add(differential);
    8895      valueNodes.Add(variable);
    8996      valueNodes.Add(constant);
     
    122129      SetAllowedSubOperators(tangens, valueNodes);
    123130
    124       ConditionalAddOperator(DIFFERENTIALS_ALLOWED, functionLibrary, differential);
     131      if (differentialAllowed) functionLibrary.AddFunction(differential);
    125132
    126133      allFunctions.ForEach(x => functionLibrary.AddFunction(x));
     
    131138      return functionLibrary;
    132139    }
    133 
    134     private void ConditionalAddFunction(string condName, IFunction fun, List<IFunction> list) {
    135       if (GetVariableValue<BoolData>(condName, null, false).Data) list.Add(fun);
    136     }
    137 
    138     private void ConditionalAddOperator(string condName, FunctionLibrary functionLib, IFunction op) {
    139       if (GetVariableValue<BoolData>(condName, null, false).Data) functionLib.AddFunction(op);
    140     }
    141140  }
    142141}
Note: See TracChangeset for help on using the changeset viewer.