DiscreteQuadraticModel.add_variable(num_cases, label=None)[source]#

Add a discrete variable.

  • num_cases (int) – The number of cases in the variable. Must be a positive integer.

  • label (hashable, optional) – A label for the variable. Can be any hashable except None. Defaults to the length of the discrete quadratic model, if that label is available. Otherwise defaults to the lowest available positive integer label.


The label of the new variable.

  • ValueError – If label already exists as a variable label.

  • TypeError – If label is not hashable.