dwave.optimization.model.States.resize#

States.resize(n)#

Resize the number of states.

If n is smaller than the current size(), states are reduced to the first n states by removing those beyond. If n is greater than the current size(), new uninitialized states are added as needed to reach a size of n.

Resizing to 0 is not guaranteed to clear the memory allocated to states.

Parameters:

n – Required number of states.

Examples

This example adds three uninitialized states to a model.

>>> from dwave.optimization.model import Model
>>> model = Model()
>>> i = model.integer(2)
>>> model.states.resize(3)