dimod.QuadraticModel.add_variable

QuadraticModel.add_variable(vartype: Union[dimod.vartypes.Vartype, str, frozenset], v: Optional[Hashable] = None, *, lower_bound: int = 0, upper_bound: Optional[int] = None) Hashable[source]

Add a variable to the quadratic model.

Parameters
  • vartype

    Variable type. One of:

    • Vartype.SPIN, 'SPIN', {-1, 1}

    • Vartype.BINARY, 'BINARY', {0, 1}

    • Vartype.INTEGER, 'INTEGER'

  • label – A 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 – A lower bound on the variable. Ignored when the variable is not Vartype.INTEGER.

  • upper_bound – An upper bound on the variable. Ignored when the variable is not Vartype.INTEGER.

Returns

The variable label.