00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00031 #ifndef GENERICLATTICE_H
00032 #define GENERICLATTICE_H
00033
00034
00035
00036 #include "Evaluator.h"
00037 #include "ItemsetLevel.h"
00038 #include "Lattice.h"
00039 #include "BinaryMatrix.h"
00040 #include "Rotor.h"
00041
00049 class GenericLattice: public Lattice
00050 {
00051 protected:
00052
00053 struct assoc
00054 {
00055 unsigned int upperBound;
00056
00057
00058 bool positiveBorder;
00059 };
00060
00061
00062 vector<ItemsetLevel<struct assoc> > levels;
00063
00064
00065
00066 ItemsetLevel<bool> dnevals;
00067
00068
00069 BinaryMatrix* bm;
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 unsigned int upperDneval;
00088
00089
00090 Rotor candidateRotor;
00091
00092
00093 Itemset* nextCandidate;
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 ItemsetLevel<bool>::iterator dnevaliter;
00116
00117
00118 bool keepFs;
00119
00120
00121
00122
00123 virtual void createCandidate();
00124 virtual void candidateTick();
00125 virtual void makeNotPositiveSubsets(const Itemset* is);
00126 virtual void fillDnevals(Itemset* is);
00127
00128 public:
00129 GenericLattice(BinaryMatrix* bm = NULL, unsigned int bufferSize = 1000,
00130 Evaluator* evaluator = NULL, bool order = false,
00131 bool keepFailures = false);
00132 GenericLattice(const GenericLattice& src);
00133 virtual ~GenericLattice();
00134 virtual GenericLattice& operator =(const GenericLattice& rhs);
00135 virtual void setBinaryMatrix(BinaryMatrix* bm);
00136 virtual void generateCandidates(unsigned int level);
00137 virtual void generateCandidates(unsigned int level, unsigned int k);
00138 virtual bool hasNextCandidate() const;
00139 virtual Itemset* getNextCandidate();
00140 virtual void evaluateItemset(Itemset* is);
00141 virtual void flushEvaluationBuffer();
00142 virtual unsigned int getUpperBound() const;
00143 virtual void setEvaluator(Evaluator* evaluator);
00144 virtual void setBufferSize(unsigned int bufferSize);
00145 virtual unsigned int analyzeLevel(unsigned int level);
00146 virtual unsigned int analyzeLevel(unsigned int level, double& status);
00147 virtual unsigned int analyzeLevel(unsigned int level, unsigned int k);
00148 virtual unsigned int analyzeLevel(unsigned int level, unsigned int k,
00149 double& status);
00150 virtual bool isEmpty(unsigned int level) const;
00151 virtual unsigned int getSize() const;
00152 virtual unsigned int getSize(unsigned int level) const;
00153 virtual unsigned int getSuccessful(unsigned int level) const;
00154 virtual const Itemset* getItemset(unsigned int level,
00155 unsigned int index) const;
00156 virtual const Itemset* getItemset(unsigned int level,
00157 unsigned int index, unsigned int& upperBound) const;
00158 virtual void generatePositiveBorder(unsigned int level);
00159 virtual bool hasNextPositiveBorder() const;
00160 virtual const Itemset* getNextPositiveBorder();
00161 virtual void destroy();
00162 virtual unsigned int getWidth() const;
00163 void dontKeepFailures();
00164 void keepFailures();
00165 };
00166
00167 #endif