| 1 |
from pathlib import Path |
| 2 |
import subprocess |
| 3 |
import json |
| 4 |
|
| 5 |
|
| 6 |
def test_mip_stats(): |
| 7 |
from minizinc import default_driver, Driver |
| 8 |
|
| 9 |
assert isinstance(default_driver, Driver) |
| 10 |
model_file = Path(__file__).with_suffix(".mzn").resolve() |
| 11 |
|
| 12 |
p = subprocess.run( |
| 13 |
[ |
| 14 |
default_driver._executable, |
| 15 |
model_file, |
| 16 |
"--json-stream", |
| 17 |
"--solver", |
| 18 |
"highs", |
| 19 |
], |
| 20 |
stdin=None, |
| 21 |
stdout=subprocess.PIPE, |
| 22 |
stderr=subprocess.PIPE, |
| 23 |
) |
| 24 |
|
| 25 |
actual = [json.loads(l) for l in p.stdout.splitlines(False)] |
| 26 |
if any( |
| 27 |
m["type"] == "error" |
| 28 |
and (m["what"] == "plugin loading error" or m["what"] == "configuration error") |
| 29 |
for m in actual |
| 30 |
): |
| 31 |
import pytest |
| 32 |
|
| 33 |
pytest.skip("HiGHS not available") |
| 34 |
return |
| 35 |
assert p.returncode == 0 |
| 36 |
stats = [ |
| 37 |
s for m in actual if m["type"] == "statistics" for s in m["statistics"].keys() |
| 38 |
] |
| 39 |
assert "objective" not in stats |