ajahl / clingo4j

Java interface for clingo a grounder and solver for logic programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clingo4j

Build Status

Java API for the clingo

Clingo4j is distributed under the Apache License 2.0.

Maven

    <dependency>
        <groupId>org.lorislab.clingo4j</groupId>
        <artifactId>clingo4j</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </dependency>

Example

    Clingo.init("src/main/clingo");
    
    try (Clingo control = Clingo.create()) {
        System.out.println(control.getVersion());
        control.add("base", "b :- not a. a :- not b.");
        control.ground("base");
        
        try (SolveHandle handle = control.solve()) {
            for (Model model : handle)  {
                System.out.println("Model type: " + model.getType());
                for (Symbol atom : model.getSymbols()) {
                    System.out.println(atom);
                }
            }  
        } 
    } catch (ClingoException ex) {
       System.err.println(ex.getMessage());
    }

Build

mvn clean install

Rebuild the java c-api

java -jar src/main/jnaerator/jnaerator.jar src/main/jnaerator/c.jnaerator 

About

Java interface for clingo a grounder and solver for logic programs.

License:Apache License 2.0


Languages

Language:Java 82.7%Language:C 17.3%