straindesign.indicatorConstraints
Class for indicator contraints (IndicatorConstraints)
Module Contents
- class straindesign.indicatorConstraints.IndicatorConstraints(binv, A, b, sense, indicval)[source]
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 <sense> 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 <sense_1> b_1 x_binv_2 = indicval_2 -> A_2 * x <sense_2> b_2 …
Example
ic = IndicatorConstraints(binv, A, b, sense, indicval)
- Parameters:
binv (list of int) – (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.
A (sparse.csr_matrix) – 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)
b (list of float) – Right hand sides of all indicator constraints. (e.g.: [0.1, 2.0, 3])
sense (str) – (In)equality signs for all indicator constraints. ‘L’ess or equal, ‘E’qual or, ‘G’reater or equal (e.g.: ‘EEGLGLGE’)
indicval (list of int) – Indicator values for all indicator constraints. Which value of the indicator enforces the constraint, 0 or 1? (e.g., 0001010110)
- Returns:
An object of the IndicatorConstraints class to pass indicator constraints.
- Return type: