Solve a published benchmark and compare its result#
The dataset loaders return ordinary Instance objects.
Install the SDK and PySCIPOpt adapter to run this example. The first retrieval
requires access to the public registry. The same solver can then be used with
either distribution.
from math import isclose
from ommx import dataset
from ommx_pyscipopt_adapter import OMMXPySCIPOptAdapter
mip = dataset.miplib2017("neos-1122047")
result = OMMXPySCIPOptAdapter.solve(mip)
published = float(mip.annotations["org.ommx.miplib.objective"])
assert result.feasible
assert isclose(result.objective, published, abs_tol=1e-6)
The MIPLIB annotation is a string describing the benchmark. Convert it to a
number before comparing it with the evaluated solver result. QPLIB annotations
instead use the org.ommx.qplib.* prefix and include the problem type and
objective curvature.
quadratic = dataset.qplib("3514")
print(quadratic.annotations["org.ommx.qplib.probtype"])
result = OMMXPySCIPOptAdapter.solve(quadratic)
assert result.feasible
If you already have candidate values, the QPLIB solution example shows how to evaluate them without searching.