Previous Page: CPXaddchannelFirst PageNext Page: CPXaddfpdest

CPXaddcols


Description

The routine CPXaddcols() adds columns to a specified LP problem object. This routine may be called any time after an LP problem object is created via CPXcreateprob().

The routine CPXaddcols() is very similar to the routine CPXaddrows(). The primary difference is that CPXaddcols() cannot add coefficients in rows that do not already exist (i.e. in rows with index greater than the number returned by CPXgetnumrows(). Whereas by the use of the ccnt argument, CPXaddrows() can add coefficients in columns with index greater than the value returned by CPXgetnumcols(); see the discussion of the ccnt argument for CPXaddrows(). Thus, CPXaddcols() has no variable rcnt and no array rowname. The routine CPXnewrows() can be used to add empty rows before adding the new columns via CPXaddcols().

Return Value

The routine returns a zero on success, and a nonzero if an error occurs.

Synopsis

int CPXaddcols (CPXENVptr env,
                CPXLPptr lp,
                int ccnt,
                int nzcnt,
                double *obj,
                int *cmatbeg,
                int *cmatind,
                double *cmatval,
                double *lb,
                double *ub,
                char **colname);

Arguments


CPXENVptr env
The pointer to the CPLEX environment as returned by one of the CPXopenCPLEX routines.

CPXLPptr lp
A pointer to a CPLEX LP problem object as returned by CPXcreateprob().

int ccnt
An integer that indicates the number of new columns being added to the constraint matrix.

int nzcnt
An integer that indicates the number of nonzero constraint coefficients to be added to the constraint matrix.

double *obj
An array of length ccnt containing 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.

int *cmatbeg
int *cmatind
double *cmatval
These three arguments are arrays that specify the nonzero elements of the columns being added. The format is similar to the format used to specify the constraint matrix in the routine CPXcopylp() (see description of matbeg, matcnt, matind and matval). 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], indicates the row number of the corresponding coefficient, cmatval[i]. Unlike CPXcopylp() the columns all need to be contiguous and cmatbeg[0] must be 0.

double *lb
An array of length ccnt containing 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_INFBOUND will be treated as -·. CPX_INFBOUND is defined in the header file cplex.h. May be NULL, in which case, the lower bounds of the new columns are set to 0.0.

double *ub
An array of length ccnt containing 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 constant CPX_INFBOUND will be treated as ·. CPX_INFBOUND is defined in the header file cplex.h. May be NULL, in which case, the upper bounds of the new columns are set to CPX_INFBOUND (+·).

char **colname
An array of length ccnt containing pointers to character strings that specify the names of the new variables added to the LP problem object. colname may be NULL in which case the new columns are assigned default names if the columns already resident in the LP problem object have names; otherwise no names are associated with the variables. If column names are passed to CPXnewcols() but existing variables have no names assigned, default names are created for them.

Example

status = CPXaddcols (env, lp, ccnt, nzcnt, obj, cmatbeg,
                     cmatind, cmatval, lb, ub, newcolname);

Previous Page: CPXaddchannelFirst PageNext Page: CPXaddfpdest