dwave.optimization.model.Model.num_constraints#

Model.num_constraints()#

Number of constraints in the model.

Examples

This example checks the number of constraints in the model after adding a couple of constraints.

>>> from dwave.optimization.model import Model
>>> model = Model()
>>> i = model.integer()
>>> c = model.constant([5, -14])
>>> model.add_constraint(i <= c[0])
>>> model.add_constraint(c[1] <= i)
>>> model.num_constraints()
2