dimod.QuadraticModel.add_variable#

QuadraticModel.add_variable(vartype: Vartype | str | frozenset, v: Hashable | None = None, *, lower_bound: float = 0, upper_bound: float | None = None) Hashable[source]#

Add a variable to the quadratic model.

Parameters:
  • vartype

    Variable type. One of:

  • v – Label for the variable. Defaults to the length of the quadratic model, if that label is available. Otherwise defaults to the lowest available positive integer label.

  • lower_bound – Lower bound on the variable. Ignored when the variable is BINARY or SPIN.

  • upper_bound – Upper bound on the variable. Ignored when the variable is BINARY or SPIN.

Returns:

The variable label.