dimod.generators.quadratic_assignment#
- quadratic_assignment(distance_matrix: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], flow_matrix: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ConstrainedQuadraticModel [source]#
Generates a constrained quadratic model encoding a quadratic-assignment problem.
Given distance and flow matrices, generates a
ConstrainedQuadraticModel
for the corresponding quadratic-assignment problem.- Parameters:
distances – Distances between locations \(i\) and \(j\) as a NumPy array.
flows – Flows between facilities \(i\) and \(j\) as a NumPy array.
- Returns:
The constrained quadratic model encoding the quadratic-assignment problem. Variables are denoted as
x_{i}_{j}
wherex_{i}_{j} == 1
means that facilityi
is placed in locationj
.