GSATThread.hpp 1000 B

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