- Timestamp:
- 02/19/10 18:49:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification.Networks/3.2/FunctionLibraryInjector.cs
r2821 r2843 28 28 namespace HeuristicLab.GP.StructureIdentification.Networks { 29 29 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;37 30 38 31 public override string Description { … … 40 33 } 41 34 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(); 48 37 } 49 38 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() { 72 40 FunctionLibrary functionLibrary = new FunctionLibrary(); 73 41 … … 147 115 f2Functions.ForEach(x => functionLibrary.AddFunction(x)); 148 116 149 variable.SetConstraints(minTimeOffset, maxTimeOffset); 150 differential.SetConstraints(minTimeOffset, maxTimeOffset); 151 openPar.SetConstraints(minTimeOffset, maxTimeOffset); 117 openPar.SetConstraints(0, 0); 152 118 153 119
Note: See TracChangeset
for help on using the changeset viewer.