CPXXcopyquad and CPXcopyquad

The routine CPXXcopyquad/CPXcopyquad is used to copy a quadratic objective matrix Q when Q is not diagonal.

int  CPXXcopyquad( CPXCENVptr env, CPXLPptr lp, CPXNNZ const * qmatbeg, CPXDIM const * qmatcnt, CPXDIM const * qmatind, double const * qmatval )

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

Description

The routine CPXXcopyquad/CPXcopyquad is used to copy a quadratic objective matrix Q 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 CPXXcopylp/CPXcopylp.

Q must be symmetric when copied by 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.

Note: CPLEX evaluates the corresponding objective with a factor of 0.5 in front of the quadratic objective term.

When you build or modify your model with this routine, you can verify that the results are as you intended by calling CPXcheckcopyquad during application development.

How the arrays are accessed

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

Arguments

env
A pointer to the CPLEX environment as returned by CPXXopenCPLEX/CPXopenCPLEX.
lp
A pointer to a CPLEX problem object as returned by CPXXcreateprob/CPXcreateprob.
qmatbeg
An array that with qmatcnt, qmatind, and qmatval defines the quadratic coefficient matrix.
qmatcnt
An array that with qmatbeg, qmatind, and qmatval defines the quadratic coefficient matrix.
qmatind
An array that with qmatbeg, qmatcnt, and qmatval defines the quadratic coefficient matrix.
qmatval
An array that with qmatbeg, qmatcnt, and qmatind defines 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 columnjand 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 explained above.

Return

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

Example


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