Changeset 2165 for trunk/sources/HeuristicLab.GP.StructureIdentification
- Timestamp:
- 07/16/09 11:34:22 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableEvaluationImpactCalculator.cs
r2043 r2165 41 41 42 42 43 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures,int start, int end) {43 protected override double[] GetOutputs(IScope scope, Dataset dataset, int targetVariable, int start, int end) { 44 44 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 45 45 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs
r2136 r2165 40 40 } 41 41 42 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, ItemList<IntData> allowedFeatures,int start, int end) {42 protected override double CalculateQuality(IScope scope, Dataset dataset, int targetVariable, int start, int end) { 43 43 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true); 44 44 IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs
r2130 r2165 32 32 namespace HeuristicLab.GP.StructureIdentification { 33 33 public class FunctionLibraryInjector : OperatorBase { 34 private const string NUMBEROFINPUTVARIABLES = "NumberOfInputVariables"; 34 35 private const string FUNCTIONLIBRARY = "FunctionLibrary"; 35 36 private const string TARGETVARIABLE = "TargetVariable"; 36 private const string ALLOWEDFEATURES = "AllowedFeatures";37 37 private const string MINTIMEOFFSET = "MinTimeOffset"; 38 38 private const string MAXTIMEOFFSET = "MaxTimeOffset"; … … 70 70 public FunctionLibraryInjector() 71 71 : base() { 72 AddVariableInfo(new VariableInfo(NUMBEROFINPUTVARIABLES, "The number of available input variables", typeof(IntData), VariableKind.In)); 72 73 AddVariableInfo(new VariableInfo(TARGETVARIABLE, "The target variable", typeof(IntData), VariableKind.In)); 73 AddVariableInfo(new VariableInfo(ALLOWEDFEATURES, "List of indexes of allowed features", typeof(ItemList<IntData>), VariableKind.In)); 74 AddVariableInfo(new Core.VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), Core.VariableKind.In)); 75 AddVariableInfo(new Core.VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), Core.VariableKind.In)); 74 AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In)); 75 AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In)); 76 76 AddVariableInfo(new VariableInfo(FUNCTIONLIBRARY, "Preconfigured default operator library", typeof(GPOperatorLibrary), VariableKind.New)); 77 77 … … 111 111 StructId.Variable variable; 112 112 GPOperatorLibrary operatorLibrary; 113 114 ItemList<IntData> allowedFeatures = GetVariableValue<ItemList<IntData>>(ALLOWEDFEATURES, scope, true); 113 int nInputVariables = GetVariableValue<IntData>(NUMBEROFINPUTVARIABLES, scope, true).Data; 115 114 int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data; 116 115 … … 226 225 ConditionalAddOperator(XOR_ALLOWED, operatorLibrary, xor); 227 226 228 int[] allowedIndexes = new int[allowedFeatures.Count]; 229 for (int i = 0; i < allowedIndexes.Length; i++) { 230 allowedIndexes[i] = allowedFeatures[i].Data; 231 } 232 233 variable.SetConstraints(allowedIndexes, minTimeOffset, maxTimeOffset); 234 differential.SetConstraints(allowedIndexes, minTimeOffset, maxTimeOffset); 227 variable.SetConstraints(1, nInputVariables, minTimeOffset, maxTimeOffset); 228 differential.SetConstraints(1, nInputVariables, minTimeOffset, maxTimeOffset); 235 229 236 230 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(FUNCTIONLIBRARY), operatorLibrary)); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs
r1618 r2165 154 154 } 155 155 156 public void SetConstraints(int [] allowedIndexes, int minSampleOffset, int maxSampleOffset) {156 public void SetConstraints(int minInputIndex, int maxInputIndex, int minSampleOffset, int maxSampleOffset) { 157 157 ConstrainedIntData offset = GetVariableValue<ConstrainedIntData>(OFFSET, null, false); 158 IntBoundedConstraint rangeConstraint = new IntBoundedConstraint();158 IntBoundedConstraint offsetConstraint = new IntBoundedConstraint(); 159 159 this.minOffset = minSampleOffset; 160 160 this.maxOffset = maxSampleOffset; 161 rangeConstraint.LowerBound = minSampleOffset;162 rangeConstraint.LowerBoundEnabled = true;163 rangeConstraint.LowerBoundIncluded = true;164 rangeConstraint.UpperBound = maxSampleOffset;165 rangeConstraint.UpperBoundEnabled = true;166 rangeConstraint.UpperBoundIncluded = true;167 offset.AddConstraint( rangeConstraint);161 offsetConstraint.LowerBound = minSampleOffset; 162 offsetConstraint.LowerBoundEnabled = true; 163 offsetConstraint.LowerBoundIncluded = true; 164 offsetConstraint.UpperBound = maxSampleOffset; 165 offsetConstraint.UpperBoundEnabled = true; 166 offsetConstraint.UpperBoundIncluded = true; 167 offset.AddConstraint(offsetConstraint); 168 168 169 169 ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false); 170 Array.Sort(allowedIndexes); 171 minIndex = allowedIndexes[0]; maxIndex = allowedIndexes[allowedIndexes.Length - 1]; 172 List<IConstraint> constraints = new List<IConstraint>(); 173 int start = allowedIndexes[0]; 174 int prev = start; 175 for(int i = 1; i < allowedIndexes.Length; i++) { 176 if(allowedIndexes[i] != prev + 1) { 177 IntBoundedConstraint lastRange = new IntBoundedConstraint(); 178 lastRange.LowerBound = start; 179 lastRange.LowerBoundEnabled = true; 180 lastRange.LowerBoundIncluded = true; 181 lastRange.UpperBound = prev; 182 lastRange.UpperBoundEnabled = true; 183 lastRange.UpperBoundIncluded = true; 184 constraints.Add(lastRange); 185 start = allowedIndexes[i]; 186 prev = start; 187 } 188 prev = allowedIndexes[i]; 189 } 190 IntBoundedConstraint range = new IntBoundedConstraint(); 191 range.LowerBound = start; 192 range.LowerBoundEnabled = true; 193 range.LowerBoundIncluded = true; 194 range.UpperBound = prev; 195 range.UpperBoundEnabled = true; 196 range.UpperBoundIncluded = true; 197 constraints.Add(range); 198 if(constraints.Count > 1) { 199 OrConstraint or = new OrConstraint(); 200 foreach(IConstraint c in constraints) or.Clauses.Add(c); 201 index.AddConstraint(or); 202 } else { 203 index.AddConstraint(constraints[0]); 204 } 170 IntBoundedConstraint indexConstraint = new IntBoundedConstraint(); 171 minIndex = minInputIndex; 172 maxIndex = maxInputIndex; 173 indexConstraint.LowerBound = minInputIndex; 174 indexConstraint.LowerBoundEnabled = true; 175 indexConstraint.LowerBoundIncluded = true; 176 indexConstraint.UpperBound = maxInputIndex; 177 indexConstraint.UpperBoundEnabled = true; 178 indexConstraint.UpperBoundIncluded = true; 179 index.AddConstraint(indexConstraint); 205 180 206 181 SetupInitialization();
Note: See TracChangeset
for help on using the changeset viewer.