dimod.QuadraticModel.add_variables_from_model#

QuadraticModel.add_variables_from_model(model: BinaryQuadraticModel | ConstrainedQuadraticModel | QuadraticModel, *, variables: Iterable[Variable] | None = None)[source]#

Add variables from another model.

Parameters:
  • model – A binary quadratic model, constrained quadratic model or quadratic model.

  • variables – The variables from the model to add. If not specified all of the variables are added.

Examples

>>> qm0 = dimod.Integer('i', lower_bound=5, upper_bound=10) + dimod.Binary('x')
>>> qm1 = dimod.QuadraticModel()
>>> qm1.add_variables_from_model(qm0)
>>> qm1.variables
Variables(['i', 'x'])
>>> qm1.lower_bound('i')
5.0