Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing answer difficulties when python clingo is installed #7

Closed
ArnaudBelcour opened this issue Jul 26, 2018 · 0 comments
Closed
Labels

Comments

@ArnaudBelcour
Copy link
Contributor

ArnaudBelcour commented Jul 26, 2018

Hello,

when the clingo package is installed in python, Clyngor will use the propagator and the ClingoAnswers by default. This is because the use_clingo_module variable in solving.py is by default set to True and the clingo package check with have_clingo_module() wil return something because "import clingo" raises no error.

Then when we use Clyngor to solve and parse answers, the script will return results without applying the answer functions (like int_not_parsed or with_optimization) because the script uses the class ClingoAnswers instead of the class Answers. And the __iter__ function of ClingoAnswers have a different behaviour than the function of Answers.

I think this happens when a user install Clingo with the conda command: conda install -c potassco clingo

And encapsulation:

import clyngor

example_solver = clyngor.solve(inline='a(1). e(X):- a(X).')

for answer in example_solver.sorted.atoms_as_string:
    print(answer)

Results are (with clingo installed):

(('a', (1,)), ('e', (1,)))

Results are (after deleting clingo so deleting /path/to/lib/python3.6/site-packages/clingo.cpython-36m-x86_64-linux-gnu.so):

('a(1)', 'e(1)')

We see that the atoms_as_string function was not applied with clingo python package installed.

One way to solve this is by setting the variable use_clingo_module to False when calling the solver.

@Aluriak Aluriak added the bug label Nov 13, 2018
Aluriak added a commit that referenced this issue Jun 5, 2019
@Aluriak Aluriak closed this as completed in 261faba Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants