use of at.ac.tuwien.kr.alpha.api.programs.Predicate in project Alpha by alpha-asp.
the class ThreeColouringWheelTest method fact.
private Atom fact(String predicateName, int... iTerms) {
List<Term> terms = new ArrayList<>(1);
Predicate predicate = Predicates.getPredicate(predicateName, iTerms.length);
for (int i : iTerms) {
terms.add(Terms.newConstant(i));
}
return Atoms.newBasicAtom(predicate, terms);
}
use of at.ac.tuwien.kr.alpha.api.programs.Predicate in project Alpha by alpha-asp.
the class AggregateRewritingTest method graphVerticesOfMaxDegree.
@Test
public // Test "count eq" and "max eq" together with global vars
void graphVerticesOfMaxDegree() {
List<AnswerSet> answerSets = NORMALIZE_AND_SOLVE.apply(NUM_MAX_DEGREE_VERTICES_ASP);
assertEquals(1, answerSets.size());
AnswerSet answerSet = answerSets.get(0);
Predicate maxDegreeVertices = Predicates.getPredicate("graph_max_degree_vertices", 3);
// System.out.println(new SimpleAnswerSetFormatter("\n").format(answerSet));
assertTrue(answerSet.getPredicates().contains(maxDegreeVertices));
assertTrue(answerSet.getPredicateInstances(maxDegreeVertices).contains(Atoms.newBasicAtom(maxDegreeVertices, Terms.newSymbolicConstant("g1"), Terms.newConstant(2), Terms.newConstant(3))));
}
use of at.ac.tuwien.kr.alpha.api.programs.Predicate in project Alpha by alpha-asp.
the class AggregateRewritingTest method greaterMin.
@Test
public void greaterMin() {
List<AnswerSet> answerSets = NORMALIZE_AND_SOLVE.apply(MIN_GT1_ASP);
assertEquals(1, answerSets.size());
AnswerSet answerSet = answerSets.get(0);
Predicate greaterMin = Predicates.getPredicate("greater_min_acceptable", 1);
// System.out.println(new SimpleAnswerSetFormatter("\n").format(answerSet));
assertTrue(answerSet.getPredicates().contains(greaterMin));
assertTrue(answerSet.getPredicateInstances(greaterMin).contains(Atoms.newBasicAtom(greaterMin, Terms.newConstant(7))));
assertTrue(answerSet.getPredicateInstances(greaterMin).contains(Atoms.newBasicAtom(greaterMin, Terms.newConstant(13))));
}
use of at.ac.tuwien.kr.alpha.api.programs.Predicate in project Alpha by alpha-asp.
the class AggregateRewritingTest method sumLessOrEqual1.
@Test
public void sumLessOrEqual1() {
List<AnswerSet> answerSets = NORMALIZE_AND_SOLVE.apply(SUM_LE1_ASP);
assertEquals(1, answerSets.size());
AnswerSet answerSet = answerSets.get(0);
Predicate boundLe = Predicates.getPredicate("bound_le_sum", 1);
// System.out.println(new SimpleAnswerSetFormatter("\n").format(answerSet));
assertTrue(answerSet.getPredicates().contains(boundLe));
assertTrue(answerSet.getPredicateInstances(boundLe).contains(Atoms.newBasicAtom(boundLe, Terms.newConstant(11))));
}
use of at.ac.tuwien.kr.alpha.api.programs.Predicate in project Alpha by alpha-asp.
the class AggregateRewritingTest method setComplexEqualityWithGlobals.
@Test
@Disabled("Open issue, as dependency analysis includes cyclic output-dependency, which it should not.")
public void setComplexEqualityWithGlobals() {
List<AnswerSet> answerSets = NORMALIZE_AND_SOLVE.apply(COMPLEX_EQUALITY_WITH_GLOBALS);
assertEquals(1, answerSets.size());
AnswerSet answerSet = answerSets.get(0);
Predicate q = Predicates.getPredicate("q", 0);
// System.out.println(new SimpleAnswerSetFormatter("\n").format(answerSet));
assertTrue(answerSet.getPredicates().contains(q));
assertTrue(answerSet.getPredicateInstances(q).contains(Atoms.newBasicAtom(q)));
}
Aggregations