예제 #1
0
파일: type_string.c 프로젝트: miklos1/scene
static obj_t make_string_fn(obj_t args, Reporter rep)
{
	size_t nargs, i, k;
	char ch;
	string str;

	nargs = list_length(args);
	if (nargs == 0 || nargs > 2) {
		reportf(rep, "make-string: "
			"length and optional fill char expected");
		return unspecific;
	}
	if (!is_num(list_ref(args, 0))) {
		reportf(rep, "make-string: "
			"first argument must be a non-negative integer");
		return unspecific;
	}
	if (nargs == 2 && !is_char(list_ref(args, 1))) {
		reportf(rep, "make-string: "
			"second argument must be a character");
		return unspecific;
	}

	k = fetch_num(list_ref(args, 0));
	ch  = (nargs == 1) ? 0 : fetch_char(list_ref(args, 1));

	str = string_alloc(k);
	for (i = 0; i < str->len; i++)
		str->data[i] = ch;
	return make_string(str);
}
예제 #2
0
void SimpSMTSolver::verifyModel()
{
  bool failed = false;
  int  cnt    = 0;
  // NOTE: elimtable.size() might be lower than nVars() at the moment
  for (int i = 0; i < elimtable.size(); i++)
  {
    if (elimtable[i].order > 0)
    {
      for (int j = 0; j < elimtable[i].eliminated.size(); j++)
      {
	cnt++;
	Clause& c = *elimtable[i].eliminated[j];
	for (int k = 0; k < c.size(); k++)
	  if (modelValue(c[k]) == l_True)
	    goto next;

	reportf("unsatisfied clause: ");
	printClause(*elimtable[i].eliminated[j]);
	reportf("\n");
	failed = true;
next:;
      }
    }
  }

  assert(!failed);

  // Modified line
  // reportf("Verified %d eliminated clauses.\n", cnt);
  /*
     if ( config.sat_verbose )
     reportf("# Verified %d eliminated clauses.\n#\n", cnt);
     */
}
예제 #3
0
// Will return '_undef_' if 'cost_limit' is exceeded.
//
Formula buildConstraint(const Linear& c, int max_cost)
{
    vec<Formula>    ps;
    vec<Int>        Cs;

    for (int j = 0; j < c.size; j++)
        ps.push(lit2fml(c[j])),
        Cs.push(c(j));

    vec<Int> dummy;
    int      cost;
    vec<int> base;
    optimizeBase(Cs, dummy, cost, base);
    FEnv::push();

    Formula ret;
    try {
        ret = buildConstraint(ps, Cs, base, c.lo, c.hi, max_cost);
    }catch (Exception_TooBig){
        FEnv::pop();
        return _undef_;
    }

    if (opt_verbosity >= 1){
        reportf("Sorter-cost:%5d     ", FEnv::topSize());
        reportf("Base:"); for (int i = 0; i < base.size(); i++) reportf(" %d", base[i]); reportf("\n");
    }
    FEnv::keep();
    return ret;
}
예제 #4
0
파일: Debug.C 프로젝트: JichaoS/dreal
void CoreSMTSolver::verifyModel()
{
#ifdef DREAL_DEBUG
  bool failed = false;
#endif
  for (int i = 0; i < clauses.size(); i++)
  {
    assert(clauses[i]->mark() == 0);
    Clause& c = *clauses[i];
    for (int j = 0; j < c.size(); j++)
      if (modelValue(c[j]) == l_True ||
          (config.nra_short_sat && modelValue(c[j]) != l_False))
        goto next;

    reportf("unsatisfied clause: ");
    printClause(*clauses[i]);
    printSMTClause( cerr, *clauses[i] );
    reportf("\n");
#ifdef DREAL_DEBUG
    failed = true;
#endif
next:;
  }
#ifdef DREAL_DEBUG
  assert(!failed);
#endif
  // Removed line
  // reportf("Verified %d original clauses.\n", clauses.size());
}
예제 #5
0
void PbSolver::propagate()
{
    if (nVars() == 0) return;
    if (occur.size() == 0) setupOccurs();

    if (opt_verbosity >= 1) reportf("  -- Unit propagations: ", constrs.size());
    bool found = false;

    while (propQ_head < trail.size()){
        //**/reportf("propagate("); dump(trail[propQ_head]); reportf(")\n");
        Var     x = var(trail[propQ_head++]);
        for (int pol = 0; pol < 2; pol++){
            vec<int>&   cs = occur[index(Lit(x,pol))];
            for (int i = 0; i < cs.size(); i++){
                if (constrs[cs[i]] == NULL) continue;
                int trail_sz = trail.size();
                if (propagate(*constrs[cs[i]]))
                    constrs[cs[i]] = NULL;
                if (opt_verbosity >= 1 && trail.size() > trail_sz) found = true, reportf("p");
                if (!ok) return;
            }
        }
    }

    if (opt_verbosity >= 1) {
        if (!found) reportf("(none)\n");
        else        reportf("\n");
    }

    occur.clear(true);
}
예제 #6
0
static void parse_DIMACS_main(B& in, mS& S) {
    vec<Lit> lits;
    Int w;
    Int max=-1;
    bool wcnf=false;
    for (;;){
        skipWhitespaceCnf(in);
        if (*in == EOF)
            break;
        else if (*in == 'c') skipLineCnf(in);
	else if(*in == 'p')
	{
		++in;
		skipWhitespaceCnf(in);
		if(*in== 'w') wcnf=true;
		if (wcnf) {reportf("Parsing WCNF file...\n"); ++in; ++in; ++in; ++in;}
		else { reportf("Parsing CNF file...\n"); ++in; ++in; ++in;}
		//if (wcnf) {reportf("Parsing WCNF file...\n"); }
		//else { reportf("Parsing CNF file...\n");}

		parseIntCnf(in); // Number of variables
		parseIntCnf(in); // Number of clauses
		while(not (*in >= '0' and *in <= '9') and not(*in == '\n')){
			++in; 
		} 
		
		S.setTop(-1);
		
		if (*in >= '0' and *in <= '9') max=parseIntCnf(in);
		if(max!=-1) { 
			reportf("UB %d \n",toint(max)); 
			S.setTop(max);
		}
		skipLineCnf(in);
	}
        else
	{
            w=readClauseCnf(in, S, lits,wcnf);
	    if(opt_sat==1) // Satisfiability
		S.addWeightedClause(lits,w,true);
	    else  {// Max-SAT 
	    	if(lits.size()>1)
		{
			if(max >-1 and w>=max) S.addWeightedClause(lits,max,true);
			else S.addWeightedClause(lits,w,false);
		}
		else {
			if(max >-1 and w>=max) S.addWeightedClause(lits,max,true);
			else S.addUnitSoftClauses(lits[0],w);
		}
	    }
	}

		
    }
}
예제 #7
0
bool SimpSMTSolver::eliminateVar(Var v, bool fail)
{
  if (!fail && asymm_mode && !asymmVar(v))    return false;

  const vec<Clause*>& cls = getOccurs(v);

  //  if (value(v) != l_Undef || cls.size() == 0) return true;
  if (value(v) != l_Undef) return true;

  // Split the occurrences into positive and negative:
  vec<Clause*>  pos, neg;
  for (int i = 0; i < cls.size(); i++)
    (find(*cls[i], Lit(v)) ? pos : neg).push(cls[i]);

  // Check if number of clauses decreases:
  int cnt = 0;
  for (int i = 0; i < pos.size(); i++)
    for (int j = 0; j < neg.size(); j++)
      if (merge(*pos[i], *neg[j], v) && ++cnt > cls.size() + grow)
	return true;
#ifdef PEDANTIC_DEBUG
  cerr << "XXY gonna-remove" << endl;
#endif
  // Delete and store old clauses:
  setDecisionVar(v, false);
  elimtable[v].order = elimorder++;
  assert(elimtable[v].eliminated.size() == 0);
  for (int i = 0; i < cls.size(); i++)
  {
    elimtable[v].eliminated.push(Clause_new(*cls[i]));
    removeClause(*cls[i]);
  }

  // Produce clauses in cross product:
  int top = clauses.size();
  vec<Lit> resolvent;
  for (int i = 0; i < pos.size(); i++)
    for (int j = 0; j < neg.size(); j++)
      if (merge(*pos[i], *neg[j], v, resolvent) && !addClause(resolvent))
	return false;

  // DEBUG: For checking that a clause set is saturated with respect to variable elimination.
  //        If the clause set is expected to be saturated at this point, this constitutes an
  //        error.
  if (fail){
    reportf("eliminated var %d, %d <= %d\n", v+1, cnt, cls.size());
    reportf("previous clauses:\n");
    for (int i = 0; i < cls.size(); i++){
      printClause(*cls[i]); reportf("\n"); }
    reportf("new clauses:\n");
    for (int i = top; i < clauses.size(); i++){
      printClause(*clauses[i]); reportf("\n"); }
    assert(0); }

    return backwardSubsumptionCheck();
}
예제 #8
0
파일: ec_log.c 프로젝트: tfarina/rsc
void info(const char *fmt, ...) {
    va_list args;

    va_start(args, fmt);
    reportf("", fmt, args);
    va_end(args);
}
예제 #9
0
bool PbSolver::convertPbs(void)
{
    vec<Formula> fs;
    vec<Lit>     ts;

    if (!rewriteAlmostClauses())
        return false;

    // construct formulas for all constraints
    for (int i = 0; i < constrs.size(); i++){
        if (constrs[i] == NULL) continue;

        /**/reportf("---[%4d]---> ", constrs.size() - 1 - i);
        linearAddition2(*constrs[i], fs);
    }

    clausify(sat_solver,fs,ts);

    for (int i = 0; i < ts.size(); i++)
        sat_solver.addUnit(ts[i]);

    constrs.clear();
    mem.clear();

    return sat_solver.okay();
}
예제 #10
0
파일: ec_log.c 프로젝트: tfarina/rsc
void warning(const char *fmt, ...) {
    va_list args;

    va_start(args, fmt);
    reportf("warning: ", fmt, args);
    va_end(args);
}
예제 #11
0
파일: ec_log.c 프로젝트: tfarina/rsc
void error(const char *fmt, ...) {
    va_list args;

    va_start(args, fmt);
    reportf("error: ", fmt, args);
    va_end(args);
}
예제 #12
0
// Backward subsumption + backward subsumption resolution
bool SimpSolver::backwardSubsumptionCheck(bool verbose)
{
    int cnt = 0;
    int subsumed = 0;
    int deleted_literals = 0;
    assert(decisionLevel() == 0);

    while (subsumption_queue.size() > 0 || bwdsub_assigns < trail.size()){

        // Check top-level assignments by creating a dummy clause and placing it in the queue:
        if (subsumption_queue.size() == 0 && bwdsub_assigns < trail.size()){
            Lit l = trail[bwdsub_assigns++];
            (*bwdsub_tmpunit)[0] = l;
            bwdsub_tmpunit->calcAbstraction();
            assert(bwdsub_tmpunit->mark() == 0);
            subsumption_queue.insert(bwdsub_tmpunit); }

        Clause&  c = *subsumption_queue.peek(); subsumption_queue.pop();

        if (c.mark()) continue;

        if (verbose && verbosity >= 2 && cnt++ % 1000 == 0)
            reportf("subsumption left: %10d (%10d subsumed, %10d deleted literals)\r", subsumption_queue.size(), subsumed, deleted_literals);

        assert(c.size() > 1 || value(c[0]) == l_True);    // Unit-clauses should have been propagated before this point.

        // Find best variable to scan:
        Var best = var(c[0]);
        for (int i = 1; i < c.size(); i++)
            if (occurs[var(c[i])].size() < occurs[best].size())
                best = var(c[i]);

        // Search all candidates:
        vec<Clause*>& _cs = getOccurs(best);
        Clause**       cs = (Clause**)_cs;

        for (int j = 0; j < _cs.size(); j++)
            if (c.mark())
                break;
            else if (!cs[j]->mark() && cs[j] != &c){
                Lit l = c.subsumes(*cs[j]);

                if (l == lit_Undef)
                    subsumed++, removeClause(*cs[j]);
                else if (l != lit_Error){
                    deleted_literals++;

                    if (!strengthenClause(*cs[j], ~l))
                        return false;

                    // Did current candidate get deleted from cs? Then check candidate at index j again:
                    if (var(l) == best)
                        j--;
                }
            }
    }

    return true;
}
예제 #13
0
  static int parseDecimal(B& in, int& nbDec=0) {
    int     val = 0;
    if (*in < '0' || *in > '9') reportf("PARSE ERROR! (parseDecimal) Unexpected char: %c\n", *in), exit(3);
    while (*in >= '0' && *in <= '9')
      val = val*10 + (*in - '0'),
	++in, ++nbDec;
    return val;
  }
예제 #14
0
파일: ec_log.c 프로젝트: tfarina/rsc
void fatal(const char *fmt, ...) {
    va_list args;

    va_start(args, fmt);
    reportf("fatal: ", fmt, args);
    va_end(args);

    exit(EXIT_FAILURE);
}
예제 #15
0
bool PbSolver::convertPbs(bool first_call)
{
    vec<Formula>    converted_constrs;

    if (first_call){
        findIntervals();
        if (!rewriteAlmostClauses()){
            ok = false;
            return false; }
    }

    for (int i = 0; i < constrs.size(); i++){
        if (constrs[i] == NULL) continue;
        Linear& c   = *constrs[i]; assert(c.lo != Int_MIN || c.hi != Int_MAX);

        if (options->opt_verbosity >= 1)
            /**/reportf("---[%4d]---> ", constrs.size() - 1 - i);

        if (options->opt_convert == ct_Sorters) {
            if (options->opt_dump) { // no formulae built
                buildConstraint(c,primesLoader, options);
            } else {
                converted_constrs.push(buildConstraint(c,primesLoader, options));
            }
        }
        else if (options->opt_convert == ct_Adders)
            linearAddition(c, converted_constrs, options->opt_verbosity);
        else if (options->opt_convert == ct_BDDs)
            converted_constrs.push(convertToBdd(c, options->opt_verbosity));
        else if (options->opt_convert == ct_Mixed){
            int adder_cost = estimatedAdderCost(c);
            //**/printf("estimatedAdderCost: %d\n", estimatedAdderCost(c));
            Formula result = convertToBdd(c, options->opt_verbosity, (int)(adder_cost * options->opt_bdd_thres));
            if (result == _undef_)
                result = buildConstraint(c,primesLoader, options, (int)(adder_cost * options->opt_sort_thres));
            if (result == _undef_)
                linearAddition(c, converted_constrs, options->opt_verbosity);
            else
                converted_constrs.push(result);
        }else
            assert(false);

        if (!ok) return false;
    }

    if (!options->opt_validateResoult) cleanPBC();
	
	formulaSize = converted_constrs.size();
	
    clausify(*sat_solver, options, converted_constrs);
    
    if (options->opt_dump) {
        exit(0);
    }

    return ok;
}
예제 #16
0
void PbSolver::findIntervals()
{
    if (opt_verbosity >= 1)
        reportf("  -- Detecting intervals from adjacent constraints: ");

    bool found = false;
    int i = 0;
    Linear* prev;
    for (; i < constrs.size() && constrs[i] == NULL; i++);
    if (i < constrs.size()){
        prev = constrs[i++];
        for (; i < constrs.size(); i++){
            if (constrs[i] == NULL) continue;
            Linear& c = *prev;
            Linear& d = *constrs[i];

            if (lhsEq(c, d)){
                if (d.lo < c.lo) d.lo = c.lo;
                if (d.hi > c.hi) d.hi = c.hi;
                constrs[i-1] = NULL;
                if (opt_verbosity >= 1) reportf("=");
                found = true;
            }
            if (lhsEqc(c, d)){
                Int sum = 0;
                for (int j = 0; j < c.size; j++)
                    sum += c(j);
                Int lo = (c.hi == Int_MAX) ? Int_MIN : sum - c.hi;
                Int hi = (c.lo == Int_MIN) ? Int_MAX : sum - c.lo;
                if (d.lo < lo) d.lo = lo;
                if (d.hi > hi) d.hi = hi;
                constrs[i-1] = NULL;
                if (opt_verbosity >= 1) reportf("#");
                found = true;
            }

            prev = &d;
        }
    }
    if (opt_verbosity >= 1) {
        if (!found) reportf("(none)\n");
        else        reportf("\n");
    }
}
예제 #17
0
void Solver::verifyModel()
{
  for (int i = 0; i < clauses.size(); i++){
    Clause& c = *clauses[i];
    for (int j = 0; j < c.size(); j++)
      if (modelValue(c[j]) == l_True)
	goto next;

    reportf("unsatisfied clause: ");
    printClause(*clauses[i]);
    reportf("\n");
    // bool failed = false;
    // failed = true;
  next:;
  }


  //  reportf("Verified %d original clauses.\n", clauses.size());
}
예제 #18
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
}
예제 #19
0
파일: Main.C 프로젝트: pmatos/maxsatzilla
static int parseInt(B& in) {
    int     val = 0;
    bool    neg = false;
    skipWhitespace(in);
    if      (*in == '-') neg = true, ++in;
    else if (*in == '+') ++in;
    if (*in < '0' || *in > '9') reportf("PARSE ERROR! Unexpected char: %c\n", *in), exit(3);
    while (*in >= '0' && *in <= '9')
        val = val*10 + (*in - '0'),
        ++in;
    return neg ? -val : val; }
예제 #20
0
파일: Main.C 프로젝트: pmatos/maxsatzilla
void printUsage(char** argv)
{
    reportf("USAGE: %s [options] <input-file> <result-output-file>\n\n  where input may be either in plain or gzipped DIMACS.\n\n", argv[0]);
    reportf("OPTIONS:\n\n");
    reportf("  -polarity-mode = {true,false,rnd}\n");
    reportf("  -decay         = <num> [ 0 - 1 ]\n");
    reportf("  -rnd-freq      = <num> [ 0 - 1 ]\n");
    reportf("  -verbosity     = {0,1,2}\n");
    reportf("\n");
}
예제 #21
0
void MiniSATP::verifyModel()
{
    bool failed = false;
    for (int i = 0; i < clauses.size(); i++){
        assert(clauses[i]->mark() == 0);
        Clause& c = *clauses[i];
        for (int j = 0; j < c.size(); j++)
            if (modelValue(c[j]) == l_True)
                goto next;

        reportf("unsatisfied clause: ");
        printClause(*clauses[i]);
        reportf("\n");
        failed = true;
    next:;
    }

    assert(!failed);

    // Modified Line
    //reportf("Verified %d original clauses.\n", clauses.size());
}
예제 #22
0
파일: Main.C 프로젝트: pmatos/maxsatzilla
static void parse_DIMACS_main(B& in, Solver& S) {
    vec<Lit> lits;
    for (;;){
        skipWhitespace(in);
        if (*in == EOF)
            break;
        else if (*in == 'p'){
            if (match(in, "p cnf")){
                int vars    = parseInt(in);
                int clauses = parseInt(in);
                reportf("|  Number of variables:  %-12d                                         |\n", vars);
                reportf("|  Number of clauses:    %-12d                                         |\n", clauses);
            }else{
                reportf("PARSE ERROR! Unexpected char: %c\n", *in), exit(3);
            }
        } else if (*in == 'c' || *in == 'p')
            skipLine(in);
        else
            readClause(in, S, lits),
            S.addClause(lits);
    }
}
예제 #23
0
void printStats(SolverStats& stats, double cpu_time)
{
    reportf("restarts              : %"I64_fmt"\n", stats.starts);
    reportf("conflicts             : %-12"I64_fmt"   (%.0f /sec)\n", stats.conflicts   , stats.conflicts   /cpu_time);
    reportf("decisions             : %-12"I64_fmt"   (%.0f /sec)\n", stats.decisions   , stats.decisions   /cpu_time);
    reportf("propagations          : %-12"I64_fmt"   (%.0f /sec)\n", stats.propagations, stats.propagations/cpu_time);
    reportf("inspects              : %-12"I64_fmt"   (%.0f /sec)\n", stats.inspects    , stats.inspects    /cpu_time);
    reportf("conflict literals     : %-12"I64_fmt"   (%4.2f %% deleted)\n", stats.tot_literals,
           (stats.max_literals - stats.tot_literals)*100 / (double)stats.max_literals);
    reportf("CPU time              : %g s\n", cpu_time);
}
예제 #24
0
파일: Solver.C 프로젝트: lokdlok/Numberjack
lbool Solver::solve(const vec<Lit>& assumps)
{
  //start_time = getRunTime();

    model.clear();
    conflict.clear();

    if (!ok) return false;

    assumps.copyTo(assumptions);

    double  nof_conflicts = restart_first;
    double  nof_learnts   = nClauses() * learntsize_factor;
    lbool   status        = l_Undef;

    if (verbosity >= 1){
        reportf("============================[ Search Statistics ]==============================\n");
        reportf("| Conflicts |          ORIGINAL         |          LEARNT          | Progress |\n");
        reportf("|           |    Vars  Clauses Literals |    Limit  Clauses Lit/Cl |          |\n");
        reportf("===============================================================================\n");
    }

    // Search:
    bool reached_limit = false;
    while (status == l_Undef && !reached_limit){
        if (verbosity >= 1)
            reportf("| %9d | %7d %8d %8d | %8d %8d %6.0f | %6.3f %% |\n", (int)conflicts, order_heap.size(), nClauses(), (int)clauses_literals, (int)nof_learnts, nLearnts(), (double)learnts_literals/nLearnts(), progress_estimate*100), fflush(stdout);
        status = search((int)nof_conflicts, (int)nof_learnts);

      reached_limit = limitsExpired();

        nof_conflicts *= restart_inc;
        nof_learnts   *= learntsize_inc;
    }

 
    if (verbosity >= 1)
        reportf("===============================================================================\n");


    if (status == l_True){
        // Extend & copy model:
        model.growTo(nVars());
        for (int i = 0; i < nVars(); i++) model[i] = value(i);
#ifndef NDEBUG
        verifyModel();
#endif
    }else if(status == l_False) {
      //assert(status == l_False);
      if (conflict.size() == 0)
	ok = false;
    } // else {

//       // limit reached
//     }

    //cancelUntil(init_level);
    return status; // == l_True;
}
예제 #25
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);
}
예제 #26
0
     static void parse_MSZ_parameters(B& in,
				      unsigned int& nbSolvers,
				      unsigned int& nbFeatures,
				      unsigned int& nbInstances,
				      unsigned int& timeOut, 			       
				      string*& solversNames,
				      string*& featuresNames,
				      string*& instancesNames,
				      double**& matrix) {
    ++in;++in;
    if ( match(in, "msz") ) {
      nbSolvers = parseInt(in);
      solversNames=new string [nbSolvers];
      nbFeatures = parseInt(in);
      featuresNames=new string [nbFeatures];
      nbInstances = parseInt(in);
      instancesNames=new string [nbInstances];
      
      const int nbCases = nbSolvers+nbFeatures;
      matrix=new double* [nbInstances];
      for (unsigned int i=0; i<nbInstances; i++)
	matrix[i]=new double [nbCases];
      timeOut = parseInt(in);
      reportf("c Number of solvers:    %2d\n", nbSolvers);
      reportf("c Number of features:   %2d\n", nbFeatures);
      reportf("c Number of instances:  %2d\n", nbInstances);
      reportf("c Timeout:              %2d\n", timeOut);
    } else if ( match(in, "slv") ) {
      reportf("c Solvers:");
      for (unsigned int i=0; i<nbSolvers; i++) {
	readWord(in,solversNames[i]);
	reportf(" %s", solversNames[i].c_str());
      }
      reportf("\n");
    }
    else if ( match(in, "ftr") ) {
      //reportf("c Features:");
      for (unsigned int i=0; i<nbFeatures; i++) {
	readWord(in,featuresNames[i]);
	//reportf(" %s", featuresNames[i].c_str());
      }
      //reportf("\n");
    }
    else reportf("PARSE ERROR! (parse_MSZ) Unexpected params chars: %c %c %c\n", *in, *in, *in), exit(3);
  }
예제 #27
0
파일: type_string.c 프로젝트: miklos1/scene
static obj_t substring_fn(obj_t args, Reporter rep)
{
	string str;
	long start, end;

	if (!args_match(rep, args, 3, is_string, is_num, is_num))
		return unspecific;
	str   = fetch_string(list_ref(args, 0));
	start = fetch_num(list_ref(args, 1));
	end   = fetch_num(list_ref(args, 2));

	if (!(0 <= start && start <= end && end <= (long)str->len)) {
		reportf(rep, "substring: invalid range [%d, %d)", start, end);
		return unspecific;
	}
	return make_string(string_from(str->data + start, end - start));
}
예제 #28
0
lbool Solver::solve(const vec<Lit>& assumps)
{
  model.clear();
  conflict.clear();

  if (!ok) {
    return false;
  }

  assumps.copyTo(assumptions);

  double  nof_conflicts = restart_first;
  double  nof_learnts   = nClauses() * learntsize_factor;
  lbool   status        = l_Undef;

  if (verbosity >= 1){
    reportf("============================[ Search Statistics ]==============================\n");
    reportf("| Conflicts |          ORIGINAL         |          LEARNT          | Progress |\n");
    reportf("|           |    Vars  Clauses Literals |    Limit  Clauses Lit/Cl |          |\n");
    reportf("===============================================================================\n");
  }

  // Search:
  while (status == l_Undef){
    if (verbosity >= 1)
      reportf("| .%9d. | .%7d. .%8d. .%8d. | .%8d. .%8d. .%6.0f. | .%6.3f. %% |\n", (int)conflicts, order_heap.size(), nClauses(), (int)clauses_literals, (int)nof_learnts, nLearnts(), (double)learnts_literals/nLearnts(), progress_estimate*100), fflush(stdout);
    status = search((int)nof_conflicts, (int)nof_learnts);
    nof_conflicts *= restart_inc;
    nof_learnts   *= learntsize_inc;
  }

  if (verbosity >= 1)
    reportf("===============================================================================\n");


  if (status == l_True){
    // Extend & copy model:
    model.growTo(nVars());
    for (int i = 0; i < nVars(); i++) 
      model[i] = value(i);
    //    printTrail();
#ifdef _DEBUG
    verifyModel();
#endif
  }else{
    if (conflict.size() == 0) {
      ok = false;
    }
  }

  //  cancelUntil(0);
  return status;
}
예제 #29
0
파일: PbParser.C 프로젝트: bytekid/mkbtt
static bool parse_PB(B& in, S& solver, bool abort_on_error)
{
    try{
        parseSize(in, solver);
        parseGoal(in, solver);
        return parseConstrs(in, solver);
    }catch (cchar* msg){
        if (abort_on_error){
            reportf("PARSE ERROR! [line %d] %s\n", in.line, msg);
            xfree(msg);
            if (opt_satlive && !opt_try)
                printf("s UNKNOWN\n");
            exit(opt_try ? 5 : 0);
        }else
            throw msg;
    }

}
예제 #30
0
파일: type_string.c 프로젝트: miklos1/scene
static obj_t string_ref_fn(obj_t args, Reporter rep)
{
	obj_t obj, idx;
	long k;

	if (!args_match(rep, args, 2, is_string, is_num))
		return unspecific;
	obj = list_ref(args, 0);
	idx = list_ref(args, 1);

	k = fetch_num(idx);
	if (k < 0 || (size_t)k >= fetch_string(obj)->len) {
		reportf(rep, "string-ref: index %ld is out of range", k);
		return unspecific;
	}

	return make_char(fetch_string(obj)->data[k]);
}