Originally posted by: JimDan
Dear all,
I am solving an LP via C callable library. I am trying to access information pertaining to the primal simplex after each simplex iteration.
First, I have a routine that sets as the starting basis all artificial variables with high cost. Each such variable has a single +1 entry in the constraint matrix corresponding to each constraint. Artificial variables are indexed original_var and above. ncol is the total number of variables including artificial variables.
void setoriginalbasis(){
for (int i = 0; i < ncol; i++) {
if (i < original_var)
cb.cstat[i] = CPX_AT_LOWER;
else
cb.cstat[i] = CPX_BASIC;
}
for (int i = 0; i < nrow; i++)
cb.rstat[i] = CPX_BASIC;
int retval = CPXcopybase(env, lp, cb.cstat, cb.rstat);
}
Then, I have
CPXsetlpcallbackfunc(env, callback, NULL);
Then, I have a user defined call back function as below:
static int CPXPUBLIC callback(CPXCENVptr env, void *cbdata, int wherefrom, void *cbhandle) {
std::cout << "Into Callback" << std::endl;
CPXLPptr lp;
CPXgetcallbackinfo(env, cbdata, wherefrom, CPX_CALLBACK_INFO_USER_PROBLEM, &lp);
int ncol = CPXgetnumcols(env, lp);
int newcstat[MAXCOL];
int retval = CPXgetbase(env, lp, newcstat, NULL);//However, when I access newcstat here,
//there is no change iteration to iteration
CPXgetcallbackinfo(env, cbdata, wherefrom, CPX_CALLBACK_INFO_PRIMAL_OBJ, &objval);
//other stuff
}
When I examine newcstat the last line in callback is executed, it has the same stuff that I originally set in setoriginalbasis. This is even though objval (which stores the objective function value after each iteration keeps changing.
Is there any different function I need to use to access which variables are currently basic?
Thanks.
#CPLEXOptimizers#DecisionOptimization