[Cbc] Failure to satisfy an SOS2 constraint

Kish Shen kisshen at cisco.com
Wed Mar 13 21:13:01 EDT 2013


Hi,

I thought I should post this as a follow-on, as I also have found some 
cases where CBC does not satisfy SOS constraints -- I have only tried 
SOS1. I have posted about one of this case last October, but I think the 
problem is still there now, with the stable (2.8) branch that I 
downloaded last week...

The case from last year is that the branch-and-bound does not seem to be 
done if there are only SOS constraints, but no 'normal' constraints:

minimise -2*(X1-X2-X3)

with SOS1 on X1,X2,X3,
and bounds between -0.5 and 1.5 for X1,X2,X3.

Solving this, X1, X2 and X3 are all set to 1.5, i.e. the SOS1 is ignored.

However, if I post a redundant constraint:

X1+X2+X3 >= 0.1

then X1 = 1.5, and X2 and X3 set to 0, so SOS1 is satisfied.

In both cases, I get the message

Cbc2007W No integer variables - nothing to do

Last week, I ran some more tests, this time with simple 'normal' 
constraints as well as SOS1, and the SOS1 constraint is still violated:

minimise X+Y

with SOS1 on X, Y

and the constraints

X+Y >= 3.2
X-Y <= 5.0

There are no bound restrictions on the variables.
the solution set X to 4.1, and Y to -0.899999
i.e. the SOS1 is violated

again, the warning about no integer variables is printed

When I impose an integer constraint on X, the solution returned is

X = 4.0, Y = -0.7999999

i.e. the SOS is still violated
(no warning is printed this time)

However, if the integer constraint is imposed on Y (but not X), the 
solution does seem to obey the SOS:

X = 3.2, Y = 0.0

making both X and Y integers also work correctly:

X = 4.0, Y = 0.0

I know that my code does call both CbcMain0 and CbcMain1, and the SOS is 
added using addObjects, just before CbcMain0 is called.

These are done using our interface to CBC, i.e. the problem was written 
in our language ECLiPSe, which then make calls to CBC. I can send the 
code that should reproduce the problem, but my guess is that the 
problems here are simple enough to not need this, but do let me know if 
you need the 'logged' files...

Thanks and cheers,

Kish


On 10/03/2013 18:03, John Forrest wrote:
> Alexis,
>
> SOS seems to be a bit of a mess at present.  It looks as if writeLP
> can't write SOS.  writeMps can but only if they were added as part of an
> Osi object not directly into CbcModel!
>
> Was your code compiled optimized?  It should work using CbcMain0 but
> a) there was a bug so you couldn't pass in options properly.  I have
> fixed in stable.  CbcMain1 does work.
> b) In debug mode SOS triggers an assert in preprocessing. Optimized
> there would not have been an assert but it probably failed - hence your
> result.
>
> As I said - a mess.
>
> I will look at preprocess assert.  Can you try using CbcMain1 or fixed
> CbcMain0 and pass in
> -preprocess off -solve
>
> and see if that works.
>
> John Forrest
>
>
> On 08/03/13 22:18, Alexis Guigue wrote:
>> Hi,
>>
>> This is kind of a follow-up of my previous email <<Problem writing
>> SOS2 constraint in the Lp file>>.
>> Here is the code again!
>>
>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>
>> // Create an OsiClpSolverInterface object
>> OsiClpSolverInterface    m_osiClpSolver;
>>
>> // Populate the solver
>> m_osiClpSolver.loadProblem(matrix, &m_vColLower[0], &m_vColUpper[0],
>> &m_vObjCoef[0], &m_vSign[0], &m_vRHS[0], 0);
>>
>> // Set continuous variables
>> m_osiClpSolver.setContinuous(&m_vContVarIndex[0],
>> (int)m_vContVarIndex.size());
>>
>> // Set column and row names
>> m_osiClpSolver.setIntParam(OsiNameDiscipline,2);
>> for(int i=0;i<(int)m_vRowName.size();i++)
>> m_osiClpSolver.setRowName(i,m_vRowName[i]);
>> for(int i=0;i<(int)m_vColName.size();i++)
>> m_osiClpSolver.setColName(i,m_vColName[i]);
>>
>> // Create the CbcModel object
>> CbcModel cbcModel(m_osiClpSolver);
>>
>> // Add sos2 constraint to CbcModel
>>  cbcModel.addObjects(...,...);
>>
>> // Optimize
>> cbcModel.branchAndBound();
>>
>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>
>>
>> This was my first version. I have a function after the optimization is
>> completed that checks
>> that my SOS2 constraints are satisfied. It passes the test when I use
>> cbcModel.branchAndBound();
>>
>> Now, I replace cbcModel.branchAndBound() with (standalone version)
>>
>>         CbcMain0(cbcModel);
>>         callCbc1("-solve -quit", cbcModel);
>>
>> One of my SOS2 constraint is not satisfied now. I have the impression
>> that the SOS2 constraints
>> were not part of the optimization problem in the first place, this
>> would explain why I am getting
>> at least not satisfied.
>>
>> Is my standalone code incorrect?
>>
>> Thanks in advance.
>>
>> Cheers
>>
>> Alexis
>>
>
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc



More information about the Cbc mailing list