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.
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, andqmatvaldefines the quadratic coefficient matrix. - qmatcnt
-
An array that with
qmatbeg,qmatind, andqmatvaldefines the quadratic coefficient matrix. - qmatind
-
An array that with
qmatbeg,qmatcnt, andqmatvaldefines the quadratic coefficient matrix. - qmatval
-
An array that with
qmatbeg,qmatcnt, andqmatinddefines the quadratic coefficient matrix. The arraysqmatbegandqmatcntshould be of length at leastCPXgetnumcols(env,lp). The arraysqmatindandqmatvalshould be of length at leastqmatbeg[numcols-1]+qmatcnt[numcols-1]. CPLEX requires only the nonzero coefficients grouped by column in the arrayqmatval. The nonzero elements of every column must be stored in sequential locations in this array withqmatbeg[j]containing the index of the beginning of columnjandqmatcnt[j]containing the number of entries in columnj. Note that the components ofqmatbegmust be in ascending order. For eachk,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);