Search in sources :

Example 21 with AnswerSetBuilder

use of at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder in project Alpha by alpha-asp.

the class AlphaImplTest method withExternalSubtype.

@Test
public void withExternalSubtype() throws Exception {
    SubThingy thingy = new SubThingy();
    BasicRule rule = new BasicRule(Heads.newNormalHead(Atoms.newBasicAtom(Predicates.getPredicate("p", 1), Terms.newConstant("x"))), singletonList(Literals.fromAtom(Atoms.newExternalAtom(Predicates.getPredicate("thinger", 1), new MethodPredicateInterpretation(this.getClass().getMethod("thinger", Thingy.class)), singletonList(Terms.newConstant(thingy)), emptyList()), true)));
    Alpha system = new AlphaImpl();
    InputProgram prog = new InputProgram(singletonList(rule), emptyList(), new InlineDirectivesImpl());
    Set<AnswerSet> actual = system.solve(prog).collect(Collectors.toSet());
    Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("p").instance("x").build()));
    assertEquals(expected, actual);
}
Also used : BasicRule(at.ac.tuwien.kr.alpha.core.rules.BasicRule) AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Alpha(at.ac.tuwien.kr.alpha.api.Alpha) MethodPredicateInterpretation(at.ac.tuwien.kr.alpha.core.common.fixedinterpretations.MethodPredicateInterpretation) AnswerSetBuilder(at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder) InlineDirectivesImpl(at.ac.tuwien.kr.alpha.core.parser.InlineDirectivesImpl) InputProgram(at.ac.tuwien.kr.alpha.core.programs.InputProgram) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

AnswerSetBuilder (at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder)21 AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)20 Test (org.junit.jupiter.api.Test)20 Alpha (at.ac.tuwien.kr.alpha.api.Alpha)12 HashSet (java.util.HashSet)12 InputConfig (at.ac.tuwien.kr.alpha.api.config.InputConfig)8 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)7 Atom (at.ac.tuwien.kr.alpha.api.programs.atoms.Atom)7 InputProgram (at.ac.tuwien.kr.alpha.core.programs.InputProgram)4 Disabled (org.junit.jupiter.api.Disabled)4 InlineDirectivesImpl (at.ac.tuwien.kr.alpha.core.parser.InlineDirectivesImpl)3 ConstantTerm (at.ac.tuwien.kr.alpha.api.terms.ConstantTerm)2 Predicates (at.ac.tuwien.kr.alpha.commons.Predicates)2 Atoms (at.ac.tuwien.kr.alpha.commons.atoms.Atoms)2 Terms (at.ac.tuwien.kr.alpha.commons.terms.Terms)2 MethodPredicateInterpretation (at.ac.tuwien.kr.alpha.core.common.fixedinterpretations.MethodPredicateInterpretation)2 BasicRule (at.ac.tuwien.kr.alpha.core.rules.BasicRule)2 Path (java.nio.file.Path)2 List (java.util.List)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2