CPXXaddqconstr and CPXaddqconstr

The routine CPXXaddqconstr/CPXaddqconstr adds a quadratic constraint to a specified CPLEX problem object.

int  CPXXaddqconstr( CPXCENVptr env, CPXLPptr lp, CPXDIM linnzcnt, CPXNNZ quadnzcnt, double rhs, int sense, CPXDIM const * linind, double const * linval, CPXDIM const * quadrow, CPXDIM const * quadcol, double const * quadval, char const * lname_str )

int  CPXaddqconstr( CPXCENVptr env, CPXLPptr lp, int linnzcnt, int quadnzcnt, double rhs, int sense, int const * linind, double const * linval, int const * quadrow, int const * quadcol, double const * quadval, char const * lname_str )

Description

The routine CPXXaddqconstr/CPXaddqconstr adds a quadratic constraint to a specified CPLEX problem object. This routine may be called any time after a call to CPXXcreateprob/CPXcreateprob.

Table 1. Codes for sense of constraints in QCPs
sense[i] = 'L' <= constraint
sense[i] = 'G' >= constraint

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.
linnzcnt
An integer that specifies the number of nonzero constraint coefficients in the linear part of the constraint. This specifies the length of the arrays linind and linval.
quadnzcnt
An integer that specifies the number of nonzero constraint coefficients in the quadratic part of the constraint. This specifies the length of the arrays quadrow, quadcol and quadval.
rhs
The righthand side term for the constraint to be added.
sense
The sense of the constraint to be added. Note that quadratic constraints may only be less-than-or-equal-to or greater-than-or-equal-to constraints. See the discussion of QCP in the CPLEX User's Manual.
linind
An array that with linval defines the linear part of the quadratic constraint to be added.
linval
An array that with linind defines the linear part of the constraint to be added. The nonzero coefficients of the linear terms must be stored in sequential locations in the arrays linind and linval from positions 0 to linnzcnt-1. Each entry, linind[i], specifies the variable index of the corresponding coefficient, linval[i]. May be NULL; then the constraint will have no linear terms.
quadrow
An array that with quadcol and quadval defines the quadratic part of the quadratic constraint to be added.
quadcol
An array that with quadrow and quadval defines the quadratic part of the quadratic constraint to be added.
quadval
An array that with quadrow and quadcol define the quadratic part of the constraint to be added. The nonzero coefficients of the quadratic terms must be stored in sequential locations in the arrays quadrow, quadcol and quadval from positions 0 to quadnzcnt-1. Each pair, quadrow[i], quadcol[i], specifies the variable indices of the quadratic term, and quadval[i] the corresponding coefficient.
lname_str
The name of the constraint to be added. May be NULL, in which case the new constraint is assigned a default name if the quadratic constraints already resident in the CPLEX problem object have names; otherwise, no name is associated with the constraint.

Return

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

Example


 status = CPXaddqconstr (env, lp, linnzcnt, quadnzcnt, rhsval,
                         sense, linind, linval,
                         quadrow, quadcol, quadval, NULL);
 

See also the example qcpex1.c in the CPLEX User's Manual and in the standard distribution.