QSopt QSget_columns_list QSopt > Callable Library > Function List
  QSopt
  Downloads
  LP Info
  Software
  Problem Formats
  Callable Library
  Overview
Function List
  Rational Solver
  Beta
  Contact Info
Purpose
Copy a list of columns.
Synopsis
int QSget_columns_list (QSprob p, int num, int *collist,
    int **colcnt, int **colbeg, int **colind, double **colval,
    double **obj, double **lower, double **upper, char ***names)
Arguments
p a handle to an initialized problem.
num the length of the array collist.
collist an array of length num; each entry specifies the index of a column (so a value between 0 and ncols - 1, where ncols is the number of columns in the problem).
colcnt returns an array of length num, with the jth entry specifying the number of non-zero coefficients in column collist[j] of the constraint matrix; this field can be NULL.
colbeg returns an array of length num, with the jth entry specifying the location of the start of column collist[j] in the colind and colval arrays; this field can be NULL.
colind returns an array that contains the row indices of the non-zero coefficients in the columns specified in the collist array; the indices for column collist[j] are stored consecutively starting at entry number colbeg[j] (there are colcnt[j] indices for collist[j]); this field can be NULL.
colval returns an array that contains the non-zero coefficients in the columns specified by the collist array; the coefficients for column collist[j] are stored consecutively starting at entry number colbeg[j] (there are colcnt[j] coefficients for collist[j]); this field can be NULL.
obj returns an array of length num, giving the objective function coefficients for the columns specified in the collist array; this field can be NULL.
lower returns an array of length num, giving the lower bounds for the columns specified in the collist array (if a variable has no lower bound, the value -QS_MAXDOUBLE is given); this field can be NULL.
upper returns an array of length num, giving the upper bounds for the columns specified in the collist array (if a variable has no upper bound, the value QS_MAXDOUBLE is given); this field can be NULL.
names returns an array of length num where the jth entry is a string that specifies the name of variable collist[j]; 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 variables for the problem can be obtained using this function; the indices for the variables are passed into the function via the collist array (the indices can be obtained from the corresponding column names by using the function QSget_column_index). Each of the arguments returns an array that is allocated by the function QSget_columns_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 (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. The form of the column information is the same as that used in the QSload_prob function.

Example
/* p is an initialized QSprob, a handle to an existing LP problem  */
/* Obtain the column information for column 2.                     */

double *colval = NULL, *obj = NULL, *lower = NULL, *upper = NULL;
int *colcnt = NULL, *colbeg = NULL, *colind = NULL;
char **names = NULL;
int collist[1] = { 2 };
int k, rval;

rval = QSget_columns_list (p, 1, collist, &colcnt, &colbeg, &colind,
                           &colval, &obj, &lower, &upper, &names);
if (rval) {
    fprintf (stderr, "could not obtain column, error code %d\n", rval);
} else {
    printf ("Variable %s, objective %f, bounds %f <= %s <= %f\n",
             names[0], obj[0], lower[0], names[0], upper[0]);
    printf ("Coefficients: ");
    for (k = colbeg[0]; k < colbeg[0] + colcnt[0]; k++) {
        printf ("Row %d = %f  ", colind[k], colval[k]);
    }
    printf ("\n");
}

QSfree (colcnt); QSfree (colbeg); QSfree (colind); QSfree (colval);
QSfree (obj);
QSfree (lower); QSfree (upper);
if (names) {
    QSfree (names[0]);
    QSfree (names);
}
 
QSopt | Problem Formats | Downloads Back
Last Updated: November 2003