Search in sources :

Example 76 with AnswerSet

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"));
        }
    }
}
Also used : ASPCore2Program(at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program) AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Alpha(at.ac.tuwien.kr.alpha.api.Alpha) ConstantTerm(at.ac.tuwien.kr.alpha.api.terms.ConstantTerm) Atom(at.ac.tuwien.kr.alpha.api.programs.atoms.Atom) Test(org.junit.jupiter.api.Test)

Example 77 with AnswerSet

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

Example 78 with AnswerSet

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

Example 79 with AnswerSet

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

Example 80 with AnswerSet

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

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