GSATThread.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef GSATTHREAD_HPP
  2. #define GSATTHREAD_HPP
  3. /* --- Include --- */
  4. #include <vector>
  5. #include <thread>
  6. #include "GSAT/GSAT.hpp"
  7. #include "ControlBandit.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. void useAverageMethod();
  24. void useEpsilonMethod(double);
  25. bool solve();
  26. bool solve(bool);
  27. void printResult();
  28. /* --- Getter --- */
  29. inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
  30. inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}
  31. private:
  32. ControlBandit cb;
  33. bool end;
  34. double calcTime;
  35. int nbThread;
  36. std::vector<GSAT*> gsat;
  37. std::vector<double> time;
  38. std::vector<std::thread> threads;
  39. GSATResult result;
  40. void initBandit(bool);
  41. void runBandit(bool);
  42. void initThread(int, bool);
  43. void runThread(int, bool);
  44. bool calc(int, bool);
  45. };
  46. #endif