Changeset 2165 for trunk/sources/HeuristicLab.GP.Boolean
- Timestamp:
- 07/16/09 11:34:22 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.Boolean/3.3/FunctionLibraryInjector.cs
r1529 r2165 32 32 public class FunctionLibraryInjector : OperatorBase { 33 33 private const string TARGETVARIABLE = "TargetVariable"; 34 private const string ALLOWEDFEATURES = "AllowedFeatures";35 34 private const string OPERATORLIBRARY = "FunctionLibrary"; 36 35 … … 45 44 : base() { 46 45 AddVariableInfo(new VariableInfo(TARGETVARIABLE, "The target variable", typeof(IntData), VariableKind.In)); 47 AddVariableInfo(new VariableInfo(ALLOWEDFEATURES, "List of indexes of allowed features", typeof(ItemList<IntData>), VariableKind.In));48 46 AddVariableInfo(new VariableInfo(OPERATORLIBRARY, "Preconfigured default operator library", typeof(GPOperatorLibrary), VariableKind.New)); 49 47 } 50 48 51 49 public override IOperation Apply(IScope scope) { 52 ItemList<IntData> allowedFeatures = GetVariableValue<ItemList<IntData>>(ALLOWEDFEATURES, scope, true);53 50 int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data; 54 51 55 // remove the target-variable in case it occures in allowed features56 List<IntData> ts = allowedFeatures.FindAll(d => d.Data == targetVariable);57 foreach (IntData t in ts) allowedFeatures.Remove(t);58 59 52 InitDefaultOperatorLibrary(); 60 61 int[] allowedIndexes = new int[allowedFeatures.Count];62 for (int i = 0; i < allowedIndexes.Length; i++) {63 allowedIndexes[i] = allowedFeatures[i].Data;64 }65 66 variable.SetConstraints(allowedIndexes);67 53 68 54 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(OPERATORLIBRARY), operatorLibrary));
Note: See TracChangeset
for help on using the changeset viewer.