straindesign.indicatorConstraints ================================= .. py:module:: straindesign.indicatorConstraints .. autoapi-nested-parse:: Class for indicator contraints (IndicatorConstraints) Module Contents --------------- .. py:class:: IndicatorConstraints(binv, A, b, sense, indicval) A class for storing indicator contraints This class is a container for indicator constraints. Indicator constraints are used to link the fulfillment of a constraint to an indicating variable. For instance the indicator constraint: z = 1 -> 2*d - 1*e <= 3 can be described as: If z=1, then 2*d - 1*e <= 3 An alternative formulation of this association is possible with a bigM constraint: 2*d - 1*e - z*M <= 3, with M = very large The constraint z = 0 -> 2*d - 1*e <= 3 would translate to 2*d - 1*e + z*M <= 3 + M Generally, indicator constraints are preferred over bigM, because they provide better numerical stability. However, not all solvers support indicator constraints Indicator constraints have the form: x_binv = indicval -> a * x b e.g.,: x_35 = 1 -> 2 * x_2 + 3 *x_3 'L' 6 (<=) This class contains a set of indicator constraints: x_binv_1 = indicval_1 -> A_1 * x b_1 x_binv_2 = indicval_2 -> A_2 * x b_2 ... .. rubric:: Example ic = IndicatorConstraints(binv, A, b, sense, indicval) :param binv: (e.g.: [25, 27, 30]) The index of the binary, indicating variables (indicators) for all indicator constraints. Integers are allowed ot occur more than once. :type binv: list of int :param A: Coefficient vectors for all indicator constraints, stored in one matrix, whereas each row is used in one indicator constraint. (num_columns = number of variables, num_rows = number of indicator constraints) :type A: sparse.csr_matrix :param b: Right hand sides of all indicator constraints. (e.g.: [0.1, 2.0, 3]) :type b: list of float :param sense: (In)equality signs for all indicator constraints. 'L'ess or equal, 'E'qual or, 'G'reater or equal (e.g.: 'EEGLGLGE') :type sense: str :param indicval: Indicator values for all indicator constraints. Which value of the indicator enforces the constraint, 0 or 1? (e.g., 0001010110) :type indicval: list of int :returns: An object of the IndicatorConstraints class to pass indicator constraints. :rtype: (IndicatorConstraints)