GSATThread.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "ControlBandit.hpp"
  9. /* --- Constante --- */
  10. #define DEFAULT_NB_THREAD 4
  11. /* --- Structure --- */
  12. typedef struct {
  13. int threadId;
  14. unsigned int nbIteration;
  15. unsigned int heuristicFill;
  16. unsigned int heuristicSolve;
  17. unsigned int nbSatisfiedClausesFill;
  18. unsigned int nbSatisfiedClausesSolve;
  19. }GSATResult;
  20. class GSATThread {
  21. public:
  22. GSATThread(int, int, char**);
  23. ~GSATThread();
  24. void useEmaMethod(bool);
  25. void useEpsilonMethod(double, bool);
  26. bool solve();
  27. bool solve(bool);
  28. void end();
  29. void end(bool);
  30. bool isEnd();
  31. void printResult();
  32. /* --- Getter --- */
  33. inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
  34. inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}
  35. private:
  36. ControlBandit cb;
  37. bool bEnd;
  38. std::mutex mEnd;
  39. double calcTime;
  40. int nbThread;
  41. std::vector<GSAT*> gsat;
  42. std::vector<double> time;
  43. std::vector<std::thread> threads;
  44. GSATResult result;
  45. void initBandit(bool);
  46. void runBandit(bool);
  47. void initThread(int, bool);
  48. void runThread(int, bool);
  49. bool calc(int, bool);
  50. };
  51. #endif