CPXXaddrows and CPXaddrows
The routine CPXXaddrows/CPXaddrows adds constraints to a specified
CPLEX problem object.
int CPXXaddrows( CPXCENVptr env, CPXLPptr lp, CPXDIM ccnt, CPXDIM rcnt, CPXNNZ nzcnt, double const * rhs, char const * sense, CPXNNZ const * rmatbeg, CPXDIM const * rmatind, double const * rmatval, char const *const * colname, char const *const * rowname )
int CPXaddrows( CPXCENVptr env, CPXLPptr lp, int ccnt, int rcnt, int nzcnt, double const * rhs, char const * sense, int const * rmatbeg, int const * rmatind, double const * rmatval, char ** colname, char ** rowname )
Description
The routine CPXXaddrows/CPXaddrows adds constraints to a specified
CPLEX problem object. This routine may be called any time after a call to
CPXXcreateprob/CPXcreateprob.
When you add a ranged row, CPXXaddrows/CPXaddrows sets the
corresponding range value to 0 (zero).
Use the routine CPXXchgrngval/CPXchgrngval
to change the range value.
sense[i] |
= 'L' |
<= constraint |
sense[i] |
= 'E' |
= constraint |
sense[i] |
= 'G' |
>= constraint |
sense[i] |
= 'R' |
ranged constraint |
When you build or modify your problem with this routine,
you can verify that the results are as you intended
by calling CPXcheckaddrows
during application development.
The use of CPXXaddrows/CPXaddrows
as a way to add new columns is discouraged in favor of a direct call to
CPXXnewcols/CPXnewcols
before calling CPXXaddrows/CPXaddrows.
CPLEX treats a righthand side (rhs) of
CPX_INFBOUND
as infinite.
Arguments
- env
-
A pointer to the CPLEX environment as returned by
CPXXopenCPLEX/CPXopenCPLEX. - lp
-
A pointer to a CPLEX problem object as returned by
CPXXcreateprob/CPXcreateprob. - ccnt
-
An integer that specifies the number of new columns in the constraints being added to the constraint matrix. When new columns are added, they are given an objective coefficient of zero, a lower bound of zero, and an upper bound of
CPX_INFBOUND. - rcnt
- An integer that specifies the number of new rows to be added to the constraint matrix.
- nzcnt
-
An integer that specifies the number of nonzero constraint coefficients to be added to the constraint matrix. This specifies the length of the arrays
rmatindandrmatval. - rhs
-
An array of length
rcntcontaining the righthand side term for each constraint to be added to the CPLEX problem object. May be NULL, in which case the new righthand side values are set to 0.0 (zero). - sense
-
An array of length
rcntcontaining the sense of each constraint to be added to the CPLEX problem object. May be NULL, in which case the new constraints are created as equality constraints. Possible values of this argument appear in the table. - rmatbeg
-
An array used with
rmatindandrmatvalto define the rows to be added. - rmatind
-
An array used with
rmatbegandrmatvalto define the rows to be added. - rmatval
-
An array used with
rmatbegandrmatindto define the rows to be added. The format is similar to the format used to describe the constraint matrix in the routineCPXXcopylp/CPXcopylp(see description ofmatbeg,matcnt,matind, andmatvalin that routine), but the nonzero coefficients are grouped by row instead of column in the arrayrmatval. The nonzero elements of every row must be stored in sequential locations in this array from positionrmatbeg[i]tormatbeg[i+1]-1(or fromrmatbeg[i]tonzcnt-1ifi=rcnt-1). Each entry,rmatind[i], specifies the column index of the corresponding coefficient,rmatval[i]. UnlikeCPXcopylp, all rows must be contiguous, andrmatbeg[0]must be 0 (zero). - colname
-
An array of length
ccntcontaining pointers to character strings that represent the names of the new columns added to the CPLEX problem object, or equivalently, the new variable names. May be NULL, in which case the new columns are assigned default names if the columns already resident in the CPLEX problem object have names; otherwise, no names are associated with the variables. If column names are passed toCPXXaddrows/CPXaddrowsbut existing variables have no names assigned, default names are created for them. - rowname
-
An array containing pointers to character strings that represent the names of the new rows, or equivalently, the constraint names. May be NULL, in which case the new rows are assigned default names if the rows already resident in the CPLEX problem object have names; otherwise, no names are associated with the constraints. If row names are passed to
CPXXaddrows/CPXaddrowsbut existing constraints have no names assigned, default names are created for them.
Return
The routine returns 0 (zero) if successful and nonzero if an error occurs.Example
status = CPXaddrows (env, lp, ccnt, rcnt, nzcnt, rhs,
sense, rmatbeg, rmatind, rmatval,
newcolname, newrowname);
See also the example lpex3.c in the
CPLEX User's Manual and in the standard distribution.
For more about the conventions for representing a matrix as
compact arrays, see the discussion of matbeg, matind, and matval
in the routine CPXXcopylp/CPXcopylp.