[Cbc] Failure to satisfy an SOS2 constraint
Alexis Guigue
aguigue at softree.com
Fri Mar 8 17:18:55 EST 2013
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
--
Software Engineer/Research Engineer
Softree Technical Systems Inc.
www.softree.com
Engineering an Easier Way
More information about the Cbc
mailing list