Make lazy constr component compatible with Pyomo+Gurobi

This commit is contained in:
2024-01-30 16:25:46 -06:00
parent c9eef36c4e
commit 25bbe20748
39 changed files with 482 additions and 264 deletions

View File

@@ -5,7 +5,11 @@ from scipy.stats import uniform, randint
from miplearn.collectors.basic import BasicCollector
from miplearn.io import write_pkl_gz
from miplearn.problems.tsp import TravelingSalesmanGenerator, build_tsp_model
from miplearn.problems.tsp import (
TravelingSalesmanGenerator,
build_tsp_model_gurobipy,
build_tsp_model_pyomo,
)
np.random.seed(42)
gen = TravelingSalesmanGenerator(
@@ -16,7 +20,27 @@ gen = TravelingSalesmanGenerator(
fix_cities=True,
round=True,
)
data = gen.generate(3)
data_filenames = write_pkl_gz(data, dirname(__file__), prefix="tsp-n20-")
params = {"seed": 42, "threads": 1}
# Gurobipy
data_filenames = write_pkl_gz(data, dirname(__file__), prefix="tsp-gp-n20-")
collector = BasicCollector()
collector.collect(data_filenames, build_tsp_model)
collector.collect(
data_filenames,
lambda d: build_tsp_model_gurobipy(d, params=params),
progress=True,
verbose=True,
)
# Pyomo
data_filenames = write_pkl_gz(data, dirname(__file__), prefix="tsp-pyo-n20-")
collector = BasicCollector()
collector.collect(
data_filenames,
lambda d: build_tsp_model_pyomo(d, params=params),
progress=True,
verbose=True,
)

BIN
tests/fixtures/tsp-gp-n20-00000.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-gp-n20-00000.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-gp-n20-00001.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-gp-n20-00001.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-gp-n20-00002.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-gp-n20-00002.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-gp-n20-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.

BIN
tests/fixtures/tsp-pyo-n20-00000.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00000.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00000.pkl.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00001.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00001.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00001.pkl.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00002.h5 vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00002.mps.gz vendored Normal file

Binary file not shown.

BIN
tests/fixtures/tsp-pyo-n20-00002.pkl.gz vendored Normal file

Binary file not shown.