Originally posted by: SystemAdmin
You need to call CPXgetbhead() to get information about which variables and slacks are currently in the basis. In the basis array that it returns, negative values indicate rows (i.e., basic slacks) while non-negative values indicate structural basic variables.
Something like this:
int processbinva(CPXENVptr env, CPXLPptr lp)
{
int cols = CPXgetnumcols(env, lp);
int rows = CPXgetnumrows(env, lp);
int *bhead = NULL;
double *coefs = NULL;
int status = 0;
int i;
bhead = malloc(rows * sizeof(int));
coefs = malloc(cols * sizeof(double));
if ( bhead == NULL || coefs == NULL ) {
status = CPXERR_NO_MEMORY;
goto TERMINATE;
}
status = CPXgetbhead(env, lp, bind, NULL);
if ( status ) goto TERMINATE;
for ( i = 0; i < rows; i++ ) {
/* get tableau row for basis entry 'i' */
status = CPXbinvarow(env, lp, i, coefs);
if ( status ) goto TERMINATE;
if ( bind[i] >= 0 ) {
/* tableau row 'i' corresponds to basic variable 'c' */
int c = bind[i];
}
else {
/* tableau row 'i' corresponds to basic row 'r' */
int r = -bind[i]-1;
}
}
TERMINATE:
if ( bhead != NULL )
free(bhead);
if ( coefs != NULL )
free(coefs);
return status;
}
I did not test this code, but still hope that there are no syntax errors. Hope this helps...
Tobias
#CPLEXOptimizers#DecisionOptimization