OPTIMISATION
quadratic_assignment
Approximates solution to the quadratic assignment problem and.
Example of usage
Python API reference included; executable data demonstration pending review.
Usage / limitations
+Use when: Find solutions efficiently.
−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.
Mathematical formula
See method documentation: implementation and assumptions vary.
Sample dataShow
{
"variable": "design_case",
"domain": "Engineering parameter estimation and optimisation",
"feature_names": [
"measurement_time_s",
"response_mm"
],
"records": [
{
"measurement_time_s": 0,
"response_mm": 1
},
{
"measurement_time_s": 1,
"response_mm": 3
},
{
"measurement_time_s": 2,
"response_mm": 5
},
{
"measurement_time_s": 3,
"response_mm": 7
},
{
"measurement_time_s": 4,
"response_mm": 9
}
],
"target_value": 4.0,
"lower_bound": 0.0,
"upper_bound": 4.0,
"method": "quadratic-assignment"
}
Code example (Python)
design_case = {'variable': 'design_case', 'domain': 'Engineering parameter estimation and optimisation', 'feature_names': ['measurement_time_s', 'response_mm'], 'records': [{'measurement_time_s': 0, 'response_mm': 1}, {'measurement_time_s': 1, 'response_mm': 3}, {'measurement_time_s': 2, 'response_mm': 5}, {'measurement_time_s': 3, 'response_mm': 7}, {'measurement_time_s': 4, 'response_mm': 9}], 'target_value': 4.0, 'lower_bound': 0.0, 'upper_bound': 4.0, 'method': 'quadratic-assignment'}
# DataLens.ai example — quadratic_assignment
# Domain: engineering parameter estimation and optimisation.
# The sample data are included by “Copy input + code + test”.
import numpy as np
from scipy import optimize
# Read the named engineering measurements.
times = np.array([row["measurement_time_s"] for row in design_case["records"]], dtype=float)
responses = np.array([row["response_mm"] for row in design_case["records"]], dtype=float)
# Use a known target, making the numerical assertion independently meaningful.
target = design_case["target_value"]
# Match three production stations to minimise flow times separation.
# Distances and flows are symmetric and labelled as station-to-station costs.
flows = np.array([[0,10,0],[10,0,1],[0,1,0]])
distances = np.array([[0,1,3],[1,0,2],[3,2,0]])
result = optimize.quadratic_assignment(flows,distances,method='faq',options={'rng':42})
permutation = result.col_ind
# Verify reported objective against a direct recomputation (not assumed global optimality).
computed = float(np.sum(flows*distances[np.ix_(permutation,permutation)]))
assert sorted(permutation.tolist())==[0,1,2] and np.isclose(computed,result.fun)
print("Expected output verified")
# DataLens.ai example — quadratic_assignment
# Domain: engineering parameter estimation and optimisation.
# The sample data are included by “Copy input + code + test”.
import numpy as np
from scipy import optimize
# Read the named engineering measurements.
times = np.array([row["measurement_time_s"] for row in design_case["records"]], dtype=float)
responses = np.array([row["response_mm"] for row in design_case["records"]], dtype=float)
# Use a known target, making the numerical assertion independently meaningful.
target = design_case["target_value"]
# Match three production stations to minimise flow times separation.
# Distances and flows are symmetric and labelled as station-to-station costs.
flows = np.array([[0,10,0],[10,0,1],[0,1,0]])
distances = np.array([[0,1,3],[1,0,2],[3,2,0]])
result = optimize.quadratic_assignment(flows,distances,method='faq',options={'rng':42})
permutation = result.col_ind
# Verify reported objective against a direct recomputation (not assumed global optimality).
computed = float(np.sum(flows*distances[np.ix_(permutation,permutation)]))
assert sorted(permutation.tolist())==[0,1,2] and np.isclose(computed,result.fun)
print("Expected output verified")