KareemYousrii / SPL

This repository holds the code for the NeurIPS 2022 paper, Semantic Probabilistic Layers
26 stars 5 forks source link

'IndexError: list index out of range' when loading the Vtree #3

Closed LedaguenelArthur closed 1 year ago

LedaguenelArthur commented 1 year ago

Hi @KareemYousrii,

I'm trying to start working with SPL, but I encountered a first error when trying to use the following ex1.vtree file:

c ids of vtree nodes start at 0
c ids of variables start at 1
c vtree nodes appear bottom-up, children before parents
c
c file syntax:
c vtree number-of-nodes-in-vtree
c L id-of-leaf-vtree-node id-of-variable
c I id-of-internal-vtree-node id-of-left-child id-of-right-child
c
vtree 9
L 0 2
L 2 3
L 4 1
L 6 4
L 8 5
I 7 6 1516123455496
I 5 4 1516123455495
I 3 2 1516123455493
I 1 0 1516123455491

For context, this vtree comes from a toy problem that I created where 5 variables are linked through hierarchical and exclusion relations (see ex1_dimacs.txt).

When I try to load it using the following script :

import sys
sys.path.insert(0, './C-HMCNN/hmc-utils/pypsdd')
from pypsdd import Vtree

# print(sys.version)

vt = Vtree.read('./ex1.vtree')

I get the following error :

PS C:\Users\arthur.ledaguenel\Documents\Experiences\SPL> python .\test.py
C:\Users\arthur.ledaguenel\Documents\Experiences\SPL\./C-HMCNN/hmc-utils/pypsdd\pypsdd\data.py:325: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if value == 1 and (var not in self.inst or self.inst[var] is 0):
Traceback (most recent call last):
  File "C:\Users\arthur.ledaguenel\Documents\Experiences\SPL\test.py", line 7, in <module>
    vt = Vtree.read('./ex1.vtree')
  File "C:\Users\arthur.ledaguenel\Documents\Experiences\SPL\./C-HMCNN/hmc-utils/pypsdd\pypsdd\vtree.py", line 133, in read
    left,right = nodes[left_id],nodes[right_id]
IndexError: list index out of range

Is there anything wrong with my ex1.vtree file ?

Best regards, Arthur

LedaguenelArthur commented 1 year ago

Hi,

As far as I know the problem is due to previous compilation step and not the Vtree object itself, so I close this issue.

See this issue for more info : https://github.com/wannesm/PySDD/issues/31

Sorry for the inconvenience, Arthur