Cbc
Cbc copied to clipboard
Indicator Constraints
Following some discussion here, it sounded like implementing indicator constraints using SOS1 would be doable.
There was some mention that work might be happening on that. I'm not sure what the status is, but I figured there at least ought to be a tracking issue and I couldn't find one, so I am creating it.
Will try and give an update this week.
I would think that the big M approach is slightly better than the SOS approach, especially if the big M is as tight as possible. There is code in Cbc/master to deal with indicator constraints in an mps file. Cplex has a baby example. So IF constraint binaryvariable 1 makes the constraint active when the binary variable is 1 and ... 0 makes it active when 0. The code starts with a given big M and then tries to tighten these values. The code has never really been tested on real problems. I have updated the code so that OsiSolverInterface:: modifyByIndicators(funnyvalue,bigM) can be called. If you want a constraint CON to be active only when X is 1 then you put a value of -funnyvalue in row CON for binary variable X. Active when 0 is +funnyvalue.
A SOS approach has a certain elegance, but is weaker and I don't think you can make a constraint active when X is 0. I will fix the many bugs in the big M approach and am willing to add an SOS approach if I can be convinced of its merit.
Added SOS version. A bit clumsy with 0 indicators as you have to add a variable and a constraint x+xnew==1