CPXcopyquad


Description

The routine CPXcopyquad() is used to copy a Q matrix when Q is not diagonal. The arguments qmatbeg, qmatcnt, qmatind, and qmatval are used to specify the nonzero coefficients of the matrix Q. The meaning of these vectors is identical to the meaning of the corresponding vectors matbeg, matcnt, matind and matval, which are used to specify the structure of A in a call to CPXcopylp().

Q must be symmetric when copied using this function. Therefore if the quadratic coefficient in algebraic form is 2x1x2, then x2 should be in the list for x1, and x1 should be in the list for x2, and the coefficient would be 1.0 in each of those entries. See the corresponding example C program to review how the symmetry requirement is implemented.

Return Value

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

Synopsis

  int CPXcopyquad (CPXCENVptr env,
                   CPXLPptr lp,
                   const int *qmatbeg,
                   const int *qmatcnt,
                   const int *qmatind,
                   const double *qmatval);

Arguments

CPXCENVptr env

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

CPXLPptr lp

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

const int *qmatbeg

const int *qmatcnt

const int *qmatind

const double *qmatval

Arrays that describe the quadratic coefficient matrix. The arrays qmatbeg and qmatcnt should be of length at least CPXgetnumcols(env,lp). The arrays qmatind and qmatval should be of length at least qmatbeg[numcols-1]+qmatcnt[numcols-1]. CPLEX requires only the nonzero coefficients grouped by column in the array qmatval. The nonzero elements of every column must be stored in sequential locations in this array with qmatbeg[j] containing the index of the beginning of column j and qmatcnt[j] containing the number of entries in column j. Note that the components of qmatbeg must be in ascending order. For each k, qmatind[k] indicates the column number of the corresponding coefficient, qmatval[k]. These arrays are accessed as follows:

Suppose that CPLEX wants to access the entries in a column j. These are assumed to be given by the array entries:

  qmatval[qmatbeg[j]],..,qmatval[qmatbeg[j]+qmatcnt[j]-1]

The corresponding column/index entries are:

  qmatind[qmatbeg[j]],..,qmatind[qmatbeg[j]+qmatcnt[j]-1

The entries in qmatind[k] are not required to be in row order. Duplicate entries in qmatind within a single column are not allowed. Note that any column j that has only a linear objective term has qmatcnt[j] = 0 and no entries in qmatind and qmatval.

Example

  status = CPXcopyquad (env, lp, qmatbeg, qmatcnt, qmatind,
                        qmatval);

See Also

CPXreadcopyqp()
Example qpex1.c in the CPLEX User's Manual.

Previous Page: CPXcopyqpsep Return to Top Next Page: CPXcopysos