Exemplo n.º 1
0
	void testNLCUnsorted() {
		std::stringstream prg;
		prg << "* #variable= 4 #constraint= 2 #product= 2 sizeproduct= 8\n"
				<< "1 x1 +1 x2 x1 >=1;\n"
			  << "1 x1 +1 x2 x3 x4 ~x4 x2 x3 >=1;\n"
				;
		ObjectiveFunction obj;
		CPPUNIT_ASSERT(parseOPB(prg, ctx, obj));
		CPPUNIT_ASSERT(ctx.numVars() == 6);
		CPPUNIT_ASSERT(ctx.master()->isTrue(posLit(1)));
		CPPUNIT_ASSERT(ctx.master()->isFalse(posLit(6)));
	}
Exemplo n.º 2
0
bool StreamInput::read(Solver& s, ProgramBuilder* api, int numModels) {
	if (format_ == Input::SMODELS) {
		assert(api);
		return parseLparse(prg_, *api);
	}
	else if (format_ == Input::DIMACS) {
		return parseDimacs(prg_, s, numModels == 1);
	}
	else {
		return parseOPB(prg_, s, func_);
	}
}
Exemplo n.º 3
0
	void testPBEqualityBug() {
		std::stringstream prg;
		prg << "* #variable= 4 #constraint= 2\n"
				<< "+1 x1 = 1;\n"
			  << "+1 x1 +1 x2 +1 x3 +1 x4 = 1;\n"
			  ;
		ObjectiveFunction obj;
		CPPUNIT_ASSERT(parseOPB(prg, ctx, obj));
		CPPUNIT_ASSERT(ctx.master()->isTrue(posLit(1)));
		CPPUNIT_ASSERT(ctx.master()->isFalse(posLit(2)));
		CPPUNIT_ASSERT(ctx.master()->isFalse(posLit(3)));
		CPPUNIT_ASSERT(ctx.master()->isFalse(posLit(4)));
	}
Exemplo n.º 4
0
	void testWBO() {
		std::stringstream prg;
		prg << "* #variable= 1 #constraint= 2 #soft= 2 mincost= 2 maxcost= 3 sumcost= 5\n"
				<< "soft: 6 ;\n"
			  << "[2] +1 x1 >= 1 ;\n"
				<< "[3] -1 x1 >= 0 ;\n"
				;
		ObjectiveFunction obj;
		CPPUNIT_ASSERT(parseOPB(prg, ctx, obj));
		CPPUNIT_ASSERT(ctx.numVars() == 3);
		CPPUNIT_ASSERT(ctx.numConstraints() == 0 || ctx.numConstraints() == 2);
		CPPUNIT_ASSERT(ctx.symTab().size() == 2);
	}
Exemplo n.º 5
0
	void testNLC() {
		std::stringstream prg;
		prg << "* #variable= 5 #constraint= 4 #product= 5 sizeproduct= 13\n"
				<< "1 x1 +4 x1 ~x2 -2 x5 >=1;\n"
			  << "-1 x1 +4 x2 -2 x5 >= 3;\n"
				<< "10 x4 +4 x3 >= 10;\n"
				<< "2 x2 x3 +3 x4 ~x5 +2 ~x1 x2 +3 ~x1 x2 x3 ~x4 ~x5 >= 1 ;\n"
				;
		ObjectiveFunction obj;
		CPPUNIT_ASSERT(parseOPB(prg, ctx, obj));
		CPPUNIT_ASSERT(ctx.numVars() == 10);
		CPPUNIT_ASSERT(ctx.numConstraints() > 4);
		CPPUNIT_ASSERT(ctx.symTab().size() == 6);
	}