Interface SCIP logicor constraints - #1255
Conversation
Adds addConsLogicor, addCoefLogicor, getNVarsLogicor, getVarsLogicor, getDualsolLogicor and getDualfarkasLogicor, following the same shape as the existing AND and OR handlers. Part of the checklist in scipopt#977.
|
Hello @mohitt31 , thank you so much! I'll only be able to take a look at this over the next week, I believe, but it's looking good! |
I would also be happy if you did it, if you don't mind 😄 if cons.isOriginal():
transcons = cons
else:
transcons = <Constraint>self.getTransformedCons(cons)This is the wrong way round, of course, and is also present in the other farkas function. Would you mind also fixing this in that separate fix? |
SCIPgetDualsolLogicor and SCIPgetDualfarkasLogicor need the transformed constraint, so follow getDualsolLinear and resolve it when an original one is passed in. Both now also reject a constraint of the wrong type rather than returning a meaningless number.
|
Sure, I'll do it. I checked and getDualfarkasKnapsack has the same problem, it passes the original constraint straight to SCIP. So the separate PR will fix both knapsack functions and the getVarsAnd assert, with tests that call them on original constraints. I'll open it in the next day or two. |
Joao-Dionisio
left a comment
There was a problem hiding this comment.
Thank you @mohitt31 ! I'll take a look at your other PR later, maybe this week.
Adds the logicor constraint handler to the Python interface. It is one of the unchecked items in #977.
Methods added:
addConsLogicor(vars, ...)creates the constraintaddCoefLogicor(cons, var)adds a variable to an existing onegetNVarsLogicor(cons)andgetVarsLogicor(cons)getDualsolLogicor(cons)andgetDualfarkasLogicor(cons)They follow the same shape as the existing AND and OR handlers, so the keyword arguments and their defaults match
addConsAnd.Tested with SCIP 10.0.3 on macOS (arm64). The suite goes from 449 to 450 passed with the same skips, and
stubs/test.shreports no issues against the stubs I added.One thing I ran into while writing the handler check in
getVarsLogicor. The equivalent line ingetVarsAnd(scip.pxi:6956) isThat asserts a two element tuple, which is always truthy, so the guard never actually fires. I wrote mine without the parentheses. I left the AND one alone to keep this PR to one thing, but happy to send a separate fix if you want it.