NO FRAMES

CPXcopyquad

int CPXPUBLIC CPXcopyquad(CPXCENVptr env, CPXLPptr lp, const int * qmatbeg, const int * qmatcnt, const int * qmatind, const double * qmatval)
Definition file: cplex.h
Include files: cplex.h

The routine CPXcopyquad is used to copy 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 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.

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.

Example

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

See Also:

Parameters:

env

A pointer to the CPLEX environment as returned by CPXopenCPLEX.

lp

A pointer to a CPLEX problem object as returned by 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 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 explained above.

Returns:

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