# hybrid.utils.bqm_induced_by¶

bqm_induced_by(bqm, variables, sample)[source]

Induce a binary quadratic model by fixing values of boundary variables.

The function is optimized for len(variables) << len(bqm), that is, for fixing the majority of variables.

Parameters: bqm (dimod.BinaryQuadraticModel) – Binary quadratic model (BQM). variables (list/set) – Subset of variables to keep in the reduced BQM, typically a subgraph. sample (dict/list) – Mapping of variable labels to values or a list when labels are sequential integers. Values are required only for boundary variables, that is, for variables with interactions with variables (having edges with non-zero quadratic biases connected to the subgraph). A BQM induced by fixing values of those variables adjacent to its subset of variables and setting the energy offset to zero. dimod.BinaryQuadraticModel

Examples

This example induces a 2-variable BQM from a 6-variable path graph—the subset of nodes 2 and 3 of nodes 0 to 5—by fixing values of boundary variables 1 and 4.

>>> import dimod
>>> import networkx as nx