Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/16/09 11:34:22 (15 years ago)
Author:
gkronber
Message:

Removed variable AllowedFeatures in all modeling algorithms. #709

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  
    4141
    4242
    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) {
    4444      ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
    4545      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Evaluators/VariableQualityImpactCalculator.cs

    r2136 r2165  
    4040    }
    4141
    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) {
    4343      ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>("TreeEvaluator", scope, true);
    4444      IFunctionTree tree = GetVariableValue<IFunctionTree>("FunctionTree", scope, true);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjector.cs

    r2130 r2165  
    3232namespace HeuristicLab.GP.StructureIdentification {
    3333  public class FunctionLibraryInjector : OperatorBase {
     34    private const string NUMBEROFINPUTVARIABLES = "NumberOfInputVariables";
    3435    private const string FUNCTIONLIBRARY = "FunctionLibrary";
    3536    private const string TARGETVARIABLE = "TargetVariable";
    36     private const string ALLOWEDFEATURES = "AllowedFeatures";
    3737    private const string MINTIMEOFFSET = "MinTimeOffset";
    3838    private const string MAXTIMEOFFSET = "MaxTimeOffset";
     
    7070    public FunctionLibraryInjector()
    7171      : base() {
     72      AddVariableInfo(new VariableInfo(NUMBEROFINPUTVARIABLES, "The number of available input variables", typeof(IntData), VariableKind.In));
    7273      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));
    7676      AddVariableInfo(new VariableInfo(FUNCTIONLIBRARY, "Preconfigured default operator library", typeof(GPOperatorLibrary), VariableKind.New));
    7777
     
    111111      StructId.Variable variable;
    112112      GPOperatorLibrary operatorLibrary;
    113 
    114       ItemList<IntData> allowedFeatures = GetVariableValue<ItemList<IntData>>(ALLOWEDFEATURES, scope, true);
     113      int nInputVariables = GetVariableValue<IntData>(NUMBEROFINPUTVARIABLES, scope, true).Data;
    115114      int targetVariable = GetVariableValue<IntData>(TARGETVARIABLE, scope, true).Data;
    116115
     
    226225      ConditionalAddOperator(XOR_ALLOWED, operatorLibrary, xor);
    227226
    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);
    235229
    236230      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(FUNCTIONLIBRARY), operatorLibrary));
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs

    r1618 r2165  
    154154    }
    155155
    156     public void SetConstraints(int[] allowedIndexes, int minSampleOffset, int maxSampleOffset) {
     156    public void SetConstraints(int minInputIndex, int maxInputIndex, int minSampleOffset, int maxSampleOffset) {
    157157      ConstrainedIntData offset = GetVariableValue<ConstrainedIntData>(OFFSET, null, false);
    158       IntBoundedConstraint rangeConstraint = new IntBoundedConstraint();
     158      IntBoundedConstraint offsetConstraint = new IntBoundedConstraint();
    159159      this.minOffset = minSampleOffset;
    160160      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);
    168168
    169169      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);
    205180
    206181      SetupInitialization();
Note: See TracChangeset for help on using the changeset viewer.