Parsing answer difficulties when python clingo is installed
ArnaudBelcour opened this issue · 0 comments
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.