 |
 |
 |
 |
Purpose |
 |
 |
Add a set of columns (variables) to the problem.
|
 |
Synopsis |
 |
 |
int QSadd_cols (QSprob p, int num, int *cmatcnt, int *cmatbeg,
int *cmatind, double *cmatval, double *obj, double *lower,
double *upper, const char **names)
|
 |
Arguments |
 |
p |
 |
a handle to an initialized problem. |
num |
 |
the number of columns to be added. |
cmatcnt |
 |
an array of length num (see QSload_prob). |
cmatbeg |
 |
an array of length num (see QSload_prob). |
cmatind |
 |
an array of row indices (see QSload_prob). |
cmatval |
 |
an array of matrix coefficients (see QSload_prob). |
obj |
 |
an array of length num specifying objective function coefficients for the variables. |
lower |
 |
an array of length num specifying lower bounds for the variables. |
upper |
 |
an array of length num specifying upper bounds for the variables. |
names |
 |
an array of length num specifying names of variables (names can be NULL ). |
|
 |
Returns |
 |
 |
A zero value if the function terminated correctly, and a non-zero value if an error occurred.
|
 |
Description |
 |
 |
Use QSadd_cols to add a collection of variables to an LP problem, including the non-zero coefficients of the variables in the existing constraints of the problem. (If the new variables do not appear in the existing rows, then it is simpler to use QSnew_col to add the variables. Also, to add only a single variable, it is simpler to use QSadd_col.) The arguments to specify the constraint coefficients follow the same pattern as in QSload_prob. 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.
|
 |
Example |
 |
 |
/* Assume p is initialized to the problem in the QSload_prob example. */
/* Add variables v and w to obtain the following LP problem. */
/* Maximize 3.0x + 2.0y + 4.0z + 5.1v + 1.1w */
/* Subject to */
/* 3.1x + 2.3y + 1.4z + 3.5v + 2.1w <= 12.2 */
/* 5.0x + 1.1y + 3.0w = 10.0 */
/* x >= 2.0 */
/* y free */
/* 1.0 <= z <= 10.0 */
/* 0.0 <= v <= 2.0 */
/* 1.0 <= w <= 2.0 */
int rval;
int cmatcnt[2] = { 1, 2 };
int cmatbeg[2] = { 0, 1 };
int cmatind[3] = { 0, 0, 1 };
double cmatval[3] = { 3.5, 2.1, 3.0 };
double obj[2] = { 5.1, 1.1 };
double lower[2] = { 0.0, 1.0 };
double upper[2] = { 2.0, 2.0 };
const char *names[2] = { "v", "w" };
rval = QSadd_cols (p, 2, cmatcnt, cmatbeg, cmatind, cmatval, obj,
lower, upper, names);
if (rval) {
fprintf (stderr, "Add columns failed, error code %d\n", rval);
} else {
rval = QSwrite_prob (p, "newsmall.lp", "LP");
if (rval) {
fprintf (stderr, "Could not write LP, error code %d\n", rval);
}
}
|
 |
|
|