00001 
00005 #include "common.hpp"
00006 #include "common/commandline.hpp"
00007 
00008 #include "io/FILERepr.hpp"
00009 #include "io/FDRepr.hpp"
00010 #include "io/input/transaction_reader/TransactionReader.hpp"
00011 #include "io/input/transaction_reader/LBufferedTransactionReader.hpp"
00012 
00013 #include "io/codec/decoder/df/DFDecoderWithEEManagement.hpp"
00014 
00015 #include "io/codec/coder/Coder.hpp"
00016 #include "util/FrequentFilter.cpp"
00017 
00018 #include "eclat.hpp"
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 long long numint=0;
00027 long long numlen=0;
00028 
00029 
00030 #ifdef ECLAT_COVER
00031 static const CodeMode RECODING_TYPE = DESC;
00032 #endif
00033 
00034 #ifdef ECLAT_DEFECT
00035 static const CodeMode RECODING_TYPE = ASC;
00036 #endif
00037 
00038 #if (!defined(ECLAT_COVER)) && (!defined(ECLAT_DEFECT))
00039 #error you must define at least one of ECLAT_COVER and ECLAT_DEFECT
00040 #endif
00041 
00042 #if (defined(ECLAT_COVER)) && (defined(ECLAT_DEFECT))
00043 #error you must define at most one of ECLAT_COVER and ECLAT_DEFECT
00044 #endif
00045 
00046 
00047 typedef LBufferedTransactionReader< > OriginalTransactionReader;
00048 
00049 typedef DFDecoderWithEEManagement< > PatternWriter;
00050 typedef Coder<OriginalTransactionReader, PatternWriter> RecodedTransactionReader;
00051 
00052 
00053 
00054 int main(int argc,  char *argv[])
00055 {
00056    counter_t min_supp;
00057    if( !process_arguments( argc, argv, min_supp ) ) 
00058    {
00059       
00060       char* filenameIn = argv[2];
00061       char* filenameOut = argv[4];
00062 
00063       
00064       std::cout << "algorithmic features:"
00065                 << " EXTDESC:" << (EXTENSION_DESCRIPTION_DEFECTS ? "DEF" : "COVER")
00066                 << " REC:" << (RECODING_TYPE == NOCARE ? "no" : (RECODING_TYPE == ASC ? "ASC" : "DESC"))
00067                 << " PEE" << (PRUNE_EQUISUPPORT_EXTENSIONS ? "+" : "-")
00068                 << " OFIN" << (OMIT_FINAL_INCIDENCE_MATRIX ? "+" : "-")
00069                 << " EFILT" << (EARLY_FILTERING ? "+" : "-");
00070       if (EXTENSION_DESCRIPTION_DEFECTS)
00071         ;
00072       else 
00073         std::cout << " RSWP" << (INTERSECTION_ROWSWAPPING ? "+" : "-");
00074       std::cout << std::endl;
00075       
00076 
00077 
00078 
00079 
00080 
00081       if ((EXTENSION_DESCRIPTION_DEFECTS && RECODING_TYPE != ASC)
00082           || (! EXTENSION_DESCRIPTION_DEFECTS && RECODING_TYPE != DESC)) {
00083         std::cout << "options are not compatible right now: "
00084                   << " EXTDESC:" << (EXTENSION_DESCRIPTION_DEFECTS ? "DEF" : "COVER")
00085                   << " and"
00086                   << " REC:" << (RECODING_TYPE == NOCARE ? "no" : (RECODING_TYPE == ASC ? "ASC" : "DESC")) << std::endl;
00087         exit(1);
00088       }
00089 
00090       
00091       OriginalTransactionReader::params_t par_i;
00092       par_i.file_name = filenameIn;
00093       par_i.mode=FileReprBase::READ;
00094       OriginalTransactionReader transactionReader(&par_i);
00095 
00096       
00097       std::cout << "Finding frequent items..." << std::flush;
00098       std::vector< std::pair<counter_t, item_t> > freq_items_with_counters;
00099       counter_t nr_of_transactions;
00100       FrequentFilter<OriginalTransactionReader> fr_filter(transactionReader);
00101       fr_filter.findFrequentItems( freq_items_with_counters, nr_of_transactions, min_supp);
00102       
00103       
00104 
00105       
00106       
00107       PatternWriter::params_t par_d;
00108       par_d.file_name = filenameOut;
00109       par_d.mode=FileReprBase::WRITE;
00110       PatternWriter patternWriter(&par_d);
00111 
00112       
00113       RecodedTransactionReader::params_t par_c;
00114       par_c.file_name = filenameIn;
00115       par_c.mode=FileReprBase::READ;
00116       par_c.largest_item = transactionReader.getLargestItem();
00117       par_c.decoder = &patternWriter;
00118       par_c.freq_items_with_counters = &freq_items_with_counters;
00119       
00120       par_c.codemode = RECODING_TYPE;
00121 
00122       RecodedTransactionReader recodedTransactionReader(&par_c);
00123       std::cout << " - done" << std::endl;
00124 
00125       
00126       Eclat<RecodedTransactionReader,PatternWriter> eclat(recodedTransactionReader, freq_items_with_counters, min_supp, nr_of_transactions, patternWriter);
00127       eclat.findFrequentPatterns();
00128 
00129       
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144       cout << "num intersections " << numint << "; num lengths " << numlen <<std::endl;
00145    }
00146 }
00147 
00148