Created
June 25, 2015 17:34
-
-
Save rocarvaj/dd88700e2861ff84c118 to your computer and use it in GitHub Desktop.
Get presolved problem and solution with CPLEX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need suport about Cplex. Can you help me?