GSATThread.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef GSATTHREAD_HPP
  2. #define GSATTHREAD_HPP
  3. /* --- Include --- */
  4. #include <vector>
  5. #include <thread>
  6. #include <mutex>
  7. #include "GSAT/GSAT.hpp"
  8. /* --- Constante --- */
  9. #define DEFAULT_NB_THREAD 4
  10. /* --- Structure --- */
  11. typedef struct {
  12. int threadId;
  13. unsigned int nbIteration;
  14. unsigned int heuristicFill;
  15. unsigned int heuristicSolve;
  16. unsigned int nbSatisfiedClausesFill;
  17. unsigned int nbSatisfiedClausesSolve;
  18. }GSATResult;
  19. class GSATThread {
  20. public:
  21. GSATThread(int, int, char**);
  22. ~GSATThread();
  23. bool solve();
  24. bool solve(int);
  25. bool solve(bool);
  26. bool solve(int, bool);
  27. void end();
  28. void end(bool);
  29. bool isEnd();
  30. void printResult();
  31. /* --- Getter --- */
  32. inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
  33. inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}
  34. private:
  35. bool bEnd;
  36. std::mutex mEnd;
  37. double calcTime;
  38. int nbThread;
  39. std::vector<GSAT*> gsat;
  40. std::vector<double> time;
  41. std::vector<std::thread> threads;
  42. int maxIteration;
  43. GSATResult result;
  44. void solverThread(int, bool);
  45. };
  46. #endif