Search in sources :

Example 56 with AnswerSet

use of at.ac.tuwien.kr.alpha.api.AnswerSet 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))));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Predicate(at.ac.tuwien.kr.alpha.api.programs.Predicate) Test(org.junit.jupiter.api.Test)

Example 57 with AnswerSet

use of at.ac.tuwien.kr.alpha.api.AnswerSet 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))));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Predicate(at.ac.tuwien.kr.alpha.api.programs.Predicate) Test(org.junit.jupiter.api.Test)

Example 58 with AnswerSet

use of at.ac.tuwien.kr.alpha.api.AnswerSet 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))));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Predicate(at.ac.tuwien.kr.alpha.api.programs.Predicate) Test(org.junit.jupiter.api.Test)

Example 59 with AnswerSet

use of at.ac.tuwien.kr.alpha.api.AnswerSet 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)));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Predicate(at.ac.tuwien.kr.alpha.api.programs.Predicate) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 60 with AnswerSet

use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.

the class HeadBodyTransformationTests method test.

private void test(ASPCore2Program program, RegressionTestConfig cfg) {
    Solver solver = TestUtils.buildSolverForRegressionTest(program, cfg);
    Optional<AnswerSet> answerSet = solver.stream().findFirst();
    assertFalse(answerSet.isPresent());
}
Also used : Solver(at.ac.tuwien.kr.alpha.api.Solver) AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet)

Aggregations

AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)80 Test (org.junit.jupiter.api.Test)64 Alpha (at.ac.tuwien.kr.alpha.api.Alpha)25 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)24 AnswerSetBuilder (at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder)20 InputConfig (at.ac.tuwien.kr.alpha.api.config.InputConfig)17 Predicate (at.ac.tuwien.kr.alpha.api.programs.Predicate)14 Atom (at.ac.tuwien.kr.alpha.api.programs.atoms.Atom)14 HashSet (java.util.HashSet)13 CompiledProgram (at.ac.tuwien.kr.alpha.core.programs.CompiledProgram)10 ProgramParserImpl (at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl)9 Solver (at.ac.tuwien.kr.alpha.api.Solver)8 InputProgram (at.ac.tuwien.kr.alpha.core.programs.InputProgram)7 Disabled (org.junit.jupiter.api.Disabled)7 SystemConfig (at.ac.tuwien.kr.alpha.api.config.SystemConfig)4 ProgramParser (at.ac.tuwien.kr.alpha.api.programs.ProgramParser)4 ConstantTerm (at.ac.tuwien.kr.alpha.api.terms.ConstantTerm)4 TestUtils.assertRegressionTestAnswerSet (at.ac.tuwien.kr.alpha.core.test.util.TestUtils.assertRegressionTestAnswerSet)4 TestUtils.buildSolverForRegressionTest (at.ac.tuwien.kr.alpha.core.test.util.TestUtils.buildSolverForRegressionTest)4 HashMap (java.util.HashMap)4