dwave.optimization.model.Symbol.reset_state#

Symbol.reset_state(index)#

Reset the state of a node and any successor symbols.

Parameters:

index – Index of the state to reset.

Examples

This example sets two states on a symbol with two successor symbols and resets just one state.

>>> from dwave.optimization import Model
>>> model = Model()
>>> lsymbol, lsymbol_lists = model.disjoint_lists(primary_set_size=5, num_disjoint_lists=2)
>>> with model.lock():
...     model.states.resize(2)
...     lsymbol.set_state(0, [[0, 4], [1, 2, 3]])
...     lsymbol.set_state(1, [[3, 4], [0, 1, 2]])
...     print(f"state 0: {lsymbol_lists[0].state(0)} and {lsymbol_lists[1].state(0)}")
...     print(f"state 1: {lsymbol_lists[0].state(1)} and {lsymbol_lists[1].state(1)}")
...     lsymbol.reset_state(0)
...     print("After reset:")
...     print(f"state 0: {lsymbol_lists[0].state(0)} and {lsymbol_lists[1].state(0)}")
...     print(f"state 1: {lsymbol_lists[0].state(1)} and {lsymbol_lists[1].state(1)}")
state 0: [0. 4.] and [1. 2. 3.]
state 1: [3. 4.] and [0. 1. 2.]
After reset:
state 0: [0. 1. 2. 3. 4.] and []
state 1: [3. 4.] and [0. 1. 2.]