int MutExploratorSeq::isomorphismExplorator(Quiver depart, int granularite) { int stop=0; int infinite=0; Quiver ct = depart; //int i; if(resume == 0) { ct.testInfiniEmpirique(50*ct.getN()); index = 0; depart.genGraph(); c.push_back(depart); } else { std::cout << "Resuming at pos: " << index << "\n"; std::cout << "Nb Quivers in queue: " << c.size() << "\n"; if(index == c.size()) { return c.size(); } } while(!stop) { while(!stop) { if(c[index].infinite()) { stop=1; infinite=1; throw Exception("The mutation class is infinite" + c[index].getMutations()); } #ifdef DEBUG std::cout << "================" << "\n"; std::cout << "Position Index: " << index << "\n"; std::cout << "================" << "\n"; #endif generateMutations(c[index]); index++; if(index % granularite == 0) checkpoint(); if(index == c.size()) stop = 1; } stop = 1; } checkpoint(); return c.size(); }
int MutExploratorSeq::isInTheMutationClass(Quiver test, Quiver depart) { int stop=0; int infinite=0; if(resume == 0) { index = 1; modeComparaison = 1; if(test.getN() != depart.getN()) { throw Exception("Les deux quiver n'ont pas le meme nombre de vertexs !"); } c.push_back(test); insertInList(&depart); } else { std::cout << "Resuming at pos: " << index << "\n"; std::cout << "Nb Quivers in queue: " << c.size() << "\n"; if(index == c.size()) { return c.size()-1; } } while(!stop) { while(!stop) { if(c[index].infinite()) { stop=1; infinite=1; throw Exception("The mutation class is infinite"); } generateMutations(c[index]); index++; if(index % 5000 == 0) checkpoint(); if(index == c.size()) stop = 1; } stop = 1; } return c.size()-1; }
void GreenExplorator::greenExploration(PrincipalExtension pe) { int index = 0; int ret; std::map<uint64_t,mpz_class>::iterator it; mpz_class total=0; std::list<PrincipalExtension>::iterator pei; std::stringstream ss (std::stringstream::in | std::stringstream::out); std::string filename; uint64_t cutPending = 0; // Initial population of the list insertInList(pe); pei = c.begin(); while(generateMutations(*pei) != 1) {pei=c.begin();}; if (isomorphTest) { insertInList(*pei,cemetary); } c.erase(pei); pei = c.begin(); for(index=c.size();index>=1;index--) { while(generateMutations(*pei) != 1) {pei=c.begin();}; if (isomorphTest) { insertInList(*pei,cemetary); } c.erase(pei); pei = c.begin(); } pei=c.end();pei--; // Main loop while(c.size()!=0) { #ifdef DEBUG std::cout << "C.size: " << c.size() << " Cem.size: " << cemetary.size() << "\t\t"; std::cout << "Travail avec "; (*pei).printMutations(0); (*pei).affiche(); #endif ret = generateMutations(*pei); switch(ret) { case 4: // Branch cut case 3: // Infinity detected on the branch // Cut the branch ! if(dumpTruncated) { ss.clear(); if(ret == 3) { ss << "DInf_" << infCut << ".quiv"; } if(ret == 4) { ss << "DTrunc_" << depthCut << ".quiv"; } ss >> filename; (*pei).toFile(filename.c_str()); } if(ret == 3) { infCut++; } if(ret == 4) { this->truncated = 1; depthCut ++; } if(isomorphTest) { if(((*pei).getMultiplicityMap())->size() > 0) { cutPending++; } } case 1: if (isomorphTest) { insertInList(*pei,cemetary); } c.erase(pei); case 2: pei=c.end();pei--; break; // Nothing to be done for case 0 // a green quiver was detected // and the list is not empty... some //mutations remains to be explored ! } } // Print results for ( it=sizes.begin() ; it != sizes.end(); it++ ) { std::cout << (*it).first << "\t=>\t" << (*it).second << std::endl; total +=(*it).second; } std::cout << "Total: " << total << std::endl; if(this->truncated == 1) { std::cout << "Exploration Truncated at depth: " << max_depth << std::endl; } if(this->infCut > 0) { std::cout << "Num branches cut because of excessive Mul: " << infCut << std::endl; } if(this->depthCut > 0) { std::cout << "Num branches cut because of excessive depth: " << depthCut << std::endl; } if(cutPending > 0) { std::cout << "WARNING: "<< cutPending << " branches were cut with pending isomorphs." << std::endl; std::cout << "All max green suite < "<< max_depth << " may not have been found." << std::endl; } }
int GreenExplorator::greenExploration(IceQuiver pe) { int index = 0; int ret; int max; std::map<uint64_t,mpz_class>::iterator it; mpz_class total=0; std::list<IceQuiver>::iterator pei; std::list<IceQuiver>::iterator peitest; std::stringstream ss (std::stringstream::in | std::stringstream::out); std::string filename; vecivect::iterator vsi; std::vector<mpz_class>::iterator veci; uint64_t cutPending = 0; // Initial population of the list insertInList(pe); if (pe.getN() == 2) {//When n=1 std::cout << 1 << "\t=>\t" << 1 << std::endl; std::cout << "Total: " << 1 << std::endl; return 1; } pei = c.begin(); //#ifdef DEBUG // for(peitest = c.begin();peitest != c.end();peitest++) { // fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); // peitest->printMutationsE(0); //} //#endif while(generateMutations(*pei) != 1){ //The purpose of this loop is to completely exhaust all initial green sequences starting from a quiver //Then it can be removed from the list of to-be-determined quivers. #ifdef DEBUG fprintf(stderr, "Now pei points to "); pei->printMutationsE(0); #endif pei=c.begin(); #ifdef DEBUG fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); for(peitest = c.begin();peitest != c.end();peitest++) { peitest->printMutationsE(0); } #endif }; //#ifdef DEBUG // fprintf(stderr, "Now this weird process is finally over.\nNow pei points to "); //pei->printMutationsE(0); //fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); //for(peitest = c.begin();peitest != c.end();peitest++) { // peitest->printMutationsE(0); //} //#endif if (isomorphTest) { insertInCemetary(*pei,cemetary); } c.erase(pei); pei = c.begin(); for(index=c.size();index>=1;index--) { while(generateMutations(*pei) != 1){ pei=c.begin(); //#ifdef DEBUG // fprintf(stderr, "Now pei points to "); // pei->printMutationsE(0); // fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); // for(peitest = c.begin();peitest != c.end();peitest++) { // peitest->printMutationsE(0); // } //#endif }; if (isomorphTest) { insertInCemetary(*pei,cemetary); } c.erase(pei); pei = c.begin(); //#ifdef DEBUG // fprintf(stderr, "Now pei points to "); // pei->printMutationsE(0); // fprintf(stderr, "Now printing all mutation sequences in the list c.\n"); //for(peitest = c.begin();peitest != c.end();peitest++) { // peitest->printMutationsE(0); // } //#endif } pei=c.end(); pei--; // Main loop while(c.size()!=0) { #ifdef DEBUG std::cout << "C.size: " << c.size() << " Cemetary.size: " << cemetary.size() << "\t\t"; std::cout << "Working on "; (*pei).printMutations(0); (*pei).print(); #endif ret = generateMutations(*pei); switch(ret) { case 4: // Branch cut case 3: // Infinity detected on the branch // Cut the branch ! if(dumpTruncated) { ss.clear(); if(ret == 3) { ss << "DInf_" << infCut << ".quiv"; } if(ret == 4) { ss << "DTrunc_" << depthCut << ".quiv"; } ss >> filename; (*pei).toFile(filename.c_str()); } if(ret == 3) { infCut++; } if(ret == 4) { this->truncated = 1; //std::cout << "Cut sequence: " << std::endl; //pei->printMutationsE(0); depthCut ++; } if(isomorphTest) { if(((*pei).getMultiplicityMap())->size() > 0) { cutPending++; } } case 1: if (isomorphTest) { insertInCemetary(*pei,cemetary); } c.erase(pei); case 2: pei=c.end();pei--; break; // Nothing to be done for case 0 // a green quiver was detected // and the list is not empty... some //mutations remains to be explored ! } } // Print results for ( it=mgsInfo.begin() ; it != mgsInfo.end(); it++ ) { std::cout << (*it).first << "\t=>\t" << (*it).second << std::endl; total +=(*it).second; } std::cout << "Total: " << total << std::endl; if(this->truncated == 1) { std::cout << "Exploration Truncated at depth: " << max_depth << std::endl; } if(this->infCut > 0) { std::cout << "Num branches cut because of BHIT violations: " << infCut << std::endl; } if(this->depthCut > 0) { std::cout << "Num branches cut because of excessive depth: " << depthCut << std::endl; } if(cutPending > 0) { std::cout << "WARNING: "<< cutPending << " branches were cut with pending isomorphs." << std::endl; std::cout << "All max green sequences < "<< max_depth << " may not have been found." << std::endl; } //Print admissible c-vectors std::cout << "Final CVec list:" << std::endl; printVectors(admissibleCVectors); //vecProcs(pe, admissibleCVectors); std::cout << "Final GVec list:" << std::endl; printVectors(admissibleGVectors); std::cout << "Final PVec list:" << std::endl; printVectors(admissiblePVectors); std::cout << "CProc" << std::endl; pe.vecProcs(admissibleCVectors); std::cout << "PProc" << std::endl; pe.vecProcs(admissiblePVectors); if(total) return mgsInfo.rbegin()->first; else return 0; }