| 1 | // Class automatically generated by Dev-C++ New Class wizard
|
|---|
| 2 |
|
|---|
| 3 | #ifndef ANALYZERDATA_H
|
|---|
| 4 | #define ANALYZERDATA_H
|
|---|
| 5 |
|
|---|
| 6 | #include <RealNumberTypes.h>
|
|---|
| 7 |
|
|---|
| 8 | //#include <Interface/Assignment.h>
|
|---|
| 9 | #include "../src_sharpSAT/Basics.h"
|
|---|
| 10 |
|
|---|
| 11 | #include <vector>
|
|---|
| 12 |
|
|---|
| 13 | #include <iostream>
|
|---|
| 14 | #include <fstream>
|
|---|
| 15 | #include <cstring>
|
|---|
| 16 |
|
|---|
| 17 | using namespace std;
|
|---|
| 18 |
|
|---|
| 19 | enum DATA_IDX
|
|---|
| 20 | {
|
|---|
| 21 |
|
|---|
| 22 | AVG_DEC_LEV = 0, // average decision Level
|
|---|
| 23 | AVG_CONFLICT_LEV, // average conflict Level
|
|---|
| 24 | AVG_SOLUTION_LEV, // average solution Level
|
|---|
| 25 |
|
|---|
| 26 | LONGEST_CCL_lastUIP, // longest conflict clause by last UIP scheme
|
|---|
| 27 | AVG_CCL_lastUIP, // avg conflict clause length by last UIP scheme
|
|---|
| 28 | LONGEST_CCL_1stUIP, // longest conflict clause by 1st UIP scheme
|
|---|
| 29 | AVG_CCL_1stUIP, // avg conflict clause length by 1st UIP scheme
|
|---|
| 30 |
|
|---|
| 31 | FCACHE_MAXMEM, // Formula Cache Memoery Bound
|
|---|
| 32 | FCACHE_MEMUSE, // Formula Cache memory usage
|
|---|
| 33 | FCACHE_USEDBUCKETS, // number of hashbuckets used
|
|---|
| 34 | FCACHE_CACHEDCOMPS,
|
|---|
| 35 | FCACHE_RETRIEVALS, // number of retrieved components
|
|---|
| 36 | FCACHE_INCLUDETRIES, // number of times it was tried to put a component into the cache
|
|---|
| 37 | XX_MAX_IDX
|
|---|
| 38 | };
|
|---|
| 39 |
|
|---|
| 40 | /// strings describing the data identified by DATA_IDX
|
|---|
| 41 | static const char * doubleDataDesc[] =
|
|---|
| 42 | {
|
|---|
| 43 | "avg dec dl","avg conflict dl","avg solution dl","longest ccl lastUIP","avg ccl lastUIP","longest ccl firstUIP","avg ccl firstUIP",
|
|---|
| 44 | "cacher memory bound", "cache mem-usage","cache used buckets","cache cached components","cache retrievals", "cache include tries","NOTHING"
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | enum INT_DATA_ID
|
|---|
| 49 | {
|
|---|
| 50 | NVARS = 0, // num Of Vars
|
|---|
| 51 | NUSED_VARS,
|
|---|
| 52 | NORIGINAL_CLAUSES,
|
|---|
| 53 | NREMOVED_CLAUSES,
|
|---|
| 54 | NADDED_CLAUSES,
|
|---|
| 55 | NRECEIVED_ASS, // int nReceivedSatAssignments;
|
|---|
| 56 | NCONFLICTS, // int nConflicts;
|
|---|
| 57 | NIMPLICATIONS, // int nImplications;
|
|---|
| 58 | NIBCPIMPLS,
|
|---|
| 59 | NPROCESSED_COMPS, // int nProcessedComponents;
|
|---|
| 60 | MAX_DL, // int maxDecLevel;
|
|---|
| 61 | MAX_SOL_DL, // int maxSolutionLevel;
|
|---|
| 62 | NDECISIONS, // int nDecisions;
|
|---|
| 63 | INT_MAX_ID
|
|---|
| 64 | };
|
|---|
| 65 |
|
|---|
| 66 | /// strings describing the data identified by INT_DATA_ID
|
|---|
| 67 | static const char * intDataDesc[] =
|
|---|
| 68 | {
|
|---|
| 69 | "variables","used vars","original clauses","removed clauses","added clauses",
|
|---|
| 70 | "received sat assignments", "conflicts","implications","ibcpimplications","processed components",
|
|---|
| 71 | "max dl","max solution dl","decisions","NOTHING"
|
|---|
| 72 | };
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | enum ID_DATA
|
|---|
| 76 | {
|
|---|
| 77 | DECISION,
|
|---|
| 78 | CONFLICT,
|
|---|
| 79 | SOLUTION,
|
|---|
| 80 | IMPLICATION,
|
|---|
| 81 | IBCPIMPL,
|
|---|
| 82 | CCL_lastUIP, // conflict clause by last UIP scheme
|
|---|
| 83 | CCL_1stUIP // conflict clause by 1st UIP scheme
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | //XX_MAX_IDX = 7
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | class AnalyzerData
|
|---|
| 92 | {
|
|---|
| 93 | public:
|
|---|
| 94 | double elapsedTime;
|
|---|
| 95 |
|
|---|
| 96 | SOLVER_StateT theExitState;
|
|---|
| 97 | /// Zahl der Variablen der Instanz
|
|---|
| 98 | int nVars;
|
|---|
| 99 |
|
|---|
| 100 | /// Zahl der Variablen, die tatsᅵhlich in Klauseln vorkommen
|
|---|
| 101 | int nUsedVars;
|
|---|
| 102 |
|
|---|
| 103 | /// Klauselzahl
|
|---|
| 104 | int nOriginalClauses;
|
|---|
| 105 |
|
|---|
| 106 | int nRemovedClauses;
|
|---|
| 107 |
|
|---|
| 108 | int nAddedClauses;
|
|---|
| 109 |
|
|---|
| 110 | // Zahl der erfllenden Belegungen, die bergeben wurden
|
|---|
| 111 | // sollte Kleiner sein, als die Zahl der eigentlichen Lᅵungen
|
|---|
| 112 | int nReceivedSatAssignments;
|
|---|
| 113 |
|
|---|
| 114 | /// Anzahl aller getroffenen Entscheidungen
|
|---|
| 115 | int nDecisions;
|
|---|
| 116 |
|
|---|
| 117 | /// Zahl aller gefundenen Implikationen
|
|---|
| 118 | int nImplications;
|
|---|
| 119 |
|
|---|
| 120 | int nImplicitImplications;
|
|---|
| 121 |
|
|---|
| 122 | /// Zahl aller wᅵrend der Suche aufgetretenen Konflikte
|
|---|
| 123 | int nConflicts;
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 | /// insgesamt bearbeitete Komponenten
|
|---|
| 127 | int nProcessedComponents;
|
|---|
| 128 |
|
|---|
| 129 | /// maximaler Decision level
|
|---|
| 130 | int maxDecLevel;
|
|---|
| 131 | int maxSolutionLevel;
|
|---|
| 132 |
|
|---|
| 133 | vector<double> evalData;
|
|---|
| 134 | /// Wahrscheinlichkeit der Erfuellbarkeit der Instanz
|
|---|
| 135 | CRealNum rnProbOfSat;
|
|---|
| 136 |
|
|---|
| 137 | // class constructor
|
|---|
| 138 | AnalyzerData();
|
|---|
| 139 | // class destructor
|
|---|
| 140 | ~AnalyzerData();
|
|---|
| 141 |
|
|---|
| 142 | /// setzt alle Werte auf Null zurck (nur intern wichtig).
|
|---|
| 143 | void init();
|
|---|
| 144 |
|
|---|
| 145 | CRealNum getAllAssignments() const
|
|---|
| 146 | {
|
|---|
| 147 | CRealNum res;
|
|---|
| 148 | pow2(res,nVars);
|
|---|
| 149 | return res;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | CRealNum getNumSatAssignments() const
|
|---|
| 153 | {
|
|---|
| 154 | return rnProbOfSat * getAllAssignments();
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | void printNumSatAss_whole() const
|
|---|
| 158 | {
|
|---|
| 159 | #ifdef GMP_BIGNUM
|
|---|
| 160 | CRealNum res;
|
|---|
| 161 | res.set_prec(nVars);
|
|---|
| 162 | pow2(res,nVars);
|
|---|
| 163 | res *= rnProbOfSat;
|
|---|
| 164 | char buf[nVars+2];
|
|---|
| 165 | mp_exp_t exp;
|
|---|
| 166 | memset(buf,0,nVars+2);
|
|---|
| 167 | mpf_get_str(buf,&exp,10,nVars+2,res.get_mpf_t());
|
|---|
| 168 |
|
|---|
| 169 | //cout <<"e"<<(exp>0?"+":"-")<<exp;
|
|---|
| 170 | for(int i=exp-1; i>=0;i--) if(buf[i] == 0) buf[i] = '0';
|
|---|
| 171 | //gmp_printf("%F",res.get_mpf_t());
|
|---|
| 172 | printf(buf);
|
|---|
| 173 | #endif
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | char* printNumSatAss_vis() const
|
|---|
| 177 | {
|
|---|
| 178 | char* buf=(char*)calloc(nVars+2,sizeof(char));
|
|---|
| 179 | #ifdef GMP_BIGNUM
|
|---|
| 180 |
|
|---|
| 181 | CRealNum res;
|
|---|
| 182 | res.set_prec(nVars);
|
|---|
| 183 | pow2(res,nVars);
|
|---|
| 184 | res *= rnProbOfSat;
|
|---|
| 185 | mp_exp_t exp;
|
|---|
| 186 | memset(buf,0,nVars+2);
|
|---|
| 187 | mpf_get_str(buf,&exp,10,nVars+2,res.get_mpf_t());
|
|---|
| 188 |
|
|---|
| 189 | //cout <<"e"<<(exp>0?"+":"-")<<exp;
|
|---|
| 190 | for(int i=exp-1; i>=0;i--) if(buf[i] == 0) buf[i] = '0';
|
|---|
| 191 | //gmp_printf("%F",res.get_mpf_t());
|
|---|
| 192 | #endif
|
|---|
| 193 | return buf;
|
|---|
| 194 |
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | double get(DATA_IDX dataID) const
|
|---|
| 198 | {
|
|---|
| 199 | return evalData[dataID];
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | unsigned int getI(INT_DATA_ID idataID) const;
|
|---|
| 203 |
|
|---|
| 204 | bool setI(INT_DATA_ID idataID, int val);
|
|---|
| 205 |
|
|---|
| 206 | void set(DATA_IDX dataID, double val)
|
|---|
| 207 | {
|
|---|
| 208 | evalData[dataID] = val;
|
|---|
| 209 | }
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 | void finishcountSATAnalysis();
|
|---|
| 213 |
|
|---|
| 214 | void writeToFile(const char *lpcstrFileName) const;
|
|---|
| 215 | void loadFromFile(const char *lpcstrFileName);
|
|---|
| 216 | };
|
|---|
| 217 | /*@}*/
|
|---|
| 218 |
|
|---|
| 219 | /** \addtogroup RunAnalyze Laufanalyse
|
|---|
| 220 | * \ingroup Interna
|
|---|
| 221 | */
|
|---|
| 222 | /*@{*/
|
|---|
| 223 | class CRunAnalyzer
|
|---|
| 224 | {
|
|---|
| 225 | AnalyzerData theData;
|
|---|
| 226 |
|
|---|
| 227 | bool first;
|
|---|
| 228 |
|
|---|
| 229 | protected:
|
|---|
| 230 |
|
|---|
| 231 | //bool includeInPrBackBone(CAssignment &s,double nSols);
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 | public:
|
|---|
| 235 |
|
|---|
| 236 | // class constructor
|
|---|
| 237 | CRunAnalyzer();
|
|---|
| 238 | // class destructor
|
|---|
| 239 | ~CRunAnalyzer();
|
|---|
| 240 |
|
|---|
| 241 | const AnalyzerData &getData() const;
|
|---|
| 242 |
|
|---|
| 243 | AnalyzerData &changeableData(){return theData;}
|
|---|
| 244 |
|
|---|
| 245 | void init(int nVars, int nClauses);
|
|---|
| 246 |
|
|---|
| 247 | //void setUsedVars(const set<int> &rUsedVars);
|
|---|
| 248 |
|
|---|
| 249 | void setUsedVars(unsigned int nUsedVars);
|
|---|
| 250 |
|
|---|
| 251 | void setRemovedClauses(int rClauses)
|
|---|
| 252 | {
|
|---|
| 253 | theData.nRemovedClauses = rClauses;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | void addValue(ID_DATA dataID, int actDecLevel = 0, double someData = 0.0);
|
|---|
| 257 |
|
|---|
| 258 | void setValue(DATA_IDX dataIDX, double someData);
|
|---|
| 259 |
|
|---|
| 260 | void addClause();
|
|---|
| 261 |
|
|---|
| 262 | void setSatCount(const CRealNum &rnCodedSols);
|
|---|
| 263 |
|
|---|
| 264 | void setSatProb(const CRealNum &rnProb)
|
|---|
| 265 | {
|
|---|
| 266 | theData.rnProbOfSat = rnProb;
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 | void setExitState(SOLVER_StateT st)
|
|---|
| 272 | {
|
|---|
| 273 | theData.theExitState = st;
|
|---|
| 274 | }
|
|---|
| 275 | void setElapsedTime(double timeV)
|
|---|
| 276 | {
|
|---|
| 277 | theData.elapsedTime = timeV;
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | // No description
|
|---|
| 281 | void finishcountSATAnalysis();
|
|---|
| 282 | };
|
|---|
| 283 | #endif // CANALYZERDATA_H
|
|---|
| 284 |
|
|---|