CPXXaddcols and CPXaddcols
The routine CPXXaddcols/CPXaddcols adds columns to a specified CPLEX
problem object.
int CPXXaddcols( CPXCENVptr env, CPXLPptr lp, CPXDIM ccnt, CPXNNZ nzcnt, double const * obj, CPXNNZ const * cmatbeg, CPXDIM const * cmatind, double const * cmatval, double const * lb, double const * ub, char const *const * colname )
int CPXaddcols( CPXCENVptr env, CPXLPptr lp, int ccnt, int nzcnt, double const * obj, int const * cmatbeg, int const * cmatind, double const * cmatval, double const * lb, double const * ub, char ** colname )
Description
The routine CPXXaddcols/CPXaddcols adds columns to a specified CPLEX
problem object. This routine may be called any time after a problem object
is created via CPXXcreateprob/CPXcreateprob.
The routine CPXXaddcols/CPXaddcols is very similar to the routine
CPXXaddrows/CPXaddrows. The primary difference is that
CPXXaddcols/CPXaddcols cannot add coefficients in rows that do not
already exist (that is, in rows with index greater than the number returned
by CPXXgetnumrows/CPXgetnumrows); whereas CPXXaddrows/CPXaddrows can add
coefficients in columns with index greater than the value returned by
CPXXgetnumcols/CPXgetnumcols, by the use of the ccnt argument.
(See the discussion of the ccnt argument for
CPXXaddrows/CPXaddrows.) Thus, CPXXaddcols/CPXaddcols has no variable
ccnt and no array colname.
The routine CPXXnewrows/CPXnewrows can be used to add empty rows
before adding new columns via CPXXaddcols/CPXaddcols.
The nonzero elements of every column must be stored in sequential
locations in the array cmatval from position
cmatbeg[i] to cmatbeg[i+1] (or from
cmatbeg[i] to nzcnt-1 if i=ccnt-1).
Each entry, cmatind[i], specifies the row number of the
corresponding coefficient, cmatval[i]. Unlike
CPXXcopylp/CPXcopylp, all columns must be contiguous, and
cmatbeg[0] must be 0 (zero).
When you build or modify your problem with this routine,
you can verify that the results are as you intended
by calling CPXcheckaddcols
during application development.
Arguments
- env
-
A pointer to the CPLEX environment as returned by the
CPXXopenCPLEX/CPXopenCPLEXroutine. - lp
-
A pointer to a CPLEX problem object as returned by
CPXXcreateprob/CPXcreateprob. - ccnt
- An integer that specifies the number of new columns being added to the constraint matrix.
- nzcnt
- An integer that specifies the number of nonzero constraint coefficients to be added to the constraint matrix.
- obj
-
An array of length
ccntcontaining the objective function coefficients of the new variables. May be NULL, in which case, the objective coefficients of the new columns are set to 0.0 (zero). - cmatbeg
- Array that specifies the nonzero elements of the columns being added.
- cmatind
- Array that specifies the nonzero elements of the columns being added.
- cmatval
-
Array that specifies the nonzero elements of the columns being added.
The format is similar to the format used to specify the constraint matrix in the routine
CPXXcopylp/CPXcopylp. (See description ofmatbeg,matcnt,matind, andmatvalin that routine). - lb
-
An array of length
ccntcontaining the lower bound on each of the new variables. Any lower bound that is set to a value less than or equal to that of the constant-CPX_INFBOUNDis treated as negative infinity.CPX_INFBOUNDis defined in the header filecpxconst.h. May be NULL, in which case the lower bounds of the new columns are set to 0.0 (zero). - ub
-
An array of length
ccntcontaining the upper bound on each of the new variables. Any upper bound that is set to a value greater than or equal to that of the constantCPX_INFBOUNDis treated as infinity.CPX_INFBOUNDis defined in the header filecpxconst.h. May be NULL, in which case the upper bounds of the new columns are set toCPX_INFBOUND(positive infinity). - colname
-
An array of length
ccntcontaining pointers to character strings that specify the names of the new variables added to the problem object. 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 toCPXXaddcols/CPXaddcolsbut existing variables 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 = CPXaddcols (env, lp, ccnt, nzcnt, obj, cmatbeg,
cmatind, cmatval, lb, ub, newcolname);