ML-KULeuven / problog

ProbLog is a Probabilistic Logic Programming Language for logic programs with probabilities.
https://dtai.cs.kuleuven.be/problog/
297 stars 34 forks source link

Error when using LFI from Python 3.8 #87

Closed JeanChristopheRohner closed 2 years ago

JeanChristopheRohner commented 2 years ago

Hi!

Thanks for making ProbLog :-)

When running the Parameter learning (LFI) example (found here):

from problog.logic import Term
from problog.program import PrologString
from problog.learning import lfi

model = """
t(0.5)::burglary.
0.2::earthquake.
t(_)::p_alarm1.
t(_)::p_alarm2.
t(_)::p_alarm3.

alarm :- burglary, earthquake, p_alarm1.
alarm :- burglary, \+earthquake, p_alarm2.
alarm :- \+burglary, earthquake, p_alarm3.
"""

alarm = Term('alarm')
burglary = Term('burglary')
earthquake = Term('earthquake')

examples = [
    [(burglary, False), (alarm, False)],
    [(earthquake, False), (alarm, True), (burglary, True)],
    [(burglary, False)]
]

score, weights, atoms, iteration, lfi_problem = lfi.run_lfi(PrologString(model), examples)

print (lfi_problem.get_model())

I get errors with Python 3.8.2 (with Python 2.7.16 the example works). I on MacOS 10.15.7 with ProbLog version 2.1.0.35.

With Python 3.8.2 the errors are:

Python/3.8/lib/python/site-packages/problog/ddnnf_formula.py", line 307, in _compile_with_dsharp
Python/3.8/lib/python/site-packages/problog/ddnnf_formula.py", line 360, in _compile
Python/3.8/lib/python/site-packages/problog/ddnnf_formula.py", line 355, in _compile
Python/3.8/lib/python/site-packages/problog/util.py", line 189, in subprocess_check_call
VincentDerk commented 2 years ago

Hi!

I am unable to reproduce the error on ProbLog 2.2.3, but perhaps it's because I'm on Ubuntu.

Does this error also occur on the newest ProbLog version (v2.2.3) for you? There have been a few changes to LFI and the dSharp binary since 2.1.0.35 that might have resolved this.

Could it be that part of the error message cut-off, you only posted the trace but not the error itself?

JeanChristopheRohner commented 2 years ago

Thanks for the fast response. I upgraded to ProbLog 2.2.3. Now I noted that this is a known issue and how to resolve it.

VincentDerk commented 2 years ago

I was hoping the changes in v2.2.3 would have resolved that. But oke, thanks for letting us know that that is still an issue then.