0

I'd like to add a NOT-constraint to my PySCIPOpt model. I can see andConsAnd, addConsOr and addConsXor but there isn't one for the NOT operator. What would be the easiest way to add a NOT-constraint?

I came up with:

x = model.addVar('B')
not_x = model.addVar('B')

model.addCons(not_x == (x - 1) * (x - 1))

but that seems ugly.

The reason I need not_x is because I'd like to add it later to a conjunction, like:

model.addConsAnd([not_x, y], True)

But, as far as I can see, PySCIPOpt interface does not work if I do it using Python not operator:

model.addConsAdd([not x, y], True)

so the above line breaks the Kernel in my jupyter notebook.

Any help appreciated.

Jacek
  • 1,048
  • 15
  • 21

1 Answers1

1

The expression not x for a binary variable x is identical to 1-x. This is used extensively in mixed-integer programming models.

Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39