dimod.QuadraticModel.add_variables_from

QuadraticModel.add_variables_from(vartype: Union[dimod.vartypes.Vartype, str, frozenset], variables: Iterable[Hashable])[source]

Add multiple variables of the same type to the quadratic model.

Parameters
  • vartype

    Variable type. One of:

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

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

    • Vartype.INTEGER, 'INTEGER'

  • variables – Iterable of variable labels.

Examples

>>> from dimod import QuadraticModel, Binary
>>> qm = QuadraticModel()
>>> qm.add_variables_from('BINARY', ['x', 'y'])