Indicator constraints
- associate a binary variable b with a linear constraint C
- model an implication:
'if b=1 then C', in symbols: b → C, or
'if b=0 then C', in symbols: b- → C
(the constraint C is active only if the condition is true) - use indicator constraints for the composition of logic expressions
Indicator constraints in Mosel: for the definition of indicator constraints (function indicator of module mmxprs) you need a binary variable (type mpvar) and a linear inequality constraint (type linctr). You also have to specify the type of the implication (1 for b → C and -1 for b- → C). The subroutine indicator returns a new constraint of type logctr that can be used in the composition of other logic expressions (see Section Logic constructs below).
uses "mmxprs" declarations R=1..10 C: array(range) of linctr L: array(range) of logctr x: array(R) of mpvar b: array(R) of mpvar end-declarations forall(i in R) b(i) is_binary ! Variables for indicator constraints C(2):= x(2)<=5 ! Define 2 indicator constraints L(1):= indicator(1, b(1), x(1)+x(2)>=12) ! b(1)=1 -> x(1)+x(2)>=12 indicator(-1, b(2), C(2)) ! b(2)=0 -> x(2)<=5 C(2):=0 ! Delete auxiliary constraint definition
Indicator constraints in BCL: an indicator constraint is defined by associating a binary decision variable (XPRBvar) and an integer flag (1 for b → C and -1 for b- → C) with a linear inequality or range constraint (XPRBctr). By defining an indicator constraint (function XPRBsetindicator or method XPRBctr.setIndicator() depending on the host language) the type of the constraint itself gets changed; it can be reset to 'standard constraint' by calling the setIndicator function with flag value 0.
XPRBprob prob("testind"); XPRBvar x[N], b[N]; XPRBctr IndCtr[N]; int i; // Create the decision variables for(i=0;i<N;i++) x[i] = prob.newVar("x", XPRB_PL); // Continuous variables for(i=0;i<N;i++) b[i] = prob.newVar("b", XPRB_BV); // Indicator variables // Define 2 linear inequality constraints IndCtr[0] = prob.newCtr("L1", x[0]+x[1]>=12); IndCtr[1] = prob.newCtr("L2", x[1]<=5); // Turn the 2 constraints into indicator constraints IndCtr[0].setIndicator(1, b[0]); // b(0)=1 -> x(0)+x(1)>=12 IndCtr[1].setIndicator(-1, b[1]); // b(1)=0 -> x(1)<=5
© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.