예제 #1
0
파일: minisat.cpp 프로젝트: ogdf/ogdf
static void satisfiableTest()
{
	Minisat::Formula F;
	Minisat::Model model;

	F.addClause(std::vector<int>{-1, -2, -3, 4});

	F.newVars(11);

	for (int i = 1; i < 10; i++) {
		Minisat::clause c = F.newClause();
		if (i % 2 == 0) {
			c->add(i);
		}
		else {
			c->add(-i);
		}
		c->add(i+1);
		F.finalizeClause(c);
	}

	bool satisfiable = F.solve(model);

	AssertThat(satisfiable, IsTrue());
#if 0
	std::cout << "#vars = " << F.getVariableCount() << std::endl;
	std::cout << "#clauses = " << F.getClauseCount() << std::endl;
	if (val) {
		model.printModel();
	}
	F.reset();
#endif
}
예제 #2
0
static void readDIMACSTest()
{
	Minisat::Formula formula;
	AssertThat(formula.readDimacs(RESOURCE_DIR + "/" + "minisat/satisfiable.txt"), IsTrue());
	Minisat::Model model;
	bool satisfiable = formula.solve(model);
	AssertThat(satisfiable, IsTrue());

	formula.addClause(std::vector<int>{3});
	satisfiable = formula.solve(model);
	AssertThat(satisfiable, IsFalse());
}
예제 #3
0
파일: minisat.cpp 프로젝트: ogdf/ogdf
static void readDIMACSTest()
{
	Minisat::Formula formula;
	std::stringstream ss{ResourceFile::get("minisat/satisfiable.txt")->data()};
	AssertThat(formula.readDimacs(ss), IsTrue());
	Minisat::Model model;
	bool satisfiable = formula.solve(model);
	AssertThat(satisfiable, IsTrue());

	formula.addClause(std::vector<int>{3});
	satisfiable = formula.solve(model);
	AssertThat(satisfiable, IsFalse());
}
예제 #4
0
파일: minisat.cpp 프로젝트: ogdf/ogdf
static void nonsatisfiableTest()
{
	Minisat::Formula F;
	Minisat::Model model;
	F.addClause(std::vector<int>{1, 2});
	F.addClause(std::vector<int>{1, -2, 3});
	F.addClause(std::vector<int>{-1, 2});
	F.addClause(std::vector<int>{-1, -2});
	F.addClause(std::vector<int>{-3});

	bool satisfiable = F.solve(model);

	AssertThat(satisfiable, IsFalse());
}