예제 #1
0
bool OnlyNonLearntBins::fill()
{
    double myTime = cpuTime();
    assert(solver.performReplace);
    while (solver.performReplace && solver.varReplacer->getClauses().size() > 0) {
        if (!solver.varReplacer->performReplace(true)) return false;
        solver.clauseCleaner->removeAndCleanAll(true);
    }
    assert(solver.varReplacer->getClauses().size() == 0);
    solver.clauseCleaner->moveBinClausesToBinClauses();
    binwatches.growTo(solver.nVars()*2);

    for(Clause **i = solver.binaryClauses.getData(), **end = solver.binaryClauses.getDataEnd(); i != end; i++) {
        Clause& c = **i;
        if (c.learnt()) continue;

        binwatches[(~c[0]).toInt()].push(WatchedBin(c[1]));
        binwatches[(~c[1]).toInt()].push(WatchedBin(c[0]));
    }

    if (solver.verbosity >= 2) {
        std::cout << "c Time to fill non-learnt binary watchlists:"
        << std::fixed << std::setprecision(2) << std::setw(5)
        << cpuTime() - myTime << " s" << std::endl;
    }

    return true;
}
예제 #2
0
int main(int argc, char* argv[]){
	double start,end;
	start = cpuTime();
	foo(36);
	end = cpuTime();
	std::cout<<"Time: "<<end - start<<'\n';
	return 0;
}
예제 #3
0
  virtual void endFrameEx(const TypedValue *retval,
                          const char *given_symbol) override {
    char symbol[512];
    HierarchicalProfilerFrame *frame =
      dynamic_cast<HierarchicalProfilerFrame *>(m_stack);
    frame->getStack(2, symbol, sizeof(symbol));
    CountMap &counts = m_stats[symbol];
    counts.count++;
    counts.wall_time += cpuCycles() - frame->m_tsc_start;

    if (m_flags & TrackCPU) {
      counts.cpu += cpuTime(m_MHz) - frame->m_vtsc_start;
    }

    if (m_flags & TrackMemory) {
      auto const& stats = MM().getStats();
      int64_t mu_end = stats.usage;
      int64_t pmu_end = stats.peakUsage;
      counts.memory += mu_end - frame->m_mu_start;
      counts.peak_memory += pmu_end - frame->m_pmu_start;
    } else if (m_flags & TrackMalloc) {
      counts.memory += get_allocs() - frame->m_mu_start;
      counts.peak_memory += get_frees() - frame->m_pmu_start;
    }
  }
예제 #4
0
// ~Game()
// Description: game ends, calculate & dump results to log
Game::~Game(){
    m_objCount--;
    if(m_objCount == 0 && m_objInit){
        m_endTime = cpuTime();
        updateStats();
        dumpLog("open_src_version.log");
    }
    else
        updateStats();
}
예제 #5
0
int WalksatSolver::solve()
{

#ifdef _DEBUGWRAP
  std::cout << "call solve" << std::endl;  
#endif 

#ifdef _DEBUGWRAP
  std::cout << "solve!" << std::endl;  
#endif 

  starttime = cpuTime();

  wsat.initialize_statistics();
  if(wsat.verbosity) wsat.print_statistics_header();
  wsat.walk_solve();
  endtime = cpuTime();

  return is_sat();
}
예제 #6
0
파일: Main.C 프로젝트: pmatos/maxsatzilla
void printStats(Solver& solver)
{
    double   cpu_time = cpuTime();
    uint64_t mem_used = memUsed();
    reportf("restarts              : %lld\n", solver.starts);
    reportf("conflicts             : %-12lld   (%.0f /sec)\n", solver.conflicts   , solver.conflicts   /cpu_time);
    reportf("decisions             : %-12lld   (%4.2f %% random) (%.0f /sec)\n", solver.decisions, (float)solver.rnd_decisions*100 / (float)solver.decisions, solver.decisions   /cpu_time);
    reportf("propagations          : %-12lld   (%.0f /sec)\n", solver.propagations, solver.propagations/cpu_time);
    reportf("conflict literals     : %-12lld   (%4.2f %% deleted)\n", solver.tot_literals, (solver.max_literals - solver.tot_literals)*100 / (double)solver.max_literals);
    if (mem_used != 0) reportf("Memory used           : %.2f MB\n", mem_used / 1048576.0);
    reportf("CPU time              : %g s\n", cpu_time);
}
static void signal_outOfTime(int signum)
{
    fprintf(stderr, "Out of time\n");
    if(pCsvDst){
        double solveTime=cpuTime()-startTime;
        (*pCsvDst)<<csvLogPrefix<<", "<<wO<<", "<<wI<<", "<<wA<<", "<<solveTime<<", "<<tries<<", "<<"OutOfTime"<<"\n";
        pCsvDst->flush();
        fflush(0);
        _exit(0);
    }else{
        _exit(1);
    }
}
void GameAgent::Game::init(){
    backup = NULL;
    m_nRound = 0;
    m_moveCnt = 0;
    m_score = 0;
    m_maxScore = 0;
    m_scoreSum = 0;
    m_maxTile = 0;
    memset(m_passCnt, 0, sizeof(m_passCnt));
    m_gameOver = FALSE;
    resetGrabBag();
    setNextTile();

    m_startTime = cpuTime();
}
예제 #9
0
  virtual void beginFrameEx(const char *symbol) override {
    m_stack->m_tsc_start = cpuCycles();

    if (m_flags & TrackCPU) {
      m_stack->m_vtsc_start = cpuTime(m_MHz);
    }

    if (m_flags & TrackMemory) {
      auto const& stats = MM().getStats();
      m_stack->m_mu_start  = stats.usage;
      m_stack->m_pmu_start = stats.peakUsage;
    } else if (m_flags & TrackMalloc) {
      m_stack->m_mu_start = get_allocs();
      m_stack->m_pmu_start = get_frees();
    }
  }
예제 #10
0
// init()
// Description: initialize game records
void Game::init(){
    m_nRound = 0;
    m_moveCnt = 0;
    m_score = 0;
    m_maxScore = 0;
    m_scoreSum = 0;
    m_maxTile = 0;
    memset(m_passCnt, 0, sizeof(m_passCnt));
    m_gameOver = FALSE;
    resetGrabBag();
    setNextTile();

    for(int i = 0;i < INITIAL_TILE_NUM;i++)
        genInitTile();

    m_startTime = cpuTime();
}
예제 #11
0
  virtual void beginFrameEx(const char *symbol) override {
    HierarchicalProfilerFrame *frame =
      dynamic_cast<HierarchicalProfilerFrame *>(m_stack);
    frame->m_tsc_start = cpuCycles();

    if (m_flags & TrackCPU) {
      frame->m_vtsc_start = cpuTime(m_MHz);
    }

    if (m_flags & TrackMemory) {
      auto const& stats = MM().getStats();
      frame->m_mu_start  = stats.usage;
      frame->m_pmu_start = stats.peakUsage;
    } else if (m_flags & TrackMalloc) {
      frame->m_mu_start = get_allocs();
      frame->m_pmu_start = get_frees();
    }
  }
예제 #12
0
void OpenSMTContext::PrintResult( const lbool & result, const lbool & config_status )
{
  ostream & out = config.getRegularOut( );
#ifdef SMTCOMP
  (void)config_status;
#else
  fflush( stderr );
  (void)config_status;
  //
  // For testing purposes we return error if bug is found
  //
  if ( config_status != l_Undef
    && result != l_Undef
    && result != config_status )
    out << "error" << endl;
  else
#endif
  if ( result == l_True )
    out << "sat" << endl;
  else if ( result == l_False )
    out << "unsat" << endl;
  else if ( result == l_Undef )
    out << "unknown" << endl;
  else
    opensmt_error( "unexpected result" );

  fflush( stdout );

#ifndef SMTCOMP
  if ( config.verbosity )
  {
    //
    // Statistics
    //
    double   cpu_time = cpuTime();
    reportf( "#\n" );
    reportf( "# CPU Time used: %g s\n", cpu_time == 0 ? 0 : cpu_time );
    uint64_t mem_used = memUsed();
    reportf( "# Memory used: %.3f MB\n",  mem_used == 0 ? 0 : mem_used / 1048576.0 );
    reportf( "#\n" );
  }
#endif
}
예제 #13
0
void RunTimes::print()
{
  if (0 !=  category_stack.size())
    {
      std::cerr << "size:" <<  category_stack.size() << std::endl;
      std::cerr << "top:" << CategoryNames[category_stack.top().first] << std::endl;
      BEEV::FatalError("category stack is not yet empty!!");
    }

  std::ostringstream result;
  result << "statistics\n";
  std::map<Category, int>::const_iterator it1 = counts.begin();
  std::map<Category, long>::const_iterator it2 = times.begin();

  int cummulative_ms = 0;

  while (it1 != counts.end())
  	{
  		int time_ms = 0;
  		if ((it2 = times.find(it1->first)) != times.end())
  			time_ms = it2->second;

  		if (time_ms!=0)
  		{
  			result << " " << CategoryNames[it1->first] << ": " << it1->second;
  			result << " [" << time_ms << "ms]";
  			result << std::endl;
  			cummulative_ms += time_ms;
  		}
  		it1++;
  	}
  std::cerr << result.str();
  std::cerr << std::fixed;
  std::cerr.precision(2);
  std::cerr << "Statistics Total: " << ((double)cummulative_ms)/1000 << "s" << std::endl;
  std::cerr << "CPU Time Used   : " << cpuTime() << "s" << std::endl;
  std::cerr << "Peak Memory Used: " << memUsedPeak()/(1024.0*1024.0) << "MB" << std::endl;

  clear();

}
예제 #14
0
void QueryCostInfo :: translateToExternalFormat(SQL_QUERY_COST_INFO *query_cost_info)
{
  query_cost_info->cpuTime 
    = cpuTime();
  query_cost_info->ioTime 
    = ioTime();
  query_cost_info->msgTime 
    = msgTime();
  query_cost_info->idleTime 
    = idleTime();
  query_cost_info->totalTime 
    = totalTime();
  query_cost_info->cardinality 
    = cardinality();
  query_cost_info->estimatedTotalMem
    = totalMem();
  query_cost_info->resourceUsage
    = resourceUsage();
  query_cost_info->maxCpuUsage
    = maxCpuUsage();
}
예제 #15
0
int main(int argc, char *argv[] ) 
{
  
  QMDDrevlibDescription circ[2];
  
  long otime;
  int i;
  char argvn[2][64];
  
  /**************************************************************************/
  /*   Argument setup                                                       */
  /**************************************************************************/        
  if(argc==1)
  {
    printf("Plase enter name of input circuit file: ");
    scanf("%s",argvn[1]);
  }
  else for(i=0;i<2;i++) strcpy(argvn[i],argv[i]);
  
  /**************************************************************************/
  /*   Initialize QMDD package                                              */
  /**************************************************************************/
  otime=cpuTime();
  
  QMDDinit(VERBOSE_MAIN);   // 0 = no verbose, 1 = verbose 
  
  if (VERBOSE_MAIN) {
    printf("Initialization time (QMDD package): ");
    printCPUtime(cpuTime()-otime);
    printf("\n");
  }
  
  /**************************************************************************/
  /*   Read the input specification                                         */
  /**************************************************************************/
  
  circ[0]=ReadSpecification(argvn[1],circ[0],0);
  if (circ[0].n == 0) {
    printf("Failed to open file.\n");
    return 1; 
  } else {
    if (VERBOSE_MAIN) printf("Reading circuit %s with %d lines was successful.\n",argvn[1], circ[0].n);
  }
  
  QMDDedge basic = circ[0].e;
  
   char outputbuffer[50];
   int largest, lastResult = ActiveNodeCount;
   int numberOfSifts = 0;
   
   std::ostringstream oss, ossSift;
   
   // Remove "Benchmarks/" from filename
   
   if (strncmp("Benchmarks/", argvn[1], 11) == 0)
     sprintf(outputbuffer, "%20s; %5d; ", &argvn[1][11], ActiveNodeCount);
   else
     sprintf(outputbuffer, "%30s; %5d; ", argvn[1], ActiveNodeCount);
   oss << outputbuffer; 
   
   /****** FIRST SIFTING ********/
   ossSift.str("");
   largest = QMDDsift(circ[0].n, &basic, &circ[0], ossSift);
   oss << ossSift.str();
   sprintf(outputbuffer, " %5d; %5d;", largest, ActiveNodeCount); 
   oss << outputbuffer;
   
   while(ActiveNodeCount != lastResult) {
     numberOfSifts++;
     lastResult = ActiveNodeCount; 
     ossSift.str("");
     largest = QMDDsift(circ[0].n, &basic, &circ[0], ossSift);
   }
   sprintf(outputbuffer, ";; %5d; %5d;", numberOfSifts,ActiveNodeCount); 
   oss << outputbuffer;
   
   oss <<  std::endl;
   std::cout << oss.str();
   exit(0);
   
}	
예제 #16
0
//---------------------------------------------------------
int main( int argc, char** argv )
{
	int strLen, SplitInpFileMode, GetStartStatMode;
	string input_file_name;
	double start_time;
	bool IsNoVecMode;
	stringstream sstream;
	Hash_process hash_p;

	hash_p.stat_file_name = "stat";
	hash_p.split_stat_file_name = "split_stat";

	//TestSolve( ); // Debug

	int corecount = 0, rank = 0;

	MPI_Init( &argc, &argv );
	MPI_Comm_size( MPI_COMM_WORLD, &corecount );
	MPI_Comm_rank( MPI_COMM_WORLD, &rank );
	
	if ( rank == 0 ) {
		start_time = cpuTime( );

		if ( !GetInputFlags( argc, argv, IsNoVecMode, GetStartStatMode, SplitInpFileMode ) )
		{ cout << "\n Error in GetInputFlags"; return 1; }

		sstream << argv[1];
		input_file_name = sstream.str( );

		cout << "\n input_file_name is "  << input_file_name;
		cout << "\n NoVecMode is "        << IsNoVecMode;
		cout << "\n GetStartStatMode is " << GetStartStatMode;
		cout << "\n SplitInpFileMode is " << SplitInpFileMode;

		hash_p.IsNoVecMode      = IsNoVecMode;
		hash_p.GetStartStatMode = GetStartStatMode;
		hash_p.SplitInpFileMode = SplitInpFileMode;
		hash_p.input_file_name  = input_file_name;
		hash_p.start_time       = start_time;
		
		if  ( !( hash_p.ReadInpFile( ) ) )
		{ cout << endl << endl << "*** Error in ReadInpFile. exit ***"; return 1; }
		cout << endl << endl << "*** End of ReadInpFile ***";

		if ( hash_p.GetStartStatMode )
			hash_p.GetStartStat( );

		if ( !SplitInpFileMode ) { // if only 1 file
			cout << endl << "Start work with one files";
			hash_p.MakeHashTabFromFile( input_file_name );
		}
		else if ( ( SplitInpFileMode == 1 ) || ( SplitInpFileMode == 3 ) ) { // many subfiles
			string dir = string(".");
			vector<string> files = vector<string>();
			getdir( dir, files );
			
			cout << endl << "Start work with subfiles";
			for ( unsigned int i = 0; i < files.size( ); i++ ) {
				if ( sscanf( files[i].c_str( ), "zplit_%d", &strLen ) ) {
					hash_p.MakeHashTabFromFile( files[i] );
					hash_p.hash_tab.clear( ); // clear hash_tab after every file
					cout << endl << "*** hash_tab was cleared";
				}
			}
			cout << endl << "End work with subfiles";
		}
		
		cout << endl << "Start of PrintFinalStat";
		hash_p.PrintFinalStat( ); // print final stat
		cout << endl << "End of PrintFinalStat";

		return 0;
	}
}
예제 #17
0
//---------------------------------------------------------
void TestSolve( )
{
	int strLen, vecSize;
	string input_file_name;
	double start_time;
	bool IsNoVecMode;
	int GetStartStatMode,
		SplitInpFileMode;
	stringstream sstream;
	Hash_process hash_p;

	hash_p.stat_file_name = "stat";
	hash_p.split_stat_file_name = "split_stat";

	int argc = 4;
	char** argv = new char*[argc];
	argv[0] = "Hash_clauses";
	argv[1] = "-GetStartStat=0";
	argv[2] = "-SplitInpFileMode=1";
	argv[3] = "clauses0.cnf";
	//argv[2] = "zplit_100";
	
	if ( !GetInputFlags( argc, argv, IsNoVecMode, GetStartStatMode, SplitInpFileMode ) )
	{ cout << "\n Erroe in GetInputFlags"; }
	
	start_time = cpuTime( );

	sstream << argv[1];
	input_file_name = sstream.str( );

	cout << "\n input_file_name is "  << input_file_name;
	cout << "\n NoVecMode is "        << IsNoVecMode;
	cout << "\n GetStartStatMode is " << GetStartStatMode;
	cout << "\n SplitInpFileMode is " << SplitInpFileMode;

	hash_p.IsNoVecMode      = IsNoVecMode;
	hash_p.GetStartStatMode = GetStartStatMode;
	hash_p.SplitInpFileMode = SplitInpFileMode;
	hash_p.input_file_name  = input_file_name;
	hash_p.start_time       = start_time;
		
	//hash_p.clauses_count = 1000;

	cout << endl << "Start of ReadInpFile";
	hash_p.ReadInpFile( );
	cout << endl << "End of ReadInpFile";

	if ( !SplitInpFileMode ) // only 1 file
		hash_p.MakeHashTabFromFile( input_file_name );
	else { // many small files
		string dir = string(".");
		vector<string> files = vector<string>( );
		getdir(dir, files);
			
		for ( unsigned int i = 0; i < files.size( ); i++ ) {
			if ( sscanf( files[i].c_str( ), "zplit_%d_%d", &strLen, &vecSize ) )
				hash_p.MakeHashTabFromFile( files[i] );
		}
	}
		
	cout << endl << "Start of PrintFinalStat";
	hash_p.PrintFinalStat( ); // print final stat
	cout << endl << "End of PrintFinalStat";
	
	delete[] argv;
}
예제 #18
0
파일: Main.C 프로젝트: pmatos/maxsatzilla
int main(int argc, char** argv)
{
    Solver      S;
    S.verbosity = 1;


    int         i, j;
    const char* value;
    for (i = j = 0; i < argc; i++){
        if ((value = hasPrefix(argv[i], "-polarity-mode="))){
            if (strcmp(value, "true") == 0)
                S.polarity_mode = Solver::polarity_true;
            else if (strcmp(value, "false") == 0)
                S.polarity_mode = Solver::polarity_false;
            else if (strcmp(value, "rnd") == 0)
                S.polarity_mode = Solver::polarity_rnd;
            else{
                reportf("ERROR! unknown polarity-mode %s\n", value);
                exit(0); }

        }else if ((value = hasPrefix(argv[i], "-rnd-freq="))){
            double rnd;
            if (sscanf(value, "%lf", &rnd) <= 0 || rnd < 0 || rnd > 1){
                reportf("ERROR! illegal rnd-freq constant %s\n", value);
                exit(0); }
            S.random_var_freq = rnd;

        }else if ((value = hasPrefix(argv[i], "-decay="))){
            double decay;
            if (sscanf(value, "%lf", &decay) <= 0 || decay <= 0 || decay > 1){
                reportf("ERROR! illegal decay constant %s\n", value);
                exit(0); }
            S.var_decay = 1 / decay;

        }else if ((value = hasPrefix(argv[i], "-verbosity="))){
            int verbosity = (int)strtol(value, NULL, 10);
            if (verbosity == 0 && errno == EINVAL){
                reportf("ERROR! illegal verbosity level %s\n", value);
                exit(0); }
            S.verbosity = verbosity;

        }else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "--help") == 0){
            printUsage(argv);
            exit(0);

        }else if (strncmp(argv[i], "-", 1) == 0){
            reportf("ERROR! unknown flag %s\n", argv[i]);
            exit(0);

        }else
            argv[j++] = argv[i];
    }
    argc = j;


    reportf("This is MiniSat 2.0 beta\n");
#if defined(__linux__)
    fpu_control_t oldcw, newcw;
    _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw);
    reportf("WARNING: for repeatability, setting FPU to use double precision\n");
#endif
    double cpu_time = cpuTime();

    solver = &S;
    signal(SIGINT,SIGINT_handler);
    signal(SIGHUP,SIGINT_handler);

    if (argc == 1)
        reportf("Reading from standard input... Use '-h' or '--help' for help.\n");

    gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb");
    if (in == NULL)
        reportf("ERROR! Could not open file: %s\n", argc == 1 ? "<stdin>" : argv[1]), exit(1);

    reportf("============================[ Problem Statistics ]=============================\n");
    reportf("|                                                                             |\n");

    parse_DIMACS(in, S);
    gzclose(in);
    FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;

    double parse_time = cpuTime() - cpu_time;
    reportf("|  Parsing time:         %-12.2f s                                       |\n", parse_time);

    if (!S.simplify()){
        reportf("Solved by unit propagation\n");
        if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res);
        printf("UNSATISFIABLE\n");
        exit(20);
    }

    bool ret = S.solve();
    printStats(S);
    reportf("\n");
    printf(ret ? "SATISFIABLE\n" : "UNSATISFIABLE\n");
    if (res != NULL){
        if (ret){
            fprintf(res, "SAT\n");
	    //S.liftModel();
            for (int i = 0; i < S.nVars(); i++)
                if (S.model[i] != l_Undef)
                    fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
	    //else fprintf(res, "\nuninstanciated variable %d\n", i+1);
            fprintf(res, " 0\n");
        }else
            fprintf(res, "UNSAT\n");
        fclose(res);
    }

#ifdef NDEBUG
    exit(ret ? 10 : 20);     // (faster than "return", which will invoke the destructor for 'Solver')
#endif
}
예제 #19
0
파일: BothCache.cpp 프로젝트: zenna/halisi
    bool BothCache::tryBoth() {
        vec<bool> seen(solver.nVars(), 0);
        vec<bool> val(solver.nVars(), 0);
        vec<Lit> tmp;
        uint32_t bProp = 0;
        uint32_t bXProp = 0;
        double myTime = cpuTime();
        uint32_t backupTrailSize = solver.trail.size();

        for (Var var = 0; var < solver.nVars(); var++) {
            if (solver.value(var) != l_Undef
                    || (solver.subsumer && solver.subsumer->getVarElimed()[var])
                    || solver.xorSubsumer->getVarElimed()[var]
                    || solver.varReplacer->getReplaceTable()[var].var() != var)
                continue;

            Lit lit = Lit(var, false);
            vector<Lit> const* cache1;
            vector<Lit> const* cache2;

            bool startWithTrue;
            if (solver.transOTFCache[lit.toInt()].lits.size() < solver.transOTFCache[(~lit).toInt()].lits.size()) {
                cache1 = &solver.transOTFCache[lit.toInt()].lits;
                cache2 = &solver.transOTFCache[(~lit).toInt()].lits;
                startWithTrue = false;
            } else {
                cache1 = &solver.transOTFCache[(~lit).toInt()].lits;
                cache2 = &solver.transOTFCache[lit.toInt()].lits;
                startWithTrue = true;
            }

            if (cache1->size() == 0) continue;

            for (vector<Lit>::const_iterator it = cache1->begin(), end = cache1->end(); it != end; it++) {
                seen[it->var()] = true;
                val[it->var()] = it->sign();
            }

            for (vector<Lit>::const_iterator it = cache2->begin(), end = cache2->end(); it != end; it++) {
                if (seen[it->var()]) {
                    Var var2 = it->var();
                    if ((solver.subsumer && solver.subsumer->getVarElimed()[var2])
                            || solver.xorSubsumer->getVarElimed()[var2]
                            || solver.varReplacer->getReplaceTable()[var2].var() != var2)
                        continue;

                    if (val[it->var()] == it->sign()) {
                        tmp.clear();
                        tmp.push(*it);
                        solver.addClauseInt(tmp, true);
                        if (!solver.ok) goto end;
                        bProp++;
                    } else {
                        tmp.clear();
                        tmp.push(Lit(var, false));
                        tmp.push(Lit(it->var(), false));
                        bool sign = true ^ startWithTrue ^ it->sign();
                        solver.addXorClauseInt(tmp, sign);
                        if (!solver.ok) goto end;
                        bXProp++;
                    }
                }
            }

            for (vector<Lit>::const_iterator it = cache1->begin(), end = cache1->end(); it != end; it++) {
                seen[it->var()] = false;
            }
        }

end:
        if (solver.conf.verbosity >= 1) {
            std::cout << "c Cache " <<
                    " BProp: " << bProp <<
                    " Set: " << (solver.trail.size() - backupTrailSize) <<
                    " BXProp: " << bXProp <<
                    " T: " << (cpuTime() - myTime) <<
                    std::endl;
        }

        return solver.ok;
    }
예제 #20
0
파일: Threes.cpp 프로젝트: choupi/thress
// ~Game()
// Description: game ends, calculate & dump results to log
Game::~Game(){
    if(m_nRound == 100){
        m_endTime = cpuTime();
        dumpLog("open_src_version.log");
    }
}
예제 #21
0
double ProofGraph::doIt(double leftTime)
{
  size_t num_non_null;

  if ( verbose() > 0 )
  {
    num_non_null=0;
    for(size_t i=0;i<graph.size();i++)
      if(graph[i]!=NULL) num_non_null++;

    cerr << "#" << endl << "# Estimate of memory used before transformation" << endl;
    cerr << "# Size graph vector:" << graph.size() << " Memory for vector:" <<
      (graph.size()*sizeof(ProofNode*)) << endl;
    cerr << "# Nonnull nodes:" << num_non_null
      << " Memory for nodes: " << (num_non_null*sizeof(ProofNode))<< endl;
    cerr << "# Memory for visit vectors (preallocated):" << sizeof(std::bitset<SIZE_BIT_VECTOR>)*2 << endl << "#" << endl;
  }
  //Transformation time calculation
  double timeInit=0;
  double timeEnd=0;

  //Number of inner transformation loops
  //-1 for exhaustiveness
  int numTransfLoops;
  //Number of outer transformation loops
  //useful for alternation with recycle pivots
  int numGlobalLoops;
  // Time available for transformations
  // -1 for exhaustiveness
  double ratio;
  //Flag to be enabled (in case) for interpolation reordering
  //Postpones node duplications in swap rules until possible
  bool lessDuplMode;
  //Flag to enable transformations
  //Set to false in reduction if doing only recycle pivots and reconstruction
  bool doTransf;

  if(produceProof())
  {
    if ( reduceProof() > 0 )
    {
      if( ( ratioReductionSolvingTime() > 0 && reductionTime() > 0) ||
	  ( ratioReductionSolvingTime() == 0 && reductionTime() == 0)   )
      {
	cerr << "Please choose either ratio or time for reduction in config file" << endl;
	assert(false);
      }

      if( ratioReductionSolvingTime() > 0)
      {
	// Ratio transformation time/solving time
	ratio=ratioReductionSolvingTime();
	leftTime*=ratio;
      }
      if( reductionTime() > 0)
      {
	leftTime=reductionTime();
      }

      doTransf=true;
      numTransfLoops=-1;
      if (reductionLoops() == 0 )
      {
	cerr << "Please set number of reduction loops to at least 1 in config file" << endl;
	assert(false);
      }
      numGlobalLoops=reductionLoops();
      lessDuplMode=false;
      double recyTime=0,initTime=0;

      if ( verbose() > 0 )
      {
	cerr << "# Compressing proof, " << numGlobalLoops << " iteration(s) ->" << endl;
	cerr << "#" << endl;
      }

      //For each outer loop, recycle pivots algorithm is executed, followed by a certain
      //number of transformation loops, or by a single restructuring loop

      //Each global loop is given an equal fraction of available time
      const double share=leftTime/numGlobalLoops;
      timeInit=cpuTime();
      for(int k=0;k<numGlobalLoops;k++)
      {
	initTime=cpuTime();
	recyclePivotsIter();
	recyTime=cpuTime()-initTime;

	//Restructure graph, in case do also transformations
	transformAndRestructureOnTheFly(share-recyTime,doTransf,numTransfLoops,true);
      }
      timeEnd=cpuTime();
    }
  }
  else if( produceInterpolants() > 0 )
  {
    if ( verbose() > 0 )
    {
      cerr << "# Reordering pivots for interpolation ->" << endl;
      cerr << "#" << endl;
    }
    leftTime=-1;
    doTransf=true;
    numTransfLoops=-1;
    numGlobalLoops=2;
    lessDuplMode=false;

    timeInit=cpuTime();
    for(int k=0;k<numGlobalLoops;k++)
    {
      recyclePivotsIter();
      transformAndRestructureOnTheFly(leftTime,doTransf,numTransfLoops,lessDuplMode);
    }
    timeEnd=cpuTime();

#ifdef CHECK
    bool (ProofGraph::*ordering)(RuleContext&)=&ProofGraph::pushUpLightVarCriterionWeakOrdered;
    checkPivotOrdering(ordering);
#endif

    if ( removeMixedPredicates() > 0 )
    {
      cout << "MAGENTIFICATION" << endl;
      systematicMagentification();
      timeEnd=cpuTime();
#ifdef CHECK
      checkMagentification();
#endif
    }
  }

  if ( verbose() > 0 )
  {
    num_non_null=0;
    for(size_t i=0;i<graph.size();i++)
      if(graph[i]!=NULL) num_non_null++;

    cerr << "#" << endl << "# Estimate of memory used after transformation" << endl;
    cerr << "# Size graph vector:" << graph.size() << " Memory for vector:" <<
      (graph.size()*sizeof(ProofNode*)) << endl;
    cerr << "# Nonnull nodes:" << num_non_null
      << " Memory for nodes: " << (num_non_null*sizeof(ProofNode))<< endl;
    cerr << "# Memory for visit vectors (preallocated):" << sizeof(std::bitset<SIZE_BIT_VECTOR>)*2 << endl;
  }

  return (timeEnd-timeInit);
}
예제 #22
0
int main(int argc, char** argv)
{
    Solver      S;
    bool        st;

    if (argc >= 2 && strlen(argv[1]) >= 5 && strcmp(&argv[1][strlen(argv[1])-5], ".bcnf") == 0)
        st = parse_BCNF(argv[1], S);
    else{
        parse_DIMACS(argv[1], S);
        st = S.okay();
        /*
        gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb");
        if (in == NULL)
            fprintf(stderr, "ERROR! Could not open file: %s\n", argc == 1 ? "<stdin>" : argv[1]),
            exit(1);
        st = parse_DIMACS(in, S);
        gzclose(in);
        */
    }
    FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;

    if (!st){
        if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res);
        reportf("Trivial problem\n");
        reportf("UNSATISFIABLE\n");
      #ifdef SAT_LIVE
        printf("s UNSATISFIABLE\n");
      #endif
        exit(20);
    }

    S.verbosity = 1;
    solver = &S;
    signal(SIGINT,SIGINT_handler);
    signal(SIGHUP,SIGINT_handler);
    st = S.solve();
    printStats(S.stats, cpuTime());
    reportf("\n");
    reportf(st ? "SATISFIABLE\n" : "UNSATISFIABLE\n");

    if (res != NULL){
        if (st){
            fprintf(res, "SAT\n");
            for (int i = 0; i < S.nVars(); i++)
                if (S.model[i] != l_Undef)
                    fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
            fprintf(res, " 0\n");
        }else
            fprintf(res, "UNSAT\n");
        fclose(res);
    }

  #ifdef SAT_LIVE
    printf(st ? "s SATISFIABLE\n" : "s UNSATISFIABLE\n");
    if (st){
        printf("v");
        for (int i = 0; i < S.nVars(); i++)
            if (S.model[i] != l_Undef)
                printf(" %s%d", (S.model[i]==l_True)?"":"-", i+1);
        printf(" 0\n");
    }
  #endif

    exit(st ? 10 : 20);     // (faster than "return", which will invoke the destructor for 'Solver')
}
예제 #23
0
void ProofGraph::transfProof( )
{
  // Time left for transformation
  double leftTime = cpuTime( );

  size_t size=0;
  int numnodes=0;
  int numedges=0;
  int numleaves=0;
  int numvars=0;
  double avgdeg=0;
  int dia=0;
  int maxclasize=0;
  double avgclasize=0;
  int unsatcoredim=0;
  int numunary=0;
  double avgnumresunary=0;
  double avgnumres=0;
  int maxnumres=0;
  double varnumres=0;
  double varclasize=0;

  if ( verbose() )
  {
    getGraphInfo( );

    size = graph.size( );
    numnodes=num_nodes;
    numedges=num_edges;
    numleaves=num_leaves;
    numvars=numVars;
    avgdeg=(double)numedges / (double)numnodes;
    dia=diameter;
    maxclasize=max_cla_size;
    avgclasize=av_cla_size;
    unsatcoredim=dim_unsat_core;
    numunary=num_unary;
    avgnumresunary=avg_num_res_unary;
    avgnumres=avg_num_res;
    maxnumres=max_num_res;
    varnumres=var_num_res;
    varclasize=var_cla_size;
  }

  double time=0;

  if( produceProof() )
  {
    if ( reduceProof() > 0 )
    {
      time = doIt( leftTime );
    }
  }
  else if( produceInterpolants() > 0 )
  {
    //No need to transform proof if no AB-mixed predicate is present!
    assert(!lightVars.empty());

    if ( reorderPivots() > 0)
      time = doIt( leftTime );
    else
    {
      opensmt_error( "Cannot produce interpolants because of AB-mixed predicates. Please enable pivot reordering in config file" );
    }
  }

#ifndef OPTIMIZE
  checkProof();
  cleanProofGraph( );
  checkProof();
#endif
  if ( verbose() > 0 )
  {
    getGraphInfo( );

    double perc_nodes=(((double)num_nodes-(double)numnodes)/(double)numnodes)*100;
    double perc_edges=(((double)num_edges-(double)numedges)/(double)numedges)*100;
    double perc_leaves=(((double)num_leaves-(double)numleaves)/(double)numleaves)*100;
    double perc_unsatcore=(((double)dim_unsat_core-(double)unsatcoredim)/(double)unsatcoredim)*100;
    cerr << "#" << endl;
    cerr << "# ------------------------------------" << endl;
    cerr << "# PROOF GRAPH TRASFORMATION STATISTICS    " << endl;
    cerr << "# ------------------------------------" << endl;
    cerr << "# Structural properties" << endl;
    cerr << "# ---------------------" << endl;
    cerr << "# Light variables............: ";
    fprintf( stderr, "%-10ld\n", lightVars.size( ) );
    cerr << "# Nominal num proof variables: ";
    fprintf( stderr, "%-10ld\n", numVarsLimit );
    cerr << "# Actual num proof variables.: ";
    fprintf( stderr, "%-10d %-10d\n", numvars, numVars );
    cerr << "# Nodes......................: ";
    fprintf( stderr, "%-10d %-10d\n", numnodes, num_nodes );
    cerr << "# Nodes variation............: ";
    fprintf( stderr, "%-9.2f %%\n", perc_nodes );
    cerr << "# Leaves.....................: ";
    fprintf( stderr, "%-10d %-10d\n", numleaves, num_leaves );
    cerr << "# Leaves variation...........: ";
    fprintf( stderr, "%-9.2f %%\n", perc_leaves );
    cerr << "# Unsat core.................: ";
    fprintf( stderr, "%-10d %-10d\n", unsatcoredim, dim_unsat_core );
    cerr << "# Unsat core variation.......: ";
    fprintf( stderr, "%-9.2f %%\n", perc_unsatcore );
    cerr << "# Edges......................: ";
    fprintf( stderr, "%-10d %-10d\n", numedges, num_edges );
    cerr << "# Edges variation............: ";
    fprintf( stderr, "%-9.2f %%\n", perc_edges );
    cerr << "# Graph vector size..........: ";
    fprintf( stderr, "%-10ld %-10ld\n", size, graph.size( ) );
    cerr << "# Average degree.............: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgdeg, (double)num_edges / (double)num_nodes );
    cerr << "# Diameter...................: ";
    fprintf( stderr, "%-10d %-10d\n", dia, diameter );
    cerr << "# Unary clauses..............: ";
    fprintf( stderr, "%-10d %-10d\n", numunary, num_unary );
    cerr << "# Max clause size............: ";
    fprintf( stderr, "%-10d %-10d\n", maxclasize, max_cla_size );
    cerr << "# Average clause size........: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgclasize, av_cla_size );
    cerr << "# Variance clause size.......: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", varclasize, var_cla_size );
    cerr << "# Max num res................: ";
    fprintf( stderr, "%-10d %-10d\n", maxnumres, max_num_res );
    cerr << "# Average num res............: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgnumres, avg_num_res );
    cerr << "# Avg num res unary clauses..: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", avgnumresunary, avg_num_res_unary );
    cerr << "# Variance num res...........: ";
    fprintf( stderr, "%-10.2f %-10.2f\n", varnumres, var_num_res );
    cerr << "# -------------------------" << endl;
    cerr << "# Transformation statistics" << endl;
    cerr << "# -------------------------" << endl;
    cerr << "# Graph building time........: " << building_time << " s" << endl;
    cerr << "# Transformation time........: " << time << " s" << endl;
    cerr << "# Duplications...............: " << num_dup << endl;
    cerr << "# Node additions due to A1...: " << num_node_add_A1 << endl;
    cerr << "# ---------------------------" << endl;
    cerr << "# Rules application statistics" << endl;
    cerr << "# ---------------------------" << endl;
    cerr << "# A1.........................: " << A1 << endl;
    cerr << "# A1 undo....................: " << A1Undo << endl;
    cerr << "# A1 to B....................: " << A1B << endl;
    cerr << "# A2.........................: " << A2 << endl;
    cerr << "# A2 to B....................: " << A2B << endl;
    cerr << "# A2 unary...................: " << A2U << endl;
    cerr << "# B1.........................: " << B1 << endl;
    cerr << "# B2.........................: " << B2 << endl;
    cerr << "# B2 killer..................: " << B2K << endl;
    cerr << "# B3.........................: " << B3 << endl;
    cerr << "# ---------------------------" << endl;
  }
}
예제 #24
0
static void SIGINT_handler(int signum) {
    printStats(solver->stats, cpuTime());
    reportf("\n");
    reportf("INTERRUPTED\n");
    exit(0); }
예제 #25
0
lbool SimpSMTSolver::solve( const vec< Lit > & assumps
    , const unsigned conflicts
    , bool do_simp
    , bool turn_off_simp)
{
  vec<Var> extra_frozen;
  bool     result = true;

  if ( config.sat_preprocess_theory == 0 )
    goto skip_theory_preproc;

  opensmt_error( "preprocess theory has been temporairly disabled in this version" );

skip_theory_preproc:

  // Added Code
  //=================================================================================================

  do_simp &= use_simplification;

  if (do_simp)
  {
    // Assumptions must be temporarily frozen to run variable elimination:
    for (int i = 0; i < assumps.size(); i++)
    {
      Var v = var(assumps[i]);

      // If an assumption has been eliminated, remember it.
      if (isEliminated(v))
	remember(v);

      if (!frozen[v])
      {
	// Freeze and store.
	setFrozen(v, true);
	extra_frozen.push(v);
      }
    }

    result = eliminate(turn_off_simp);
  }

#ifdef STATISTICS
  CoreSMTSolver::preproc_time = cpuTime( );
#endif

  lbool lresult = l_Undef;
  if (result)
    lresult = CoreSMTSolver::solve(assumps, conflicts);
  else
    lresult = l_False;

  if (lresult == l_True)
  {
    extendModel();
    // Previous line
    // #ifndef NDEBUG
#ifndef SMTCOMP
    verifyModel();
#endif
  }

  if (do_simp)
    // Unfreeze the assumptions that were frozen:
    for (int i = 0; i < extra_frozen.size(); i++)
      setFrozen(extra_frozen[i], false);

  return lresult;
}
예제 #26
0
int main(int argc, char *argv[])
{

    int verbose=2;
    std::string srcFileName="-";
    int maxTries=INT_MAX;
    std::string name="perfect";
    //std::string writeCpp="";
    std::string method="default";
    int wV=0;
    unsigned maxHash=0;

    double maxTime=600;
    double maxMem=4000;

    double solveTime=0.0;
    std::string csvLogDst;

    urng.seed(time(0));

    try {
        int ia = 1;
        while (ia < argc) {
            if (!strcmp(argv[ia], "--verbose")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --verbose");
                verbose = atoi(argv[ia + 1]);
                ia += 2;
            } else if (!strcmp(argv[ia], "--input")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --input");
                srcFileName = argv[ia + 1];
                ia += 2;
            } else if (!strcmp(argv[ia], "--csv-log")) {
                if ((argc - ia) < 3) throw std::runtime_error("No argument to --csv-dst");
                csvLogPrefix = argv[ia + 1];
                csvLogDst = argv[ia + 2];
                ia += 3;
            } else if (!strcmp(argv[ia], "--wa")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --wa");
                wA = atoi(argv[ia + 1]);
                if (wA < 1) throw std::runtime_error("Can't have wa < 1");
                if (wA > 12) throw std::runtime_error("wa > 12 is unexpectedly large (edit code if you are sure).");
                ia += 2;
            } else if (!strcmp(argv[ia], "--wo")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --wo");
                wO = atoi(argv[ia + 1]);
                if (wO < 1) throw std::runtime_error("Can't have wo < 1");
                if (wO > 16) throw std::runtime_error("wo > 16 is unexpectedly large (edit code if you are sure).");
                ia += 2;
            } else if (!strcmp(argv[ia], "--wv")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --wv");
                wV = atoi(argv[ia + 1]);
                if (wV < 0) throw std::runtime_error("Can't have wv < 0");
                ia += 2;
            } else if (!strcmp(argv[ia], "--wi")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --wi");
                wI = atoi(argv[ia + 1]);
                if (wI < 1) throw std::runtime_error("Can't have wi < 1");
                if (wI > 32) throw std::runtime_error("wo > 32 is unexpectedly large (edit code if you are sure).");
                ia += 2;
            } else if (!strcmp(argv[ia], "--max-time")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --max-time");
                maxTime = strtod(argv[ia + 1], 0);
                ia += 2;
            } else if (!strcmp(argv[ia], "--max-mem")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --max-mem");
                maxMem = strtod(argv[ia + 1], 0);
                ia += 2;
            } else if (!strcmp(argv[ia], "--method")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --method");
                method = argv[ia + 1];
                ia += 2;
            } else if (!strcmp(argv[ia], "--max-hash")) {
                if ((argc - ia) < 2) throw std::runtime_error("No argument to --max-hash");
                maxHash = atoi(argv[ia + 1]);
                ia += 2;
            } else if (!strcmp(argv[ia], "--minimal")) {
                if ((argc - ia) < 1) throw std::runtime_error("No argument to --minimal");
                maxHash=UINT_MAX;
                ia += 1;
            /*} else if (!strcmp(argv[ia], "--write-cpp")) {
                if ((argc - ia) < 2) throw std::runtime_error("Not enough arguments to --write-cpp");
                writeCpp = argv[ia + 1];
                ia += 2;*/
            } else {
                throw std::runtime_error(std::string("Didn't understand argument ") + argv[ia]);
            }
        }

        if(!csvLogDst.empty()){
            if(csvLogDst=="-"){
                pCsvDst = &std::cout;
            }else{
                csvLogFile.open(csvLogDst);
                if(!csvLogFile.is_open()){
                    throw std::runtime_error("Couldn't open csv log destination.");
                }
                pCsvDst=&csvLogFile;
            }

        }

        if(verbose>0){
            fprintf(stderr, "Setting limits of %f seconds CPU time and %f MB of memory.\n", maxTime, maxMem);
            setTimeAndSpaceLimit(maxTime, maxMem);
        }

        if (method == "default") {
            if (verbose > 0) {
                method = "minisat_weighted";
                std::cerr << "Selecting default method = " << method << "\n";
            }
        }


        if (verbose > 0) {
            std::cerr << "Loading input from " << (srcFileName == "-" ? "<stdin>" : srcFileName) << ".\n";
        }

        key_value_set problem;

        if (srcFileName == "-") {
            problem = parse_key_value_set(std::cin);
        } else {
            std::ifstream srcFile(srcFileName);
            if (!srcFile.is_open())
                throw std::runtime_error("Couldn't open source file " + srcFileName);
            problem = parse_key_value_set(srcFile);
        }

        if (verbose > 1) {
            std::cerr << "Input key value pairs:\n";
            problem.print(std::cerr, "  ");
            std::cerr << "nKeys = " << problem.size() << "\n";
            std::cerr << "wKey = " << problem.getKeyWidth() << "\n";
            std::cerr << "wValue = " << problem.getValueWidth() << "\n";
        }

        if(maxHash==UINT_MAX){
            if(verbose>0){
                std::cerr << " Building minimal hash.\n";
            }
            problem.setMaxHash(maxHash);
        }else if(maxHash>0){
            if(verbose>0){
                std::cerr << " Setting maxHash="<<maxHash<<"\n";
            }
            problem.setMaxHash(maxHash);
        }

        if (wI == -1) {
            wI = problem.getKeyWidth();
            if (verbose > 0) {
                std::cerr << "Auto-selecting wI = " << wI << "\n";
            }
        } else {
            if (wI < (int) problem.getKeyWidth()) {
                throw std::runtime_error("Specified key width does not cover all keys.");
            }
        }

        if (wO == -1) {
            unsigned nKeys = problem.keys_size();
            wO = (unsigned) ceil(log(nKeys) / log(2.0));
            if (verbose > 0) {
                std::cerr << "Auto-selecting wO = " << wO << " based on nKeys = " << nKeys << "\n";
            }
        } else {
            if ((1u << wO) < problem.keys_size()) {
                throw std::runtime_error("Specified output width cannot span number of keys.");
            }
        }
        if (verbose > 0) {
            std::cerr << "Group load factor is 2^wO / nKeyGroups = " << problem.keys_size() << " / " << (1 << wO) <<
            " = " << problem.keys_size() / (double) (1 << wO) << "\n";
            std::cerr << "True load factor is 2^wO / nKeysDistinct = " << problem.keys_size_distinct() << " / " <<
            (1 << wO) << " = " << problem.keys_size_distinct() / (double) (1 << wO) << "\n";
        }

        BitHash result;

        startTime=cpuTime();

        tries = 1;
        bool success = false;
        while (tries < maxTries) {
            if (verbose > 0) {
                std::cerr << "  Attempt " << tries << "\n";
            }
            if (verbose > 0) {
                std::cerr << "  Creating bit hash...\n";
            }
            auto bh = (method == "minisat_weighted") ? makeWeightedBitHash(urng, problem, wO, wI, wA) : makeBitHash(
                    urng, wO, wI, wA);
            if (verbose > 0) {
                std::cerr << "  Converting to CNF...\n";
            }
            cnf_problem prob;
            to_cnf(bh, problem.keys(), prob, problem.getMaxHash());
            if (verbose > 0) {
                std::cerr << "  Solving problem with minisat...\n";
            }
            auto sol = minisat_solve(prob, verbose);

            if (sol.empty()) {
                if (verbose > 0) {
                    std::cerr << "  No solution\n";
                }
            } else {
                if (verbose > 0) {
                    std::cerr << "  Checking raw...\n";
                }

                if (verbose > 0) {
                    std::cerr << "  Substituting...\n";
                }
                auto back = substitute(bh, prob, sol);

                if (verbose > 0) {
                    std::cerr << "  checking...\n";
                }
                if (!back.is_solution(problem))
                    throw std::runtime_error("Failed post substitution check.");

                success = true;
                result = back;
                break;
            }
            tries++;
        }

        double finishTime=cpuTime();
        solveTime=finishTime-startTime;

        if(pCsvDst){
            (*pCsvDst)<<csvLogPrefix<<", "<<wO<<", "<<wI<<", "<<wA<<", "<<solveTime<<", "<<tries<<", "<<(success?"Success":"OutOfAttempts")<<"\n";
        }

        if (!success) {
            if(pCsvDst) {
                exit(0);
            }else{
                exit(1);
            }
        }
        if(verbose>1){
            for(const auto &kv : problem){
                auto key = *kv.first.variants_begin();

                std::cerr<<"  "<<key<<" -> "<<result(key)<<"\n";
            }
        }

        // Print the two back to back
        result.print(std::cout);
        problem.print(std::cout);

    }catch(Minisat::OutOfMemoryException &e){

        if(pCsvDst){
            (*pCsvDst)<<csvLogPrefix<<", "<<wO<<", "<<wI<<", "<<wA<<", "<<solveTime<<", "<<tries<<", "<<"OutOfMemory"<<"\n";
	    pCsvDst->flush();
        }

        std::cerr<<"Memory limit exceeded.";
        _exit(pCsvDst ? 0 : 1);
    }catch(std::exception &e){
        if(pCsvDst){
            (*pCsvDst)<<csvLogPrefix<<", "<<wO<<", "<<wI<<", "<<wA<<", "<<solveTime<<", "<<tries<<", "<<"Exception"<<"\n";
	    pCsvDst->flush();
        }

        std::cerr<<"Caught exception : ";
        print_exception(e);
	std::cerr.flush();
        _exit(pCsvDst ? 0 : 1);
    }

    return 0;
}