NO FRAMES

CPXaddlazyconstraints

int CPXPUBLIC CPXaddlazyconstraints(CPXCENVptr env, CPXLPptr lp, int rcnt, int nzcnt, const double * rhs, const char * sense, const int * rmatbeg, const int * rmatind, const double * rmatval)
Definition file: cplex.h
Include files: cplex.h

The routine CPXaddlazyconstraints is used to add 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 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 CPX_PARAM_REDUCE should be set to CPX_PREREDUCE_NOPRIMALORDUAL (0) or to CPX_PREREDUCE_PRIMALONLY (1) in order to turn off dual reductions.

Use CPXfreelazyconstraints to clear the list of lazy constraints.

The arguments of CPXaddlazyconstraints are the same as those of CPXaddrows, with the exception that new columns may not be specified, so there are no ccnt and colname arguments, and row names may not be specified, so there is no rowname argument. Furthermore, unlike CPXaddrows, CPXaddlazyconstraints does not accept a NULL pointer for the array of right-hand side values.

Example

 status = CPXaddlazyconstraints(env, lp, cnt, nzcnt, rhs, sense,
                                beg, ind, val);
 

Parameters:

env

A pointer to the CPLEX environment as returned by CPXopenCPLEX.

lp

A pointer to a CPLEX problem object as returned by CPXcreateprob.

rcnt

An integer that indicates the number of new lazy constraints to be added.

nzcnt

An integer that indicates the number of nonzero constraint coefficients to be added to the constraint matrix. This specifies the length of the arrays rmatind and rmatval.

rhs

An array of length rcnt containing the right-hand side (RHS) term for each constraint to be added to the CPLEX problem object. May be NULL, in which case the new right-hand side values are set to 0.0.

sense

An array of length rcnt containing the sense of each constraint to be added to the CPLEX problem object. May be NULL, in which case the new constraints are created as equality constraints. Possible values of this argument appear in the table.

rmatbeg

An array used with rmatind and rmatval to define the lazy constraints to be added.

rmatind

An array used with rmatbeg and rmatval to define the lazy constraints to be added.

rmatval

An array used with rmatbeg and rmatind to define the lazy constraints to be added. The format is similar to the format used to describe the constraint matrix in the routine CPXcopylp (see description of matbeg, matcnt, matind, and matval in that routine), but the nonzero coefficients are grouped by row instead of column in the array rmatval. The nonzero elements of every lazy constraint must be stored in sequential locations in this array from position rmatbeg[i] to rmatbeg[i+1]-1 (or from rmatbeg[i] to nzcnt -1 if i=rcnt-1). Each entry, rmatind[i], indicates the column index of the corresponding coefficient, rmatval[i]. Unlike CPXcopylp, all rows must be contiguous, and rmatbeg[0] must be 0 (zero).

Returns:

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