dwave.optimization.symbols.QuadraticModel#
- class QuadraticModel#
Quadratic model.
Examples
This example adds a quadratic model.
>>> from dwave.optimization.model import Model >>> model = Model() >>> x = model.binary(3) >>> Q = {(0, 0): 0, (0, 1): 1, (0, 2): 2, (1, 1): 1, (1, 2): 3, (2, 2): 2} >>> qm = model.quadratic_model(x, Q) >>> type(qm) <class 'dwave.optimization.symbols.QuadraticModel'>
- __init__(*args, **kwargs)#
Methods
__init__
(*args, **kwargs)all
()Create an
All
symbol.equals
(other)Compare whether two nodes are identical.
expired
()get_linear
(v)Get the linear bias of v
get_quadratic
(u, v)Get the quadratic bias of u and v.
has_state
([index])Return the initialization status of the indexed state.
iter_predecessors
()Iterate over a node's predecessors in the model.
iter_successors
()Iterate over a node's successors in the model.
max
()Create a
Max
symbol.maybe_equals
(other)Compare to another symbol.
min
()Create a
Min
symbol.ndim
()Return the number of dimensions for a symbol.
num_interactions
()The number of quadratic interactions in the quadratic model
num_variables
()The number of variables in the quadratic model.
prod
()Create a
Prod
symbol.reset_state
(index)Reset the state of a node and any successor symbols.
reshape
(*shape)Create a
Reshape
symbol.shape
()Return the shape of the symbol.
shares_memory
(other)Determine if two symbols share memory.
size
()Return the number of elements in the symbol.
state
([index, copy])Return the state of the node.
state_size
()Return an estimated byte-size of the state.
strides
()Return the stride length, in bytes, for traversing a symbol.
sum
()Create a
Sum
symbol.topological_index
()Topological index of the node.
Attributes
model