GSATThread.hpp 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 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, 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. std::vector<GSAT*> gsat;
  34. std::vector<double> time;
  35. std::vector<std::thread> threads;
  36. int maxIteration;
  37. GSATResult result;
  38. void solverThread(int, bool);
  39. };
  40. #endif