Пример #1
0
static SatProblem* DpsToSat(SatData *s)
{
	SatProblem *s = new SatProblem(s->m_nVars, s->m_nConjunctions);
	VarData *vd = s->m_conjunctions;

	for(int i=0; i<s->m_nConjunctions; ++i) {
		Conjunction c = new Conjunction();
		for(int j=0; j<Conjunction::Size; ++j, ++vd) {
			c[j] = Conjunct(vd->m_varId, vd->m_isInverted);
		}
	}

	return s;
}
Пример #2
0
    std::vector<Conjunct> NextSmallCnf() {
	try {
	    if (next_cnf_number_ >= (1 << (4 * variables_amount_ * variables_amount_)) )
		throw std::logic_error("FAIL in generating cnf");

	    std::vector<Conjunct> next_cnf;
	    std::vector<Edge> next_list_of_edges = list_of_edges_generator_.NextSmallListOfEdges();
	    for (int i = 0; i < next_list_of_edges.size(); ++i) {
	        next_cnf.push_back(Conjunct(next_list_of_edges[i].begin_ / 2, next_list_of_edges[i].end_ / 2, 
						next_list_of_edges[i].begin_ % 2, next_list_of_edges[i].end_ % 2));
	    }
	    next_cnf_number_++;
	    return next_cnf;;
        } catch (const std::exception& ex) {
            throw std::logic_error(std::string(ex.what()));
        }
    }