The header file for the use of CLP's presolve functionality is COIN/Clp/include/Presolve.hpp. The sample program below illustrates some of the possibilities offered by CLP's presolve:
Example 2.3. Presolve code fragment
#include "ClpSimplex.hpp"
#include "ClpPresolve.hpp"
int main (int argc, const char *argv[])
{
ClpSimplex model;
model.readMps("../../Mps/Sample/p0033.mps"); // initialized by readMps or whatever
ClpPresolve presolveInfo;
ClpSimplex * presolvedModel = presolveInfo.presolvedModel(model);
// at this point we have original model and a new model. The information
// on the operations done is in presolveInfo
if (presolvedModel) {
// was not found to be infeasible - so lets solve
// if presolvedModel was NULL then it was primal infeasible and ...
presolvedModel->dual(); // or whatever else we wish to do
presolveInfo.postsolve(true); // the true updates status arrays in original
/* If the presolved model was optimal then so should the
original be.
We can use checkSolution and test feasibility */
model.checkSolution();
if (model.numberDualInfeasibilities()||
model.numberPrimalInfeasibilities())
printf("%g dual %g(%d) Primal %g(%d)\n",
model.objectiveValue(),
model.sumDualInfeasibilities(),
model.numberDualInfeasibilities(),
model.sumPrimalInfeasibilities(),
model.numberPrimalInfeasibilities());
// Due to tolerances we can not guarantee that so you may wish to throw in
model.primal(1);
}
}
Presolve has a few more options which can be found in the header file, for example whether to treat as an integer problem or whether to keep row and column names.