Get presolved problem and solution with CPLEX
int GetPresolvedProblem(CPXENVptr env,
string problemfilename,
string solutionfilename,
CPXLPptr &presolvedproblem,
vector<double> &presolvedsolution,
double &presolvetime)
{
int status;
vector<double> originalsolution;
double originalobjective;
double starttime;
double endtime;
CPXLPptr temppresolvedproblem;
CPXLPptr tmpproblem = CPXcreateprob(env, &status, "TmpProblem");
assert(!status);
status = CPXreadcopyprob(env, tmpproblem, problemfilename.c_str(), NULL);
assert(!status);
status = ReadSolution(solutionfilename,
originalsolution,
originalobjective);
assert(!status);
assert(!CPXgettime(env, &starttime));
status = CPXpresolve(env, tmpproblem, CPX_ALG_NONE);
assert(!status);
assert(!CPXgettime(env, &endtime));
presolvetime = endtime - starttime;
status = CPXgetredlp(env, tmpproblem, &tmppresolvedproblem);
assert(!status);
presolvedproblem = CPXcloneprob(env, tmppresolvedproblem, &status);
assert(!status);
presolvedsolution.resize(CPXgetnumcols(env, presolvedproblem));
status = CPXcrushx(env, tmpproblem, &(originalsolution[0]),
&(presolvedsolution[0]));
status = CPXfreeprob(env, tmpproblem);
assert(!status);
return 0;
}