[Coin-discuss] ClpModel, optimize for delayed constraint generation
Sebastian Nowozin
nowozin at gmail.com
Mon Oct 13 09:10:15 EDT 2008
Hello everybody,
I am using OsiClpSolverInterface for delayed constraint generation,
using a sequence of resolve()/addRow() calls. How to best optimize for
this setting?
So far, I do:
OsiClpSolverInterface* si = new OsiClpSolverInterface;
ClpSolve lp_options;
lp_options.setPresolveType(ClpSolve::presolveOff);
si->setSolveOptions(lp_options);
// Initial static constraints
CoinPackedMatrix* matrix = new CoinPackedMatrix(false, 0.5, 0);
// ... (setup matrix, var*, row*
si->loadProblem(*matrix, varLB, varUB, objective, rowLB, rowUB);
int constraints_found = 0;
do {
si->resolve(); // Warm-start solving (we only add constraints)
RemoveInactiveConstraints(); // delete non-binding constraints
constraints_found = AddViolatedInequalities(); // add cuts
} while (constraints_found > 0);
Here, RemoveInactiveConstraints uses si->deleteRows, and
AddViolatedInequalities() uses si->addRow() repeatedly. From profiling,
I see that quite some time is spend in addRow().
I tried using:
if (si->getModelPtr()->matrix()->isColOrdered()) {
si->getModelPtr()->matrix()->setExtraGap(0.5);
} else {
si->getModelPtr()->matrix()->setExtraMajor(0.5);
}
with no result. Strangely, the si->getModelPtr()->matrix() is always
column ordered, even if my initial CoinPackedMatrix using in
si->loadProblem is row-ordered. Calling reverseOrdering() on the matrix
leads to a crash in the solver, so it does not seem to be working.
How to optimize OsiClpSolverInterface for repeated calls of addRow() and
resolve()? I do not know the exact number of cuts a-priori (around
5000-10000 cuts per iteration).
Thank you,
Sebastian
More information about the Coin-discuss
mailing list