GSATThread.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. };
  45. #endif