dwave.optimization.model.Symbol.iter_predecessors#
- Symbol.iter_predecessors()#
Iterate over a symbol’s predecessors in the model.
Examples
This example constructs a \(b = \sum a\) model, where \(a\) is a multiplication of two symbols, and iterates over the predecessor’s of \(b\) (which is just \(a\)).
>>> from dwave.optimization.model import Model >>> model = Model() >>> i = model.integer((2, 2), upper_bound=20) >>> c = model.constant([[21, 11], [10, 4]]) >>> a = c * i >>> b = a.sum() >>> a.equals(next(b.iter_predecessors())) True