CPXXaddlazyconstraints and CPXaddlazyconstraints
The routine CPXXaddlazyconstraints/CPXaddlazyconstraints adds
constraints to the list of constraints that should be added to the LP
subproblem of a MIP optimization if they are violated.
int CPXXaddlazyconstraints( CPXCENVptr env, CPXLPptr lp, CPXDIM rcnt, CPXNNZ nzcnt, double const * rhs, char const * sense, CPXNNZ const * rmatbeg, CPXDIM const * rmatind, double const * rmatval, char const *const * rowname )
int CPXaddlazyconstraints( CPXCENVptr env, CPXLPptr lp, int rcnt, int nzcnt, double const * rhs, char const * sense, int const * rmatbeg, int const * rmatind, double const * rmatval, char ** rowname )
Description
This is an advanced routine. Advanced routines typically demand a thorough understanding of the algorithms used by CPLEX. Thus they incur a higher risk of incorrect behavior in your application, behavior that can be difficult to debug. Therefore, the team encourages you to consider carefully whether you can accomplish the same task by means of other Callable Library routines instead.
The routine CPXXaddlazyconstraints/CPXaddlazyconstraints adds
constraints to the list of constraints that should be added to the LP
subproblem of a MIP optimization if they are violated. CPLEX handles
addition of the constraints and makes sure that all integer solutions
satisfy all the constraints. The constraints are added to those specified in
prior calls to CPXXaddlazyconstraints/CPXaddlazyconstraints.
Lazy constraints are constraints not specified in the constraint matrix of the MIP problem, but that must be not be violated in a solution. Using lazy constraints makes sense when there are a large number of constraints that must be satisfied at a solution, but are unlikely to be violated if they are left out.
The CPLEX parameter that controls
primal and dual reduction type
(CPXPARAM_Preprocessing_Reduce)
should be set to
CPX_PREREDUCE_NOPRIMALORDUAL(0) or to
CPX_PREREDUCE_PRIMALONLY(1) in order to turn off dual
reductions.
Use CPXXfreelazyconstraints/CPXfreelazyconstraints to clear the list of lazy
constraints.
The arguments of CPXXaddlazyconstraints/CPXaddlazyconstraints are similar to
those of CPXXaddrows/CPXaddrows, with the exception that new columns may
not be specified, so there are no rcnt and rowname
arguments. Furthermore, unlike CPXXaddrows/CPXaddrows,
CPXXaddlazyconstraints/CPXaddlazyconstraints does not accept a NULL pointer for the
array of righthand side values or senses. Nor does it accept ranged
rows as lazy constraints. Acceptable values of the array
sense appear in the table.
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. - rcnt
- An integer that specifies the number of new lazy constraints to be added.
- nzcnt
-
An integer that specifies the number of nonzero constraint coefficients to be added to the constraint matrix. This specifies the length of the arrays
rmatindandrmatval. - rhs
-
An array of length
rcntcontaining the righthand side (RHS) term for each lazy constraint to be added to the CPLEX problem object. - sense
-
An array of length
rcntcontaining the sense of each lazy constraint to be added to the CPLEX problem object. Possible values of this argument appear in the table. - rmatbeg
-
An array used with
rmatindandrmatvalto define the lazy constraints to be added. - rmatind
-
An array used with
rmatbegandrmatvalto define the lazy constraints to be added. - rmatval
-
An array used with
rmatbegandrmatindto define the lazy constraints to be added. The format is similar to the format used to describe the constraint matrix in the routineCPXXcopylp/CPXcopylp(see description ofmatbeg,matcnt,matind, andmatvalin that routine), but the nonzero coefficients are grouped by row instead of column in the arrayrmatval. The nonzero elements of every lazy constraint must be stored in sequential locations in this array from positionrmatbeg[i]tormatbeg[i+1]-1(or fromrmatbeg[i]tonzcnt-1ifi=rcnt-1). Each entry,rmatind[i], specifies the column index of the corresponding coefficient,rmatval[i]. UnlikeCPXcopylp, all rows must be contiguous, andrmatbeg[0]must be 0 (zero). - rowname
-
An array containing pointers to character strings that represent the names of the lazy constraints. Can be
NULL, in which case the new lazy constraints are assigned default names if the lazy constraints already resident in the CPLEX problem object have names; otherwise, no names are associated with the lazy constraints. If row names are passed toCPXXaddlazyconstraints/CPXaddlazyconstraintsbut existing lazy constraints have no names assigned, default names are created for them.
Return
The routine returns 0 (zero) if successful and nonzero if an error occurs.Example
status = CPXaddlazyconstraints (env, lp, cnt, nzcnt, rhs, sense,
beg, ind, val, NULL);
sense[i] |
'L' |
<= constraint |
sense[i] |
'E' |
= constraint |
sense[i] |
'G' |
>= constraint |