Search in sources :

Example 31 with AnswerSet

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

the class FixedInterpretationLiteralsTest method positiveExternalBindingOutput.

@Test
public void positiveExternalBindingOutput() {
    Optional<AnswerSet> answer = this.alpha.solve(this.alpha.readProgramString(TEST_PROG, this.externals)).findFirst();
    assertTrue(answer.isPresent());
    AnswerSet answerSet = answer.get();
    Predicate pred = Predicates.getPredicate("positive_external_binding_output", 2);
    assertTrue(answerSet.getPredicates().contains(pred));
    Set<Atom> instances = answerSet.getPredicateInstances(pred);
    assertEquals(3, instances.size());
    assertTrue(instances.contains(Atoms.newBasicAtom(pred, Terms.newConstant("Klagenfurt"), Terms.newConstant("Villach"))));
    assertTrue(instances.contains(Atoms.newBasicAtom(pred, Terms.newConstant("Klagenfurt"), Terms.newConstant("Graz"))));
    assertTrue(instances.contains(Atoms.newBasicAtom(pred, Terms.newConstant("Villach"), Terms.newConstant("Salzburg"))));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Atom(at.ac.tuwien.kr.alpha.api.programs.atoms.Atom) Predicate(at.ac.tuwien.kr.alpha.api.programs.Predicate) Test(org.junit.jupiter.api.Test)

Example 32 with AnswerSet

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

the class FixedInterpretationLiteralsTest method negativeExternalWithOutputDontfire.

@Test
public void negativeExternalWithOutputDontfire() {
    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_with_output_dontfire", 0)));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Test(org.junit.jupiter.api.Test)

Example 33 with AnswerSet

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

the class FixedInterpretationLiteralsTest method negativeExternalMultioutput.

@Test
public void negativeExternalMultioutput() {
    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_external_multioutput", 0)));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Test(org.junit.jupiter.api.Test)

Example 34 with AnswerSet

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

the class FixedInterpretationLiteralsTest method positiveExternalMultioutputDontfire.

@Test
public void positiveExternalMultioutputDontfire() {
    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("positive_external_multioutput_dontfire", 0)));
}
Also used : AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Test(org.junit.jupiter.api.Test)

Example 35 with AnswerSet

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

the class FixedInterpretationLiteralsTest method positiveExternalWithOutput.

@Test
public void positiveExternalWithOutput() {
    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_with_output", 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