use of at.ac.tuwien.kr.alpha.core.grounder.Grounder in project Alpha by alpha-asp.
the class StratifiedEvaluationRegressionTest method runTest.
@ParameterizedTest
@MethodSource("at.ac.tuwien.kr.alpha.core.programs.transformation.StratifiedEvaluationRegressionTest#params")
public void runTest(String aspString, Consumer<CompiledProgram> programVerifier, Consumer<Set<AnswerSet>> resultVerifier) {
// Parse and pre-evaulate program
ProgramParser parser = new ProgramParserImpl();
ASPCore2Program prog = parser.parse(aspString);
AnalyzedProgram analyzed = AnalyzedProgram.analyzeNormalProgram(new NormalizeProgramTransformation(SystemConfig.DEFAULT_AGGREGATE_REWRITING_CONFIG).apply(prog));
CompiledProgram evaluated = new StratifiedEvaluation().apply(analyzed);
// Verify stratified evaluation result
programVerifier.accept(evaluated);
// Solve remaining program
AtomStore atomStore = new AtomStoreImpl();
Grounder grounder = GrounderFactory.getInstance("naive", evaluated, atomStore, false);
Solver solver = SolverFactory.getInstance(new SystemConfig(), atomStore, grounder);
Set<AnswerSet> answerSets = solver.collectSet();
resultVerifier.accept(answerSets);
}
use of at.ac.tuwien.kr.alpha.core.grounder.Grounder in project Alpha by alpha-asp.
the class AlphaImpl method prepareSolverFor.
/**
* Prepares a solver (and accompanying grounder) instance pre-loaded with the given program. Use this if the
* solver is needed after reading answer sets (e.g. for obtaining statistics).
*
* @param program the program to solve.
* @param filter a (java util) predicate that filters (asp-)predicates which should be contained in the answer
* set stream from the solver.
* @return a solver (and accompanying grounder) instance pre-loaded with the given program.
*/
private Solver prepareSolverFor(CompiledProgram program, java.util.function.Predicate<Predicate> filter) {
String grounderName = config.getGrounderName();
boolean doDebugChecks = config.isDebugInternalChecks();
GrounderHeuristicsConfiguration grounderHeuristicConfiguration = GrounderHeuristicsConfiguration.getInstance(config.getGrounderToleranceConstraints(), config.getGrounderToleranceRules());
grounderHeuristicConfiguration.setAccumulatorEnabled(config.isGrounderAccumulatorEnabled());
AtomStore atomStore = new AtomStoreImpl();
Grounder grounder = GrounderFactory.getInstance(grounderName, program, atomStore, filter, grounderHeuristicConfiguration, doDebugChecks);
return SolverFactory.getInstance(config, atomStore, grounder);
}
Aggregations