What I'm really trying to do is to convert boolean expressions to integer linear programming constraints. I'm trying to first convert the expressions into a CNF (using pyeda
) and then from the CNF form the constraints (since this is pretty straight forward). However, I'm having trouble to understand the abstract syntax tree which the .to_ast()
function is outputting. As an example, when running .to_ast()
on the expression (~C1 | ~P1 | ~O1) & (~C1 | ~P1 | ~O2)
the output is
('and', ('or', ('lit', -1), ('lit', -2), ('lit', -3)), ('or', ('lit', -1), ('lit', -2), ('lit', -4)))
It is pretty obvious that the -
is the negation and the integer is representing one of the variables. Does anyone know if there is a mapping from the integer to the variable? Long description for short question...