BinaryQuadraticModel.add_linear_inequality_constraint(terms: Iterable[Tuple[Hashable, int]], lagrange_multiplier: Union[float, numpy.floating, numpy.integer], label: str, constant: int = 0, lb: int = - 9223372036854775808, ub: int = 0, cross_zero: bool = False) Iterable[Tuple[Hashable, int]][source]

Add a linear inequality constraint as a quadratic objective.

The linear inequality constraint is of the form: \(lb <= \sum_{i,k} a_{i,k} x_{i,k} + constant <= ub\).

For constraints with fractional coefficients, multiply both sides of the inequality by an appropriate factor of ten to attain or approximate integer coefficients.

  • terms – Values of the \(\sum_{i} a_{i} x_{i}\) term as an \(i\)–length iterable of 2-tuples, (variable, bias), with each tuple constituting a term in the summation.

  • lagrange_multiplier – Weight or penalty strength. The linear constraint is multiplied by this value (which does not appear explicitly in the above equation) when added to the binary quadratic model.

  • label – Prefix for labels of any slack variables used in the added objective.

  • constant – Value of the constant term of the linear constraint.

  • lb – Lower bound for the constraint.

  • ub – Upper bound for the constraint.

  • cross_zero – When True, adds zero to the domain of constraint.


Values of \(\sum_{i} b_{i} slack_{i}\) as an \(i\)–length iterable of 2-tuples, (slack variable, bias), with each tuple constituting a term in the summation.

Return type