Changeset 2843 for trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs
- Timestamp:
- 02/19/10 18:49:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs
r2728 r2843 29 29 [SymbolicRegressionFunctionLibraryInjector] 30 30 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 37 31 public override string Description { 38 32 get { return @"Injects a simple function library for regression and classification problems."; } 39 33 } 40 34 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(); 45 37 } 46 38 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() { 65 40 FunctionLibrary functionLibrary = new FunctionLibrary(); 66 41 … … 111 86 allFunctions.ForEach(x => functionLibrary.AddFunction(x)); 112 87 113 variable.SetConstraints(minTimeOffset, maxTimeOffset);114 differential.SetConstraints(minTimeOffset, maxTimeOffset);115 116 88 return functionLibrary; 117 89 }
Note: See TracChangeset
for help on using the changeset viewer.