CPXaddcols


Description

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().

Return Value

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

Synopsis

  int 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);

Arguments

CPXCENVptr env

The pointer to the CPLEX environment as returned by the CPXopenCPLEX() routine.

CPXLPptr lp

A pointer to a CPLEX 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.

const 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.

const int *cmatbeg

const int *cmatind

const double *cmatval

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 in that routine).

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.

const 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 is 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.

const 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 is 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 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.

Example

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


Previous Page: CPXaddchannel Return to Top Next Page: CPXaddfpdest