 |
 |
 |
 |
Purpose |
 |
 |
Add a single row (constraint) to the problem.
|
 |
Synopsis |
 |
 |
int QSadd_row (QSprob p, int cnt, int *rmatind, double *rmatval,
double rhs, char sense, const char *name)
|
 |
Arguments |
 |
p |
 |
a handle to an initialized problem. |
cnt |
 |
the number of non-zero entries in the row. |
rmatind |
 |
an array of length cnt specifying the column indices of the non-zero entries. |
rmatval |
 |
an array of length cnt specifying the values of the matrix coefficients for the non-zero entries. |
rhs |
 |
the right-hand-side value of the constraint. |
sense |
 |
the sense of the constraint; to specify an equation use 'E' , to specify a = constraint use 'L' , and to specify a ≤ constraint use 'G' . |
name |
 |
the name of the constraint (can be NULL ). |
|
 |
Returns |
 |
 |
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
|
 |
Description |
 |
 |
The QSadd_row function provides a simpler interface than QSadd_rows for adding a single constraint to an existing LP, for example, the argument rhs is a double rather than an array of doubles (of length 1 when adding only a single constraint). When specifying rmatval and rhs , 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 constraints, it is more efficient to use QSadd_rows rather than repeated calls to QSadd_row, due to the internal data management in the QSopt library.
|
 |
Example |
 |
 |
/* Assume p is initialized to the problem in the QSload_prob example. */
/* Add the constraint 0.5x + 2.0y + 4.0z >= 6.0 to the LP. */
int rval;
int rmatind[3] = { 0, 1, 2 };
int rmatval[3] = { 0.5, 2.0, 4.0 };
rval = QSadd_row (p, 2, rmatind, rmatval, 6.0, 'G', (const char *) NULL);
if (rval) {
fprintf (stderr, "QSadd_row failed with return code %d\n", rval);
}
|
 |
|
|