NO FRAMES

CPXaddcols

int CPXPUBLIC CPXaddcols(CPXCENVptr env, CPXLPptr lp, int ccnt, int nzcnt, const double * obj, const int * cmatbeg, const int * cmatind, const double * cmatval, const double * lb, const double * ub, char ** colname)
Definition file: cplex.h
Include files: cplex.h

The routine CPXaddcols adds columns to a specified CPLEX problem object. This routine may be called any time after a 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 (that is, in rows with index greater than the number returned by CPXgetnumrows); whereas CPXaddrows can add coefficients in columns with index greater than the value returned by CPXgetnumcols, by the use of the ccnt argument. (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 new columns via 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], indicates the row number of the corresponding coefficient, cmatval[i]. Unlike CPXcopylp, all columns must be contiguous, and cmatbeg[0] must be 0.

Example

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

Parameters:

env

A pointer to the CPLEX environment as returned by the CPXopenCPLEX routine.

lp

A pointer to a CPLEX problem object as returned by CPXcreateprob.

ccnt

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

nzcnt

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

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.

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 CPXcopylp. (See description of matbeg, matcnt, matind, and matval in that routine).

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 is treated as negative infinity. 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.

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 is treated as infinity. 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 (positive infinity).

colname

An array of length ccnt containing 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 to CPXaddcols but existing variables have no names assigned, default names are created for them.

Returns:

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