Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

eclat/main.cpp

Go to the documentation of this file.
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 // get rid of non-informative namespaces...
00022 //using namespace Bodon;
00023 // using namespace Lars;
00024 
00025 
00026 long long numint=0;
00027 long long numlen=0;
00028 
00029 // feature flags: (see also in SparseBitmatrix_setdifference.hpp and SparseBitmatrix_intersection.hpp)
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 // template types:
00047 typedef LBufferedTransactionReader< > OriginalTransactionReader;
00048 // typedef DFDecoderWithEEManagement<OutputBase<FILERepr> > PatternWriter;
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       // 1. commandline parameters:
00060       char* filenameIn = argv[2];
00061       char* filenameOut = argv[4];
00062 
00063       // 1.5 output features: (for the logs)
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 // if (EXTENSION_DESCRIPTION_COVERS) 
00073         std::cout << " RSWP" << (INTERSECTION_ROWSWAPPING ? "+" : "-");
00074       std::cout << std::endl;
00075       /*
00076       std::cout << "implementation features:"
00077                 << " LARR" << (USE_LOCAL_ARRAYS ? "+" : "-")
00078                 << endl;
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       // 2. create transaction reader:
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       // 3. find frequent items:
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       // item_t maxitem = freq_items_with_counters.size();
00103       // std::cout << " - done" << std::endl;
00104 
00105       // 4. setup pattern writer:
00106       // std::cout << "Setup i/o..." << std::flush;
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       // 5. setup transaction reader:
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       // par_c.codemode = ASC;
00120       par_c.codemode = RECODING_TYPE;
00121 
00122       RecodedTransactionReader recodedTransactionReader(&par_c);
00123       std::cout << " - done" << std::endl;
00124 
00125       // 6. find frequent patterns
00126       Eclat<RecodedTransactionReader,PatternWriter> eclat(recodedTransactionReader, freq_items_with_counters, min_supp, nr_of_transactions, patternWriter);
00127       eclat.findFrequentPatterns();
00128 
00129       /*
00130       // 6. output all transaction to stdout:
00131       sorted_coder.rewind();
00132       std::vector<item_t> transaction;
00133       std::vector<item_t>::iterator it_transaction;
00134       while( sorted_coder.nextTransactionBIS( transaction ) )
00135       {      
00136          for( it_transaction = transaction.begin(); 
00137               it_transaction != transaction.end(); ++it_transaction )
00138          {
00139             std::cout << *it_transaction << " ";
00140          }
00141          std::cout << std::endl;
00142       }
00143       */
00144       cout << "num intersections " << numint << "; num lengths " << numlen <<std::endl;
00145    }
00146 }
00147 
00148 

Generated on Sun Sep 17 17:50:39 2006 for FIM environment by  doxygen 1.4.4