use of at.ac.tuwien.kr.alpha.api.config.SystemConfig in project Alpha by alpha-asp.
the class CommandLineParser method parseCommandLine.
public AlphaConfig parseCommandLine(String[] args) throws ParseException {
CommandLine commandLine = new DefaultParser().parse(CommandLineParser.CLI_OPTS, args);
if (commandLine.getArgs().length > 0) {
throw new ParseException("Positional arguments { " + StringUtils.join(args, ' ') + " } are invalid!");
}
AlphaConfig retVal = new AlphaConfig();
SystemConfig sysConf = new SystemConfig();
InputConfig inputConf = new InputConfig();
if (commandLine.hasOption(CommandLineParser.OPT_HELP.getOpt())) {
LOGGER.debug("Found help option!");
this.handleHelp();
} else {
this.validate(commandLine);
}
for (Option opt : commandLine.getOptions()) {
this.handleOption(opt, sysConf, inputConf);
}
retVal.setSystemConfig(sysConf);
retVal.setInputConfig(inputConf);
return retVal;
}
use of at.ac.tuwien.kr.alpha.api.config.SystemConfig 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.config.SystemConfig in project Alpha by alpha-asp.
the class AlphaImplTest method disableStratifiedEvalTest.
/**
* Verifies that no stratified evaluation is performed up-front when disabled in config.
*/
@Test
public void disableStratifiedEvalTest() {
// Note: This might be cleaner if the test used the debugSolve method from the interface
String progstr = "p(a). q(X) :- p(X).";
SystemConfig cfg = new SystemConfig();
cfg.setEvaluateStratifiedPart(false);
AlphaImpl system = new AlphaImpl(cfg);
ASPCore2Program input = system.readProgramString(progstr);
NormalProgram normal = system.normalizeProgram(input);
CompiledProgram preprocessed = system.performProgramPreprocessing(normal);
assertFalse(preprocessed.getFacts().contains(Atoms.newBasicAtom(Predicates.getPredicate("q", 1), Terms.newSymbolicConstant("a"))), "Preprocessed program contains fact derived from stratifiable rule, but should not!");
}
use of at.ac.tuwien.kr.alpha.api.config.SystemConfig in project Alpha by alpha-asp.
the class AlphaImplTest method enableStratifiedEvalTest.
/**
* Verifies that stratified evaluation is performed up-front if not otherwise configured.
*/
@Test
public void enableStratifiedEvalTest() {
// Note: This might be cleaner if the test used the debugSolve method from the interface
String progstr = "p(a). q(X) :- p(X).";
SystemConfig cfg = new SystemConfig();
AlphaImpl system = new AlphaImpl(cfg);
ASPCore2Program input = system.readProgramString(progstr);
NormalProgram normal = system.normalizeProgram(input);
CompiledProgram preprocessed = system.performProgramPreprocessing(normal);
assertTrue(preprocessed.getFacts().contains(Atoms.newBasicAtom(Predicates.getPredicate("q", 1), Terms.newSymbolicConstant("a"))), "Preprocessed program does not contain fact derived from stratifiable rule, but should!");
}
Aggregations