CPXXaddindconstraints and CPXaddindconstraints
Adds a set of indicator constraints to the specified problem object.
int CPXXaddindconstraints( CPXCENVptr env, CPXLPptr lp, CPXDIM indcnt, int const * type, CPXDIM const * indvar, int const * complemented, CPXNNZ nzcnt, double const * rhs, char const * sense, CPXNNZ const * linbeg, CPXDIM const * linind, double const * linval, char const *const * indname )
int CPXaddindconstraints( CPXCENVptr env, CPXLPptr lp, int indcnt, int const * type, int const * indvar, int const * complemented, int nzcnt, double const * rhs, char const * sense, int const * linbeg, int const * linind, double const * linval, char const *const * indname )
Description
The routine
CPXXaddindconstraints/CPXaddindconstraints
adds a set of indicator constraints
to the specified problem object. You can call this routine any time
after a call to CPXXcreateprob/CPXcreateprob.
An indicator constraint defines a relationship between a binary variable (the indicator variable) and a linear constraint. The linear constraint can be a less-than-or-equal-to constraint, a greater-than-or-equal-to constraint, or an equality constraint. There are three types of indicator constraints:
CPX_INDICATOR_IF: In this case, the linear constraint is enforced only if the indicator variable is not complemented and takes the value 1 (one) or if it is complemented and takes the value 0 (zero).CPX_INDICATOR_ONLYIF: This case is the reverse of the previous case. If the linear constraint is satisfied, then the indicator variable must take the value 1 (one) if it is not complemented or must take the value 0 (zero) if it is complemented.CPX_INDICATOR_IFANDONLYIF. Both of the previous cases must hold true.
In the case of
CPX_INDICATOR_ONLYIF, the condition
is whether the linear constraint (say, ax <= b)
is satisfied or not. When it is not satisfied, then CPLEX is dealing with a
strict inequality. Since strict inqualities cannot be represented as such,
CPLEX handles this dichotomy as ax <= b and
ax >= b + epsilon. The "only if" part of
CPX_INDICATOR_IFANDONLYIF is
treated similarly. CPLEX consults the linearization parameter
epsilon (degree of tolerance) used in linearization
when it needs to perform this transformation.
The linear portion of the indicator constraints are specified in the same style that rows-to-be-added are specified in CPXXaddrows and CPXaddrows.
Arguments
- env
-
A pointer to the CPLEX environment, as returned by
CPXXopenCPLEX/CPXopenCPLEX. - lp
-
A pointer to a CPLEX LP problem object, as returned by
CPXXcreateprob/CPXcreateprob. - indcnt
-
The number of indicator constraints. This argument specifies
the length of the arrays in the arguments
indvar,complemented,rhs,sense,linbeg,type,indname. - type
-
An array of integers that specifies the type
(
CPX_INDICATOR_IF,CPX_INDICATOR_ONLYIF, orCPX_INDICATOR_IFANDONLYIF) of each indicator constraint. This argument can be NULL; in that case, all entries are set toCPX_INDICATOR_IF. - indvar
- The indices of the binary variables that act as the indicator variables for the indicator constraints. This argument can be NULL; in that case, all entries are set to -1. (That is, no indicator variable is set.)
- complemented
- An array of Boolean values that specify for each indicator variable whether the variable is complemented. This argument can be NULL; in that case, all entries are set to 0 (zero).
- nzcnt
-
The total number of nonzero coefficients in the linear
constraint part of the indicator constraints. This
argument gives the length of the arrays
linindandlinval. - rhs
- The righthand side values for the linear portion of the indicator constraints. This argument can be NULL; in that case, all entries are set to 0.0 (zero point zero).
- sense
- The sense values of the linear portion of the indicator constraints. Specify 'L' for <= or 'G' for >= or 'E' for ==. This argument can be NULL; in that case, all entries are set to 'E'.
- linbeg
-
An array used with
linindandlinvalto define the linear portion of the indicator constraints. - linind
-
An array used with
linbegandlinvalto define the linear portion of the indicator constraints. - linval
-
An array used with
linbegandlinindto define the the linear portion of the indicator constraints. The format is similar to the format used to define the rows-to-be-added in the routine CPXXaddrows and CPXaddrows. (See also the description ofrcnt,nzcnt,rmatbeg,rmatind, andrmatvalin that routine). - indname
- The array of the names of the constraint constraints. This argument can be NULL; in that case, the new constraints are assigned a default name if the indicator constraints already resident in the CPLEX problem object have names; otherwise, no names are associated with the new constraints.
Return
The routine returns zero if successful and nonzero if an error occurs.Example
status = CPXaddindconstraints (env, lp, numind, type, indicator,
complemented, nzcnt,
rhs, sense, linbeg, linind, linval,
newindnames);