use of at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl in project Alpha by alpha-asp.
the class ThreeColouringTestWithRandom method testThreeColouring.
private void testThreeColouring(int n, boolean shuffle, int seed, RegressionTestConfig cfg) {
ASPCore2Program tmpPrg = new ProgramParserImpl().parse("col(V,C) :- v(V), c(C), not ncol(V,C)." + "ncol(V,C) :- col(V,D), c(C), C != D." + ":- e(V,U), col(V,C), col(U,C).");
InputProgram.Builder prgBuilder = InputProgram.builder().accumulate(tmpPrg);
prgBuilder.addFacts(createColors("1", "2", "3"));
prgBuilder.addFacts(createVertices(n));
prgBuilder.addFacts(createEdges(n, shuffle, seed));
InputProgram program = prgBuilder.build();
Solver solver = buildSolverForRegressionTest(program, cfg);
@SuppressWarnings("unused") Optional<AnswerSet> answerSet = solver.stream().findAny();
// System.out.println(answerSet);
// TODO: check correctness of answer set
}
use of at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl in project Alpha by alpha-asp.
the class RacksTest method test.
private void test(RegressionTestConfig cfg) throws IOException {
CharStream programInputStream = CharStreams.fromPath(Paths.get("benchmarks", "siemens", "racks", "racks.lp"));
Solver solver = buildSolverForRegressionTest(new ProgramParserImpl().parse(programInputStream), cfg);
@SuppressWarnings("unused") Optional<AnswerSet> answerSet = solver.stream().findFirst();
// System.out.println(answerSet);
// TODO: check correctness of answer set
}
use of at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl in project Alpha by alpha-asp.
the class AlphaImplTest method testLearnedUnaryNoGoodCausingOutOfOrderLiteralsConflict.
// Detailed reproduction test-case for github issue #239.
@Test
public void testLearnedUnaryNoGoodCausingOutOfOrderLiteralsConflict() throws IOException {
final ProgramParser parser = new ProgramParserImpl();
InputProgram.Builder bld = InputProgram.builder();
bld.accumulate(parser.parse(Files.newInputStream(Paths.get("src", "test", "resources", "HanoiTower_Alpha.asp"), StandardOpenOption.READ)));
bld.accumulate(parser.parse(Files.newInputStream(Paths.get("src", "test", "resources", "HanoiTower_instances", "simple.asp"), StandardOpenOption.READ)));
InputProgram parsedProgram = bld.build();
SystemConfig config = new SystemConfig();
config.setSolverName("default");
config.setNogoodStoreName("alpharoaming");
config.setSeed(0);
config.setBranchingHeuristic(Heuristic.valueOf("VSIDS"));
config.setDebugInternalChecks(true);
config.setDisableJustificationSearch(false);
config.setEvaluateStratifiedPart(false);
config.setReplayChoices(Arrays.asList(21, 26, 36, 56, 91, 96, 285, 166, 101, 290, 106, 451, 445, 439, 448, 433, 427, 442, 421, 415, 436, 409, 430, 397, 391, 424, 385, 379, 418, 373, 412, 406, 394, 388, 382, 245, 232, 208));
Alpha alpha = new AlphaImpl(config);
Optional<AnswerSet> answerSet = alpha.solve(parsedProgram).findFirst();
assertTrue(answerSet.isPresent());
}
use of at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl in project Alpha by alpha-asp.
the class ThreeColouringWheelTest method testThreeColouring.
private void testThreeColouring(int n, RegressionTestConfig cfg) {
ASPCore2Program tmpPrg = new ProgramParserImpl().parse("col(V,C) :- v(V), c(C), not ncol(V,C)." + "ncol(V,C) :- col(V,D), c(C), C != D." + ":- e(V,U), col(V,C), col(U,C).");
InputProgram.Builder prgBuilder = InputProgram.builder(tmpPrg);
prgBuilder.addFacts(createColors("red", "blue", "green"));
prgBuilder.addFacts(createVertices(n));
prgBuilder.addFacts(createEdges(n));
InputProgram program = prgBuilder.build();
maybeShuffle(program);
Solver solver = buildSolverForRegressionTest(program, cfg);
@SuppressWarnings("unused") Optional<AnswerSet> answerSet = solver.stream().findAny();
// System.out.println(answerSet);
// TODO: check correctness of answer set
}
use of at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl in project Alpha by alpha-asp.
the class AggregateRewritingContextTest method rewritingContextForAspString.
// @formatter:on
private static final AggregateRewritingContext rewritingContextForAspString(String asp) {
ASPCore2Program program = new ProgramParserImpl().parse(asp);
AggregateRewritingContext ctx = new AggregateRewritingContext();
for (Rule<Head> rule : program.getRules()) {
ctx.registerRule(rule);
}
return ctx;
}
Aggregations