QSopt QSadd_col QSopt > Callable Library > Function List
  QSopt
  Downloads
  LP Info
  Software
  Problem Formats
  Callable Library
  Overview
Function List
  Rational Solver
  Beta
  Contact Info
Purpose
Add a single column (variable) to the problem.
Synopsis
int QSadd_col (QSprob p, int cnt, int *cmatind, double *cmatval,
    double obj, double lower, double upper, const char *name)
Arguments
p a handle to an initialized problem.
cnt the number of non-zero entries in the column.
cmatind an array of length cnt specifying the row indices of the non-zero entries.
cmatval an array of length cnt specifying the values of the matrix coefficients for the non-zero entries.
obj the objective function coefficient for the variable.
lower the lower bound for the variable (use -QS_MAXDOUBLE if no lower bound).
upper the upper bound for the variable (use QS_MAXDOUBLE if no upper bound).
name the name of the variable (can be NULL).
Returns
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
Description

The QSadd_col function provides a simpler interface than QSadd_cols for adding a single variable to an existing LP, for example, the argument obj is a double rather than an array of doubles (of length 1 when adding only a single variable).

When specifying cmatval, obj, lower, and upper, it is important not to give any value larger in magnitude than QS_MAXDOUBLE (1e30). This restriction is due to the internal structures used in the QSopt solvers.

Note that when adding many variables, it is more efficient to use QSadd_cols rather than repeated calls to QSadd_col, due to the internal data management in the QSopt library.

Example
/* Assume p is initialized to the problem in the QSload_prob example. */
/* Add a variable w, with an objective coefficient of 1.1, with a 2.1 */
/* in the first constraint, with a 3.0 in the second constraint, and  */
/* 1.0 <= w <= 2.0.                                                   */

int rval;
const char *name = "w";
int cmatind[2] = { 0, 1 };
int cmatval[2] = { 2.1, 3.0 };

rval = QSadd_col (p, 2, cmatind, cmatval, 1.1, 1.0, 2.0, name);
if (rval) {
    fprintf (stderr, "QSadd_col failed with return code %d\n", rval);
}
 
QSopt | Problem Formats | Downloads Back
Last Updated: November 2003