[Cbc] Problem writing SOS2 constraint in the Lp file
Alexis Guigue
aguigue at softree.com
Thu Mar 7 15:15:34 EST 2013
Hi,
I am not able to write the SOS2 constraint in the Lp file. Here is what
I am doing:
// 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();
Now, I am curious to have a look at the lp file.
If I insert
m_osiClpSolver.writeLp(FILENAME);
where (**) is, then I get the lp file without the SOS2 constraint (which
makes sense to me).
I have tried to insert
cbcModel.solver()->writeLp(FILENAME); or
cbcModel.referenceSolver()->writeLp(FILENAME);
where (***) is. I still get the same lp file, without the SOS2 constraint.
Am I doing something wrong? How can I get my lp file with the SOS2
constraints included?
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