use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class ThreeColouringRandomGraphTest method testThreeColouring.
private void testThreeColouring(int nVertices, int nEdges, RegressionTestConfig cfg) {
ASPCore2Program tmpPrg = new ProgramParserImpl().parse("blue(N) :- v(N), not red(N), not green(N)." + "red(N) :- v(N), not blue(N), not green(N)." + "green(N) :- v(N), not red(N), not blue(N)." + ":- e(N1,N2), blue(N1), blue(N2)." + ":- e(N1,N2), red(N1), red(N2)." + ":- e(N1,N2), green(N1), green(N2).");
InputProgram.Builder prgBuilder = InputProgram.builder(tmpPrg);
prgBuilder.addFacts(createVertices(nVertices));
prgBuilder.addFacts(createEdges(nVertices, nEdges));
InputProgram program = prgBuilder.build();
maybeShuffle(program);
@SuppressWarnings("unused") Optional<AnswerSet> answerSet = buildSolverForRegressionTest(program, cfg).stream().findAny();
// System.out.println(answerSet);
// TODO: check correctness of answer set
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class ParserTest method parseChoiceRule.
@Test
public void parseChoiceRule() {
ASPCore2Program parsedProgram = parser.parse("dom(1). dom(2). { a ; b } :- dom(X).");
ChoiceHead choiceHead = (ChoiceHead) parsedProgram.getRules().get(0).getHead();
assertEquals(2, choiceHead.getChoiceElements().size());
assertTrue(choiceHead.getChoiceElements().get(0).getChoiceAtom().toString().equals("a"));
assertTrue(choiceHead.getChoiceElements().get(1).getChoiceAtom().toString().equals("b"));
assertEquals(null, choiceHead.getLowerBound());
assertEquals(null, choiceHead.getUpperBound());
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class ParserTest method parseChoiceRuleBounded.
@Test
public void parseChoiceRuleBounded() {
ASPCore2Program parsedProgram = parser.parse("dom(1). dom(2). 1 < { a: p(v,w), not r; b } <= 13 :- dom(X). foo.");
ChoiceHead choiceHead = (ChoiceHead) parsedProgram.getRules().get(0).getHead();
assertEquals(2, choiceHead.getChoiceElements().size());
assertTrue(choiceHead.getChoiceElements().get(0).getChoiceAtom().toString().equals("a"));
assertTrue(choiceHead.getChoiceElements().get(1).getChoiceAtom().toString().equals("b"));
List<Literal> conditionalLiterals = choiceHead.getChoiceElements().get(0).getConditionLiterals();
assertEquals(2, conditionalLiterals.size());
assertFalse(conditionalLiterals.get(0).isNegated());
assertTrue(conditionalLiterals.get(1).isNegated());
assertEquals(Terms.newConstant(1), choiceHead.getLowerBound());
assertEquals(ComparisonOperators.LT, choiceHead.getLowerOperator());
assertEquals(Terms.newConstant(13), choiceHead.getUpperBound());
assertEquals(ComparisonOperators.LE, choiceHead.getUpperOperator());
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class ParserTest method parseBuiltinAtom.
@Test
public void parseBuiltinAtom() {
ASPCore2Program parsedProgram = parser.parse("a :- p(X), X != Y, q(Y).");
assertEquals(1, parsedProgram.getRules().size());
assertEquals(3, parsedProgram.getRules().get(0).getBody().size());
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class ParserTest method parseEnumerationDirective.
@Test
public void parseEnumerationDirective() {
ASPCore2Program parsedProgram = parser.parse("p(a,1)." + "# enumeration_predicate_is mune." + "r(X) :- p(X), mune(X)." + "p(b,2).");
String directive = parsedProgram.getInlineDirectives().getDirectiveValue(InlineDirectives.DIRECTIVE.enum_predicate_is);
assertEquals("mune", directive);
}
Aggregations