dimod.binary.BinaryQuadraticModel.resize#
- BinaryQuadraticModel.resize(n: int)[source]#
Resize a binary quadratic model to the specified number of variables.
- Parameters:
n – Number of variables in the resized model. If
n
is smaller than the current number of variables, variables are removed; if larger, variables are added.- Returns:
- Difference between the number of variables in the resized model
and previous model.
- Return type:
Examples
>>> bqm = dimod.BinaryQuadraticModel({"a": 1, "b": 2}, {}, 0, "BINARY") >>> bqm.resize(4) 2 >>> bqm.variables Variables(['a', 'b', 2, 3]) >>> bqm.resize(3) -1 >>> bqm.variables Variables(['a', 'b', 2])