Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 18:49:17 (15 years ago)
Author:
gkronber
Message:

Removed max. and min. time offset constraints as algorithm parameters and from all engines. The time constraints were added to the relevant terminal symbols (variable & differential) instead. The time offset constraint can be changed by editing the symbols in the function library. #880 (Max and min time offsets for variable symbols are not set correctly by FunctionLibraryInjectors)

Location:
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors
Files:
4 edited

Legend:

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

    r2728 r2843  
    2929  [SymbolicRegressionFunctionLibraryInjector]
    3030  public class ArithmeticFunctionLibraryInjector : FunctionLibraryInjectorBase {
    31     public const string MINTIMEOFFSET = "MinTimeOffset";
    32     public const string MAXTIMEOFFSET = "MaxTimeOffset";
    33 
    34     private int minTimeOffset;
    35     private int maxTimeOffset;
    36 
    3731    public override string Description {
    3832      get { return @"Injects a function library with (+, -, *,  /) symbols."; }
    39     }
    40 
    41     public ArithmeticFunctionLibraryInjector()
    42       : base() {
    43       AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    44       AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In));
    45     }
    46 
    47     public override IOperation Apply(IScope scope) {
    48       // try to get minTimeOffset (use 0 as default if not available)
    49       IItem minTimeOffsetItem = GetVariableValue(MINTIMEOFFSET, scope, true, false);
    50       minTimeOffset = minTimeOffsetItem == null ? 0 : ((IntData)minTimeOffsetItem).Data;
    51       // try to get maxTimeOffset (use 0 as default if not available)
    52       IItem maxTimeOffsetItem = GetVariableValue(MAXTIMEOFFSET, scope, true, false);
    53       maxTimeOffset = maxTimeOffsetItem == null ? 0 : ((IntData)maxTimeOffsetItem).Data;
    54 
    55       return base.Apply(scope);
    5633    }
    5734
     
    7855      doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun));
    7956
    80       variable.SetConstraints(minTimeOffset, maxTimeOffset);
    81       differential.SetConstraints(minTimeOffset, maxTimeOffset);
    82 
    8357      return functionLibrary;
    8458    }
  • TabularUnified trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/DefaultFunctionLibraryInjector.cs

    r2821 r2843  
    2929  [SymbolicRegressionFunctionLibraryInjector]
    3030  public class DefaultFunctionLibraryInjector : FunctionLibraryInjectorBase {
    31     public const string MINTIMEOFFSET = "MinTimeOffset";
    32     public const string MAXTIMEOFFSET = "MaxTimeOffset";
    33 
    34     private int minTimeOffset;
    35     private int maxTimeOffset;
    36 
    3731    public override string Description {
    3832      get { return @"Injects a default function library for regression and classification problems."; }
    39     }
    40 
    41     public DefaultFunctionLibraryInjector()
    42       : base() {
    43       AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    44       AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In));
    45     }
    46 
    47     public override IOperation Apply(IScope scope) {
    48       // try to get minTimeOffset (use 0 as default if not available)
    49       IItem minTimeOffsetItem = GetVariableValue(MINTIMEOFFSET, scope, true, false);
    50       minTimeOffset = minTimeOffsetItem == null ? 0 : ((IntData)minTimeOffsetItem).Data;
    51       // try to get maxTimeOffset (use 0 as default if not available)
    52       IItem maxTimeOffsetItem = GetVariableValue(MAXTIMEOFFSET, scope, true, false);
    53       maxTimeOffset = maxTimeOffsetItem == null ? 0 : ((IntData)maxTimeOffsetItem).Data;
    54 
    55       return base.Apply(scope);
    5633    }
    5734
     
    12198      booleanFunctions.ForEach(fun => functionLibrary.AddFunction(fun));
    12299
    123       variable.SetConstraints(minTimeOffset, maxTimeOffset);
    124       differential.SetConstraints(minTimeOffset, maxTimeOffset);
    125 
    126100      return functionLibrary;
    127101    }
  • TabularUnified trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs

    r2728 r2843  
    2929  [SymbolicRegressionFunctionLibraryInjector]
    3030  public class SimpleFunctionLibraryInjector : FunctionLibraryInjectorBase {
    31     public const string MINTIMEOFFSET = "MinTimeOffset";
    32     public const string MAXTIMEOFFSET = "MaxTimeOffset";
    33 
    34     private int minTimeOffset;
    35     private int maxTimeOffset;
    36 
    3731    public override string Description {
    3832      get { return @"Injects a simple function library for regression and classification problems."; }
    3933    }
    4034
    41     public SimpleFunctionLibraryInjector()
    42       : base() {
    43       AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    44       AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In));
     35    protected override FunctionLibrary CreateFunctionLibrary() {
     36      return Create();
    4537    }
    4638
    47     public override IOperation Apply(IScope scope) {
    48       // try to get minTimeOffset (use 0 as default if not available)
    49       IItem minTimeOffsetItem = GetVariableValue(MINTIMEOFFSET, scope, true, false);
    50       minTimeOffset = minTimeOffsetItem == null ? 0 : ((IntData)minTimeOffsetItem).Data;
    51       // try to get maxTimeOffset (use 0 as default if not available)
    52       IItem maxTimeOffsetItem = GetVariableValue(MAXTIMEOFFSET, scope, true, false);
    53       maxTimeOffset = maxTimeOffsetItem == null ? 0 : ((IntData)maxTimeOffsetItem).Data;
    54 
    55       return base.Apply(scope);
    56     }
    57 
    58     protected override FunctionLibrary CreateFunctionLibrary() {
    59       return Create(
    60         minTimeOffset,
    61         maxTimeOffset);
    62     }
    63 
    64     public static FunctionLibrary Create(int minTimeOffset, int maxTimeOffset) {
     39    public static FunctionLibrary Create() {
    6540      FunctionLibrary functionLibrary = new FunctionLibrary();
    6641
     
    11186      allFunctions.ForEach(x => functionLibrary.AddFunction(x));
    11287
    113       variable.SetConstraints(minTimeOffset, maxTimeOffset);
    114       differential.SetConstraints(minTimeOffset, maxTimeOffset);
    115 
    11688      return functionLibrary;
    11789    }
  • TabularUnified trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/UnconstrainedFunctionLibraryInjector.cs

    r2728 r2843  
    2929  [SymbolicRegressionFunctionLibraryInjector]
    3030  public class UnconstrainedFunctionLibraryInjector : FunctionLibraryInjectorBase {
    31     public const string MINTIMEOFFSET = "MinTimeOffset";
    32     public const string MAXTIMEOFFSET = "MaxTimeOffset";
    33 
    34     private int minTimeOffset;
    35     private int maxTimeOffset;
    36 
    3731    public override string Description {
    3832      get { return @"Injects a function library for regression and classification problems."; }
    39     }
    40 
    41     public UnconstrainedFunctionLibraryInjector()
    42       : base() {
    43       AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    44       AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In));
    45     }
    46 
    47     public override IOperation Apply(IScope scope) {
    48       // try to get minTimeOffset (use 0 as default if not available)
    49       IItem minTimeOffsetItem = GetVariableValue(MINTIMEOFFSET, scope, true, false);
    50       minTimeOffset = minTimeOffsetItem == null ? 0 : ((IntData)minTimeOffsetItem).Data;
    51       // try to get maxTimeOffset (use 0 as default if not available)
    52       IItem maxTimeOffsetItem = GetVariableValue(MAXTIMEOFFSET, scope, true, false);
    53       maxTimeOffset = maxTimeOffsetItem == null ? 0 : ((IntData)maxTimeOffsetItem).Data;
    54 
    55       return base.Apply(scope);
    5633    }
    5734
     
    11390      doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun));
    11491
    115       variable.SetConstraints(minTimeOffset, maxTimeOffset);
    116       differential.SetConstraints(minTimeOffset, maxTimeOffset);
    117 
    11892      return functionLibrary;
    119     }
    120 
    121     private void ConditionalAddFunction(string condName, IFunction fun, List<IFunction> list) {
    122       if (GetVariableValue<BoolData>(condName, null, false).Data) list.Add(fun);
    123     }
    124 
    125     private void ConditionalAddOperator(string condName, FunctionLibrary functionLib, IFunction op) {
    126       if (GetVariableValue<BoolData>(condName, null, false).Data) functionLib.AddFunction(op);
    12793    }
    12894  }
Note: See TracChangeset for help on using the changeset viewer.