indicator
indicator |
Purpose
Synopsis
function indicator(type:integer,y:mpvar,ctr:linctr):logctr
Arguments
type
|
The indicator type:
|
||||
y
|
The variable associated to the constraint
|
||||
ctr
|
A linear inequality constraint
|
Return value
Example
This example shows how to define two indicator constraints. The second constraint labeled
L is stated with the help of an auxiliary linear constraint definition. This temporary constraint
C needs to be deleted from the problem after having been used in the definition of the indicator constraint. The notation
b(1)=1 -> ... should be read as 'if b(1) takes the value 1 then ... must hold'
declarations R=1..2, S=1..3 C: linctr ! Linear constraint L: logctr ! Logical (indicator) constraint x: array(S) of mpvar ! Decision variables b: array(R) of mpvar ! Indicator variables end-declarations forall(i in R) b(i) is_binary ! Indicator variables must be binaries C:= x(2)+x(3)<=5 ! Constraint to transform into indicator ctr. ! Define 2 indicator constraints indicator(1, b(1), x(1)+x(2)>=12) ! b(1)=1 -> x(1)+x(2)>=12 L:= indicator(-1, b(2), C) ! b(2)=0 -> x(2)+x(3)<=5 C:=0 ! Delete the auxiliary constraint definition
Related topics
Module