Search in sources :

Example 6 with SystemConfig

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;
}
Also used : CommandLine(org.apache.commons.cli.CommandLine) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) AlphaConfig(at.ac.tuwien.kr.alpha.api.config.AlphaConfig) InputConfig(at.ac.tuwien.kr.alpha.api.config.InputConfig) Option(org.apache.commons.cli.Option) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 7 with SystemConfig

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());
}
Also used : Path(java.nio.file.Path) ASPCore2Program(at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) Alpha(at.ac.tuwien.kr.alpha.api.Alpha) ArrayList(java.util.ArrayList) InputConfig(at.ac.tuwien.kr.alpha.api.config.InputConfig)

Example 8 with SystemConfig

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!");
}
Also used : ASPCore2Program(at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) NormalProgram(at.ac.tuwien.kr.alpha.api.programs.NormalProgram) CompiledProgram(at.ac.tuwien.kr.alpha.core.programs.CompiledProgram) Test(org.junit.jupiter.api.Test)

Example 9 with SystemConfig

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!");
}
Also used : ASPCore2Program(at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) NormalProgram(at.ac.tuwien.kr.alpha.api.programs.NormalProgram) CompiledProgram(at.ac.tuwien.kr.alpha.core.programs.CompiledProgram) Test(org.junit.jupiter.api.Test)

Aggregations

SystemConfig (at.ac.tuwien.kr.alpha.api.config.SystemConfig)9 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)6 Alpha (at.ac.tuwien.kr.alpha.api.Alpha)4 InputConfig (at.ac.tuwien.kr.alpha.api.config.InputConfig)4 Test (org.junit.jupiter.api.Test)4 AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)3 NormalProgram (at.ac.tuwien.kr.alpha.api.programs.NormalProgram)3 CompiledProgram (at.ac.tuwien.kr.alpha.core.programs.CompiledProgram)3 Solver (at.ac.tuwien.kr.alpha.api.Solver)2 AlphaConfig (at.ac.tuwien.kr.alpha.api.config.AlphaConfig)2 ProgramParser (at.ac.tuwien.kr.alpha.api.programs.ProgramParser)2 ProgramParserImpl (at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 ParseException (org.apache.commons.cli.ParseException)2 DebugSolvingContext (at.ac.tuwien.kr.alpha.api.DebugSolvingContext)1 StatisticsReportingSolver (at.ac.tuwien.kr.alpha.api.StatisticsReportingSolver)1 AlphaImpl (at.ac.tuwien.kr.alpha.api.impl.AlphaImpl)1 ComponentGraph (at.ac.tuwien.kr.alpha.api.programs.analysis.ComponentGraph)1 DependencyGraph (at.ac.tuwien.kr.alpha.api.programs.analysis.DependencyGraph)1