00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00031 #ifndef POSLATTICE_H
00032 #define POSLATTICE_H
00033
00034
00035
00036 #include "Evaluator.h"
00037 #include "ItemsetLevel.h"
00038 #include "Lattice.h"
00039 #include "BinaryMatrix.h"
00040
00048 class PosLattice: public Lattice
00049 {
00050 protected:
00051
00052 struct assoc
00053 {
00054 unsigned int count;
00055
00056 unsigned int upperBound;
00057
00058
00059 bool positiveBorder;
00060 };
00061
00062
00063 vector<ItemsetLevel<struct assoc> > levels;
00064
00065
00066 BinaryMatrix* bm;
00067
00068
00069 vector<Itemset*> cBuffer;
00070
00071
00072 Evaluator* evaluator;
00073
00074
00075 bool order;
00076
00077
00078 unsigned int targetCandidate;
00079
00080
00081 unsigned int lowerCandidate;
00082
00083
00084 unsigned int kCandidate;
00085
00086
00087 vector<unsigned int> candidateRotor;
00088
00089
00090 Itemset* nextCandidate;
00091
00092
00093 unsigned int cBufferPos;
00094
00095
00096
00097 vector<Itemset*> eBuffer;
00098
00099
00100 unsigned int eBufferPos;
00101
00102
00103 unsigned int borderPos;
00104
00105
00106 unsigned int borderLevel;
00107
00108
00109 vector<unsigned int> successful;
00110
00111
00112 unsigned int maxlev;
00113
00114
00115
00116
00117 virtual void generateCandidatesNonzero();
00118 virtual void generateCandidatesZero();
00119 virtual void candidateRotate();
00120 virtual void candidateRotateZero();
00121 virtual void candidateRotorStart(unsigned int pos);
00122 virtual void candidateRotorStartZero(unsigned int pos);
00123 virtual bool testCandidateRotor(unsigned int pos);
00124 virtual bool testCandidateRotorZero(unsigned int pos);
00125 virtual void createCandidate();
00126 virtual void candidateTick(unsigned int pos);
00127 virtual bool badCandidateRotor(unsigned int pos) const;
00128 virtual bool createCandidateRotate(vector<unsigned int>& rotorPool,
00129 vector<unsigned int>& isRotor);
00130 virtual bool testCreateCandidateRotor(vector<unsigned int>& isRotor,
00131 vector<unsigned int>& rotorPool, unsigned int pos, bool& success);
00132 virtual bool createCandidateRotorStart(vector<unsigned int>& isRotor,
00133 vector<unsigned int>& rotorPool, unsigned int pos);
00134
00135
00136 virtual void countSubsets(Itemset* is);
00137 virtual void flushCountBuffer();
00138 virtual void countSets(const vector<Itemset*>& sets, unsigned int size);
00139 virtual void getRowSetCounts(const Itemset* is,
00140 vector<unsigned int>& counts) ;
00141 virtual void makeNotPositiveSubsets(const Itemset* is);
00142 virtual int generateSupport(const Itemset& pos, const Itemset& neg,
00143 unsigned int start) ;
00144 virtual void generateSupports(const Itemset& is, const Itemset& pos,
00145 const Itemset& neg, vector<unsigned int>& counts) ;
00146
00147 public:
00148 PosLattice(BinaryMatrix* bm = NULL, unsigned int bufferSize = 1000,
00149 Evaluator* evaluator = NULL, bool order = false);
00150 PosLattice(const PosLattice& src);
00151 virtual ~PosLattice();
00152 virtual PosLattice& operator =(const PosLattice& rhs);
00153 virtual void setBinaryMatrix(BinaryMatrix* bm);
00154 virtual void generateCandidates(unsigned int level);
00155 virtual void generateCandidates(unsigned int level, unsigned int k);
00156 virtual bool hasNextCandidate() const;
00157 virtual Itemset* getNextCandidate();
00158 virtual void evaluateItemset(Itemset* is);
00159 virtual void flushEvaluationBuffer();
00160 virtual unsigned int getUpperBound() const;
00161 virtual void setEvaluator(Evaluator* evaluator);
00162 virtual void setBufferSize(unsigned int bufferSize);
00163 virtual unsigned int analyzeLevel(unsigned int level);
00164 virtual unsigned int analyzeLevel(unsigned int level, double& status);
00165 virtual unsigned int analyzeLevel(unsigned int level, unsigned int k);
00166 virtual unsigned int analyzeLevel(unsigned int level, unsigned int k,
00167 double& status);
00168 virtual bool isEmpty(unsigned int level) const;
00169 virtual unsigned int getSize() const;
00170 virtual unsigned int getSize(unsigned int level) const;
00171 virtual unsigned int getSuccessful(unsigned int level) const;
00172 virtual const Itemset* getItemset(unsigned int level,
00173 unsigned int index) const;
00174 virtual const Itemset* getItemset(unsigned int level,
00175 unsigned int index, unsigned int& upperBound) const;
00176 virtual void generatePositiveBorder(unsigned int level);
00177 virtual bool hasNextPositiveBorder() const;
00178 virtual const Itemset* getNextPositiveBorder();
00179 virtual void destroy();
00180 virtual unsigned int getWidth() const;
00181 };
00182
00183 #endif