Search in sources :

Example 21 with InputConfig

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

the class AlphaImplTest method noInput.

@Test
public void noInput() throws Exception {
    Alpha system = new AlphaImpl();
    InputConfig cfg = InputConfig.forString("node(1). a :- &bestNode(X), node(X).");
    cfg.addPredicateMethod("bestNode", Externals.processPredicateMethod(this.getClass().getMethod("bestNode")));
    ASPCore2Program prog = system.readProgram(cfg);
    Set<AnswerSet> expected = AnswerSetsParser.parse("{ node(1), a }");
    Set<AnswerSet> actual = system.solve(prog).collect(Collectors.toSet());
    assertEquals(expected, actual);
}
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) InputConfig(at.ac.tuwien.kr.alpha.api.config.InputConfig) Test(org.junit.jupiter.api.Test)

Example 22 with InputConfig

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

the class AlphaImplTest method smallGraphNoNeighbors.

@Test
@Disabled("Test program is not safe (external lacking output variables). This should throw some exception.")
public void smallGraphNoNeighbors() throws Exception {
    Alpha system = new AlphaImpl();
    InputConfig cfg = InputConfig.forString("noNeighbors(2) :- not &neighbors[2].");
    cfg.addPredicateMethod("neighbors", Externals.processPredicateMethod(this.getClass().getMethod("neighbors", int.class)));
    ASPCore2Program prog = system.readProgram(cfg);
    Set<AnswerSet> expected = AnswerSetsParser.parse("{ noNeighbors(2) }");
    Set<AnswerSet> actual = system.solve(prog).collect(Collectors.toSet());
    assertEquals(expected, actual);
}
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) InputConfig(at.ac.tuwien.kr.alpha.api.config.InputConfig) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

InputConfig (at.ac.tuwien.kr.alpha.api.config.InputConfig)22 Alpha (at.ac.tuwien.kr.alpha.api.Alpha)20 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)19 Test (org.junit.jupiter.api.Test)18 AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)16 HashSet (java.util.HashSet)8 AnswerSetBuilder (at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder)7 Disabled (org.junit.jupiter.api.Disabled)5 SystemConfig (at.ac.tuwien.kr.alpha.api.config.SystemConfig)4 AlphaConfig (at.ac.tuwien.kr.alpha.api.config.AlphaConfig)3 ParseException (org.apache.commons.cli.ParseException)3 DebugSolvingContext (at.ac.tuwien.kr.alpha.api.DebugSolvingContext)2 Solver (at.ac.tuwien.kr.alpha.api.Solver)2 StatisticsReportingSolver (at.ac.tuwien.kr.alpha.api.StatisticsReportingSolver)2 AlphaImpl (at.ac.tuwien.kr.alpha.api.impl.AlphaImpl)2 CommandLineParser (at.ac.tuwien.kr.alpha.app.config.CommandLineParser)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2