use of at.ac.tuwien.kr.alpha.api.Alpha in project Alpha by alpha-asp.
the class AlphaImplTest method problematicRun.
private void problematicRun(String program, long seed, int limit) throws IOException {
final Path base = Paths.get("src", "test", "resources", "PreviouslyProblematic");
SystemConfig cfg = new SystemConfig();
cfg.setGrounderName("naive");
cfg.setSolverName("default");
cfg.setNogoodStoreName("alpharoaming");
cfg.setDebugInternalChecks(true);
cfg.setSeed(seed);
final Alpha system = new AlphaImpl(cfg);
InputConfig inputCfg = new InputConfig();
List<String> files = new ArrayList<>();
files.add(base.resolve(program).toString());
inputCfg.setFiles(files);
ASPCore2Program prog = system.readProgram(inputCfg);
assertFalse(system.solve(prog).limit(limit).collect(Collectors.toList()).isEmpty());
}
use of at.ac.tuwien.kr.alpha.api.Alpha in project Alpha by alpha-asp.
the class AlphaImplTest method basicUsage.
@Test
public void basicUsage() throws Exception {
Alpha system = new AlphaImpl();
Set<AnswerSet> actual = system.solve(system.readProgram(InputConfig.forString("p(a)."))).collect(Collectors.toSet());
Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("p").symbolicInstance("a").build()));
assertEquals(expected, actual);
}
use of at.ac.tuwien.kr.alpha.api.Alpha in project Alpha by alpha-asp.
the class AlphaImplTest method smallGraphWithWrongType.
@Test
public void smallGraphWithWrongType() {
assertThrows(IllegalArgumentException.class, () -> {
Alpha system = new AlphaImpl();
InputConfig cfg = InputConfig.forString("a :- &connected[\"hello\",2].");
cfg.addPredicateMethod("connected", Externals.processPredicate((Integer a, Integer b) -> (a == 1 && b == 2) || (b == 2 || b == 3)));
ASPCore2Program prog = system.readProgram(cfg);
system.solve(prog).collect(Collectors.toSet());
});
}
use of at.ac.tuwien.kr.alpha.api.Alpha in project Alpha by alpha-asp.
the class AlphaImplTest method withExternal.
@Test
public void withExternal() throws Exception {
Alpha alpha = new AlphaImpl();
InputConfig inputCfg = InputConfig.forString("a :- &isOne[1].");
inputCfg.addPredicateMethod("isOne", Externals.processPredicateMethod(this.getClass().getMethod("isOne", int.class)));
ASPCore2Program program = alpha.readProgram(inputCfg);
Set<AnswerSet> actual = alpha.solve(program).collect(Collectors.toSet());
Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("a").build()));
assertEquals(expected, actual);
}
use of at.ac.tuwien.kr.alpha.api.Alpha in project Alpha by alpha-asp.
the class AlphaImplTest method addsFacts.
@Test
public void addsFacts() {
Alpha system = new AlphaImpl();
Thingy a = new Thingy();
Thingy b = new Thingy();
List<Thingy> things = asList(a, b);
InputProgram program = InputProgram.builder().addFacts(Externals.asFacts(Thingy.class, things)).build();
Set<AnswerSet> actual = system.solve(program).collect(Collectors.toSet());
Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("thingy").instance(a).instance(b).build()));
assertEquals(expected, actual);
}
Aggregations