 |
 |
 |
 |
Purpose |
 |
 |
Copy a list of rows.
|
 |
Synopsis |
 |
 |
int QSget_rows_list (QSprob p, int num, int *rowlist, int **rowcnt,
int **rowbeg, int **rowind, double **rowval, double **rhs,
char **sense, char ***names)
|
 |
Arguments |
 |
p |
 |
a handle to an initialized problem. |
num |
 |
the length of the array rowlist . |
rowlist |
 |
an array of length num ; each entry specifies the index of a row (so a value between 0 and nrows - 1 , where nrows is the number of rows in the problem). |
rowcnt |
 |
returns an array of length num , with the i th entry specifying the number of non-zero coefficients in the row specified by rowlist[i] ; this field can be NULL . |
rowbeg |
 |
returns an array of length num , with the i th entry specifying the location of the start of rowlist[i] in the rowind and rowval arrays; this field can be NULL . |
rowind |
 |
returns an array that contains the column indices of the non-zero coefficients in the rows specified in the rowlist array; the indices for rowlist[i] are stored consecutively starting at entry number rowbeg[i] (there are rowcnt[i] indices for row rowlist[i] ); this field can be NULL . |
rowval |
 |
returns an array that contains the non-zero coefficients in the rows specified by the rowlist array; the coefficients for rowlist[i] are stored consecutively starting at entry number rowbeg[i] (there are rowcnt[i] coefficients for rowlist[i] ); this field can be NULL . |
rhs |
 |
returns an array of length num , giving the right-hand-side values for rows specified in the rowlist array; this field can be NULL . |
sense |
 |
returns an array of length num where the i th entry specifies the sense of constraint rowlist[i] ('E' for ≥ , 'L' for = ; 'G' for ≤ ); this field can be NULL . |
names |
 |
returns an array of length num where the i th entry is a string that specifies the name of constraint rowlist[i] ; 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 subset of the constraints for the problem can be obtained using this function; the indices for the constraints are passed into the function via the rowlist array (the indices can be obtained from the corresponding row names by using the function QSget_row_index). Each of the arguments returns an array that is allocated by QSget_rows_list; 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 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. The form of the row information is the same as that used in the QSadd_rows function.
|
 |
Example |
 |
 |
/* p is an initialized QSprob, a handle to an existing LP problem */
/* Obtain the row information for row 0 and row 2. */
double *rowval = NULL, *rhs = NULL;
int *rowcnt = NULL, *rowbeg = NULL, *rowind = NULL;
char *sense = NULL, **names = NULL;
int rowlist[2] = { 0, 2 };
int i, j, rval;
rval = QSget_rows_list (p,
2, rowlist, &rowcnt, &rowbeg, &rowind, &rowval,
&rhs, &sense, &names);
if (rval) {
fprintf (stderr, "could not obtain rows, error code %d\n", rval);
} else {
for (i = 0; i < 2; i++) {
printf ("%s RHS = %f, SENSE = %c\n",
names[i], rhs[i], sense[i]);
printf (" Coefficients: ");
for (j = rowbeg[i]; j < rowbeg[i] + rowcnt[i]; j++) {
printf ("(%d, %f) ", rowind[j], rowval[j]);
}
printf ("\n");
}
}
QSfree (rowcnt);
QSfree (rowbeg);
QSfree (rowind);
QSfree (rowval);
QSfree (rhs);
QSfree (sense);
if (names) {
for (i = 0; i < 2; i++) {
QSfree (names[i]);
}
QSfree (names);
}
|
 |
|
|