walk.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "walk.hpp"
  2. void walk(Stack& stack,Results &results,string filename,int timeout){
  3. const auto start = time(nullptr);
  4. size_t numbers=0;
  5. Semigroup* father=new Semigroup;
  6. while(not stack.is_empty()){
  7. ++numbers;
  8. if(numbers%10000000==0){
  9. const auto now = time(nullptr);
  10. auto duration=now-start;
  11. if(duration>timeout){
  12. cout<<"Timeout"<<endl;
  13. cout<<"Stack size : "<<stack.size<<endl;
  14. if(timeout>60){
  15. for(size_t i=0;i<stack.size;++i){
  16. cout<<i<<" : ";
  17. string filename2=filename+"_"+to_string(i);
  18. cout<<filename2<<endl;
  19. stack.data[i]->to_file("todo/"+filename2);
  20. }
  21. results.to_file("output/"+filename);
  22. if(results.has_counter_example){
  23. results.S_counter_example.to_file("counter_example/"+filename);
  24. }
  25. rename(("lock/"+filename).c_str(),("done/"+filename).c_str());
  26. }
  27. else{
  28. rename(("lock/"+filename).c_str(),("todo/"+filename).c_str());
  29. }
  30. return;
  31. }
  32. }
  33. stack.pop(&father);
  34. auto it=SonIterator(father);
  35. size_t irr_pos=0;
  36. size_t g=father->g;
  37. if(g<g_max-1){
  38. while(it.move_next()){
  39. Semigroup* son=stack.next();
  40. son->son(*father,it.get_gen(),irr_pos++);
  41. if(not trim(*son)){
  42. stack.push();
  43. treat(*son,results);
  44. }
  45. }
  46. }
  47. else{
  48. while(it.move_next()){
  49. Semigroup* son=stack.next();
  50. son->son(*father,it.get_gen(),irr_pos++);
  51. if(not trim(*son)){
  52. treat(*son,results);
  53. }
  54. }
  55. }
  56. }
  57. delete father;
  58. }