Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/14 13:00:11 (10 years ago)
Author:
mleitner
Message:

Setup filter logic

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/Filter/ComparisonFilter.cs

    r10611 r10619  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Data;
     29using System.Collections.Generic;
    2930
    3031namespace HeuristicLab.DataPreprocessing.Filter
     
    104105
    105106
    106         protected override bool Check(object constrainedMember)
     107        public bool[] Check(object constrainedMember)
    107108        {
     109            bool[] result = new bool[ConstrainedValue.Rows];
     110
    108111            if (!Active)
    109                 return false;
     112                return result;
    110113
    111114            for (int row = 0; row < ConstrainedValue.Rows; ++row)
    112115            {
    113 
    114116                object item = null;
    115117                if (ConstrainedValue.IsType<double>(constraintColumn))
     
    126128                }
    127129
    128                 if (base.Check(item))
    129                     return true;
    130 
     130                result[row] = base.Check(item);
    131131            }
    132132
    133             return false;
     133            return result;
    134134        }
    135135
    136         protected override bool Check(object constrainedMember, out string errorMessage)
     136        public bool[] Check(object constrainedMember, out string errorMessage)
    137137        {
    138138            errorMessage = string.Empty;
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs

    r10558 r10619  
    2020#endregion
    2121
     22using HeuristicLab.DataPreprocessing.Filter;
     23using System.Collections.Generic;
    2224namespace HeuristicLab.DataPreprocessing {
    2325  public class FilterLogic : IFilterLogic {
     26
     27    private ITransactionalPreprocessingData preprocessingData;
     28
     29    public FilterLogic(ITransactionalPreprocessingData preprocessingData) {
     30      this.preprocessingData = preprocessingData;
     31    }
     32
     33
     34    public bool[] Preview(IList<ComparisonFilter> filters)
     35    {
     36       bool[] result = new bool[preprocessingData.Rows];
     37
     38        foreach (ComparisonFilter filter in filters) {
     39            bool[] filterResult = filter.Check();
     40
     41            for(int row = 0; row < result.Length; ++row) {
     42                result[row] = result[row] & filterResult[row];
     43            }
     44        }
     45
     46        return result;
     47    }
     48
     49    public void Apply(IList<ComparisonFilter> filters)
     50    {
     51        bool[] results = Preview(filters);
     52
     53        for(int row = 0; row < results.Length; ++row)
     54            if(!results[row]){
     55                preprocessingData.DeleteRow(row);
     56            }
     57        }
     58     }
    2459  }
    2560}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IFilterLogic.cs

    r10558 r10619  
    2020#endregion
    2121
     22using HeuristicLab.DataPreprocessing.Filter;
     23using System.Collections.Generic;
    2224namespace HeuristicLab.DataPreprocessing {
    2325  public interface IFilterLogic {
     26      List<bool> Preview(IList<IFilter> filters);
     27      void Apply(IList<IFilter> filters);
    2428  }
    2529}
Note: See TracChangeset for help on using the changeset viewer.