Make cuts component compatible with Pyomo+Gurobi

This commit is contained in:
2024-01-29 00:41:29 -06:00
parent d2faa15079
commit c9eef36c4e
35 changed files with 203 additions and 87 deletions

View File

@@ -7,9 +7,11 @@ from miplearn.collectors.basic import BasicCollector
from miplearn.io import write_pkl_gz
from miplearn.problems.stab import (
MaxWeightStableSetGenerator,
build_stab_model,
build_stab_model_gurobipy,
build_stab_model_pyomo,
)
np.random.seed(42)
gen = MaxWeightStableSetGenerator(
w=uniform(10.0, scale=1.0),
@@ -18,6 +20,25 @@ gen = MaxWeightStableSetGenerator(
fix_graph=True,
)
data = gen.generate(3)
data_filenames = write_pkl_gz(data, dirname(__file__), prefix="stab-n50-")
params = {"seed": 42, "threads": 1}
# Gurobipy
data_filenames = write_pkl_gz(data, dirname(__file__), prefix="stab-gp-n50-")
collector = BasicCollector()
collector.collect(data_filenames, build_stab_model)
collector.collect(
data_filenames,
lambda data: build_stab_model_gurobipy(data, params=params),
progress=True,
verbose=True,
)
# Pyomo
data_filenames = write_pkl_gz(data, dirname(__file__), prefix="stab-pyo-n50-")
collector = BasicCollector()
collector.collect(
data_filenames,
lambda model: build_stab_model_pyomo(model, params=params),
progress=True,
verbose=True,
)

BIN
tests/fixtures/stab-gp-n50-00000.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00000.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00000.pkl.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00001.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00001.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00001.pkl.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00002.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00002.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-gp-n50-00002.pkl.gz vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00000.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00000.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00000.pkl.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00001.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00001.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00001.pkl.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00002.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00002.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/stab-pyo-n50-00002.pkl.gz vendored Normal file

Binary file not shown.