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

DecoderOutputTester.hpp

Go to the documentation of this file.
00001 #ifndef DecoderOutputTester_HPP
00002 #define DecoderOutputTester_HPP
00003 
00008 #include "common.hpp"
00009 #include "io/FDRepr.hpp"
00010 #include <vector>
00011 
00012 class DecoderOutputTester
00013 {
00014    public:
00015       void usageDecoderOutput();
00016       int doTest( int argc, char *argv[] );
00017 
00018    private:
00019       template <class D> inline void 
00020       writeAllCodedSubsetsNormal( const unsigned int set_size, char* file_name );
00021       template <class DF_D> inline void 
00022       writeAllCodedSubsetsDF( const unsigned int set_size, char* file_name );
00023 };
00024 
00025 template <class D> void DecoderOutputTester::
00026 writeAllCodedSubsetsNormal( const unsigned int set_size, char* file_name )
00027 {
00028    typename D::params_t par;
00029    par.file_name = file_name;
00030    par.mode=FileReprBase::WRITE;
00031    D decoder(&par);
00032 
00033    std::vector<item_t> code_inverse(set_size);
00034    for( unsigned int index=0; index < set_size; ++index )
00035       code_inverse[index] = rand();
00036 
00037    decoder.setCodeInverse(code_inverse);
00038 
00039    std::vector<item_t> transaction;
00040    std::vector<bool> pattern(set_size, false);
00041    std::vector<bool>::size_type index;
00042 
00043    counter_t support = 1; //we dont care about the support
00044    do
00045    {
00046       decoder.writeItemsetAndCounter( 
00047          transaction.begin(), transaction.end(), support);
00048       index=0;
00049       while(index < set_size && pattern[index] == true )
00050       {
00051          pattern[index] = false;
00052          transaction.pop_back();
00053          index++;
00054       }
00055       if( index == set_size )
00056          break;
00057       else
00058       {
00059          pattern[index] = true;
00060          transaction.push_back(index);
00061       }
00062    }
00063    while(true);
00064 }
00065 template <class DF_D> void DecoderOutputTester::
00066 writeAllCodedSubsetsDF( const unsigned int set_size, char* file_name )
00067 {
00068    typename DF_D::params_t par;
00069    par.file_name = file_name;
00070    par.mode=FileReprBase::WRITE;
00071    DF_D df_decoder(&par);
00072 
00073    std::vector<item_t> code_inverse(set_size);
00074    for( unsigned int index=0; index < set_size; ++index )
00075       code_inverse[index] = rand();
00076 
00077    df_decoder.setCodeInverse(code_inverse);
00078 
00079    std::vector<bool> pattern(set_size, false);
00080    std::vector<bool>::size_type index;
00081 
00082    counter_t support = 1; //we dont care about the support
00083    do
00084    {
00085       df_decoder.write(support);
00086       index=0;
00087       while(index < set_size && pattern[index] == true )
00088       {
00089          pattern[index] = false;
00090          df_decoder.popItem();
00091          index++;
00092       }
00093       if( index == set_size )
00094          break;
00095       else
00096       {
00097          pattern[index] = true;
00098          df_decoder.pushItem(index);
00099       }
00100    }
00101    while(true);
00102 }
00103 
00104 #endif

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