Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 18:49:17 (14 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)

File:
1 edited

Legend:

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

    r2821 r2843  
    2828namespace HeuristicLab.GP.StructureIdentification.Networks {
    2929  public class FunctionLibraryInjector : FunctionLibraryInjectorBase {
    30     public const string MINTIMEOFFSET = "MinTimeOffset";
    31     public const string MAXTIMEOFFSET = "MaxTimeOffset";
    32 
    33     public const string DIFFERENTIALS_ALLOWED = "Differentials";
    34 
    35     private int minTimeOffset;
    36     private int maxTimeOffset;
    3730
    3831    public override string Description {
     
    4033    }
    4134
    42     public FunctionLibraryInjector()
    43       : base() {
    44       AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    45       AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In));
    46 
    47       AddVariable(DIFFERENTIALS_ALLOWED, false);
     35    protected override FunctionLibrary CreateFunctionLibrary() {
     36      return Create();
    4837    }
    4938
    50     private void AddVariable(string name, bool allowed) {
    51       AddVariableInfo(new VariableInfo(name, name + " allowed", typeof(BoolData), Core.VariableKind.New));
    52       GetVariableInfo(name).Local = true;
    53       AddVariable(new Core.Variable(name, new BoolData(allowed)));
    54     }
    55 
    56     public override IOperation Apply(IScope scope) {
    57       // try to get minTimeOffset (use 0 as default if not available)
    58       IItem minTimeOffsetItem = GetVariableValue(MINTIMEOFFSET, scope, true, false);
    59       minTimeOffset = minTimeOffsetItem == null ? 0 : ((IntData)minTimeOffsetItem).Data;
    60       // try to get maxTimeOffset (use 0 as default if not available)
    61       IItem maxTimeOffsetItem = GetVariableValue(MAXTIMEOFFSET, scope, true, false);
    62       maxTimeOffset = maxTimeOffsetItem == null ? 0 : ((IntData)maxTimeOffsetItem).Data;
    63 
    64       return base.Apply(scope);
    65     }
    66 
    67     protected override FunctionLibrary CreateFunctionLibrary() {
    68       return Create(minTimeOffset, maxTimeOffset);
    69     }
    70 
    71     public static FunctionLibrary Create(int minTimeOffset, int maxTimeOffset) {
     39    public static FunctionLibrary Create() {
    7240      FunctionLibrary functionLibrary = new FunctionLibrary();
    7341
     
    147115      f2Functions.ForEach(x => functionLibrary.AddFunction(x));
    148116
    149       variable.SetConstraints(minTimeOffset, maxTimeOffset);
    150       differential.SetConstraints(minTimeOffset, maxTimeOffset);
    151       openPar.SetConstraints(minTimeOffset, maxTimeOffset);
     117      openPar.SetConstraints(0, 0);
    152118
    153119
Note: See TracChangeset for help on using the changeset viewer.