 |
This function returns an array of column and row indices, specifying the ordering of the variables in the current basis. If an entry k is less than ncols (the number of columns in the problem), then it means column k . If an entry k is greater than or equal to ncols , then it means row k-ncols . The calling function must allocate the memory for the array basorder ; the array should be of length at least nrows (the number of rows in the problem).
|
 |
/* p is an initialized QSprob, a handle to an existing LP problem */
int i, rval, ncols, nrows;
int *basorder;
ncols = QSget_colcount (p);
nrows = QSget_rowcount (p);
basorder = (int *) malloc (nrows * sizeof (int));
rval = QSget_basis_order (p, basorder);
if (rval) {
fprintf (stderr, "could not obtain order, error code %d\n", rval);
} else {
for (i = 0; i < nrows; i++) {
if (basorder[i] < ncols) {
printf ("Basis[%d] = Column %d\n", i, basorder[i]);
} else {
printf ("Basis[%d] = Row %d\n", i, basorder[i] - ncols);
}
}
}
free (basorder);
|