|
@@ -114,29 +114,7 @@ void GSATThread::initThread(int id, bool verbose) {
|
|
|
//Les threads vont jouer les bandits pour etablir les moyennes
|
|
|
bool solve = false;
|
|
|
while(!end && !solve && !cb.queueIsEmpty()){
|
|
|
- //Recup le prochaine fill et heuristic à tester
|
|
|
- fillAndHeuristic fah = cb.next();
|
|
|
- //Calcul
|
|
|
- solve = gsat[id]->start(fah.fill, fah.heuristic);
|
|
|
- //Affiche
|
|
|
- if(verbose) {
|
|
|
- if(solve) {
|
|
|
- printf(CYAN);
|
|
|
- }
|
|
|
- printf("c [thread:%2d][iteration:%5d][fill:%d][heuristic:%d]Satisfied clauses (begin: %d)(end:%d)\n",
|
|
|
- id,
|
|
|
- gsat[id]->getNbIterations(),
|
|
|
- gsat[id]->getHeuristicFill(),
|
|
|
- gsat[id]->getHeuristicSolve(),
|
|
|
- gsat[id]->getNbSatisfiedClausesFill(),
|
|
|
- gsat[id]->getNbSatisfiedClausesSolve());
|
|
|
- if(solve) {
|
|
|
- printf(RESET);
|
|
|
- }
|
|
|
- }
|
|
|
- //Ajoute le resultat aux moyenne
|
|
|
- cb.addFill(fah.fill, gsat[id]->getNbSatisfiedClausesFill());
|
|
|
- cb.addHeuristic(fah.heuristic, gsat[id]->getNbSatisfiedClausesSolve());
|
|
|
+ solve = this->calc(id, verbose);
|
|
|
}
|
|
|
//Si 1er arreter
|
|
|
if(!end && solve) {
|
|
@@ -155,29 +133,7 @@ void GSATThread::runThread(int id, bool verbose) {
|
|
|
//Les threads vont jouer les bandits avec la méthode choisit
|
|
|
bool solve = false;
|
|
|
while(!end && !solve){
|
|
|
- //Recup le prochaine fill et heuristic à tester
|
|
|
- fillAndHeuristic fah = cb.next();
|
|
|
- //Calcul
|
|
|
- solve = gsat[id]->start(fah.fill, fah.heuristic);
|
|
|
- //Affiche
|
|
|
- if(verbose) {
|
|
|
- if(solve) {
|
|
|
- printf(CYAN);
|
|
|
- }
|
|
|
- printf("c [thread:%2d][iteration:%5d][fill:%d][heuristic:%d]Satisfied clauses (begin: %d)(end:%d)\n",
|
|
|
- id,
|
|
|
- gsat[id]->getNbIterations(),
|
|
|
- gsat[id]->getHeuristicFill(),
|
|
|
- gsat[id]->getHeuristicSolve(),
|
|
|
- gsat[id]->getNbSatisfiedClausesFill(),
|
|
|
- gsat[id]->getNbSatisfiedClausesSolve());
|
|
|
- if(solve) {
|
|
|
- printf(RESET);
|
|
|
- }
|
|
|
- }
|
|
|
- //Ajoute le resultat aux moyenne
|
|
|
- cb.addFill(fah.fill, gsat[id]->getNbSatisfiedClausesFill());
|
|
|
- cb.addHeuristic(fah.heuristic, gsat[id]->getNbSatisfiedClausesSolve());
|
|
|
+ solve = this->calc(id, verbose);
|
|
|
}
|
|
|
//Si 1er arreter
|
|
|
if(!end && solve) {
|
|
@@ -190,4 +146,31 @@ void GSATThread::runThread(int id, bool verbose) {
|
|
|
result.nbSatisfiedClausesFill = gsat[id]->getNbSatisfiedClausesFill();
|
|
|
result.nbSatisfiedClausesSolve = gsat[id]->getNbSatisfiedClausesSolve();
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+bool GSATThread::calc(int id, bool verbose) {
|
|
|
+ //Recup le prochaine fill et heuristic à tester
|
|
|
+ fillAndHeuristic fah = cb.next();
|
|
|
+ //Calcul
|
|
|
+ bool solve = gsat[id]->start(fah.fill, fah.heuristic);
|
|
|
+ //Affiche
|
|
|
+ if(verbose) {
|
|
|
+ if(solve) {
|
|
|
+ printf(CYAN);
|
|
|
+ }
|
|
|
+ printf("c [thread:%2d][iteration:%5d][fill:%d][heuristic:%d]Satisfied clauses (begin: %d)(end:%d)\n",
|
|
|
+ id,
|
|
|
+ gsat[id]->getNbIterations(),
|
|
|
+ gsat[id]->getHeuristicFill(),
|
|
|
+ gsat[id]->getHeuristicSolve(),
|
|
|
+ gsat[id]->getNbSatisfiedClausesFill(),
|
|
|
+ gsat[id]->getNbSatisfiedClausesSolve());
|
|
|
+ if(solve) {
|
|
|
+ printf(RESET);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //Ajoute le resultat aux moyenne
|
|
|
+ cb.addFill(fah.fill, gsat[id]->getNbSatisfiedClausesFill());
|
|
|
+ cb.addHeuristic(fah.heuristic, gsat[id]->getNbSatisfiedClausesSolve());
|
|
|
+ return solve;
|
|
|
}
|