dimod.QuadraticModel.add_variables_from#

QuadraticModel.add_variables_from(vartype: Literal[Vartype.SPIN, 'SPIN', Vartype.BINARY, 'BINARY', Vartype.INTEGER, 'INTEGER', Vartype.REAL, 'REAL'], variables: Iterable[Hashable])[source]#

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

Parameters:
  • vartype

    Variable type. One of:

  • variables – collections.abc.Iterable of variable labels.

Examples

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