Index Out of Range Error
Closed this issue · 1 comments
damianoazzolini commented
Hi, I'm testing a simple program, but, as the title says, I get an index out of range error.
These are my files, stored in a folder called test
:
bk.pl
bird(alice).
bird(betty).
can(alice,fly).
can(betty,swim).
ability(fly).
ability(swim).
not_can(X):- \+can(X).
exs.pl
pos(penguin(betty)).
neg(penguin(alice)).
bias.pl
head_pred(penguin,1).
body_pred(bird(bird), 1).
body_pred(can(bird,ability), 4).
type(penguin,(bird)).
type(bird,(bird)).
type(can(bird,ability)).
Here the command I run
> python3 p3 popper.py examples/test/ --debug
15:35:27 Max rules: 1
15:35:27 Max vars: 6
15:35:27 Max body: 6
15:35:27 Num. pos examples: 1
15:35:27 Num. neg examples: 1
Traceback (most recent call last):
File "popper.py", line 8, in <module>
prog, score, stats = learn_solution(settings)
File "/mnt/c/Users/damia/Desktop/Ricerca/Repos/Popper/popper/loop.py", line 206, in learn_solution
timeout(settings, popper, (settings,), timeout_duration=int(settings.timeout),)
File "/mnt/c/Users/damia/Desktop/Ricerca/Repos/Popper/popper/util.py", line 63, in timeout
result = func(*args, **kwargs)
File "/mnt/c/Users/damia/Desktop/Ricerca/Repos/Popper/popper/loop.py", line 59, in popper
generator = Generator(settings, grounder)
File "/mnt/c/Users/damia/Desktop/Ricerca/Repos/Popper/popper/generate.py", line 48, in __init__
solver.ground([('base', [])])
File "/home/damiano/anaconda3/envs/deepstochlog/lib/python3.7/site-packages/clingo/control.py", line 339, in ground
self._rep, c_parts, len(parts), c_cb, c_data), data)
File "/home/damiano/anaconda3/envs/deepstochlog/lib/python3.7/site-packages/clingo/_internal.py", line 65, in _handle_error
raise RuntimeError(msg)
RuntimeError: Traceback (most recent call last):
File "/home/damiano/anaconda3/envs/deepstochlog/lib/python3.7/site-packages/clingo/script.py", line 202, in _pyclingo_call
_ffi.new_handle(_PYTHON_SCRIPT))
File "/home/damiano/anaconda3/envs/deepstochlog/lib/python3.7/site-packages/clingo/script.py", line 165, in _pyclingo_script_call
ret = script.call(_py_location(location), py_name, py_args)
File "/home/damiano/anaconda3/envs/deepstochlog/lib/python3.7/site-packages/clingo/script.py", line 139, in call
return fun(*arguments)
File "<string>", line 3, in pytype
IndexError: list index out of range
andrewcropper commented
The bias file is incorrect. It should be:
head_pred(penguin,1).
body_pred(bird, 1).
body_pred(can, 2).
type(penguin,(bird,)).
type(bird,(bird,)).
type(can,(bird,ability)).
Also, this version of Popper does not support constants in induced rules, so you would need to define these background relations:
can_fly(alice).
can_swim(Betty).
and add can_fly and can_swim to the bias file