- Timestamp:
- 02/19/10 18:49:17 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/ArithmeticFunctionLibraryInjector.cs
r2728 r2843 29 29 [SymbolicRegressionFunctionLibraryInjector] 30 30 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 37 31 public override string Description { 38 32 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);56 33 } 57 34 … … 78 55 doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 79 56 80 variable.SetConstraints(minTimeOffset, maxTimeOffset);81 differential.SetConstraints(minTimeOffset, maxTimeOffset);82 83 57 return functionLibrary; 84 58 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/DefaultFunctionLibraryInjector.cs
r2821 r2843 29 29 [SymbolicRegressionFunctionLibraryInjector] 30 30 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 37 31 public override string Description { 38 32 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);56 33 } 57 34 … … 121 98 booleanFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 122 99 123 variable.SetConstraints(minTimeOffset, maxTimeOffset);124 differential.SetConstraints(minTimeOffset, maxTimeOffset);125 126 100 return functionLibrary; 127 101 } -
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 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/UnconstrainedFunctionLibraryInjector.cs
r2728 r2843 29 29 [SymbolicRegressionFunctionLibraryInjector] 30 30 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 37 31 public override string Description { 38 32 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);56 33 } 57 34 … … 113 90 doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 114 91 115 variable.SetConstraints(minTimeOffset, maxTimeOffset);116 differential.SetConstraints(minTimeOffset, maxTimeOffset);117 118 92 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);127 93 } 128 94 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
r2750 r2843 112 112 </Compile> 113 113 <Compile Include="StandardGPRegression.cs" /> 114 <Compile Include="Symbols\VariableView.cs"> 115 <SubType>UserControl</SubType> 116 </Compile> 117 <Compile Include="Symbols\VariableView.Designer.cs"> 118 <DependentUpon>VariableView.cs</DependentUpon> 119 </Compile> 114 120 <Compile Include="VariableFrequencyAnalyser.cs" /> 115 121 <Compile Include="Symbols\Addition.cs" /> … … 235 241 <DependentUpon>PredictorView.cs</DependentUpon> 236 242 </EmbeddedResource> 243 <EmbeddedResource Include="Symbols\VariableView.resx"> 244 <DependentUpon>VariableView.cs</DependentUpon> 245 </EmbeddedResource> 237 246 </ItemGroup> 238 247 <ItemGroup> -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Differential.cs
r2222 r2843 36 36 return new VariableFunctionTree(this); 37 37 } 38 39 public override HeuristicLab.Core.IView CreateView() { 40 return new VariableView(this); 41 } 38 42 } 39 43 } -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Symbols/Variable.cs
r2365 r2843 24 24 using HeuristicLab.Random; 25 25 using HeuristicLab.Data; 26 using System.Xml; 26 27 27 28 namespace HeuristicLab.GP.StructureIdentification { … … 32 33 33 34 private int minOffset; 35 public int MinTimeOffset { 36 get { 37 return minOffset; 38 } 39 set { 40 if (value != minOffset) { 41 minOffset = value; 42 SetupInitialization(); 43 SetupManipulation(); 44 } 45 } 46 } 47 34 48 private int maxOffset; 49 public int MaxTimeOffset { 50 get { 51 return maxOffset; 52 } 53 set { 54 if (value != maxOffset) { 55 maxOffset = value; 56 SetupManipulation(); 57 SetupInitialization(); 58 } 59 } 60 } 35 61 36 62 public override string Description { … … 116 142 } 117 143 118 public void SetConstraints(int minSampleOffset, int maxSampleOffset) { 119 this.minOffset = minSampleOffset; 120 this.maxOffset = maxSampleOffset; 121 SetupInitialization(); 122 SetupManipulation(); 144 public override HeuristicLab.Core.IView CreateView() { 145 return new VariableView(this); 123 146 } 147 148 #region persistence 149 public override object Clone(System.Collections.Generic.IDictionary<System.Guid, object> clonedObjects) { 150 Variable clone = (Variable)base.Clone(clonedObjects); 151 clone.MaxTimeOffset = MaxTimeOffset; 152 clone.MinTimeOffset = MinTimeOffset; 153 return clone; 154 } 155 public override System.Xml.XmlNode GetXmlNode(string name, System.Xml.XmlDocument document, System.Collections.Generic.IDictionary<System.Guid, HeuristicLab.Core.IStorable> persistedObjects) { 156 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 157 var minTimeOffsetAttr = document.CreateAttribute("MinTimeOffset"); 158 minTimeOffsetAttr.Value = MinTimeOffset.ToString(); 159 var maxTimeOffsetAttr = document.CreateAttribute("MaxTimeOffset"); 160 maxTimeOffsetAttr.Value = MaxTimeOffset.ToString(); 161 node.Attributes.Append(minTimeOffsetAttr); 162 node.Attributes.Append(maxTimeOffsetAttr); 163 return node; 164 } 165 public override void Populate(System.Xml.XmlNode node, System.Collections.Generic.IDictionary<System.Guid, HeuristicLab.Core.IStorable> restoredObjects) { 166 base.Populate(node, restoredObjects); 167 MinTimeOffset = XmlConvert.ToInt32(node.Attributes["MinTimeOffset"].Value); 168 MaxTimeOffset = XmlConvert.ToInt32(node.Attributes["MaxTimeOffset"].Value); 169 } 170 #endregion 124 171 } 125 172 }
Note: See TracChangeset
for help on using the changeset viewer.