Python wrapper around Clingo/Answer Set Programming
Project description
<p align="center">
<img src="clyngor.png"/>
</p>
Handy python wrapper around [Potassco's Clingo](https://potassco.org/) [ASP solver](https://en.wikipedia.org/wiki/Answer%20set%20programming).
## Example
Clyngor offers multiple interfaces. The followings are all equivalent.
(they search for [formal concepts](https://en.wikipedia.org/wiki/Formal_concept_analysis))
from clyngor import ASP, solve
answers = ASP("""
rel(a,(c;d)). rel(b,(d;e)).
obj(X):- rel(X,_) ; rel(X,Y): att(Y).
att(Y):- rel(_,Y) ; rel(X,Y): obj(X).
:- not obj(X):obj(X).
:- not att(Y):att(Y).
""")
for answer in answers:
print(answer)
More traditional interface, using file containing the ASP source code:
for answer in solve('concepts.lp'): # also accepts list of file
print(answer)
## Chaining
Clyngor allows you to specify the answer sets format using builtin methods:
for answer in answers.by_predicate.first_arg_only:
print('{' + ','.join(answer['obj']) + '} × {' + ','.join(answer['att']) + '}')
And if you need a [*pyasp-like*](https://github.com/sthiele/pyasp) interface:
for answer in answers.as_pyasp:
print('{' + ','.join(a.args()[0] for a in answer if a.predicate == 'obj')
+ '} × {' + ','.join(a.args()[0] for a in answer if a.predicate == 'att') + '}')
## Debugging
TODO: Clyngor is also able to parse an ASP program to generate debugging help.
## Solver scripting
TODO: Clyngor is able to manage python inside ASP source code, allowing user to fully control the solving.
## Alternatives
[pyasp](https://github.com/sthiele/pyasp) comes into mind, but do not (yet) supports clingo alone.
## Installation
pip install clyngor
You must have `clingo` in your path. Depending on your OS, it might be done with a system installation,
or through compilation + manual installation.
[See the doc]().
<img src="clyngor.png"/>
</p>
Handy python wrapper around [Potassco's Clingo](https://potassco.org/) [ASP solver](https://en.wikipedia.org/wiki/Answer%20set%20programming).
## Example
Clyngor offers multiple interfaces. The followings are all equivalent.
(they search for [formal concepts](https://en.wikipedia.org/wiki/Formal_concept_analysis))
from clyngor import ASP, solve
answers = ASP("""
rel(a,(c;d)). rel(b,(d;e)).
obj(X):- rel(X,_) ; rel(X,Y): att(Y).
att(Y):- rel(_,Y) ; rel(X,Y): obj(X).
:- not obj(X):obj(X).
:- not att(Y):att(Y).
""")
for answer in answers:
print(answer)
More traditional interface, using file containing the ASP source code:
for answer in solve('concepts.lp'): # also accepts list of file
print(answer)
## Chaining
Clyngor allows you to specify the answer sets format using builtin methods:
for answer in answers.by_predicate.first_arg_only:
print('{' + ','.join(answer['obj']) + '} × {' + ','.join(answer['att']) + '}')
And if you need a [*pyasp-like*](https://github.com/sthiele/pyasp) interface:
for answer in answers.as_pyasp:
print('{' + ','.join(a.args()[0] for a in answer if a.predicate == 'obj')
+ '} × {' + ','.join(a.args()[0] for a in answer if a.predicate == 'att') + '}')
## Debugging
TODO: Clyngor is also able to parse an ASP program to generate debugging help.
## Solver scripting
TODO: Clyngor is able to manage python inside ASP source code, allowing user to fully control the solving.
## Alternatives
[pyasp](https://github.com/sthiele/pyasp) comes into mind, but do not (yet) supports clingo alone.
## Installation
pip install clyngor
You must have `clingo` in your path. Depending on your OS, it might be done with a system installation,
or through compilation + manual installation.
[See the doc]().
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clyngor-0.0.2.tar.gz
(4.8 kB
view hashes)