use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class AlphaImplTest method withNegatedExternal.
@Test
@SuppressWarnings("unchecked")
public void withNegatedExternal() throws IOException {
Alpha alpha = new AlphaImpl();
ASPCore2Program prog = alpha.readProgram(InputConfig.forString(NEGATED_EXTERNAL_ASP));
Set<AnswerSet> answerSets = alpha.solve(prog).collect(Collectors.toSet());
assertEquals(31, answerSets.size());
// Verify every result string has length 6 and contains "foo"
for (AnswerSet as : answerSets) {
for (Atom atom : as.getPredicateInstances(Predicates.getPredicate("resultstring", 1))) {
String resultstring = ((ConstantTerm<String>) atom.getTerms().get(0)).getObject();
LOGGER.debug("ResultString is {}", resultstring);
assertEquals(6, resultstring.length());
assertTrue(resultstring.contains("foo"));
}
}
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class FixedInterpretationLiteralsTest method negativeExternalMultioutputDontfire.
@Test
public void negativeExternalMultioutputDontfire() {
Optional<AnswerSet> answer = this.alpha.solve(this.alpha.readProgramString(TEST_PROG, this.externals)).findFirst();
assertTrue(answer.isPresent());
AnswerSet answerSet = answer.get();
assertFalse(answerSet.getPredicates().contains(Predicates.getPredicate("negative_external_multioutput_dontfire", 0)));
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class FixedInterpretationLiteralsTest method positiveExternalMultioutput.
@Test
public void positiveExternalMultioutput() {
Optional<AnswerSet> answer = this.alpha.solve(this.alpha.readProgramString(TEST_PROG, this.externals)).findFirst();
assertTrue(answer.isPresent());
AnswerSet answerSet = answer.get();
assertTrue(answerSet.getPredicates().contains(Predicates.getPredicate("positive_external_multioutput", 0)));
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class FixedInterpretationLiteralsTest method positiveUnaryExternal.
@Test
public void positiveUnaryExternal() {
Optional<AnswerSet> answer = this.alpha.solve(this.alpha.readProgramString(TEST_PROG, this.externals)).findFirst();
assertTrue(answer.isPresent());
AnswerSet answerSet = answer.get();
assertTrue(answerSet.getPredicates().contains(Predicates.getPredicate("positive_unary_external", 0)));
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class FixedInterpretationLiteralsTest method negativeUnaryExternal.
@Test
public void negativeUnaryExternal() {
Optional<AnswerSet> answer = this.alpha.solve(this.alpha.readProgramString(TEST_PROG, this.externals)).findFirst();
assertTrue(answer.isPresent());
AnswerSet answerSet = answer.get();
assertTrue(answerSet.getPredicates().contains(Predicates.getPredicate("negative_unary_external", 0)));
}
Aggregations