 |
 |
 |
 |
Purpose |
 |
 |
Copy all columns.
|
 |
Synopsis |
 |
 |
int QSget_columns (QSprob p, int **colcnt, int **colbeg, int **colind,
double **colval, double **obj, double **lower, double **upper,
char ***names)
|
 |
Arguments |
 |
p |
 |
a handle to an initialized problem. |
colcnt |
 |
returns an array of length ncols (the number of columns in the problem), with the j th entry specifying the number of non-zero coefficients in the j th column of the constraint matrix; this field can be NULL . |
colbeg |
 |
returns an array of length ncols , with the j th entry specifying the location of the start of the j th column in the colind and colval arrays; this field can be NULL . |
colind |
 |
returns an array that contains the row indices of the columns; the indices for j th column are stored consecutively starting at entry number colbeg[j] (there are colcnt[j] indices for the j th column); this field can be NULL . |
colval |
 |
returns an array that contains the non-zero coefficients in the columns; the coefficients for the j th column are stored consecutively starting at entry number colbeg[j] (there are colcnt[j] coefficients for j th column); this field can be NULL . |
obj |
 |
returns an array of length ncols , giving the objective function coefficients; this field can be NULL . |
lower |
 |
returns an array of length ncols , giving the lower bounds for the variables (if a variable has no lower bound, the value -QS_MAXDOUBLE is given); this field can be NULL . |
upper |
 |
returns an array of length ncols , giving the upper bounds for the variables (if a variable has no upper bound, the value QS_MAXDOUBLE is given); this field can be NULL . |
names |
 |
returns an array of length ncols , where the j th entry is a string that specifies the name of j th variable; this field can be NULL . |
|
 |
Returns |
 |
 |
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
|
 |
Description |
 |
 |
A complete description of the variables for the problem can be obtained using this function. Each of the arguments returns an array that is allocated by the function QSget_columns; if some piece of information is not needed, the corresponding argument for the function should be set to NULL . The calling function should free the memory for each of the arrays (and for the strings in the array names ) when the information is no longer needed; since the memory for the arrays and strings is allocated by the QSopt library, the memory must be freed with calls to QSfree and not by the system free() function. (Note that without the call to QSfree , the QSopt library will not free the memory for the string, even after a call to QSfree_prob(p) .The form of the column information is the same as in the QSload_prob function.
|
 |
Example |
 |
 |
/* p is an initialized QSprob, a handle to an existing LP problem */
double *colval = NULL, *obj = NULL, *lower = NULL, *upper = NULL;
int *colcnt = NULL, *colbeg = NULL, *colind = NULL;
char **names = NULL;
int ncols, j, k, rval;
ncols = QSget_colcount (p);
rval = QSget_columns (p, &colcnt, &colbeg, &colind, &colval,
&obj, &lower, &upper, &names);
if (rval) {
fprintf (stderr, "could not obtain cols, error code %d\n", rval);
} else {
for (j = 0; j < ncols; j++) {
printf ("%s OBJ = %f, LOWER = %f, UPPER = %f\n",
names[j], obj[j], lower[j], upper[j]);
printf (" Coefficients: ");
for (k = colbeg[j]; k < colbeg[j] + colcnt[j]; k++) {
printf ("(%d, %f) ", colind[k], colval[k]);
}
printf ("\n");
}
}
QSfree (colcnt);
QSfree (colbeg);
QSfree (colind);
QSfree (colval);
QSfree (obj);
QSfree (lower);
QSfree (upper);
if (names) {
for (j = 0; j < ncols; j++) {
QSfree (names[j]);
}
QSfree (names);
}
|
 |
|
|