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.
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
linindandlinval. - 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,quadcolandquadval. - 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
linvaldefines the linear part of the quadratic constraint to be added. - linval
-
An array that with
lininddefines the linear part of the constraint to be added. The nonzero coefficients of the linear terms must be stored in sequential locations in the arrayslinindandlinvalfrom positions0tolinnzcnt-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
quadcolandquadvaldefines the quadratic part of the quadratic constraint to be added. - quadcol
-
An array that with
quadrowandquadvaldefines the quadratic part of the quadratic constraint to be added. - quadval
-
An array that with
quadrowandquadcoldefine the quadratic part of the constraint to be added. The nonzero coefficients of the quadratic terms must be stored in sequential locations in the arraysquadrow,quadcolandquadvalfrom positions0toquadnzcnt-1. Each pair,quadrow[i], quadcol[i], specifies the variable indices of the quadratic term, andquadval[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.