GSAT.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef GSAT_HPP_
  2. #define GSAT_HPP_
  3. #include "FillMethod.hpp"
  4. #include "ArrayFiller.hpp"
  5. #include "CFormula.hpp"
  6. #include <iostream>
  7. #include <string.h>
  8. #include <string>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <vector>
  12. #include <set>
  13. #include <string>
  14. #include <fstream>
  15. #include <random>
  16. #include <math.h>
  17. #include <sys/time.h>
  18. #define DEFAULT_ITERATIONS 1000
  19. #define DEFAULT_MAX_TRY 255
  20. #define DEFAULT_GREEDY_FACTOR 0.8
  21. #define DEFAULT_GW_FACTOR 0.5
  22. #define DEFAULT_RND_METHOD -1
  23. #define DEFAULT_H_METHOD -1
  24. class Options{
  25. public:
  26. int iterations;
  27. int maxTry;
  28. float greedyFactor;
  29. float gwFactor;
  30. int rndMethod;
  31. int hMethod;
  32. char* filename;
  33. };
  34. char* getCmdOption(char ** begin, char ** end, const std::string & option);
  35. bool cmdOptionExists(char** begin, char** end, const std::string& option);
  36. void printHelp();
  37. class GSAT{
  38. public:
  39. CFormula* formula;
  40. Options* options;
  41. Options* setParameters(int argc,char* argv[]);
  42. void initialize();
  43. bool start(int fill=DEFAULT_RND_METHOD,int heuristic=DEFAULT_H_METHOD);
  44. inline double realTime() {
  45. struct timeval tv;
  46. gettimeofday(&tv, NULL);
  47. return (double)tv.tv_sec + (double) tv.tv_usec / 1000000;
  48. }
  49. inline unsigned int getNbClauses(){return formula->getNbClauses();}
  50. inline unsigned int getNbVariables(){return formula->getNbVariables();}
  51. inline unsigned int getNbSatisfiedClausesFill(){return formula->getNbSatisfiedClausesFill();}
  52. inline unsigned int getNbSatisfiedClausesSolve(){return formula->getNbSatisfiedClausesSolve();}
  53. inline unsigned int getHeuristicFill(){return formula->getHeuristicFill();}
  54. inline unsigned int getHeuristicSolve(){return formula->getHeuristicSolve();}
  55. inline unsigned int getNbIterations(){return formula->getNbIterations();}
  56. };
  57. #endif